Skip to content

Conversation

Robbepop
Copy link
Member

@Robbepop Robbepop commented Aug 29, 2025

Closes #1642.

New Wasmi IR bytecode that stores immediates inline instead of relying on function local constants.
This new Wasmi IR is generated via build.rs script and thus out of the box way more consistent than its precursor.
The new IR supports encoding the instruction stream into a byte stream and decode it from a byte stream back into instructions.

The following features are supported:

  • enum Op: type similar to Wasmi's current Instruction type
  • enum OpCode: Op discriminants encoded as u16 - helps with threaded code encoding
  • Encode & Decode: safe encoding of Op (and its components) and unsafe but efficient decoding of Op.
    • This encode and decode scheme was designed with direct and indirect threaded code architecture in mind.
  • Encoder and Decoder traits that are going to be implemented in the wasmi crate by respective types.

Unblocks the following issues:

ToDos

  • Add missing simd operators.
    • v128.load memarg: (i32) -> (v128)
    • v128.store memarg: (i32 v128) -> ()
    • v128.load8x8_s memarg: (i32) -> (v128)
    • v128.load8x8_u memarg: (i32) -> (v128)
    • v128.load16x4_s memarg: (i32) -> (v128)
    • v128.load16x4_u memarg: (i32) -> (v128)
    • v128.load32x2_s memarg: (i32) -> (v128)
    • v128.load32x2_u memarg: (i32) -> (v128)
    • v128.load8_splat memarg: (i32) -> (v128)
    • v128.load16_splat memarg: (i32) -> (v128)
    • v128.load32_splat memarg: (i32) -> (v128)
    • v128.load64_splat memarg: (i32) -> (v128)
    • v128.load8_lane memarg laneidx: (i32 v128) -> (v128)
    • v128.load16_lane memarg laneidx: (i32 v128) -> (v128)
    • v128.load32_lane memarg laneidx: (i32 v128) -> (v128)
    • v128.load64_lane memarg laneidx: (i32 v128) -> (v128)
    • v128.store8_lane memarg laneidx: (i32 v128) -> ()
    • v128.store16_lane memarg laneidx: (i32 v128) -> ()
    • v128.store32_lane memarg laneidx: (i32 v128) -> ()
    • v128.store64_lane memarg laneidx: (i32 v128) -> ()
    • v128.load32_zero memarg: (i32) -> (v128)
    • v128.load64_zero memarg: (i32) -> (v128)
  • Add missing relaxed-simd operators.
    • I16x8RelaxedDotI8x16I7x16S
    • I32x4RelaxedDotI8x16I7x16AddS
    • F32x4RelaxedMadd
    • F32x4RelaxedNmadd
    • F64x2RelaxedMadd
    • F64x2RelaxedNmadd

Copy link

codecov bot commented Aug 29, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.76%. Comparing base (5439ae6) to head (0e1e32d).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1650      +/-   ##
==========================================
- Coverage   70.78%   70.76%   -0.02%     
==========================================
  Files         179      179              
  Lines       15199    15199              
==========================================
- Hits        10758    10755       -3     
- Misses       4441     4444       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Robbepop Robbepop marked this pull request as ready for review September 2, 2025 09:04
@Robbepop Robbepop merged commit 774995b into main Sep 5, 2025
19 checks passed
@Robbepop Robbepop deleted the rf-wasmi-ir-3.0 branch September 5, 2025 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Redesign Wasmi bytecode
1 participant