Improved instance & module data pointers location

# Conflicts:
#	src/webassembly/instance.rs
#	src/webassembly/module.rs
This commit is contained in:
Syrus Akbary 2018-11-14 11:05:57 -08:00
parent ac2d605472
commit e4ed4cc532
2 changed files with 6 additions and 0 deletions

View File

@ -67,6 +67,7 @@ fn get_function_addr(
/// first field /// first field
#[repr(C)] #[repr(C)]
#[derive(Debug)] #[derive(Debug)]
#[repr(C)]
pub struct Instance { pub struct Instance {
// C-like pointers to data (heaps, globals, tables) // C-like pointers to data (heaps, globals, tables)
pub data_pointers: DataPointers, pub data_pointers: DataPointers,
@ -99,6 +100,7 @@ pub struct Instance {
/// NOTE: Rearranging the fields will break the memory arrangement model /// NOTE: Rearranging the fields will break the memory arrangement model
#[repr(C)] #[repr(C)]
#[derive(Debug)] #[derive(Debug)]
#[repr(C)]
pub struct DataPointers { pub struct DataPointers {
// Pointer to tables // Pointer to tables
pub tables: TablesSlice, pub tables: TablesSlice,

View File

@ -489,6 +489,7 @@ impl<'environment> FuncEnvironmentTrait for FuncEnvironment<'environment> {
.special_param(ir::ArgumentPurpose::VMContext) .special_param(ir::ArgumentPurpose::VMContext)
.expect("Missing vmctx parameter"); .expect("Missing vmctx parameter");
// The `callee` value is an index into a table of function pointers. // The `callee` value is an index into a table of function pointers.
// Apparently, that table is stored at absolute address 0 in this dummy environment. // Apparently, that table is stored at absolute address 0 in this dummy environment.
// TODO: Generate bounds checking code. // TODO: Generate bounds checking code.
@ -537,6 +538,9 @@ impl<'environment> FuncEnvironmentTrait for FuncEnvironment<'environment> {
.special_param(ir::ArgumentPurpose::VMContext) .special_param(ir::ArgumentPurpose::VMContext)
.expect("Missing vmctx parameter"); .expect("Missing vmctx parameter");
// println!("POINTER BYTES {}", self.pointer_bytes());
// println!("POINTER SIZE {}", self.ptr_size());
// Build a value list for the call instruction containing the call_args and the vmctx // Build a value list for the call instruction containing the call_args and the vmctx
// parameter. // parameter.
let mut args = ir::ValueList::default(); let mut args = ir::ValueList::default();