Add support for arrays
Categories
(Core :: JavaScript: WebAssembly, task, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox88 | --- | fixed |
People
(Reporter: rhunt, Assigned: rhunt)
References
Details
Attachments
(8 files)
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review |
Add support for Wasm-GC array types.
Assignee | ||
Comment 1•5 years ago
|
||
This commit adds a version of the struct new instruction
which takes no initial values and gives each field the
default value.
Depends on D104271
Assignee | ||
Comment 2•5 years ago
|
||
This commit reorganizes the ValType class to be a base template PackedType<T>, which
is instantiated as a FieldType and ValType. This allows for some type safety
so that most code that never cares about I8/I16 doesn't need to be extended, while
still allowing sharing of implementation across ValType and FieldType.
I tried several different ways of achieving these goals, and this was the least
bad. I'm open to other alternatives.
StructType is extended to use FieldType for it's fields and struct instructions are
extended to handle this. The tricky case is struct.get which will zero extend the
packed fields. A later commit will make this spec compliant by adding get_u,get_s.
Depends on D104273
Assignee | ||
Comment 3•5 years ago
|
||
This commit adds ArrayType, extends TypedObject to support arrays, adds array
instructions to validation and the baseline compiler.
- ArrayType subtyping is initially shallow just like StructType.
- Every array value is an OutlineTypedObject to simplify codegen
- The length of an array is a uint32_t stored at the beginning of the object
- TypedObject trace lists were removed to simplify the implementation
- The implementation of gc object load/storing is factored out in the baseline
compiler to allow for sharing between struct.new/struct.get/struct.set/array.new
/array.get/array.set. This was the trickiest part and had the most churn. - New methods are added for pushing/popping AnyReg from the value stack to share
code for gc set/get - Helper methods were added for pushing/popping host pointers from the value stack
that are not GC references - The only correct use of StructType.isInline_ is during struct.new, so the field
is removed and replaced with a direct check of if the struct's size is small
enough to be inline.
Depends on D104274
Assignee | ||
Comment 4•5 years ago
|
||
This was only needed because at one point you could acquire the backing
storage of a TypedObject. Replace this with explicitly allocated data
to simplify OutlineTypedObject, along with removing the need to
have a separate object/owner pointer in baseline codegen.
Depends on D104275
Assignee | ||
Comment 5•5 years ago
|
||
This commit adds the zero/sign extension get instructions for
arrays and structs. The proposal specifies that these instructions
are used iff the field type is i8 or i16. Validation is updated
to check for this.
Depends on D104276
Assignee | ||
Comment 6•5 years ago
|
||
Depends on D104277
Assignee | ||
Comment 7•4 years ago
|
||
This commit tries to add more type safety to the baseline compiler by adding a
new RegRef and moving all GC uses to use it.
A couple of notes on the changes.
- RegRef is used only for GC pointers. It is realized on the Stk as a separate type.
- RegPtr is used only for non-GC pointers. It is pushed on the Stk as a I32/I64 depending
on the host system. RegPtr is not a typedef of RegI32/RegI64 to get slightly more type
safety during codegeneration. This could be subverted through the Stk, but I think this is
a good compromise. - ValType::hostPtr() is added for determining the wasm equivalent for a native ptr, I32/I64.
- BaseStackFrame::pushPtr/popPtr is renamed to pushGPR/popGPR to signify that it's
used for RegI32, RegPtr, and RegRef. - AnyReg only operates on RegRef
- Stk only allows RegRef
- valueAddr used by PostBarrier is switched to be a RegPtr to avoid a type mismatch as
it is not a GC object, it only points into a GC object.
Depends on D104274
Assignee | ||
Comment 8•4 years ago
|
||
This commit reduces the register usage of the GC instructions to allow
this code to work on x86.
Specifically
- array.new switches to a decrement
length
to zero loop to drop the separate index register - emitGcArraySet uses a manual lshift and rshift on the array index instead of a scratch register
- emitBarrieredStore is tweaked to preserve registers so we don't need an extra register
in emitGcArraySet - struct.set uses the rdata register as a scratch pointer while loading the rdata pointer
- array.set shuffles the
value
operand from the top of the stack to the bottom, so that
we don't need it in a register until later in the instruction.
Depends on D104278
Comment 10•4 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/20e86923858e
https://hg.mozilla.org/mozilla-central/rev/88a2bbde640f
https://hg.mozilla.org/mozilla-central/rev/1a9ebd331db4
https://hg.mozilla.org/mozilla-central/rev/3abb4481cd81
https://hg.mozilla.org/mozilla-central/rev/29b8a684ecfe
https://hg.mozilla.org/mozilla-central/rev/b4a9631c5ec4
https://hg.mozilla.org/mozilla-central/rev/b7978698e03f
https://hg.mozilla.org/mozilla-central/rev/f2cab503e546
Description
•