MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / emit

Method emit

winch/codegen/src/codegen/call.rs:87–113  ·  view source on GitHub ↗

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,
    )

Source from the content-addressed store, hash-verified

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>(

Callers

nothing calls this directly

Calls 6

OkFunction · 0.85
spillMethod · 0.80
params_stack_sizeMethod · 0.80
lowerFunction · 0.50
callMethod · 0.45
as_refMethod · 0.45

Tested by

no test coverage detected