Commit graph

633 commits

Author SHA1 Message Date
Yoshi Cheng-Hao Huang
0f577f10c3 Bug 1815180 : Dump error message when import maps aren't allowed. r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D169185
2023-02-08 12:22:04 +00:00
Jon Coppeard
08b9729ccf Bug 1813494 - Part 1: Common up code to cancel and remove all load requests r=smaug
Cancellation happend in ParsingComplete() and Destroy() but was inconsistent in
which kinds of requests were cancelled and which were cancelled and removed.
This makes one method that cancels and removes everything and uses it in both
places.

Differential Revision: https://phabricator.services.mozilla.com/D168231
2023-02-07 11:55:50 +00:00
Jon Coppeard
58aee4e76a Bug 1809861 - Part 3: Reorder off-thread compilation methods r=smaug
This just moves the method definitions so that they appear in roughly in the
order they are executed, to make reading and understanding this easier.

Differential Revision: https://phabricator.services.mozilla.com/D166669
2023-01-17 17:06:51 +00:00
Jon Coppeard
2def9365b7 Bug 1809861 - Part 2: Rename off-thread compilation methods to improve consistency r=smaug
This renames the following in an attempt to give consistent names to off-thread
compliation related things:
 - AttemptAsyncScriptCompile -> AttemptOffThreadScriptCompile
 - NotifyOffThreadScriptLoadCompletedRunnable -> OffThreadJobCompleteRunnable
 - OffThreadScriptLoaderCallback -> OffThreadJobCompleteCallback

Differential Revision: https://phabricator.services.mozilla.com/D166668
2023-01-17 17:06:50 +00:00
Jon Coppeard
9041daf265 Bug 1809861 - Part 1: Simplify and clean up off-main thread script compilation r=smaug
The main change in this patch is to prevent access to main-thread objects
while off-thread. This is done by using nsMainThreadPtrHandle to wrap main
thread pointers in the runnable. This prevents access to their targets when
off thread and ensure they are only released on the main thread.

This means that mRunnable is now only accessed on the main thread and so it
doesn't need to be atomic and can be a normal RefPtr. We also don't need to
leak a reference to it in AttemptOffThreadScriptCompile.

This also requires that timing data is moved to the runnable.

Cancellation should always have happened by unlink or destruction of
ScriptLoadContext so handling for that is removed.

Differential Revision: https://phabricator.services.mozilla.com/D166667
2023-01-17 17:06:50 +00:00
Stanca Serban
6a0d860e76 Backed out 3 changesets (bug 1809861) for causing bustages in ScriptLoader.cpp. CLOSED TREE
Backed out changeset d8b7cb85d87f (bug 1809861)
Backed out changeset fa4190d9f97e (bug 1809861)
Backed out changeset 15b4b4f318a7 (bug 1809861)
2023-01-17 17:56:26 +02:00
Jon Coppeard
9de78f79c8 Bug 1809861 - Part 3: Reorder off-thread compilation methods r=smaug
This just moves the method definitions so that they appear in roughly in the
order they are executed, to make reading and understanding this easier.

Differential Revision: https://phabricator.services.mozilla.com/D166669
2023-01-17 14:37:07 +00:00
Jon Coppeard
8faf8ae204 Bug 1809861 - Part 2: Rename off-thread compilation methods to improve consistency r=smaug
This renames the following in an attempt to give consistent names to off-thread
compliation related things:
 - AttemptAsyncScriptCompile -> AttemptOffThreadScriptCompile
 - NotifyOffThreadScriptLoadCompletedRunnable -> OffThreadJobCompleteRunnable
 - OffThreadScriptLoaderCallback -> OffThreadJobCompleteCallback

Differential Revision: https://phabricator.services.mozilla.com/D166668
2023-01-17 14:37:07 +00:00
Jon Coppeard
62c190d44c Bug 1809861 - Part 1: Simplify and clean up off-main thread script compilation r=smaug
The main change in this patch is to prevent access to main-thread objects
while off-thread. This is done by using nsMainThreadPtrHandle to wrap main
thread pointers in the runnable. This prevents access to their targets when
off thread and ensure they are only released on the main thread.

This means that mRunnable is now only accessed on the main thread and so it
doesn't need to be atomic and can be a normal RefPtr. We also don't need to
leak a reference to it in AttemptOffThreadScriptCompile.

This also requires that timing data is moved to the runnable.

Cancellation should always have happened by unlink or destruction of
ScriptLoadContext so handling for that is removed.

Differential Revision: https://phabricator.services.mozilla.com/D166667
2023-01-17 14:37:06 +00:00
Yoshi Cheng-Hao Huang
230d9802ae Bug 1808360 - Add error message for external import maps. r=jonco,flod
Differential Revision: https://phabricator.services.mozilla.com/D166028
2023-01-05 14:16:58 +00:00
Manuel Bucher
7681efff11 Bug 1771867 - Early Hints Phase 2 - Part 5: Pass early hint preload to script preloader r=necko-reviewers,valentin
Note that modules can't be specified in Link preloads with `rel=preload`,
only in `rel=modulepreload`.  We currently only support `rel=preload` in
early hints. See Bug 1798319 for updates on module preloads.

Differential Revision: https://phabricator.services.mozilla.com/D161175
2022-12-02 16:15:54 +00:00
Csoregi Natalia
5a260d61a4 Backed out 13 changesets (bug 1771867) for causing CanonicalBrowsingContext crashes. CLOSED TREE
Backed out changeset 120838b58449 (bug 1771867)
Backed out changeset aea7ca0bbd17 (bug 1771867)
Backed out changeset 2fe2afdee09d (bug 1771867)
Backed out changeset 8bdb1f682d22 (bug 1771867)
Backed out changeset a9f3158ed688 (bug 1771867)
Backed out changeset 1177913e1edf (bug 1771867)
Backed out changeset d33ccbbf407d (bug 1771867)
Backed out changeset 110ac12e16f5 (bug 1771867)
Backed out changeset 7f20525f5e94 (bug 1771867)
Backed out changeset b3d65b1aa872 (bug 1771867)
Backed out changeset 7cdf3cef2773 (bug 1771867)
Backed out changeset 5090eae24a5c (bug 1771867)
Backed out changeset f8a03d226c73 (bug 1771867)
2022-12-02 13:44:55 +02:00
Manuel Bucher
4ec279d231 Bug 1771867 - Early Hints Phase 2 - Part 5: Pass early hint preload to script preloader r=necko-reviewers,valentin
Note that modules can't be specified in Link preloads with `rel=preload`,
only in `rel=modulepreload`.  We currently only support `rel=preload` in
early hints. See Bug 1798319 for updates on module preloads.

Differential Revision: https://phabricator.services.mozilla.com/D161175
2022-12-02 09:45:25 +00:00
Tooru Fujisawa
373c7f77e9 Bug 1802525 - Do not perform serialization in GiveUpBytecodeEncoding. r=nbp
Differential Revision: https://phabricator.services.mozilla.com/D163424
2022-12-01 09:28:47 +00:00
Adam Vandolder
aad960043b Bug 1632975 - Run microtask checkpoint before processing script. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D162261
2022-11-17 20:11:23 +00:00
Cristian Tuns
eee0f3c4ff Backed out changeset dd72eb737d96 (bug 1632975) for causing Bug 1800981 CLOSED TREE 2022-11-16 19:15:14 -05:00
Adam Vandolder
d7e3ad7220 Bug 1632975 - Run microtask checkpoint before processing script. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D160988
2022-11-15 20:24:15 +00:00
Tom Schuster
b680625ab0 Bug 1797070 - CSP: Add a basic implementation of unsafe-hashes behind a flag. r=freddyb
Differential Revision: https://phabricator.services.mozilla.com/D160046
2022-11-07 17:56:23 +00:00
Yoshi Cheng-Hao Huang
ee07ecaeec Bug 1778289 - Part 12: Update spec links as the PR is merged. r=jonco,yulia
The PR has been merged.
See https://html.spec.whatwg.org/multipage/webappapis.html#import-maps

Differential Revision: https://phabricator.services.mozilla.com/D158828
2022-10-07 13:56:27 +00:00
Yoshi Cheng-Hao Huang
0d7b683b7a Bug 1778289 - Part 10: Update comments for 'register an import map'. r=jonco,yulia
Differential Revision: https://phabricator.services.mozilla.com/D152877
2022-10-07 13:56:26 +00:00
Yoshi Cheng-Hao Huang
61951dd873 Bug 1778289 - Part 9: Bail out early if adding an import map is disallowed. r=jonco,yulia
If an adding import map is disallowed, we bail out early to prevent creating a
ScriptLoadRequest.

Differential Revision: https://phabricator.services.mozilla.com/D152876
2022-10-07 13:56:26 +00:00
Yoshi Cheng-Hao Huang
9415beeaef Bug 1778289 - Part 6: Update comments for external import maps. r=jonco,yulia
Differential Revision: https://phabricator.services.mozilla.com/D152873
2022-10-07 13:56:25 +00:00
Yoshi Cheng-Hao Huang
1adff58d99 Bug 1778289 - Part 4: Don't call onerror if parsing import maps fails. r=jonco,yulia
script's result will be an import map parse result, which will never be
null.

See explanation from https://github.com/WICG/import-maps/issues/279

Differential Revision: https://phabricator.services.mozilla.com/D152871
2022-10-07 13:56:24 +00:00
Yoshi Cheng-Hao Huang
77f6c4ae7e Bug 1778289 - Part 2: Rename to 'import maps allowed' and add 'disallow import maps'. r=jonco,yulia
Rename 'acquiring import maps' to 'import maps allowed'.

Old:
https://wicg.github.io/import-maps/#document-acquiring-import-maps

New:
https://whatpr.org/html/8075/webappapis.html#import-maps-allowed

And add 'disallow further import maps':
https://whatpr.org/html/8075/webappapis.html#disallow-further-import-maps

Differential Revision: https://phabricator.services.mozilla.com/D152869
2022-10-07 13:56:23 +00:00
Andreea Pavel
1e8bd660ee Backed out changeset 7cfadef6f30f (bug 1790765) for causing bug 1791309 2022-09-20 09:16:58 +03:00
Jon Coppeard
53b72f131f Bug 1790765 - Replace superstitious comment in ScriptLoader::MaybeMoveToLoadedList with release assertion r=smaug
An initial try is green with this change.

Differential Revision: https://phabricator.services.mozilla.com/D157304
2022-09-15 09:14:59 +00:00
Jon Coppeard
bccb7ef6f3 Bug 1788532 - Block dynamic module load processing during sync XHR r=smaug
The problem is that synchronous XMLHttpRequest requests can spin the event loop
and cause us to process dynamic module loads (by calling
JS::FinishDynamicModuleImport) when we are already inside JS::ModuleEvaluate.
The module algorithms assume that they are not reentrant.

The patch changes dyammic module load processing to happen in the same way as
async script loads (of both classic scripts and modules), which are blocked
during sync XHR by Document::SuppressEventHandling calling
ScriptLoader::AddExecuteBlocker.

Differential Revision: https://phabricator.services.mozilla.com/D157218
2022-09-15 09:14:11 +00:00
Ted Campbell
63b0610c8f Bug 1788977 - Share stencil-instantiate code in JSExecutionContext. r=arai
Differential Revision: https://phabricator.services.mozilla.com/D156339
2022-09-06 12:01:36 +00:00
Tooru Fujisawa
a927c643ec Bug 1787529 - Align the conditions in ScriptLoadContext::MaybeCancelOffThreadScript to ScriptLoader::AttemptAsyncScriptCompile. r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D155740
2022-08-31 22:38:21 +00:00
Bryan Thrall
f9c451035e Bug 1768679 - Expose cache fetch count as uint32_t r=dragana,necko-reviewers
The value is stored as uint32_t, and there doesn't seem to be a need to convert
it to int.

