Remove the local field of Module (#2091)

This was added long ago at this point to assist with caching, but
caching has moved to a different level such that this wonky second level
of a `Module` isn't necessary. This commit removes the `ModuleLocal`
type to simplify accessors and generally make it easier to work with.
This commit is contained in:
Alex Crichton
2020-08-04 12:29:16 -05:00
committed by GitHub
parent c21fe0eb73
commit 3d2e0e55f2
26 changed files with 131 additions and 164 deletions

View File

@@ -18,14 +18,14 @@ pub fn layout_vmcontext(
module: &Module,
target_config: &TargetFrontendConfig,
) -> (Box<[u8]>, Box<[TableRelocation]>) {
let ofs = VMOffsets::new(target_config.pointer_bytes(), &module.local);
let ofs = VMOffsets::new(target_config.pointer_bytes(), &module);
let out_len = ofs.size_of_vmctx() as usize;
let mut out = vec![0; out_len];
// Assign unique indices to unique signatures.
let mut signature_registry = HashMap::new();
let mut signature_registry_len = signature_registry.len();
for (index, sig) in module.local.signatures.iter() {
for (index, sig) in module.signatures.iter() {
let offset = ofs.vmctx_vmshared_signature_id(index) as usize;
let target_index = match signature_registry.entry(sig) {
Entry::Occupied(o) => *o.get(),
@@ -42,10 +42,10 @@ pub fn layout_vmcontext(
}
}
let num_tables_imports = module.local.num_imported_tables;
let mut table_relocs = Vec::with_capacity(module.local.table_plans.len() - num_tables_imports);
for (index, table) in module.local.table_plans.iter().skip(num_tables_imports) {
let def_index = module.local.defined_table_index(index).unwrap();
let num_tables_imports = module.num_imported_tables;
let mut table_relocs = Vec::with_capacity(module.table_plans.len() - num_tables_imports);
for (index, table) in module.table_plans.iter().skip(num_tables_imports) {
let def_index = module.defined_table_index(index).unwrap();
let offset = ofs.vmctx_vmtable_definition(def_index) as usize;
let current_elements = table.table.minimum;
unsafe {
@@ -66,9 +66,9 @@ pub fn layout_vmcontext(
});
}
let num_globals_imports = module.local.num_imported_globals;
for (index, global) in module.local.globals.iter().skip(num_globals_imports) {
let def_index = module.local.defined_global_index(index).unwrap();
let num_globals_imports = module.num_imported_globals;
for (index, global) in module.globals.iter().skip(num_globals_imports) {
let def_index = module.defined_global_index(index).unwrap();
let offset = ofs.vmctx_vmglobal_definition(def_index) as usize;
let to = unsafe { out.as_mut_ptr().add(offset) };
match global.initializer {