summaryrefslogtreecommitdiff
path: root/crates/parser/src/lib.rs
diff options
context:
space:
mode:
authorHenry Gressmann <mail@henrygressmann.de>2026-08-17 20:07:51 +0200
committerGitHub <noreply@github.com>2026-08-17 20:07:51 +0200
commit358a183e5c12c32b8836acf9c71799f56e00b036 (patch)
treeffe63de847cebf5935951454eb8d76d9c76c222a /crates/parser/src/lib.rs
parenta42cb3434bd79accb6a49298f498e016e9c93b9e (diff)
chore: reduce instruction enum size (#52)
this is a fairly big commit since I've been just playing around with this for a while now. the main goal is to reduce instruction size by moving some operands into two separate vecs. memory operations still seem like the biggest issue right now, so as a follow op I'll probably remove the public linear memory trait again but let's see how this goes first. performance wise this is about the same as before, but serialization/deserialization is about 20% faster now. Signed-off-by: Henry <mail@henrygressmann.de> --------- Signed-off-by: Henry <mail@henrygressmann.de>
Diffstat (limited to 'crates/parser/src/lib.rs')
-rw-r--r--crates/parser/src/lib.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/crates/parser/src/lib.rs b/crates/parser/src/lib.rs
index 8db7920..90e239b 100644
--- a/crates/parser/src/lib.rs
+++ b/crates/parser/src/lib.rs
@@ -65,6 +65,10 @@ pub struct ParserOptions {
pub optimize_local_memory_allocation: bool,
/// Whether to run the peephole rewrite optimizer.
pub optimize_rewrite: bool,
+ /// Whether to deduplicate immutable function operands while parsing.
+ ///
+ /// This uses more parse CPU to reduce precompiled module and archive size.
+ pub deduplicate_operands: bool,
#[cfg(parallel_parser)]
/// Number of threads to use for parallel parsing.
@@ -83,6 +87,7 @@ impl Default for ParserOptions {
validation: cfg!(feature = "validate"),
optimize_local_memory_allocation: true,
optimize_rewrite: true,
+ deduplicate_operands: false,
#[cfg(parallel_parser)]
parser_threads: None,
}
@@ -134,6 +139,17 @@ impl ParserOptions {
self.optimize_rewrite
}
+ /// Enable or disable parse-time deduplication of immutable function operands.
+ pub const fn with_operand_deduplication(mut self, enabled: bool) -> Self {
+ self.deduplicate_operands = enabled;
+ self
+ }
+
+ /// Returns whether immutable function operands are deduplicated while parsing.
+ pub const fn deduplicate_operands(&self) -> bool {
+ self.deduplicate_operands
+ }
+
#[cfg(parallel_parser)]
/// Set the number of threads for parallel parsing.
///