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

Function define_leaf

cranelift/object/tests/basic.rs:340–360  ·  view source on GitHub ↗

Define a leaf function that just returns. With `preserve_frame_pointers` on, this is enough to make cranelift emit a System V FDE for it.

(module: &mut ObjectModule, name: &str)

Source from the content-addressed store, hash-verified

338 /// Define a leaf function that just returns. With `preserve_frame_pointers`
339 /// on, this is enough to make cranelift emit a System V FDE for it.
340 fn define_leaf(module: &mut ObjectModule, name: &str) -> FuncId {
341 let sig = Signature {
342 params: vec![],
343 returns: vec![],
344 call_conv: CallConv::SystemV,
345 };
346 let func_id = module.declare_function(name, Linkage::Local, &sig).unwrap();
347 let mut ctx = Context::new();
348 ctx.func = Function::with_name_signature(UserFuncName::user(0, func_id.as_u32()), sig);
349 let mut func_ctx = FunctionBuilderContext::new();
350 {
351 let mut bcx = FunctionBuilder::new(&mut ctx.func, &mut func_ctx);
352 let block = bcx.create_block();
353 bcx.switch_to_block(block);
354 bcx.ins().return_(&[]);
355 bcx.seal_all_blocks();
356 bcx.finalize();
357 }
358 module.define_function(func_id, &mut ctx).unwrap();
359 func_id
360 }
361
362 /// Iterate the entries in `.eh_frame` bytes, returning `(cie_count, fde_count)`.
363 fn count_entries(data: &[u8]) -> (usize, usize) {

Calls 10

create_blockMethod · 0.80
switch_to_blockMethod · 0.80
newFunction · 0.50
unwrapMethod · 0.45
declare_functionMethod · 0.45
as_u32Method · 0.45
insMethod · 0.45
seal_all_blocksMethod · 0.45
finalizeMethod · 0.45
define_functionMethod · 0.45

Tested by

no test coverage detected