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

Method call_hook

tests/all/call_hook.rs:850–894  ·  view source on GitHub ↗

This implementation asserts that hooks are always called in a stack-like manner.

(&mut self, s: CallHook)

Source from the content-addressed store, hash-verified

848impl State {
849 // This implementation asserts that hooks are always called in a stack-like manner.
850 fn call_hook(&mut self, s: CallHook) -> Result<()> {
851 match s {
852 CallHook::CallingHost => {
853 self.calls_into_host += 1;
854 if self.trap_next_call_host {
855 bail!("call_hook: trapping on CallingHost");
856 } else {
857 self.context.push(Context::Host);
858 }
859 }
860 CallHook::ReturningFromHost => match self.context.pop() {
861 Some(Context::Host) => {
862 self.returns_from_host += 1;
863 if self.trap_next_return_host {
864 bail!("call_hook: trapping on ReturningFromHost");
865 }
866 }
867 c => panic!(
868 "illegal context: expected Some(Host), got {:?}. remaining: {:?}",
869 c, self.context
870 ),
871 },
872 CallHook::CallingWasm => {
873 self.calls_into_wasm += 1;
874 if self.trap_next_call_wasm {
875 bail!("call_hook: trapping on CallingWasm");
876 } else {
877 self.context.push(Context::Wasm);
878 }
879 }
880 CallHook::ReturningFromWasm => match self.context.pop() {
881 Some(Context::Wasm) => {
882 self.returns_from_wasm += 1;
883 if self.trap_next_return_wasm {
884 bail!("call_hook: trapping on ReturningFromWasm");
885 }
886 }
887 c => panic!(
888 "illegal context: expected Some(Wasm), got {:?}. remaining: {:?}",
889 c, self.context
890 ),
891 },
892 }
893 Ok(())
894 }
895}
896
897pub fn sync_call_hook(mut ctx: StoreContextMut<'_, State>, transition: CallHook) -> Result<()> {

Callers 14

call_wrapped_funcFunction · 0.45
call_wrapped_async_funcFunction · 0.45
call_linked_funcFunction · 0.45
call_linked_func_asyncFunction · 0.45
instantiateFunction · 0.45
instantiate_asyncFunction · 0.45
recursionFunction · 0.45
trappingFunction · 0.45
sync_call_hookFunction · 0.45
call_wrapped_funcFunction · 0.45
call_func_with_reallocFunction · 0.45

Calls 3

OkFunction · 0.85
pushMethod · 0.45
popMethod · 0.45

Tested by 9

call_wrapped_funcFunction · 0.36
call_linked_funcFunction · 0.36
instantiateFunction · 0.36
recursionFunction · 0.36
trappingFunction · 0.36
call_wrapped_funcFunction · 0.36
call_func_with_reallocFunction · 0.36
trappingFunction · 0.36