Fix table/memory import

This commit is contained in:
Brandon Fish
2019-01-30 19:19:53 -06:00
parent cf325f7cd6
commit 9dcbea7408

View File

@ -6,25 +6,25 @@ use libc::c_int;
use std::cell::UnsafeCell;
use std::{ffi::c_void, fmt, mem, ptr};
use wasmer_runtime_core::{
error::CallResult,
export::{Context, Export, FuncPointer},
func,
global::Global,
import::{ImportObject, Namespace},
imports,
memory::Memory,
error::CallResult,
table::Table,
types::{
ElementType, FuncSig, GlobalDescriptor,
ElementType, FuncSig, GlobalDescriptor, MemoryDescriptor, TableDescriptor,
Type::{self, *},
Value, TableDescriptor, MemoryDescriptor
Value,
},
Module, Instance,
units::Pages,
vm::Ctx,
vm::LocalGlobal,
vm::LocalMemory,
vm::LocalTable,
vm::Ctx,
Instance, Module,
};
#[macro_use]
@ -281,12 +281,7 @@ pub struct EmscriptenGlobals {
pub data: EmscriptenGlobalsData,
// The emscripten memory
pub memory: Memory,
pub vm_memory: LocalMemory,
// The emscripten table
pub table: Table,
pub vm_table: LocalTable,
pub table_min: u32,
pub table_max: Option<u32>,
pub memory_min: Pages,
pub memory_max: Option<Pages>,
}
@ -303,8 +298,6 @@ impl EmscriptenGlobals {
shared: false,
};
let mut memory = Memory::new(memory_type).unwrap();
let vm_memory = memory.vm_local_memory();
let table_type = TableDescriptor {
element: ElementType::Anyfunc,
@ -312,7 +305,6 @@ impl EmscriptenGlobals {
maximum: table_max,
};
let mut table = Table::new(table_type).unwrap();
let vm_table = table.vm_local_table();
let memory_base = STATIC_BASE as u64;
let table_base = 0 as u64;
@ -332,19 +324,13 @@ impl EmscriptenGlobals {
nan: std::f64::NAN.to_bits() as _,
};
unimplemented!()
// Self {
// data,
// memory,
// vm_memory,
// table,
// vm_table,
// table_min,
// table_max,
// memory_min,
// memory_max,
// }
Self {
data,
memory,
table,
memory_min,
memory_max,
}
}
}
@ -361,38 +347,9 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
// We generate a fake Context that traps on access
let null_ctx = Context::External(ptr::null_mut());
// Memory
// let local_memory = unsafe { MemoryPointer::new(&mut globals.vm_memory) };
env_namespace.insert("memory".to_string(), Export::Memory(globals.memory.clone()));
// env_namespace.insert(
// "memory".to_string(),
// Export::Memory {
// local: local_memory,
// ctx: null_ctx,
// memory: Memory {
// min: globals.memory_min,
// max: globals.memory_max,
// shared: false,
// },
// },
// );
//
// // Table
// let local_table = unsafe { TablePointer::new(&mut globals.vm_table) };
//
// env_namespace.insert(
// "table".to_string(),
// Export::Table {
// local: local_table,
// // We generate a fake Context that traps on access
// ctx: null_ctx,
// table: Table {
// ty: ElementType::Anyfunc,
// min: globals.table_min,
// max: globals.table_max,
// },
// },
// );
env_namespace.insert("table".to_string(), Export::Table(globals.table.clone()));
//
// env_namespace.insert(
// "STACKTOP".to_string(),