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

Method hook_malloc_exit

crates/cranelift/src/func_environ.rs:779–799  ·  view source on GitHub ↗
(&mut self, builder: &mut FunctionBuilder, retvals: &[ir::Value])

Source from the content-addressed store, hash-verified

777 }
778
779 fn hook_malloc_exit(&mut self, builder: &mut FunctionBuilder, retvals: &[ir::Value]) {
780 let check_malloc = self.builtin_functions.check_malloc(builder.func);
781 let vmctx = self.vmctx_val(&mut builder.cursor());
782 let func_args = builder
783 .func
784 .dfg
785 .block_params(builder.func.layout.entry_block().unwrap());
786 let len = if func_args.len() < 3 {
787 return;
788 } else {
789 // If a function named `malloc` has at least one argument, we assume the
790 // first argument is the requested allocation size.
791 func_args[2]
792 };
793 let retval = if retvals.len() < 1 {
794 return;
795 } else {
796 retvals[0]
797 };
798 builder.ins().call(check_malloc, &[vmctx, retval, len]);
799 }
800
801 fn hook_free_exit(&mut self, builder: &mut FunctionBuilder) {
802 let check_free = self.builtin_functions.check_free(builder.func);

Callers 1

handle_before_returnMethod · 0.80

Calls 8

vmctx_valMethod · 0.45
cursorMethod · 0.45
block_paramsMethod · 0.45
unwrapMethod · 0.45
entry_blockMethod · 0.45
lenMethod · 0.45
callMethod · 0.45
insMethod · 0.45

Tested by

no test coverage detected