Call the new ModuleEnvironment reserve functions.
This commit is contained in:
@@ -28,6 +28,8 @@ pub fn parse_type_section(
|
|||||||
types: TypeSectionReader,
|
types: TypeSectionReader,
|
||||||
environ: &mut ModuleEnvironment,
|
environ: &mut ModuleEnvironment,
|
||||||
) -> WasmResult<()> {
|
) -> WasmResult<()> {
|
||||||
|
environ.reserve_signatures(types.get_count());
|
||||||
|
|
||||||
for entry in types {
|
for entry in types {
|
||||||
match entry? {
|
match entry? {
|
||||||
FuncType {
|
FuncType {
|
||||||
@@ -59,6 +61,8 @@ pub fn parse_import_section<'data>(
|
|||||||
imports: ImportSectionReader<'data>,
|
imports: ImportSectionReader<'data>,
|
||||||
environ: &mut ModuleEnvironment<'data>,
|
environ: &mut ModuleEnvironment<'data>,
|
||||||
) -> WasmResult<()> {
|
) -> WasmResult<()> {
|
||||||
|
environ.reserve_imports(imports.get_count());
|
||||||
|
|
||||||
for entry in imports {
|
for entry in imports {
|
||||||
let import = entry?;
|
let import = entry?;
|
||||||
|
|
||||||
@@ -113,6 +117,8 @@ pub fn parse_import_section<'data>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
environ.finish_imports();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,10 +127,13 @@ pub fn parse_function_section(
|
|||||||
functions: FunctionSectionReader,
|
functions: FunctionSectionReader,
|
||||||
environ: &mut ModuleEnvironment,
|
environ: &mut ModuleEnvironment,
|
||||||
) -> WasmResult<()> {
|
) -> WasmResult<()> {
|
||||||
|
environ.reserve_func_types(functions.get_count());
|
||||||
|
|
||||||
for entry in functions {
|
for entry in functions {
|
||||||
let sigindex = entry?;
|
let sigindex = entry?;
|
||||||
environ.declare_func_type(SignatureIndex::from_u32(sigindex));
|
environ.declare_func_type(SignatureIndex::from_u32(sigindex));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,6 +142,8 @@ pub fn parse_table_section(
|
|||||||
tables: TableSectionReader,
|
tables: TableSectionReader,
|
||||||
environ: &mut ModuleEnvironment,
|
environ: &mut ModuleEnvironment,
|
||||||
) -> WasmResult<()> {
|
) -> WasmResult<()> {
|
||||||
|
environ.reserve_tables(tables.get_count());
|
||||||
|
|
||||||
for entry in tables {
|
for entry in tables {
|
||||||
let table = entry?;
|
let table = entry?;
|
||||||
environ.declare_table(Table {
|
environ.declare_table(Table {
|
||||||
@@ -144,6 +155,7 @@ pub fn parse_table_section(
|
|||||||
maximum: table.limits.maximum,
|
maximum: table.limits.maximum,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,6 +164,8 @@ pub fn parse_memory_section(
|
|||||||
memories: MemorySectionReader,
|
memories: MemorySectionReader,
|
||||||
environ: &mut ModuleEnvironment,
|
environ: &mut ModuleEnvironment,
|
||||||
) -> WasmResult<()> {
|
) -> WasmResult<()> {
|
||||||
|
environ.reserve_memories(memories.get_count());
|
||||||
|
|
||||||
for entry in memories {
|
for entry in memories {
|
||||||
let memory = entry?;
|
let memory = entry?;
|
||||||
environ.declare_memory(Memory {
|
environ.declare_memory(Memory {
|
||||||
@@ -160,6 +174,7 @@ pub fn parse_memory_section(
|
|||||||
shared: memory.shared,
|
shared: memory.shared,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,6 +183,8 @@ pub fn parse_global_section(
|
|||||||
globals: GlobalSectionReader,
|
globals: GlobalSectionReader,
|
||||||
environ: &mut ModuleEnvironment,
|
environ: &mut ModuleEnvironment,
|
||||||
) -> WasmResult<()> {
|
) -> WasmResult<()> {
|
||||||
|
environ.reserve_globals(globals.get_count());
|
||||||
|
|
||||||
for entry in globals {
|
for entry in globals {
|
||||||
let wasmparser::Global {
|
let wasmparser::Global {
|
||||||
ty: GlobalType {
|
ty: GlobalType {
|
||||||
@@ -194,6 +211,7 @@ pub fn parse_global_section(
|
|||||||
};
|
};
|
||||||
environ.declare_global(global);
|
environ.declare_global(global);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,6 +220,8 @@ pub fn parse_export_section<'data>(
|
|||||||
exports: ExportSectionReader<'data>,
|
exports: ExportSectionReader<'data>,
|
||||||
environ: &mut ModuleEnvironment<'data>,
|
environ: &mut ModuleEnvironment<'data>,
|
||||||
) -> WasmResult<()> {
|
) -> WasmResult<()> {
|
||||||
|
environ.reserve_exports(exports.get_count());
|
||||||
|
|
||||||
for entry in exports {
|
for entry in exports {
|
||||||
let Export {
|
let Export {
|
||||||
field,
|
field,
|
||||||
@@ -221,6 +241,8 @@ pub fn parse_export_section<'data>(
|
|||||||
ExternalKind::Global => environ.declare_global_export(GlobalIndex::new(index), name),
|
ExternalKind::Global => environ.declare_global_export(GlobalIndex::new(index), name),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
environ.finish_exports();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,6 +257,8 @@ pub fn parse_element_section<'data>(
|
|||||||
elements: ElementSectionReader<'data>,
|
elements: ElementSectionReader<'data>,
|
||||||
environ: &mut ModuleEnvironment,
|
environ: &mut ModuleEnvironment,
|
||||||
) -> WasmResult<()> {
|
) -> WasmResult<()> {
|
||||||
|
environ.reserve_table_elements(elements.get_count());
|
||||||
|
|
||||||
for entry in elements {
|
for entry in elements {
|
||||||
let Element {
|
let Element {
|
||||||
table_index,
|
table_index,
|
||||||
@@ -281,6 +305,8 @@ pub fn parse_data_section<'data>(
|
|||||||
data: DataSectionReader<'data>,
|
data: DataSectionReader<'data>,
|
||||||
environ: &mut ModuleEnvironment<'data>,
|
environ: &mut ModuleEnvironment<'data>,
|
||||||
) -> WasmResult<()> {
|
) -> WasmResult<()> {
|
||||||
|
environ.reserve_data_initializers(data.get_count());
|
||||||
|
|
||||||
for entry in data {
|
for entry in data {
|
||||||
let Data {
|
let Data {
|
||||||
memory_index,
|
memory_index,
|
||||||
@@ -300,5 +326,6 @@ pub fn parse_data_section<'data>(
|
|||||||
data,
|
data,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user