Closed Bug 1622828 Opened 4 years ago Closed 4 years ago

Implement wasm->js multi-value calls

Categories

(Core :: JavaScript: WebAssembly, enhancement, P2)

enhancement

Tracking

()

RESOLVED FIXED
mozilla76
Tracking Status
firefox76 --- fixed

People

(Reporter: wingo, Assigned: wingo)

References

Details

Attachments

(1 file)

The patch to be attached will let wasm modules import JS functions that return multiple values.

Spec here: https://webassembly.github.io/multi-value/js-api/index.html#exported-function-exotic-objects

Specifically, I paste some contents inline here:

To run a host function from the JavaScript object func, type functype, and list of WebAssembly values arguments, perform the following steps:

  1. Let [parameters] → [results] be functype.
  2. Let ret be ? Call(func, undefined, jsArguments).
  3. If results is empty, return « ».
  4. Otherwise, if results’s size is 1, return « ? ToWebAssemblyValue(ret, results[0]) ».
  5. Otherwise:
    1. Let method be ? GetMethod(ret, @@iterator).
    2. If method is undefined, throw a TypeError.
    3. Let values be ? IterableToList(ret, method).
    4. Let wasmValues be a new, empty list.
    5. If values and results do not have the same length, throw a TypeError.
    6. For each value and resultType in values and results, paired linearly, append ToWebAssemblyValue(value, resultType) to wasmValues.
    7. Return wasmValues.
Assignee: nobody → wingo

This patch implements calls from WebAssembly to JS, where the JS
function returns multiple values. The multiple values are returned as
an iterable.

Spec here:
https://webassembly.github.io/multi-value/js-api/index.html#exported-function-exotic-objects

Priority: -- → P2
Blocks: 1625885
Pushed by shindli@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/5bd28470648f
Implement wasm->js multi-value calls r=lth
Backout by shindli@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/746cfdd2c4d5
Backed out changeset 5bd28470648f for linux build bustages CLOSED TREE
Pushed by shindli@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/5c02a3e6d56e
Implement wasm->js multi-value calls r=lth
Pushed by rgurzau@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/4f66cfb5d2f2
Implement wasm->js multi-value calls r=lth
Flags: needinfo?(wingo)
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla76
Regressions: 1626903
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: