Closed Bug 1674126 Opened 4 years ago Closed 4 years ago

Store native object private fields using PrivateValue()

Categories

(Core :: JavaScript Engine, task, P3)

task

Tracking

()

RESOLVED FIXED
84 Branch
Tracking Status
firefox84 --- fixed

People

(Reporter: jonco, Assigned: jonco)

Details

Attachments

(1 file)

Currently private fields work by getting a reference to the private field's HeapSlot (which is a class containing a Value), casting it to a void* reference and accessing that. Instead we can store private pointers in Value using PrivateValue and it would be simpler to do so. This could also help simplify GC marking in the future because it wouldn't have to take account of whether a slot is a private field.

(The stored representation for this actually ends up the same because PrivateValue() converts the pointer to a uintptr_t. When interpreted as a Value it looks like a double for all valid pointers that we want to store:

https://searchfox.org/mozilla-central/source/js/public/Value.h#198-199 )

This means all native object slots are JS::Values and removes a bunch of
dubious casting.

One wrinkle was that we now have to initialize both words of the value on
32-bit platforms; previously JIT code got away with leaving one word
uninitialized.

Pushed by jcoppeard@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/6441ff615b73
Store native object's private slot using PrivateValue r=jandem
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 84 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: