diff options
| author | Henry <mail@henrygressmann.de> | 2026-04-19 15:12:25 +0200 |
|---|---|---|
| committer | Henry <mail@henrygressmann.de> | 2026-04-19 15:12:25 +0200 |
| commit | 684d5a04a928ea4132d0c5e61bb4086fac9feb22 (patch) | |
| tree | 54255946136739876cafe9e5a066f2d1753c93c6 /crates/parser/src/lib.rs | |
| parent | 143c7dd66e2dda360d0b042579245737576344dc (diff) | |
feat: lazy memory allocation, fix instruction rewrite order
Signed-off-by: Henry <mail@henrygressmann.de>
Diffstat (limited to 'crates/parser/src/lib.rs')
| -rw-r--r-- | crates/parser/src/lib.rs | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/crates/parser/src/lib.rs b/crates/parser/src/lib.rs index ad58cc2..0b5af2e 100644 --- a/crates/parser/src/lib.rs +++ b/crates/parser/src/lib.rs @@ -43,8 +43,30 @@ pub use tinywasm_types::TinyWasmModule; /// Parser optimization and lowering options. #[non_exhaustive] -#[derive(Debug, Clone, Default)] -pub struct ParserOptions {} +#[derive(Debug, Clone)] +pub struct ParserOptions { + /// Whether to optimize local memory allocation by skipping allocation of unused local memories. + pub optimize_local_memory_allocation: bool, +} + +impl Default for ParserOptions { + fn default() -> Self { + Self { optimize_local_memory_allocation: true } + } +} + +impl ParserOptions { + /// Enable or disable the optimization that skips allocating unused local memories. + pub const fn with_local_memory_allocation_optimization(mut self, enabled: bool) -> Self { + self.optimize_local_memory_allocation = enabled; + self + } + + /// Returns whether unused local memory allocation optimization is enabled. + pub const fn optimize_local_memory_allocation(&self) -> bool { + self.optimize_local_memory_allocation + } +} /// A WebAssembly parser #[derive(Debug, Default)] |
