Closed Bug 2038557 Opened 6 months ago Closed 6 months ago

Remove reservedSlots pointer from proxy objects

Categories

(Core :: JavaScript Engine, task, P2)

task

Tracking

()

RESOLVED FIXED
152 Branch
Tracking Status
firefox152 --- fixed

People

(Reporter: jandem, Assigned: jandem)

References

(Blocks 1 open bug)

Details

(Keywords: perf-alert)

Attachments

(8 external files)

Bug 2037186 changed the object transplant/swap code to require proxies and we now only support objects with matching alloc kinds. This made it possible to remove the external ProxyValueArray code so now ProxyValueArray is always allocated inline in the object. This means we can remove the reservedSlots pointer next.

After we remove the reservedSlots pointer, we can use this field to store the expando object (currently stored as an object-or-null Value in the ProxyValueArray). The result is that proxies with 1 reserved slot (eg typical DOM proxies) will get 16 bytes smaller (OBJECT4 => OBJECT2 alloc kind).

The main wrinkle is that JS::{G,S}etReservedSlot currently work on both native objects and proxies because the proxy reservedSlots pointer overlays NativeObject::slots_. I think that's worth changing to simplify and shrink proxy objects.

Blocks: sm-embedding
Severity: -- → N/A
Priority: -- → P2

When we could transplant native objects, this wasn't valid for transplantable (DOM)
objects, but we can now do this and it's a bit faster.

At some point it would be nice to assert getSlot/setSlot aren't used for reserved slots.

Let's stop exposing this capability to embedders.

Since bug 2037186 we already required the same allocation kind, but that can change
when we make object layout or GC changes so isn't ideal.

This change also simplifies later patches.

This worked because it relied on the proxy's reservedSlots pointer having the same
offset as NativeObject::slots_ (and proxies have nfixed 0 in the shape).

It seems better to separate this and provide separate functions for callers that know
the object is always a native object or a proxy. Later patches will start using those.
This lets us change and optimize the proxy object layout.

The NativeObject APIs are now a bit faster because they use the same trick as
NativeObject::getReservedSlotRef (they no longer have to look at the shape's
number of fixed slots).

JS::GetClass was moved to shadow/Object.h to break an include cycle.

At this point proxies still have a reservedSlots pointer, but it always points
to the inline data so we can access these slots directly. The next patch will
remove this pointer and change the C++ code.

The ProxyValueArray is now always allocated inline in the object so we don't need
to store a pointer to it.

This patch replaces reservedSlots with a padding field so there's no change in
object size yet.

This shrinks proxies with 1 reserved slot by 16 bytes because they can now use
OBJECT2 (private slot + reserved slot) instead of OBJECT4.

Part 4 adds a branch to JS::GetReservedSlot and JS::SetReservedSlot. A lot of
calls to these functions are in the generated DOM bindings and there we can call
the specialized versions instead in almost all cases. This avoids a small amount
of overhead and a binary size regression.

Attachment #9585897 - Attachment description: Bug 2038557 part 3 - Require matching reserved slot counts for proxy swap/transplant. r?jonco! → Bug 2038557 part 3 - Require proxies with two reserved slots for proxy swap/transplant. r?jonco!
Pushed by jdemooij@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/a7c7b7ae986c https://hg.mozilla.org/integration/autoland/rev/a1ba5f6947cd part 1 - Use {g,s}etReservedSlot more instead of {g,s}etSlot. r=jonco https://github.com/mozilla-firefox/firefox/commit/73f5084548af https://hg.mozilla.org/integration/autoland/rev/2df4e79c21d8 part 2 - Inline SetProxyHandler into sole caller. r=jonco https://github.com/mozilla-firefox/firefox/commit/bf3a79b7fbef https://hg.mozilla.org/integration/autoland/rev/3b9c8c655fa4 part 3 - Require proxies with two reserved slots for proxy swap/transplant. r=jonco https://github.com/mozilla-firefox/firefox/commit/e09592db9eb4 https://hg.mozilla.org/integration/autoland/rev/0a2a06838665 part 4 - Don't use the same code path for proxies and native objects in JS::{G,S}etReservedSlot. r=jonco https://github.com/mozilla-firefox/firefox/commit/f0146ee4debe https://hg.mozilla.org/integration/autoland/rev/383223eecf56 part 5 - Stop using ProxyObject reservedSlots pointer in JIT code. r=iain https://github.com/mozilla-firefox/firefox/commit/653f12bd8d8f https://hg.mozilla.org/integration/autoland/rev/73ff23529736 part 6 - Remove reservedSlots pointer from ProxyObject. r=jonco https://github.com/mozilla-firefox/firefox/commit/cb4eed70853f https://hg.mozilla.org/integration/autoland/rev/0fc132861215 part 7 - Move proxy expando object pointer to ProxyDataLayout. r=jonco https://github.com/mozilla-firefox/firefox/commit/9db557977ace https://hg.mozilla.org/integration/autoland/rev/0a45000775c9 part 8 - Use specialized proxy/native reserved slot functions in generated DOM bindings where possible. r=edgar

