WebAssembly / WebAssembly/binaryen

Extra pass for v128 operands in exported functions and globals?

Open
#4,891 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
WebAssembly
Stars
8.6k
Forks
885
Avg merge
1d 19h
Merged PRs (30d)
69

Description

At current moment, we can produce such code:

(func (export "a") $a (param $0 v128) (result v128) ;; [v128] -> [v128]
  local.get $0
  local.get $0
  i32x4.mul
 )

But web engines can't call functions with such signature. I'm not sure about standalone runtimes like wasmtime / wasmer, but web engines definitely not.

So I propose to add a new separate pass (at the end of pass pipeline) that would modify the code and the signature as follows:

(module
  (memory $0 1)
  ;; reserve temp data for return value of $a
  (data (i32.const 16) "\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00")
  
  (func (export "a") $a (param $0 i32) (result i32) ;; [i32] -> [i32]
    (local $1 v128)
    i32.const 16
    local.get $0
    v128.load
    local.tee $1
    local.get $1
    i32x4.mul
    v128.store
    i32.const 16
  )
 )

That is, now v128 values are stored and loaded from linear memory. WDYT?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files, tests, or entry points are named. Start by locating the end of Binaryen’s pass pipeline and the handling of exported function and global signatures, then check the proposal against web-engine constraints. Done would require an agreed design and coverage for v128 operands in exported interfaces.

Written by the indexing model from the issue text.

Assessment

Tech stack
wasm
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.