Cache module scripts in the bytecode cache
Categories
(Core :: DOM: Core & HTML, enhancement, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox100 | --- | fixed |
People
(Reporter: jonco, Assigned: arai)
References
(Blocks 1 open bug)
Details
Attachments
(14 files)
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review |
The bytecode cache currently only supports classic scripts. We should extend this to support JS modules too.
Assignee | ||
Updated•3 years ago
|
Assignee | ||
Comment 2•3 years ago
|
||
Assignee | ||
Comment 3•3 years ago
|
||
Depends on D140288
Assignee | ||
Comment 4•3 years ago
|
||
As a preparation to add bytecode case to CompileOrFinishModuleScript, removed
the shared nsresult variable and make each branch directly return, and also
do early return for error case.
Depends on D140289
Assignee | ||
Comment 5•3 years ago
|
||
To add conditional JS::StartIncrementalEncoding, and also to add a bytecode
decoding branch, replace nsJSUtils::CompileModule with raw JSAPI calls with
Stencil.
Depends on D140290
Assignee | ||
Comment 6•3 years ago
|
||
Module bytecode should use different MIME type, to avoid mixing up script/module
bytecodes for single JS file.
This patch adds a static method that simply returns the current bytecode MIME
type.
The later patch adds a new MIME type for module bytecode and modify the
ScriptLoader::BytecodeMimeTypeFor method to return corresponding MIME type.
Depends on D140291
Assignee | ||
Comment 7•3 years ago
|
||
Depends on D140292
Assignee | ||
Comment 8•3 years ago
|
||
Module's ScriptSlot is cleared after executing the top-level script.
In order to skip modules imported multiple times when encoding, added
JS::IsExecutedModule.
Depends on D140293
Assignee | ||
Comment 9•3 years ago
|
||
As a preparation to use the bytecode encoding in the module evaluation code,
ScriptLoader::MaybePrepareForBytecodeEncoding is split into 2 parts:
- one for performing preparation before executing script
- one for queuing the request for bytecode encoding after executing script
In module's case, the bytecode encoding handling must be done on the entire
import tree, and also the module object's ScriptSlot is cleared on execution.
So, the script reference must be copied to the corresponding script load request
field before execution, and the script source must be queued for bytecode
encoding after executing the top-level script, so that incremental encoding
reflects functions called there.
Depends on D140294
Assignee | ||
Comment 10•3 years ago
|
||
The module scripts are scanned immediately before executing, and if the
module script is not yet executed, and it matches the requirement for encoding
(size, fetch count, etc), it's marked as encode,
and they're scanned again immediately after executing, and marked scripts are
queued for bytecode encoding.
This patch doesn't actually enable the encoding, given ShouldCacheBytecode
returns false because the caching is not enabled for the channel and
GetCacheTokenFetchCount fails.
Depends on D140295
Assignee | ||
Comment 11•3 years ago
|
||
Depends on D140296
Updated•3 years ago
|
Assignee | ||
Comment 12•3 years ago
|
||
After enabling bytecode cache for module script, we need to handle
the SRI mismatch on bytecode cache, that requires reloading the script source
again.
Depends on D140296
Updated•3 years ago
|
Assignee | ||
Comment 13•3 years ago
|
||
Depends on D140297
Assignee | ||
Comment 14•3 years ago
|
||
Depends on D140552
Assignee | ||
Comment 15•3 years ago
|
||
Depends on D140553
Assignee | ||
Comment 16•3 years ago
|
||
TODO: add testcase with <link rel="preload">
Assignee | ||
Comment 17•3 years ago
|
||
(In reply to Tooru Fujisawa [:arai] from comment #16)
TODO: add testcase with
<link rel="preload">
This was unrelated here.
will post test with iframes.
Assignee | ||
Comment 18•3 years ago
|
||
Depends on D140554
Comment 19•3 years ago
|
||
Pushed by arai_a@mac.com: https://hg.mozilla.org/integration/autoland/rev/40b474d430e9 Part 1: Remove Unused parameter from ExecuteCompiledScript. r=jonco https://hg.mozilla.org/integration/autoland/rev/e38a959648e1 Part 2: Simplify ModuleLoader::CompileOrFinishModuleScript code flow. r=jonco https://hg.mozilla.org/integration/autoland/rev/dd0fea93bcd7 Part 3: Remove nsJSUtils::CompileModule and directly use JSAPI with stencil. r=nbp https://hg.mozilla.org/integration/autoland/rev/b1c2084042fa Part 4: Add ScriptLoader::BytecodeMimeTypeFor static method to get bytecode MIME type for given request. r=nbp https://hg.mozilla.org/integration/autoland/rev/dd2bb1b46f75 Part 5: Add bytecode MIME type for regular script and module. r=nbp https://hg.mozilla.org/integration/autoland/rev/001d8528ff96 Part 6: Add JS::IsModuleEvaluated. r=jonco https://hg.mozilla.org/integration/autoland/rev/cce080064d82 Part 7: Split ScriptLoader::MaybePrepareForBytecodeEncoding into 2 parts. r=nbp https://hg.mozilla.org/integration/autoland/rev/8f894ea40eb2 Part 8: Add code path for bytecode encoding module scripts. r=nbp https://hg.mozilla.org/integration/autoland/rev/c33620854115 Part 9: Support restarting module load request. r=jonco https://hg.mozilla.org/integration/autoland/rev/6f473bcf809a Part 10: Support bytecode cache for module script. r=nbp https://hg.mozilla.org/integration/autoland/rev/561aeb550892 Part 11: Modify test_script_loader_js_cache.html to test basic module script. r=nbp https://hg.mozilla.org/integration/autoland/rev/5ac844508d8b Part 12: Add testcases for bytecode encoding and module with import. r=nbp https://hg.mozilla.org/integration/autoland/rev/ffd9ddcef6b0 Part 13: Add testcases for bytecode encoding and module with SRI fallback. r=nbp https://hg.mozilla.org/integration/autoland/rev/4be29c1eb5bc Part 14: Add testcases for bytecode encoding and module with iframes. r=nbp
Comment 20•3 years ago
|
||
Backed out along with Bug 1757597 for causing mochitest failures on test_bug1656248.html
Comment 21•3 years ago
•
|
||
New failure log , involving the above backout :
https://treeherder.mozilla.org/logviewer?job_id=371065622&repo=autoland&lineNumber=2707
Comment 22•3 years ago
|
||
Pushed by arai_a@mac.com: https://hg.mozilla.org/integration/autoland/rev/ee0194a35613 Part 1: Remove Unused parameter from ExecuteCompiledScript. r=jonco https://hg.mozilla.org/integration/autoland/rev/a4c1a6688a8c Part 2: Simplify ModuleLoader::CompileOrFinishModuleScript code flow. r=jonco https://hg.mozilla.org/integration/autoland/rev/3a587ff43de9 Part 3: Remove nsJSUtils::CompileModule and directly use JSAPI with stencil. r=nbp https://hg.mozilla.org/integration/autoland/rev/dc2dc93cafaf Part 4: Add ScriptLoader::BytecodeMimeTypeFor static method to get bytecode MIME type for given request. r=nbp https://hg.mozilla.org/integration/autoland/rev/d8dbb7131db9 Part 5: Add bytecode MIME type for regular script and module. r=nbp https://hg.mozilla.org/integration/autoland/rev/b5378c419f06 Part 6: Add JS::IsModuleEvaluated. r=jonco https://hg.mozilla.org/integration/autoland/rev/d4847bfb8b12 Part 7: Split ScriptLoader::MaybePrepareForBytecodeEncoding into 2 parts. r=nbp https://hg.mozilla.org/integration/autoland/rev/f43d53e2b41e Part 8: Add code path for bytecode encoding module scripts. r=nbp https://hg.mozilla.org/integration/autoland/rev/53bd843e4e47 Part 9: Support restarting module load request. r=jonco https://hg.mozilla.org/integration/autoland/rev/03c914329e22 Part 10: Support bytecode cache for module script. r=nbp https://hg.mozilla.org/integration/autoland/rev/f2ff76a6acf5 Part 11: Modify test_script_loader_js_cache.html to test basic module script. r=nbp https://hg.mozilla.org/integration/autoland/rev/2408f4c4260a Part 12: Add testcases for bytecode encoding and module with import. r=nbp https://hg.mozilla.org/integration/autoland/rev/38be4c94b912 Part 13: Add testcases for bytecode encoding and module with SRI fallback. r=nbp https://hg.mozilla.org/integration/autoland/rev/123ba639073b Part 14: Add testcases for bytecode encoding and module with iframes. r=nbp
Comment 23•3 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/ee0194a35613
https://hg.mozilla.org/mozilla-central/rev/a4c1a6688a8c
https://hg.mozilla.org/mozilla-central/rev/3a587ff43de9
https://hg.mozilla.org/mozilla-central/rev/dc2dc93cafaf
https://hg.mozilla.org/mozilla-central/rev/d8dbb7131db9
https://hg.mozilla.org/mozilla-central/rev/b5378c419f06
https://hg.mozilla.org/mozilla-central/rev/d4847bfb8b12
https://hg.mozilla.org/mozilla-central/rev/f43d53e2b41e
https://hg.mozilla.org/mozilla-central/rev/53bd843e4e47
https://hg.mozilla.org/mozilla-central/rev/03c914329e22
https://hg.mozilla.org/mozilla-central/rev/f2ff76a6acf5
https://hg.mozilla.org/mozilla-central/rev/2408f4c4260a
https://hg.mozilla.org/mozilla-central/rev/38be4c94b912
https://hg.mozilla.org/mozilla-central/rev/123ba639073b
Assignee | ||
Updated•3 years ago
|
Description
•