deno_core
deno_core copied to clipboard
feat(op2): implement fast wasm memory ops
Closes #273
#[op2(fast)]
fn op_wasm(state: &mut OpState, #[smi] rid: u32, #[memory] memory: WasmMemory) {
let memory = memory.get(state, rid).expect("invalid wasm memory");
memory[0] = 69;
}
// Save memory handle for slow call access
const handle = ops.op_core_set_wasm_memory(instance.exports.memory);
// Expose op to Wasm module
const instance = new WebAssembly.Instance(module, {
wasm: {
op_wasm: () => ops.op_wasm(handle),
},
});
instance.exports.call(rid);