summaryrefslogtreecommitdiff
path: root/crates/types/src
diff options
context:
space:
mode:
authorHenry <mail@henrygressmann.de>2026-08-29 14:34:58 +0200
committerHenry <mail@henrygressmann.de>2026-08-29 14:34:58 +0200
commitbb17468c990ba2ef819e5d3349539bb7a4aaedbd (patch)
tree2ac9acd6c213340c394ce3126c6025d54121db4e /crates/types/src
parente73c92160041ed0db5bda81e5c55b0e4c6293a87 (diff)
chore: improve optimizer and simplify function execution
- add stack-constant and fused local-update rewrites - split host and Wasm function storage and execution paths - add the default full feature - recursively discover WAST test files Signed-off-by: Henry <mail@henrygressmann.de>
Diffstat (limited to 'crates/types/src')
-rw-r--r--crates/types/src/instructions.rs14
-rw-r--r--crates/types/src/operands.rs19
2 files changed, 13 insertions, 20 deletions
diff --git a/crates/types/src/instructions.rs b/crates/types/src/instructions.rs
index b92a0f4..6a357ea 100644
--- a/crates/types/src/instructions.rs
+++ b/crates/types/src/instructions.rs
@@ -511,8 +511,9 @@ pub enum BinOp128 {
#[cfg_attr(feature = "archive", derive(serde::Serialize, serde::Deserialize))]
pub enum Instruction {
LocalCopy32(LocalAddr, LocalAddr), LocalCopy64(LocalAddr, LocalAddr), LocalCopy128(LocalAddr, LocalAddr),
- AddConst32(i32), AddConst64(Operand64Idx<i64>),
+ AddConst32(i32), AndConst32(i32), XorConst32(i32), ShrUConst32(i32), AddConst64(Operand64Idx<i64>),
IncLocal32(I32LocalArg), IncLocal64(PackedOp64<LocalAddr, i64>),
+
// The 32/64 suffix describes the operand width. Future compare-style ops may still yield i32 results.
BinOpLocalLocal32(BinOp, LocalAddr, LocalAddr), BinOpLocalLocal64(BinOp, LocalAddr, LocalAddr),
BinOpLocalLocal128(BinOp128, LocalAddr, LocalAddr),
@@ -520,18 +521,25 @@ pub enum Instruction {
AddLocalLocalSet32(LocalTripleArg), AddLocalLocalTee32(LocalTripleArg),
BinOpLocalLocalSet32(PackedOp64<BinOp, (u16, u16, u16)>), BinOpLocalLocalSet64(PackedOp64<BinOp, (u16, u16, u16)>), BinOpLocalLocalSet128(PackedOp64<BinOp128, (u16, u16, u16)>),
BinOpLocalLocalTee32(PackedOp64<BinOp, (u16, u16, u16)>), BinOpLocalLocalTee64(PackedOp64<BinOp, (u16, u16, u16)>), BinOpLocalLocalTee128(PackedOp64<BinOp128, (u16, u16, u16)>),
+
AddLocalConst32(I32LocalArg), SubLocalConst32(I32LocalArg), MulLocalConst32(I32LocalArg),
+ AndLocalConst32(I32LocalArg), ShrULocalConst32(I32LocalArg),
BinOpLocalConst32(PackedOp64<BinOp, (u16, u32)>), BinOpLocalConst64(PackedOp128<BinOp, (u16, u64)>),
- BinOpGlobalConst32(PackedOp64<BinOp, (u32, u32)>), BinOpGlobalConst64(PackedOp128<BinOp, (u32, u64)>),
- BinOpGlobalConst128(PackedOp64<BinOp128, (u32, Operand128Idx<[u8; 16]>)>), BinOpLocalConst128(PackedOp64<BinOp128, (u16, Operand128Idx<[u8; 16]>)>),
+ BinOpLocalConst128(PackedOp64<BinOp128, (u16, Operand128Idx<[u8; 16]>)>),
BinOpLocalConstSet32(PackedOp64<BinOp, (u16, u16, u32)>), BinOpLocalConstSet64(PackedOp128<BinOp, (u16, u16, u64)>), BinOpLocalConstSet128(PackedOp64<BinOp128, (u16, u16, Operand128Idx<[u8; 16]>)>),
BinOpLocalConstTee32(PackedOp64<BinOp, (u16, u16, u32)>), BinOpLocalConstTee64(PackedOp128<BinOp, (u16, u16, u64)>), BinOpLocalConstTee128(PackedOp64<BinOp128, (u16, u16, Operand128Idx<[u8; 16]>)>),
+
+ BinOpStackConst32(BinOp, i32), BinOpStackConst64(PackedOp64<BinOp, i64>),
+
BinOpStackLocal32(BinOp, LocalAddr),
BinOpStackLocalSet32(BinOp, LocalAddr, LocalAddr),
BinOpStackLocalTee32(BinOp, LocalAddr, LocalAddr),
BinOpStackLocal128(BinOp128, LocalAddr),
BinOpStackGlobal32(BinOp, u32),
BinOpStackGlobal64(BinOp, u32),
+ BinOpGlobalConst32(PackedOp64<BinOp, (u32, u32)>), BinOpGlobalConst64(PackedOp128<BinOp, (u32, u64)>),
+ BinOpGlobalConst128(PackedOp64<BinOp128, (u32, Operand128Idx<[u8; 16]>)>),
+
SetLocalConst32(I32LocalArg), SetLocalConst64(PackedOp64<LocalAddr, i64>), SetLocalConst128(PackedOp128<LocalAddr, [u8; 16]>),
IncMemoryLocal32(MemoryLocalArg), IncMemoryLocal64(MemoryLocalArg),
StoreLocalLocal32(MemoryLocalArg), StoreLocalLocal64(MemoryLocalArg), StoreLocalLocal128(MemoryLocalArg),
diff --git a/crates/types/src/operands.rs b/crates/types/src/operands.rs
index edbab26..af1b17f 100644
--- a/crates/types/src/operands.rs
+++ b/crates/types/src/operands.rs
@@ -146,26 +146,11 @@ macro_rules! define_operand {
define_operand!(Operand64, 8);
define_operand!(Operand128, 16);
-macro_rules! unwrap_or_unreachable {
- ($value:expr) => {{
- match $value {
- Some(value) => value,
- None => { core::hint::cold_path(); unreachable!() },
- }
- }};
- ($value:expr, $($arg:tt)+) => {{
- match $value {
- Some(value) => value,
- None => { core::hint::cold_path(); unreachable!($($arg)+) },
- }
- }};
-}
-
impl<T> Operand64Idx<T> {
/// Resolves this index to a copied 64-bit packed operand.
#[inline(always)]
pub fn resolve(self, data: &crate::WasmFunctionData) -> Operand64<T> {
- (*unwrap_or_unreachable!(data.operands64.get(self.index()), "invalid 64-bit operand index")).cast()
+ data.operands64[self.index as usize].cast()
}
}
@@ -173,7 +158,7 @@ impl<T> Operand128Idx<T> {
/// Resolves this index to a copied 128-bit packed operand.
#[inline(always)]
pub fn resolve(self, data: &crate::WasmFunctionData) -> Operand128<T> {
- (*unwrap_or_unreachable!(data.operands128.get(self.index()), "invalid 128-bit operand index")).cast()
+ data.operands128[self.index as usize].cast()
}
}