Module is not bytecode encoded if the second request is evaluated first
Categories
(Core :: DOM: Core & HTML, defect, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox100 | --- | fixed |
People
(Reporter: arai, Assigned: arai)
References
Details
Attachments
(2 files)
from https://phabricator.services.mozilla.com/D140554
Bug 1436400 patch introduces JSBC support for module script, but the encoding requires the following 2 fields available:
ScriptLoadRequest.mCacheInfo
fieldJSScript
reference inModuleObject
'sScriptSlot
ModuleObject
's ScriptSlot
is cleared on the evaluation, so the encode must be done before the evaluation.
ScriptLoadRequest.mCacheInfo
field is populated only for the first ModuleLoadRequest
that triggers network/cache request,
and the subsequent ModuleLoadRequest
for the same URL waits for the ModuleScript
and uses it,
where ScriptLoadRequest.mCacheInfo
is not inherited from the first request, and there's no reference to the first request.
So, if the subsequent ModuleLoadRequest
's module is evaluated first,
bytecode encoding cannot be performed because:
- The first evaluation lacks
ScriptLoadRequest.mCacheInfo
field - The second evaluation lacks
ModuleObject
'sScriptSlot
The possible solution would be one of:
- Somehow keep the
JSScript
reference after evaluation - Inherit or copy the
ScriptLoadRequest.mCacheInfo
from the first request to subsequent requests
Assignee | ||
Comment 1•3 years ago
|
||
If the ScriptSlot
needs to be kept after the first evaluation due to top-level-await (see bug 1758322),
this bug can also be solved by not-clearing the slot.
Assignee | ||
Comment 2•3 years ago
|
||
The JSScript*
reference is passed to JS::FinishIncrementalEncoding
, but what the bytecode encoding needs is ScriptSource
, not the top-level JSScript*
.
Also, the ScriptSource
should be kept by functions' scripts anyway.
So, we could expose the ScriptSource
and add ScriptSource
variant of JS::FinishIncrementalEncoding
, in order to avoid keeping the top-level JSScript
unnecessarily.
Assignee | ||
Comment 3•3 years ago
|
||
ModuleObject
already has ScriptSourceObjectSlot
that holds ScriptSourceObject
, and the slot is never cleared.
So this can be fixed by:
- Add public API that returns
ScriptSourceObject
of givenModuleObject
- Add
ScriptSourceObject
variant ofJS::FinishIncrementalEncoding
- Use
ScriptSourceObject
instead ofJSScript
inScriptLoader
Assignee | ||
Comment 4•3 years ago
|
||
Apparently we don't expose ScriptSourceObject
in any other place.
we might be better using ModuleObject
itself in the public API instead.
Assignee | ||
Updated•3 years ago
|
Assignee | ||
Comment 6•3 years ago
|
||
This has no impact.
Just that cache mechanism introduced by bug 1436400 isn't used in some edge case.
Assignee | ||
Comment 7•3 years ago
|
||
Depends on D141742
Assignee | ||
Comment 8•3 years ago
|
||
Depends on D141743
Comment 10•3 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/0e76b6d814cc
https://hg.mozilla.org/mozilla-central/rev/d2d7b3b5fe70
Description
•