From 644395712a81c8f3fd56b6beafe9d3e09dfa9501 Mon Sep 17 00:00:00 2001 From: Henry Gressmann Date: Fri, 28 Jun 2024 01:10:54 +0200 Subject: 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 --- crates/parser/src/module.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'crates/parser/src/module.rs') 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() { -- cgit v1.3.1