Closed Bug 1543211 Opened 1 year ago Closed 1 year ago

Move immutable bytecode-related fields from JSScript to SharedScriptData

Categories

(Core :: JavaScript Engine, task, P1)

task

Tracking

()

RESOLVED FIXED
mozilla68
Tracking Status
firefox68 --- fixed

People

(Reporter: tcampbell, Assigned: tcampbell)

References

Details

Attachments

(3 files)

We currently keep scalar fields associated with bytecode compilation results on the JSScript itself, but since SharedScriptData always exists we should move the non-pointer /immutable fields off JSScript.

The primary motivation is memory reduction, especially when we are able to use SharedScriptData across processes. It also is useful if LazyScript and JSScript types get unified.

As more fields get added to SharedScriptData it becomes more problematic
to check them in hashing function so this changes code to hash raw bytes
of the immutable portion of SharedScriptData itself as well as its
trailing arrays (which currently hash as bytes already).

This redefines those data ranges in terms of mozilla::Span to make it
simpler to work with.

The ScriptBytecodeHasher is renamed to SharedScriptDataHasher to be
clearer about its scope.

The ScriptBytecodeHasher::Lookup struct is removed. The self-hash of a
lookup is only computed once during lookup so it is not necessary for
use to cache the result ourselves.

The SharedScriptData allocation always exists so moving these immutable
integer fields allows more sharing for memory savings. This adds an
extra dereference in a few paths in the JITs but they are negligable.

When describing multiple packed arrays that make up a SharedScriptData
we previously saved the length of each array and computed the start of
an array from the other of the others. Instead, this patch records the
offset from |this| to the end of each array. This makes seeking to the
start of an array simpler while still allowing computing the length of
an array as the difference of its start and end offsets.

This patch replaces the SharedScriptData::natoms/noteLength fields with
offsets instead.

Pushed by tcampbell@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/3240bfce551d
Hash raw bytes in ScriptBytecodeHasher r=jandem
https://hg.mozilla.org/integration/autoland/rev/0930e8c0f382
Move integer fields from JSScript to SharedScriptData r=jandem
https://hg.mozilla.org/integration/autoland/rev/495c41f92744
Store offsets instead of lengths in SharedScriptData r=jandem
Blocks: 1537908
You need to log in before you can comment on or make changes to this bug.