Browse Source

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.
pull/6248/head
Alex Crichton 2 years ago
committed by GitHub
parent
commit
077d4755d9
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      crates/cranelift/src/func_environ.rs

6
crates/cranelift/src/func_environ.rs

@ -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 =

Loading…
Cancel
Save