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.mCacheInfofieldJSScriptreference 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.mCacheInfofield - The second evaluation lacks
ModuleObject'sScriptSlot
The possible solution would be one of:
- Somehow keep the
JSScriptreference after evaluation - Inherit or copy the
ScriptLoadRequest.mCacheInfofrom the first request to subsequent requests
| Assignee | ||
Comment 1•4 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•4 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•4 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
ScriptSourceObjectof givenModuleObject - Add
ScriptSourceObjectvariant ofJS::FinishIncrementalEncoding - Use
ScriptSourceObjectinstead ofJSScriptinScriptLoader
| Assignee | ||
Comment 4•4 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•4 years ago
|
| Assignee | ||
Comment 6•4 years ago
|
||
This has no impact.
Just that cache mechanism introduced by bug 1436400 isn't used in some edge case.
| Assignee | ||
Comment 7•4 years ago
|
||
Depends on D141742
| Assignee | ||
Comment 8•4 years ago
|
||
Depends on D141743
Comment 10•4 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/0e76b6d814cc
https://hg.mozilla.org/mozilla-central/rev/d2d7b3b5fe70
Description
•