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:
@@ -5,13 +5,16 @@ use wasmtime::*;
|
||||
fn link_undefined() -> Result<()> {
|
||||
let store = Store::default();
|
||||
let linker = Linker::new(&store);
|
||||
let module = Module::new(&store, r#"(module (import "" "" (func)))"#)?;
|
||||
let module = Module::new(store.engine(), r#"(module (import "" "" (func)))"#)?;
|
||||
assert!(linker.instantiate(&module).is_err());
|
||||
let module = Module::new(&store, r#"(module (import "" "" (global i32)))"#)?;
|
||||
let module = Module::new(store.engine(), r#"(module (import "" "" (global i32)))"#)?;
|
||||
assert!(linker.instantiate(&module).is_err());
|
||||
let module = Module::new(&store, r#"(module (import "" "" (memory 1)))"#)?;
|
||||
let module = Module::new(store.engine(), r#"(module (import "" "" (memory 1)))"#)?;
|
||||
assert!(linker.instantiate(&module).is_err());
|
||||
let module = Module::new(&store, r#"(module (import "" "" (table 1 funcref)))"#)?;
|
||||
let module = Module::new(
|
||||
store.engine(),
|
||||
r#"(module (import "" "" (table 1 funcref)))"#,
|
||||
)?;
|
||||
assert!(linker.instantiate(&module).is_err());
|
||||
Ok(())
|
||||
}
|
||||
@@ -71,7 +74,7 @@ fn function_interposition() -> Result<()> {
|
||||
let mut linker = Linker::new(&store);
|
||||
linker.allow_shadowing(true);
|
||||
let mut module = Module::new(
|
||||
&store,
|
||||
store.engine(),
|
||||
r#"(module (func (export "green") (result i32) (i32.const 7)))"#,
|
||||
)?;
|
||||
for _ in 0..4 {
|
||||
@@ -82,7 +85,7 @@ fn function_interposition() -> Result<()> {
|
||||
instance.get_export("green").unwrap().clone(),
|
||||
)?;
|
||||
module = Module::new(
|
||||
&store,
|
||||
store.engine(),
|
||||
r#"(module
|
||||
(import "red" "green" (func (result i32)))
|
||||
(func (export "green") (result i32) (i32.mul (call 0) (i32.const 2)))
|
||||
@@ -104,7 +107,7 @@ fn function_interposition_renamed() -> Result<()> {
|
||||
let mut linker = Linker::new(&store);
|
||||
linker.allow_shadowing(true);
|
||||
let mut module = Module::new(
|
||||
&store,
|
||||
store.engine(),
|
||||
r#"(module (func (export "export") (result i32) (i32.const 7)))"#,
|
||||
)?;
|
||||
for _ in 0..4 {
|
||||
@@ -115,7 +118,7 @@ fn function_interposition_renamed() -> Result<()> {
|
||||
instance.get_export("export").unwrap().clone(),
|
||||
)?;
|
||||
module = Module::new(
|
||||
&store,
|
||||
store.engine(),
|
||||
r#"(module
|
||||
(import "red" "green" (func (result i32)))
|
||||
(func (export "export") (result i32) (i32.mul (call 0) (i32.const 2)))
|
||||
@@ -137,14 +140,14 @@ fn module_interposition() -> Result<()> {
|
||||
let mut linker = Linker::new(&store);
|
||||
linker.allow_shadowing(true);
|
||||
let mut module = Module::new(
|
||||
&store,
|
||||
store.engine(),
|
||||
r#"(module (func (export "export") (result i32) (i32.const 7)))"#,
|
||||
)?;
|
||||
for _ in 0..4 {
|
||||
let instance = linker.instantiate(&module)?;
|
||||
linker.instance("instance", &instance)?;
|
||||
module = Module::new(
|
||||
&store,
|
||||
store.engine(),
|
||||
r#"(module
|
||||
(import "instance" "export" (func (result i32)))
|
||||
(func (export "export") (result i32) (i32.mul (call 0) (i32.const 2)))
|
||||
|
||||
Reference in New Issue
Block a user