summaryrefslogtreecommitdiff
path: root/crates/parser/src/module.rs
diff options
context:
space:
mode:
authorHenry Gressmann <mail@henrygressmann.de>2024-06-28 01:10:54 +0200
committerGitHub <noreply@github.com>2024-06-28 01:10:54 +0200
commit644395712a81c8f3fd56b6beafe9d3e09dfa9501 (patch)
tree15e1b62b7f96a56155d965daee0f3d4eef23fdee /crates/parser/src/module.rs
parentba1f2638d2979bcd86313f9429c48da22478adc8 (diff)
feat: compact value stack (#21)
Not fully done, but ready for the `next` branch now. This changes how values are represented internally, making this pr particularly large, as this touches most parts of the codebase. The parser should now also be ready for multithreaded compilation to speed this up a bit. --------- Signed-off-by: Henry Gressmann <mail@henrygressmann.de>
Diffstat (limited to 'crates/parser/src/module.rs')
-rw-r--r--crates/parser/src/module.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/crates/parser/src/module.rs b/crates/parser/src/module.rs
index 294782c..3ee619f 100644
--- a/crates/parser/src/module.rs
+++ b/crates/parser/src/module.rs
@@ -3,12 +3,12 @@ use crate::{conversion, ParseError, Result};
use alloc::string::ToString;
use alloc::{boxed::Box, format, vec::Vec};
use tinywasm_types::{
- Data, Element, Export, FuncType, Global, Import, Instruction, MemoryType, TableType, TinyWasmModule, ValType,
+ Data, Element, Export, FuncType, Global, Import, Instruction, LocalCounts, MemoryType, TableType, TinyWasmModule,
WasmFunction,
};
use wasmparser::{FuncValidatorAllocations, Payload, Validator};
-pub(crate) type Code = (Box<[Instruction]>, Box<[ValType]>);
+pub(crate) type Code = (Box<[Instruction]>, LocalCounts);
#[derive(Default)]
pub(crate) struct ModuleReader {
@@ -135,9 +135,10 @@ impl ModuleReader {
CodeSectionEntry(function) => {
debug!("Found code section entry");
let v = validator.code_section_entry(&function)?;
- let mut func_validator = v.into_validator(self.func_validator_allocations.take().unwrap_or_default());
- self.code.push(conversion::convert_module_code(function, &mut func_validator)?);
- self.func_validator_allocations = Some(func_validator.into_allocations());
+ let func_validator = v.into_validator(self.func_validator_allocations.take().unwrap_or_default());
+ let (code, allocations) = conversion::convert_module_code(function, func_validator)?;
+ self.code.push(code);
+ self.func_validator_allocations = Some(allocations);
}
ImportSection(reader) => {
if !self.imports.is_empty() {