Improve infrastructure.

Do more encapsulation of raw pointers, use more PrimaryMaps instead of
Vecs, add a table.rs for managing table storage.
This commit is contained in:
Dan Gohman
2018-12-03 03:20:15 -08:00
parent fe1643733b
commit bd69768e0d
14 changed files with 360 additions and 253 deletions

View File

@@ -52,10 +52,10 @@ impl binemit::RelocSink for RelocSink {
let reloc_target = if let ExternalName::User { namespace, index } = *name {
debug_assert!(namespace == 0);
RelocationTarget::UserFunc(FuncIndex::new(index as usize))
} else if *name == ExternalName::testcase("grow_memory") {
RelocationTarget::GrowMemory
} else if *name == ExternalName::testcase("current_memory") {
RelocationTarget::CurrentMemory
} else if *name == ExternalName::testcase("wasmtime_memory_grow") {
RelocationTarget::MemoryGrow
} else if *name == ExternalName::testcase("wasmtime_memory_size") {
RelocationTarget::MemorySize
} else {
panic!("unrecognized external name")
};
@@ -104,9 +104,9 @@ pub enum RelocationTarget {
/// The user function index.
UserFunc(FuncIndex),
/// Function for growing the default memory by the specified amount of pages.
GrowMemory,
MemoryGrow,
/// Function for query current size of the default linear memory.
CurrentMemory,
MemorySize,
}
/// Relocations to apply to function bodies.

View File

@@ -98,7 +98,7 @@ pub struct Module {
pub signatures: PrimaryMap<SignatureIndex, ir::Signature>,
/// Names of imported functions.
pub imported_funcs: Vec<(String, String)>,
pub imported_funcs: PrimaryMap<FuncIndex, (String, String)>,
/// Types of functions, imported and local.
pub functions: PrimaryMap<FuncIndex, SignatureIndex>,
@@ -127,7 +127,7 @@ impl Module {
pub fn new() -> Self {
Self {
signatures: PrimaryMap::new(),
imported_funcs: Vec::new(),
imported_funcs: PrimaryMap::new(),
functions: PrimaryMap::new(),
tables: PrimaryMap::new(),
memory_plans: PrimaryMap::new(),