Differential Revision: https://phabricator.services.mozilla.com/D147888
2022-08-04 16:20:17 +00:00
Tom Schuster
0610723e31 Bug 1529337 - Implement CSP 'script-src-elem' and 'script-src-attr' directives. r=freddyb,webidl,smaug,dveditz
Differential Revision: https://phabricator.services.mozilla.com/D150965
2022-08-01 12:32:58 +00:00
Dianna Smith
54494382c7 Backed out 1 changesets (bug 1776205) for causing bug 1780426, a=backout
Backed out changeset 84c72c2fbfd6 (bug 1776205)
2022-07-26 14:34:59 -04:00
Dianna Smith
27fbc1c20a Backed out 1 changesets (bug 1776668) for causing bug 1780426, a=backout
Backed out changeset f3cd67fc1a50 (bug 1776668)
2022-07-26 14:30:18 -04:00
Nicolas B. Pierron
03fbdc6ade Bug 1776668 - ApplyDelazifyStrategy: Skip inline script sooner. r=arai
Differential Revision: https://phabricator.services.mozilla.com/D152091
2022-07-19 10:41:16 +00:00
smolnar
bd8c576702 Backed out 2 changesets (bug 1529337) for awaiting decision on implementing other CSP 3 features
Backed out changeset 12cd014c46e8 (bug 1529337)
Backed out changeset f1489d7cf1a1 (bug 1529337)
2022-07-18 11:09:25 +03:00
Tom Schuster
e8d99d0ef6 Bug 1529337 - Implement CSP 'script-src-elem' and 'script-src-attr' directives. r=freddyb,webidl,smaug
Differential Revision: https://phabricator.services.mozilla.com/D150965
2022-07-13 10:21:48 +00:00
Nicolas B. Pierron
49f29dc411 Bug 1776205 - Set the delazify option in all ScriptLoader code paths. r=arai
This patch move the ShouldApplyDelazificationStartegy as well as the
ApplyDelazificationStrategy under FillCompileOptionsForRequest.

As not all delazification strategies are capable of handling modules yet (Bug
1760334), and do not apply to cached-stencil, we have to add extra filters to
prevent ShouldApplyDelazificationStrategy to access custom delazification mode.

Differential Revision: https://phabricator.services.mozilla.com/D150118
2022-07-08 13:19:30 +00:00
Matthew Gaudet
cc218be0b6 Bug 1747059 - Add ShadowRealm module loader support to ScriptLoader r=yulia
Differential Revision: https://phabricator.services.mozilla.com/D147465
2022-06-28 22:04:18 +00:00
criss
460e05fa2d Backed out changeset a411b158a51e (bug 1776205) for causing ccov failures (bug 1776521) . CLOSED TREE 2022-06-28 11:40:20 +03:00
Csoregi Natalia
a6c7516d80 Backed out 9 changesets (bug 1747059, bug 1767525)for causing hazard failures on ShadowRealmGlobalScope.cpp. CLOSED TREE
Backed out changeset ed7aad37f2cf (bug 1747059)
Backed out changeset 40a257fb4788 (bug 1747059)
Backed out changeset f7b049ef3b8c (bug 1747059)
Backed out changeset aad38abc7139 (bug 1747059)
Backed out changeset 8115813e77a5 (bug 1747059)
Backed out changeset e06192e664fd (bug 1747059)
Backed out changeset a198b0893220 (bug 1767525)
Backed out changeset c083f0824619 (bug 1767525)
Backed out changeset 9a3bf794ec6d (bug 1767525)
2022-06-28 02:39:08 +03:00
Matthew Gaudet
c940e88de9 Bug 1747059 - Add ShadowRealm module loader support to ScriptLoader r=yulia
Differential Revision: https://phabricator.services.mozilla.com/D147465
2022-06-27 21:17:35 +00:00
Nicolas B. Pierron
5194fc0eef Bug 1776205 - Set the delazify option in all ScriptLoader code paths. r=arai
This patch move the ShouldApplyDelazificationStartegy as well as the
ApplyDelazificationStrategy under FillCompileOptionsForRequest.

