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

Function trampolines

cranelift/filetests/src/function_runner.rs:883–920  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

881
882 #[test]
883 fn trampolines() {
884 // Skip this test when cranelift doesn't support the native platform.
885 if cranelift_native::builder().is_err() {
886 return;
887 }
888 let function = parse(
889 "
890 function %test(f32, i8, i64x2, i8) -> f32x4, i64 {
891 block0(v0: f32, v1: i8, v2: i64x2, v3: i8):
892 v4 = vconst.f32x4 [0x0.1 0x0.2 0x0.3 0x0.4]
893 v5 = iconst.i64 -1
894 return v4, v5
895 }",
896 );
897
898 let compiler = TestFileCompiler::with_default_host_isa().unwrap();
899 let trampoline = make_trampoline(
900 UserFuncName::user(0, 0),
901 &function.signature,
902 compiler.module.isa(),
903 );
904 println!("{trampoline}");
905 assert!(format!("{trampoline}").ends_with(
906 "sig0 = (f32, i8, i64x2, i8) -> f32x4, i64 fast
907
908block0(v0: i64, v1: i64):
909 v2 = load.f32 notrap aligned v1
910 v3 = load.i8 notrap aligned v1+16
911 v4 = load.i64x2 notrap aligned little v1+32
912 v5 = load.i8 notrap aligned v1+48
913 v6, v7 = call_indirect sig0, v0(v2, v3, v4, v5)
914 store notrap aligned little v6, v1
915 store notrap aligned v7, v1+16
916 return
917}
918"
919 ));
920 }
921}

Callers

nothing calls this directly

Calls 5

make_trampolineFunction · 0.85
parseFunction · 0.70
builderFunction · 0.50
unwrapMethod · 0.45
isaMethod · 0.45

Tested by

no test coverage detected