Closed Bug 1606113 Opened 1 year ago Closed 1 year ago

Move JSScript/LazyScript finalization/tracing to js::BaseScript


(Core :: JavaScript Engine, task, P1)




Tracking Status
firefox73 --- fixed


(Reporter: tcampbell, Assigned: tcampbell)




(4 files)

The trace/finalize logic should be moved to the BaseScript to prepare for unifying the GC arena.

Care must be taken with side-table data used for JSScripts. We can add a BaseScript::hasBytecode() method that looks for the presence of sharedData_ to determine if side-tables needed to be traced or updated. These side-tables are only used for successfully compiled scripts, so checking for bytecode is a reasonable mechanism.

The script->lazy and lazy->script tracing is not moved to BaseScript because those fields will be removed shortly.

Associated tables like DebuggerScripts still need access to bytecode, so make
sure we finalize the script's actual fields last.

Assignee: nobody → tcampbell

The trace logic is already part of BaseScript so move the finalization logic.
Use a down-cast to JSScript now since only JSScripts have bytecode and
JitScripts. This lets us avoid rewriting a lot of helper methods just yet.

Depends on D58300

Move the code from JSScript to BaseScript and rename freeScriptData to

Depends on D58301

A number of side-tables exist that are keyed by JSScript pointers. This patch
moves the tracing and finalization of these from JSScript to BaseScript to
support combining LazyScript/JSScript GC arena. This patch eliminates the
LazyScript and JSScript finalize method specializations.

A BaseScript::hasBytecode() method is added to determine if a BaseScript was
a JSScript that was successfully compiled with bytecode. Only these scripts
may be used as keys in side-tables so we check this in finalize methods. A
down-cast to JSScript is used once again to avoid rewriting all the accessor
methods yet.

Depends on D58303

Priority: -- → P1
Pushed by
Finalize JSScript fields after associated data. r=jandem
Move BaseScript::warmUpData tracing/finalizing to BaseScript. r=jandem
Move BaseScript::sharedData tracing/finalizing to BaseScript. r=jandem
Trace/finalize script side-tables from BaseScript. r=jandem
You need to log in before you can comment on or make changes to this bug.