Improve InlineTable data structure
Categories
(Core :: JavaScript Engine, task, P1)
Tracking
()
Tracking | Status | |
---|---|---|
firefox132 | --- | fixed |
People
(Reporter: jandem, Assigned: jandem)
References
Details
Attachments
(6 files)
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 | |
48 bytes,
text/x-phabricator-request
|
Details | Review |
I'm using InlineMap
for bug 1920430, but I noticed it has a number of issues:
- Removed inline entries are set to a tombstone value, but are never reused. This means we can expand to a full
HashMap
/HashSet
before using all inline entries. - Support was added for customizing tombstone values through
KeyPolicy
, but this is incomplete. There are still multiple places where we rely on key values being 'truthy'. - Tombstone values add some complexity - see the separate
inlCount_
vsinlNext_
fields.
It's simpler to implement removal by swapping the last item in the array with the removed item.
Also, the class contains both an array of inline entries and a HashMap
/HashSet
. We can save space by using a Variant
.
Assignee | ||
Comment 1•24 days ago
|
||
Also use private
instead of protected
in a few places.
Assignee | ||
Comment 2•24 days ago
|
||
InlineTable
supports customizing tombstone values through KeyPolicy
, but this was
incomplete. Some places still relied on valid keys being 'truthy'.
Also, removed inline entries were never reused. This means we could expand to a
HashMap
/HashSet
before using all inline entries.
This patch implements removal by swapping the removed item with the last item.
This also lets us merge the inlNext_
and inlCount_
fields.
A later patch will add mutationCount
assertions to ensure we don't remove items
from the table while iterating.
Assignee | ||
Comment 3•24 days ago
|
||
This is more memory efficient and also means we don't initialize the
HashMap
/HashSet
if it's not used.
Assignee | ||
Comment 4•24 days ago
|
||
Also use uint32_t
instead of size_t
to save some space. This will never be a
large value.
Assignee | ||
Comment 5•24 days ago
|
||
Add assertions to check no entries are added/removed while using Ptr
/AddPtr
or Range
.
Assignee | ||
Comment 6•24 days ago
|
||
Updated•22 days ago
|
Comment 8•22 days ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/7933f2426217
https://hg.mozilla.org/mozilla-central/rev/67349f52462c
https://hg.mozilla.org/mozilla-central/rev/e41d64b380a3
https://hg.mozilla.org/mozilla-central/rev/a04d374230a3
https://hg.mozilla.org/mozilla-central/rev/2390753f710e
https://hg.mozilla.org/mozilla-central/rev/e88470b69a09
Description
•