Closed Bug 1774840 Opened 3 months ago Closed 21 days ago

Implement advanced array construction instructions in baseline

Categories

(Core :: JavaScript: WebAssembly, task, P3)

task

Tracking

()

RESOLVED FIXED
106 Branch
Tracking Status
firefox106 --- fixed

People

(Reporter: rhunt, Assigned: jseward)

References

(Blocks 1 open bug)

Details

Attachments

(8 files)

The GC proposal has several new instructions since we last updated our implementation:

array.copy
array.init
array.init_static
br_on_non_null
br_on_cast_fail
ref.is_T
ref.br_on_T
ref.br_on_non_T

And possibly more. This bug is just for the work to implement them in baseline (the only compiler we support GC in).

We have several new array instructions [1]. We should track the actual proposal here, and not V8's document as the proposal is more up to date here. The one exception is that the proposal still lists these instructions as taking an (rtt) operand. This won't be the case after rtt values are removed.

  1. array.new_fixed <typeidx> <N> - pops N values from the stack to form an array of N values
  2. array.new_data <typeidx> <dataidx> - create an array and initialize it from a data segment
  3. array.new_elem <typeidx> <elemidx> - create an array and initialize it from an elem segment

There is also a V8 only array.copy instruction [2] that we will also need to implement.

  1. array.copy <typeidx1> <typeidx2> - copies a range from srcArray to destArray

array.new_data/new_elem/copy should all be implemented via instance calls (at least for the baseline compiler). array.new_fixed can use an instance call to create the array, but will need to pop the values itself and store them in the array.

[1] https://github.com/WebAssembly/gc/blob/main/proposals/gc/MVP.md#arrays
[2] https://docs.google.com/document/d/1DklC3qVuOdLHSXB5UXghM_syCh-4cMinQ50ICiXnK3Q/edit#

The new instructions will depend on the the text format being updated in [1]. We'll vendor in this change in bug 1774829.

[1] https://github.com/bytecodealliance/wasm-tools/pull/677

Here's a roughed-in test file for the new array instructions. There may be some syntax errors, but the essence should be correct.

Assignee: nobody → jseward

WIP patch, first working implementation of array.new_fixed, array.new_data,
array.new_elem and array.copy. Is almost certainly a long way off being fully
correct, in multiple ways.

Part 1 - debug/comment improvements. No functional change.

  • Add a debug-only method BaseCompiler::showStack, to dump the compiler's
    value stack to stderr.

  • Add comment describing argument-handling in BaseCompiler::emitInstanceCall.

In the existing GC array implementation, change some names that are length
or elementsLength to be numElements, to remove ambiguity about whether
those quantities are "number of bytes" or "number of array elements". No
functional change.

Depends on D154228

Adds wasm baseline implementation and test cases for array.new_fixed.

Depends on D154229

Adds wasm baseline implementation and test cases for array.new_data.

Depends on D154230

Adds wasm baseline implementation and test cases for array.new_elem.

Depends on D154231

Adds wasm baseline implementation and test cases for array.new_copy.

Depends on D154232

Summary: Implement new GC instructions in baseline → Implement advanced array construction instructions in baseline
Blocks: 1784274
No longer blocks: wasm-gc
Pushed by jseward@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/da4e5d8fb7e9
Implement new GC instructions in baseline (Part 1).  r=rhunt.
https://hg.mozilla.org/integration/autoland/rev/2c7fcebf117c
Implement new GC instructions in baseline (Part 2).  r=rhunt.
https://hg.mozilla.org/integration/autoland/rev/976cd7902cb5
Implement new GC instructions in baseline (Part 3).  r=rhunt.
Keywords: leave-open
Blocks: 1774836
Depends on: 1786374
Pushed by jseward@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/dad36378291b
Implement new GC instructions in baseline (Part 4).  r=rhunt.
https://hg.mozilla.org/integration/autoland/rev/31aa38a5e2fc
Implement new GC instructions in baseline (Part 5).  r=rhunt.
Pushed by jseward@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/8b27b90ec991
Implement new GC instructions in baseline (Part 6).  r=rhunt.
Keywords: leave-open
Status: NEW → RESOLVED
Closed: 21 days ago
Resolution: --- → FIXED
Target Milestone: --- → 106 Branch
You need to log in before you can comment on or make changes to this bug.