As not all delazification strategies are capable of handling modules yet (Bug
1760334), and do not apply to cached-stencil, we have to add extra filters to
prevent ShouldApplyDelazificationStrategy to access custom delazification mode.

Differential Revision: https://phabricator.services.mozilla.com/D150118
2022-06-24 12:16:04 +00:00
Nicolas B. Pierron
7d50cd5850 Bug 1774796 - Add largest-first delazification strategy. r=arai
This patch adds a new off-thread delazification strategy, which adds a bit of
overhead to queue function with a priority order, which put the largest function
as the first functions to be delazified.

The intent of this new strategy is to limit the usage of main-thread
delazification to the smallest function, in case where the main-thread would win
the delazification race.

Differential Revision: https://phabricator.services.mozilla.com/D149651
2022-06-20 13:33:49 +00:00
Manuel Bucher
14dd2f26fc Bug 1761242 - Expose computing security flags for early hint preloader r=ckerschb,smaug
Differential Revision: https://phabricator.services.mozilla.com/D144798
2022-06-15 09:59:44 +00:00
Yoshi Cheng-Hao Huang
4419c1b898 Bug 1773143 - Call SetAcquiringImportMaps(false) when loading inline modules. r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D149048
2022-06-14 12:53:18 +00:00
Molnar Sandor
1fc858a96d Backed out 5 changesets (bug 1761242, bug 1744822, bug 1761252) for causing browser-chrome failures in netwerk/test/browser/browser_103_assets.js CLOSED TREE
Backed out changeset 33cc08eb51b3 (bug 1744822)
Backed out changeset b70697d24e75 (bug 1761252)
Backed out changeset 4a5e10110c6a (bug 1761242)
Backed out changeset 7cda175b833d (bug 1761242)
Backed out changeset 4f5ed111093b (bug 1761242)
2022-06-08 18:56:35 +03:00
Manuel Bucher
35abf46688 Bug 1761242 - Expose computing security flags for early hint preloader r=ckerschb,smaug
Differential Revision: https://phabricator.services.mozilla.com/D144798
2022-06-08 14:33:10 +00:00
Kagami Sascha Rosylight
3d0e3d5413 Bug 1769290 - Part 10: Apply mozilla-js-handle-rooted-typedef against remaining dom directories r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D148283
2022-06-05 20:55:00 +00:00
Bryan Thrall
23c45ca806 Bug 1757833 - Extract methods ScriptBytecodeCompress and ScriptBytecodeDecompress r=nbp
This leaves the code in ScriptLoader and ScriptLoadHandler a lot more readable.

ScriptBytecodeCompressedDataLayout and ScriptBytecodeDataLayout simplify
locating data in the ScriptLoadRequest bytecode buffer when compressing and
decompressing it.

The interface is still error-prone. For example, these classes don't check
that the returned pointers are within the bounds of the buffer.

Differential Revision: https://phabricator.services.mozilla.com/D145011
2022-05-20 18:25:40 +00:00
Bryan Thrall
9dba8f9cc0 Bug 1757833 - Compress Stencil bytecode before writing to cache r=nbp
The SRI hash at the beginning of ScriptLoadRequest::mScriptBytecode is left
uncompressed because ScriptLoader::OnIncrementalData() tries to decode it
as soon as enough data is read (instead of waiting until OnStreamComplete()).

ScriptLoader writes the length of the uncompressed bytecode to the buffer
to make it easy for ScriptLoadHandler to allocate an buffer of the right size
to decompress the bytecode.

These changes are based on the bytecode compression implemented for WASM in
dom/fetch/FetchUtil.cpp.

Differential Revision: https://phabricator.services.mozilla.com/D141524
2022-05-20 18:25:40 +00:00