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:
Yury Delendik
2020-06-02 13:44:39 -05:00
committed by GitHub
parent b41330393d
commit 15c68f2cc1
61 changed files with 982 additions and 663 deletions

View File

@@ -57,8 +57,9 @@ fn bad_tables() {
fn cross_store() -> anyhow::Result<()> {
let mut cfg = Config::new();
cfg.wasm_reference_types(true);
let store1 = Store::new(&Engine::new(&cfg));
let store2 = Store::new(&Engine::new(&cfg));
let engine = Engine::new(&cfg);
let store1 = Store::new(&engine);
let store2 = Store::new(&engine);
// ============ Cross-store instantiation ==============
@@ -70,17 +71,17 @@ fn cross_store() -> anyhow::Result<()> {
let ty = TableType::new(ValType::FuncRef, Limits::new(1, None));
let table = Table::new(&store2, ty, Val::ExternRef(None))?;
let need_func = Module::new(&store1, r#"(module (import "" "" (func)))"#)?;
assert!(Instance::new(&need_func, &[func.into()]).is_err());
let need_func = Module::new(&engine, r#"(module (import "" "" (func)))"#)?;
assert!(Instance::new(&store1, &need_func, &[func.into()]).is_err());
let need_global = Module::new(&store1, r#"(module (import "" "" (global i32)))"#)?;
assert!(Instance::new(&need_global, &[global.into()]).is_err());
let need_global = Module::new(&engine, r#"(module (import "" "" (global i32)))"#)?;
assert!(Instance::new(&store1, &need_global, &[global.into()]).is_err());
let need_table = Module::new(&store1, r#"(module (import "" "" (table 1 funcref)))"#)?;
assert!(Instance::new(&need_table, &[table.into()]).is_err());
let need_table = Module::new(&engine, r#"(module (import "" "" (table 1 funcref)))"#)?;
assert!(Instance::new(&store1, &need_table, &[table.into()]).is_err());
let need_memory = Module::new(&store1, r#"(module (import "" "" (memory 1)))"#)?;
assert!(Instance::new(&need_memory, &[memory.into()]).is_err());
let need_memory = Module::new(&engine, r#"(module (import "" "" (memory 1)))"#)?;
assert!(Instance::new(&store1, &need_memory, &[memory.into()]).is_err());
// ============ Cross-store globals ==============
@@ -106,7 +107,7 @@ fn cross_store() -> anyhow::Result<()> {
// ============ Cross-store funcs ==============
// TODO: need to actually fill this out once we support externref params/locals
// let module = Module::new(&store1, r#"(module (func (export "a") (param funcref)))"#)?;
// let module = Module::new(&engine, r#"(module (func (export "a") (param funcref)))"#)?;
Ok(())
}