Disconnects Store state fields from Compiler (#1761)
* Moves CodeMemory, VMInterrupts and SignatureRegistry from Compiler * CompiledModule holds CodeMemory and GdbJitImageRegistration * Store keeps track of its JIT code * Makes "jit_int.rs" stuff Send+Sync * Adds the threads example.
This commit is contained in:
@@ -19,14 +19,14 @@ fn hugely_recursive_module(store: &Store) -> anyhow::Result<Module> {
|
||||
}
|
||||
wat.push_str("(func call 0)\n");
|
||||
|
||||
Module::new(&store, &wat)
|
||||
Module::new(store.engine(), &wat)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn loops_interruptable() -> anyhow::Result<()> {
|
||||
let store = interruptable_store();
|
||||
let module = Module::new(&store, r#"(func (export "loop") (loop br 0))"#)?;
|
||||
let instance = Instance::new(&module, &[])?;
|
||||
let module = Module::new(store.engine(), r#"(func (export "loop") (loop br 0))"#)?;
|
||||
let instance = Instance::new(&store, &module, &[])?;
|
||||
let iloop = instance.get_func("loop").unwrap().get0::<()>()?;
|
||||
store.interrupt_handle()?.interrupt();
|
||||
let trap = iloop().unwrap_err();
|
||||
@@ -39,7 +39,7 @@ fn functions_interruptable() -> anyhow::Result<()> {
|
||||
let store = interruptable_store();
|
||||
let module = hugely_recursive_module(&store)?;
|
||||
let func = Func::wrap(&store, || {});
|
||||
let instance = Instance::new(&module, &[func.into()])?;
|
||||
let instance = Instance::new(&store, &module, &[func.into()])?;
|
||||
let iloop = instance.get_func("loop").unwrap().get0::<()>()?;
|
||||
store.interrupt_handle()?.interrupt();
|
||||
let trap = iloop().unwrap_err();
|
||||
@@ -59,7 +59,7 @@ fn loop_interrupt_from_afar() -> anyhow::Result<()> {
|
||||
static HITS: AtomicUsize = AtomicUsize::new(0);
|
||||
let store = interruptable_store();
|
||||
let module = Module::new(
|
||||
&store,
|
||||
store.engine(),
|
||||
r#"
|
||||
(import "" "" (func))
|
||||
|
||||
@@ -73,7 +73,7 @@ fn loop_interrupt_from_afar() -> anyhow::Result<()> {
|
||||
let func = Func::wrap(&store, || {
|
||||
HITS.fetch_add(1, SeqCst);
|
||||
});
|
||||
let instance = Instance::new(&module, &[func.into()])?;
|
||||
let instance = Instance::new(&store, &module, &[func.into()])?;
|
||||
|
||||
// Use the instance's interrupt handle to wait for it to enter the loop long
|
||||
// enough and then we signal an interrupt happens.
|
||||
@@ -109,7 +109,7 @@ fn function_interrupt_from_afar() -> anyhow::Result<()> {
|
||||
let func = Func::wrap(&store, || {
|
||||
HITS.fetch_add(1, SeqCst);
|
||||
});
|
||||
let instance = Instance::new(&module, &[func.into()])?;
|
||||
let instance = Instance::new(&store, &module, &[func.into()])?;
|
||||
|
||||
// Use the instance's interrupt handle to wait for it to enter the loop long
|
||||
// enough and then we signal an interrupt happens.
|
||||
|
||||
Reference in New Issue
Block a user