Mark loads from VMCallerCheckedAnyfunc as readonly (#6243)

This commit marks the loads of `*mut VMContext` and the callee function
pointer as `readonly` in the context of indirect function calls and
additionally calls to imported functions (which are indirect). Once a
`VMCallerCheckedAnyfunc` is initialized it's never modified so it should
be valid to mark these as readonly and if called in a loop should be
hoistable outside of the loop.
This commit is contained in:
Alex Crichton
2023-04-19 14:22:25 -05:00
committed by GitHub
parent 0a062369a8
commit 077d4755d9

View File

@@ -1595,7 +1595,7 @@ impl<'module_environment> cranelift_wasm::FuncEnvironment for FuncEnvironment<'m
.trapz(funcref_ptr, ir::TrapCode::IndirectCallToNull);
// Dereference the funcref pointer to get the function address.
let mem_flags = ir::MemFlags::trusted();
let mem_flags = ir::MemFlags::trusted().with_readonly();
let func_addr = builder.ins().load(
pointer_type,
mem_flags,
@@ -1631,7 +1631,7 @@ impl<'module_environment> cranelift_wasm::FuncEnvironment for FuncEnvironment<'m
.load(sig_id_type, mem_flags, signatures, offset);
// Load the callee ID.
let mem_flags = ir::MemFlags::trusted();
let mem_flags = ir::MemFlags::trusted().with_readonly();
let callee_sig_id = builder.ins().load(
sig_id_type,
mem_flags,
@@ -1703,7 +1703,7 @@ impl<'module_environment> cranelift_wasm::FuncEnvironment for FuncEnvironment<'m
let vmctx = self.vmctx(&mut pos.func);
let base = pos.ins().global_value(pointer_type, vmctx);
let mem_flags = ir::MemFlags::trusted();
let mem_flags = ir::MemFlags::trusted().with_readonly();
// Load the callee address.
let body_offset =