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

Function nop

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

Source from the content-addressed store, hash-verified

843
844 #[test]
845 fn nop() {
846 // Skip this test when cranelift doesn't support the native platform.
847 if cranelift_native::builder().is_err() {
848 return;
849 }
850 let code = String::from(
851 "
852 test run
853 function %test() -> i8 {
854 block0:
855 nop
856 v1 = iconst.i8 -1
857 return v1
858 }",
859 );
860 let ctrl_plane = &mut ControlPlane::default();
861
862 // extract function
863 let test_file = parse_test(code.as_str(), ParseOptions::default()).unwrap();
864 assert_eq!(1, test_file.functions.len());
865 let function = test_file.functions[0].0.clone();
866
867 // execute function
868 let mut compiler = TestFileCompiler::with_default_host_isa().unwrap();
869 compiler.declare_function(&function).unwrap();
870 compiler
871 .define_function(function.clone(), ctrl_plane)
872 .unwrap();
873 compiler
874 .create_trampoline_for_function(&function, ctrl_plane)
875 .unwrap();
876 let compiled = compiler.compile().unwrap();
877 let trampoline = compiled.get_trampoline(&function).unwrap();
878 let returned = trampoline.call(&compiled, &[]);
879 assert_eq!(returned, vec![DataValue::I8(-1)])
880 }
881
882 #[test]
883 fn trampolines() {

Callers

nothing calls this directly

Calls 12

fromFunction · 0.85
parse_testFunction · 0.85
get_trampolineMethod · 0.80
builderFunction · 0.50
unwrapMethod · 0.45
as_strMethod · 0.45
cloneMethod · 0.45
declare_functionMethod · 0.45
define_functionMethod · 0.45
compileMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected