Orchestrates the emission of a function call: 1. Resolves the [`Callee`] through the given callback. 2. Lowers the resolved [`Callee`] to a ([`CalleeKind`], [ContextArgs]) 3. Spills the value stack. 4. Creates the stack space needed for the return area. 5. Emits the call. 6. Cleans up the stack space.
(
env: &mut FuncEnv<M::Ptr>,
masm: &mut M,
context: &mut CodeGenContext<Emission>,
callee: Callee,
)
| 85 | /// 5. Emits the call. |
| 86 | /// 6. Cleans up the stack space. |
| 87 | pub fn emit<M: MacroAssembler>( |
| 88 | env: &mut FuncEnv<M::Ptr>, |
| 89 | masm: &mut M, |
| 90 | context: &mut CodeGenContext<Emission>, |
| 91 | callee: Callee, |
| 92 | ) -> Result<()> { |
| 93 | let (kind, callee_context) = Self::lower(env, context.vmoffsets, &callee, context, masm)?; |
| 94 | |
| 95 | let sig = env.callee_sig::<M::ABI>(&callee)?; |
| 96 | context.spill(masm)?; |
| 97 | let ret_area = Self::make_ret_area(&sig, masm)?; |
| 98 | let arg_stack_space = sig.params_stack_size(); |
| 99 | let reserved_stack = masm.call(arg_stack_space, |masm| { |
| 100 | Self::assign(sig, &callee_context, ret_area.as_ref(), context, masm)?; |
| 101 | Ok((kind, sig.call_conv)) |
| 102 | })?; |
| 103 | |
| 104 | Self::cleanup( |
| 105 | sig, |
| 106 | &callee_context, |
| 107 | &kind, |
| 108 | reserved_stack, |
| 109 | ret_area, |
| 110 | masm, |
| 111 | context, |
| 112 | ) |
| 113 | } |
| 114 | |
| 115 | /// Calculates the return area for the callee, if any. |
| 116 | fn make_ret_area<M: MacroAssembler>( |