Handles the end of a control stack frame.
(
&mut self,
masm: &mut M,
context: &mut CodeGenContext<Emission>,
)
| 554 | |
| 555 | /// Handles the end of a control stack frame. |
| 556 | pub fn emit_end<M: MacroAssembler>( |
| 557 | &mut self, |
| 558 | masm: &mut M, |
| 559 | context: &mut CodeGenContext<Emission>, |
| 560 | ) -> Result<()> { |
| 561 | use ControlStackFrame::*; |
| 562 | match self { |
| 563 | If { stack_state, .. } | Else { stack_state, .. } | Block { stack_state, .. } => { |
| 564 | ensure!( |
| 565 | stack_state.target_len == context.stack.len(), |
| 566 | CodeGenError::control_frame_state_mismatch() |
| 567 | ); |
| 568 | // Before binding the exit label, we handle the block results. |
| 569 | self.pop_abi_results(context, masm, |results, _, _| { |
| 570 | Ok(results.ret_area().copied()) |
| 571 | })?; |
| 572 | self.bind_end(masm, context)?; |
| 573 | } |
| 574 | Loop { stack_state, .. } => { |
| 575 | ensure!( |
| 576 | stack_state.target_len == context.stack.len(), |
| 577 | CodeGenError::control_frame_state_mismatch() |
| 578 | ); |
| 579 | } |
| 580 | }; |
| 581 | |
| 582 | Ok(()) |
| 583 | } |
| 584 | |
| 585 | /// Binds the exit label of the current control stack frame and pushes the |
| 586 | /// ABI results to the value stack. |