Closed Bug 1731121 Opened 3 years ago Closed 3 years ago

Collect type definitions referenced by wasm-GC objects

Categories

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

task

Tracking

()

RESOLVED FIXED
94 Branch
Tracking Status
firefox94 --- fixed

People

(Reporter: rhunt, Assigned: rhunt)

References

Details

Attachments

(6 files)

Currently we allocate GC type definitions in a JSContext global TypeContext per instantiation. Then when we allocate GC objects for that instance, we use an index into the JSContext global TypeContext for the RttValue. This scheme is easy to implement but doesn't allow the type definitions to ever be freed.

Driveby fix to use a more descriptive 'subtype' 'supertype' naming
scheme for the subtype algorithm and tests. Equivalence testing
is changed to first/second as well.

This commit makes TypeContext refcounted/shareable. This is so that
we can change RttValue's representation to be:

  1. RefPtr<TypeContext> typeContext;
  2. uint32_t typeIndex;
    Effectively adding an explicit type context field to RttValue instead
    of using an implicit global TypeContext, as it is now.

The big change here is that as TypeContext is now refcounted, it
needs to be heap-allocated, and cannot be a plain member of
ModuleEnvironment, as it is now. This adds some extra indirections.
If this is unacceptable, then I think we can find a workaround.

The next commit will implement the changes to RttValue.

Depends on D125888

Drop the global type context from WasmContext. RttValue's now hold
a strong reference to their TypeContext which they can use with their
pre-existing type index to get their type definition.

Depends on D125889

RttValue::Size,Kind were required when a JSContext* was needed to
access the TypeDef object. This is no longer a requirement and so we
can just directly get those fields.

Depends on D125890

While we're at it, let's remove the TypedProto slot as well. This is
currently unused and unlikely to match whatever is decided upon for
the MVP JS-API.

Depends on D125891

The direct pointer to TypeDef* is needed far more often, and can be used to
map back to the index whenever required.

Depends on D125892

Pushed by rhunt@eqrion.net:
https://hg.mozilla.org/integration/autoland/rev/3137f58698a4
wasm: Use better names in subtype algorithms. r=lth
https://hg.mozilla.org/integration/autoland/rev/7b2661dfc414
wasm: Make TypeContext refcounted and shareable. r=lth
https://hg.mozilla.org/integration/autoland/rev/7ce33df6f26d
wasm: Drop implicit global type context and refer to explicit TypeContext in RttValue. r=lth
https://hg.mozilla.org/integration/autoland/rev/819092ae2815
wasm: Drop duplicated slots no longer needed. r=lth
https://hg.mozilla.org/integration/autoland/rev/743c6ee17c28
wasm: Drop TypedProto. r=lth
https://hg.mozilla.org/integration/autoland/rev/959de44518b1
wasm: Store raw pointer to TypeDef instead of index in RttValue. r=lth
Regressions: 1731599
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: