Use AvlTree for profiler's JIT code table
Categories
(Core :: JavaScript Engine: JIT, task, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox109 | --- | fixed |
People
(Reporter: jandem, Assigned: jandem)
References
(Blocks 1 open bug)
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 |
While looking at bug 1799806 I tried to fix some issues and then ended up making larger changes in this area.
We currently use a skip list to implement the profiler's JIT entry table. We can simplify this table a lot by replacing it with the AvlTree
class that Julian added recently. My patches also change the profiler entries to use proper constructors/destructors with UniquePtr
.
Assignee | ||
Comment 1•2 years ago
|
||
This doesn't provide much value now, but will simplify the next patch.
Assignee | ||
Comment 2•2 years ago
|
||
The skip list implementation in JitcodeGlobalTable is hard to work with and
intertwined with the rest of the code. This patch replaces it with the new
js::AvlTree
. The way it's used is very similar to how the register allocator
now uses AVL trees to track live ranges.
Entries are now allocated with malloc
instead of the LifoAlloc
. This should
be fine because there's at most one entry per JIT compilation, and means we don't
need to maintain our own free list. It also makes it easier to move away from
fixed-size entries in the next patch.
Because the AvlTree
has some limitations that are hard to fix (supporting
deletions while iterating over the tree, UniquePtr
values), the entries are
actually stored in (and owned by) a Vector
. The Vector
is used for iterating
over all entries and the tree is only used to look up entries by address.
The fake QueryEntry
type that was used only for lookups can be removed now
because we can use JitCodeRange
instead.
Depends on D162836
Assignee | ||
Comment 3•2 years ago
|
||
This patch makes a few changes that have to happen simultaneously.
Profiler entries now use UniquePtr
with proper C++ constructors/destructors and
move semantics, replacing the init()
and destroy()
methods. The raw pointers in
IonEntry
can likely be cleaned up more later.
Entries are no longer copied. Once allocated by the compiler, ownership is transfered
to the table's Vector
until the entry can be removed from the table. At that point
all data is destroyed automatically by the UniquePtr
.
JitcodeGlobalEntry
no longer contains a union of all entry types. It's now just the
entry base class (merged with BaseEntry
). This means entries no longer have to be
the same size in memory. IonEntry
can likely be simplified in the future to get rid
of the separate allocations for the data it points to.
It might be possible to simplify this more in the future by using virtual
methods.
Depends on D162837
Assignee | ||
Comment 4•2 years ago
|
||
Make it an enum class, remove sentinel values we no longer need, and remove
default
cases from switch-statements so we get compiler exhaustiveness checking.
Depends on D162838
Assignee | ||
Comment 5•2 years ago
|
||
Depends on D162839
Assignee | ||
Comment 6•2 years ago
|
||
This is more consistent with code elsewhere, now that JitcodeGlobalEntry
is
just the base class.
Depends on D162840
Comment 8•2 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/a75fad391eb6
https://hg.mozilla.org/mozilla-central/rev/ac4c555a1991
https://hg.mozilla.org/mozilla-central/rev/85f0bce2cb73
https://hg.mozilla.org/mozilla-central/rev/ae93de9d3673
https://hg.mozilla.org/mozilla-central/rev/0e482c20ae1c
https://hg.mozilla.org/mozilla-central/rev/4259f3b15c45
Updated•2 years ago
|
Description
•