(In reply to Pulsebot from comment #9)

Pushed by jdemooij@mozilla.com:
https://github.com/mozilla-firefox/firefox/commit/a7c7b7ae986c
https://hg.mozilla.org/integration/autoland/rev/a1ba5f6947cd
part 1 - Use {g,s}etReservedSlot more instead of {g,s}etSlot. r=jonco
https://github.com/mozilla-firefox/firefox/commit/73f5084548af
https://hg.mozilla.org/integration/autoland/rev/2df4e79c21d8
part 2 - Inline SetProxyHandler into sole caller. r=jonco
https://github.com/mozilla-firefox/firefox/commit/bf3a79b7fbef
https://hg.mozilla.org/integration/autoland/rev/3b9c8c655fa4
part 3 - Require proxies with two reserved slots for proxy swap/transplant.
r=jonco
https://github.com/mozilla-firefox/firefox/commit/e09592db9eb4
https://hg.mozilla.org/integration/autoland/rev/0a2a06838665
part 4 - Don't use the same code path for proxies and native objects in
JS::{G,S}etReservedSlot. r=jonco
https://github.com/mozilla-firefox/firefox/commit/f0146ee4debe
https://hg.mozilla.org/integration/autoland/rev/383223eecf56
part 5 - Stop using ProxyObject reservedSlots pointer in JIT code. r=iain
https://github.com/mozilla-firefox/firefox/commit/653f12bd8d8f
https://hg.mozilla.org/integration/autoland/rev/73ff23529736
part 6 - Remove reservedSlots pointer from ProxyObject. r=jonco
https://github.com/mozilla-firefox/firefox/commit/cb4eed70853f
https://hg.mozilla.org/integration/autoland/rev/0fc132861215
part 7 - Move proxy expando object pointer to ProxyDataLayout. r=jonco
https://github.com/mozilla-firefox/firefox/commit/9db557977ace
https://hg.mozilla.org/integration/autoland/rev/0a45000775c9
part 8 - Use specialized proxy/native reserved slot functions in generated
DOM bindings where possible. r=edgar

Perfherder has detected a talos performance change from push 0a45000775c9e4c2c455216d6bf4999d0542a2e7.

No action is required from the author; this comment is provided for informational purposes only.

Improvement Test Platform Options Absolute values [old vs new]
16% perf_reftest_singletons has-reject-by-local-name.html (doc) macosx1470-64-shippable e10s fission stylo webrender 0.42 ms -> 0.35 ms
13% perf_reftest_singletons has-reject-by-local-name.html (doc) linux2404-64-shippable e10s fission stylo webrender 0.45 ms -> 0.39 ms

Need Help or Information?

If you have any questions, please reach out to aesanu@mozilla.com. Alternatively, you can find help on Slack by joining #perf-help, and on Matrix you can find help by joining #perftest.

Details of the alert can be found in the alert summary, including links to graphs and comparisons for each of the affected tests.

Keywords: perf-alert
QA Whiteboard: [qa-triage-done-c153/b152]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: