Improve C++ class hierarchy for Shapes
Categories
(Core :: JavaScript Engine, task, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox110 | --- | fixed |
People
(Reporter: jandem, Assigned: jandem)
References
Details
Attachments
(6 files)
21.33 KB,
patch
|
Details | Diff | Splinter 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 |
It would be nice if the C++ Shape
type had a class hierarchy like this:
Shape
NativeShape => for NativeObject
SharedShape
DictionaryShape
ProxyShape => for ProxyObject
WasmGCShape => for Wasm GC objects
After the ReShape work this shouldn't be too hard to do I think.
We could then move the proxy handler from the proxy object to the proxy shape, and similarly store Wasm-GC-specific data in WasmGCShape
(this is why I'm filing this now).
Assignee | ||
Comment 1•2 years ago
|
||
Also, some of the JSClass
hooks and flags could potentially be replaced by switching on the "shape kind" enum. This is especially nice for the very hot object->is<NativeObject>()
check.
Comment 2•2 years ago
|
||
In case it's helpful, here's the WIP patch I have for wasm GC shapes. You can ignore the part about keeping a HashSet of them, I don't need that anymore.
Really the only point for a WasmGcShape at this point is to keep a strong reference to the atomically refcounted wasm::RecGroup so that all WasmGcObject's don't need finalizers that perform the atomic dec-ref.
Any actual access to the type information is going to be done through the second header word of WasmGcObject, which will be a raw pointer to the wasm::TypeDef (stored in the recursion group kept alive by the shape).
Assignee | ||
Comment 3•2 years ago
|
||
(In reply to Ryan Hunt [:rhunt] from comment #2)
In case it's helpful, here's the WIP patch I have for wasm GC shapes.
That looks good. I want to clean up the Shape
subclasses a bit before adding more of them, but the result will be similar.
Adding separate classes for proxy shapes and wasm gc objects will be nice. We can then add NativeShape
as base class of SharedShape
and DictionaryShape
, so shapes will be less biased towards native objects.
Assignee | ||
Comment 4•2 years ago
|
||
Assignee | ||
Comment 5•2 years ago
|
||
Add separate Shape
subclasses. SharedShape
is now only used for native objects.
This will make it possible to store other data in Proxy/WasmGC shapes in the future.
Depends on D164211
Assignee | ||
Comment 6•2 years ago
|
||
The Shape
methods related to property information and number of fixed slots are
moved into NativeShape
, to improve type safety.
Depends on D164212
Assignee | ||
Comment 7•2 years ago
|
||
This saves two dereferences by looking at the shape instead of the class.
Depends on D164213
Assignee | ||
Comment 8•2 years ago
|
||
Depends on D164214
Comment 10•2 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/8492a84977c9
https://hg.mozilla.org/mozilla-central/rev/e9ec0e089b0d
https://hg.mozilla.org/mozilla-central/rev/6e25cfb0c2c9
https://hg.mozilla.org/mozilla-central/rev/fec2ed2fbde3
https://hg.mozilla.org/mozilla-central/rev/79c3e5d3415f
Description
•