Closed Bug 1599858 Opened 1 year ago Closed 10 months ago

Batch all script initialization for a parse tree into a single operation

Categories

(Core :: JavaScript Engine, task, P1)

task

Tracking

()

RESOLVED FIXED
mozilla78
Tracking Status
firefox78 --- fixed

People

(Reporter: mgaudet, Assigned: tcampbell)

References

Details

Attachments

(8 files, 2 obsolete files)

47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review

In order for us do JSScript initialization and all allocation on main thread we first will need to batch all the GC object allocation and script initialization for a parse task into a single place; this is what would be moved to main thread.

This will require changing the lifetime of some parse artifacts that are current LifoAlloc'd, and thus wouldn't have a lifetime long enough for batching.

Priority: -- → P2
Depends on: 1607854
Depends on: 1618631
Depends on: 1632260
Depends on: 1623956
No longer depends on: 1623956
Assignee: nobody → tcampbell
Priority: P2 → P1

This sets up for later patches that do batch script allocation.

This is called for each newly allocated JSFunction that will be exposed to
script via JSOp::Lambda/LambdaArrow in their enclosing script.

This must currently be performed before creating the script. For such
functions that are generating bytecode, we defer the call until the
BaseScript is created. For functions that are lazy, we batch the calls at the
end during CompilationInfo::finishFunctions.

Depends on D76547

Split the array of variants into an array of JSFunction and and array of
ScriptStencil. This will let use hold the Stencil from the BCE until the end.
In the future we will be able to remove the JSFunction array.

Depends on D76548

Stash the ScriptStencil when generated and at the end of bytecode emission
allocate the BaseScripts together.

Fix the FunctionBox::wasEmitted flag to handle standalone functions. We then
rely on this flag to know that a FunctionBox is actually live and wasn't
elided by the BCE. This can happen in pathological cases when an anonymous
function doesn't save its value.

Depends on D76549

Rename CompilationInfo::finishFunctions to instantiateStencils and include
the instantation of non-function stencil as well.

Depends on D76548

Absorb CompilationInfo::publishDeferredFunctions into instantiateStencils so
that it runs after BytecodeEmitter completes.

Depends on D76566

Attachment #9151163 - Attachment is obsolete: true
Attachment #9151195 - Attachment is obsolete: true
Attachment #9151165 - Attachment description: Bug 1599858 - Split CompilationInfo::funcData array → Bug 1599858 - Split CompilationInfo::funcData array. r?mgaudet

When we reparse, also rollback some deferred object creation records. This
will avoid creating junk data in the Stencil. We limit this to only the
FunctionBox list for now since that is what we traverse over.

Depends on D76549

Remove FunctionBox::exposeScript in favour of checking wasEmitted. AsmJS
functions are wasEmitted but not exposeScript so handle that case too.

Remove FunctionBox::emitLazy since the reparse rollback patch avoids us
seeing an incomplete FunctionBox. The lazy BaseScript allocation will
eventually be merged with other Stencil instantiation.

Note: During delazification, the JSFunctions already exist and as a result
publishDeferredFunctions has no work to do. The emitLazy flag was never set
for delazification.

Depends on D76765

Attachment #9151166 - Attachment description: Bug 1599858 - Batch allocate BaseScripts at end of BCE → Bug 1599858 - Batch allocate BaseScripts at end of BCE. r?mgaudet
Attachment #9151164 - Attachment description: Bug 1599858 - Defer JSFunction::setTypeForScriptedFunction call → Bug 1599858 - Defer JSFunction::setTypeForScriptedFunction call. r?mgaudet
Attachment #9151197 - Attachment description: Bug 1599858 - Defer function allocation until after bce → Bug 1599858 - Defer JSFunction allocation until after BCE. r?mgaudet

The Inferred/Guessed atoms are computed by the BytecodeEmitter running on the
enclosing script. During initial compilation we have the name before we
allocate the JSFunction, but for delazification the inner functions already
have been allocated without a name. Use FunctionBox::finish to apply these
names.

Depends on D76568

Attachment #9151164 - Attachment description: Bug 1599858 - Defer JSFunction::setTypeForScriptedFunction call. r?mgaudet → Bug 1599858 - Defer JSFunction::setTypeForScriptedFunction until after BCE. r?mgaudet
Attachment #9151166 - Attachment description: Bug 1599858 - Batch allocate BaseScripts at end of BCE. r?mgaudet → Bug 1599858 - Defer BaseScript allocation until after BCE. r?mgaudet
Attachment #9151609 - Attachment description: Bug 1599858 - Rollback stencil info when parser reparses source. r?mgaudet → Bug 1599858 - Rewind stencil info when parser reparses source. r?mgaudet
Pushed by tcampbell@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/cfefeb4ca74b
Split CompilationInfo::funcData array. r=mgaudet
https://hg.mozilla.org/integration/autoland/rev/b24b6c32a6f7
Rewind stencil info when parser reparses source. r=mgaudet
https://hg.mozilla.org/integration/autoland/rev/3f5d11bc4142
Cleanup FunctionBox::emitBytecode and friends. r=mgaudet
https://hg.mozilla.org/integration/autoland/rev/347c4f6c2a7e
Defer BaseScript allocation until after BCE. r=mgaudet
https://hg.mozilla.org/integration/autoland/rev/c1496d6074bc
Defer JSFunction::setTypeForScriptedFunction until after BCE. r=mgaudet
https://hg.mozilla.org/integration/autoland/rev/9a60e9023397
Defer JSFunction allocation until after BCE. r=mgaudet
https://hg.mozilla.org/integration/autoland/rev/4e1835470ba3
Defer JSFunction name assignments during delazification. r=mgaudet
https://hg.mozilla.org/integration/autoland/rev/b4278438eaa6
Remove unused GCThingList::finishInnerFunctions. r=mgaudet
You need to log in before you can comment on or make changes to this bug.