Closed Bug 1824904 Opened 2 years ago Closed 2 years ago

Make Wasm{Struct,Array}Object point directly at their SuperTypeVectors

Categories

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

enhancement

Tracking

()

RESOLVED FIXED
113 Branch
Tracking Status
firefox113 --- fixed

People

(Reporter: jseward, Assigned: jseward)

References

(Blocks 1 open bug)

Details

Attachments

(3 files)

Currently Wasm{Struct,Array}Object point at their relevant TypeDef, which
in turn points at the associated SuperTypeVector. This causes all references
to the SuperTypeVector -- particularly for casting -- to need a double
indirection. It would be better for these objects to point directly at their
SuperTypeVectors.

Severity: -- → N/A
Priority: -- → P2

Instance::refTest is no longer ever called; such tests are now (presumably)
generated in-line. This patch removes it and all the supporting machinery
(SASigRefTest, etc) needed to call it. No functional change.

Currently Wasm{Struct,Array}Object point at their relevant TypeDef, which in
turn points at the associated SuperTypeVector. This causes all references to
the SuperTypeVector -- particularly for casting -- to need a double
indirection. This patch makes them point directly at their SuperTypeVectors
instead.

The changes are almost all mechanical. Points of note are:

  • WasmGcObject (hence WSO/WAO) now hold a SuperTypeVector*, not a TypeDef*.

  • SuperTypeVector now holds a TypeDef*; and TypeDef already has a pointer to
    its SuperTypeVector. These two must point at each other, so as to form a
    1:1 relationship.

  • TypeDefInstanceData now has both a SuperTypeVector* and TypeDef*, since both
    are needed at run time.

  • The point of all the changes is so that
    MacroAssembler::branchWasmTypeDefIsSubtype -- now renamed to
    ::branchWasmSuperTypeVectorIsSubtype -- can omit the load that would chase
    from a TypeDef to its SuperTypeVector. However, this routine is also
    changed so as to skip the fast-path check for the type defs (as-was) being
    equal; profiling suggests it is perf-neutral, and so generating smaller code
    seems preferable.

  • MinSuperTypeVectorLength has been increased from 3 to 8 following profiling
    with Barista-3. jit-test/tests/wasm/gc/casting.js is updated accordingly.

  • The example in the comment explaining type vectors in WasmTypeDef.h has been
    reworked so as to make it clear that the type numbers have no relationship
    to the vector indices (this wasn't clear before).

  • SuperTypeVector has been changed from a struct to a class; we seem to mostly
    use classes elsewhere, even for objects accessed from generated code.

Depends on D174060

WasmTypeDef.h contains all the key data types for the wasm-gc extension.
These are arranged more or less in a def-before-use ordering, which is good.
But the file is still a bit hard to navigate. This patch adds dividing
comments, and a few in WasmTypeDef.cpp too. No functional change.

Depends on D174061

Pushed by jseward@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/9754f151ef66 part 1: remove Instance::refTest. r=rhunt. https://hg.mozilla.org/integration/autoland/rev/10fdad0cb315 part 2: make Wasm{Struct,Array}Object point directly at their SuperTypeVectors. r=rhunt. https://hg.mozilla.org/integration/autoland/rev/badd00a28e4e part 3: add some division markers to WasmTypeDef.h. r=rhunt.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: