Commit graph

734 commits

Author SHA1 Message Date
Tooru Fujisawa
8d1465e219 Bug 1800641 - Part 2: Add ScriptLoadRequest::Bytecode and let JSExecutionContext::Decode receive JS::TranscodeRange. r=nbp
Depends on D197839

Differential Revision: https://phabricator.services.mozilla.com/D197840
2024-01-08 14:57:36 +00:00
Mirko Brodesser
68de76e511 Bug 1861061: change internal priority to low for async/deferred scripts with fetchpriority=auto and to high for module-scripts and scripts from head. r=smaug
For web-compatibility; match Chromium's behavior.

Differential Revision: https://phabricator.services.mozilla.com/D196954
2024-01-02 14:12:50 +00:00
Noemi Erli
7fd755cbb5 Backed out changeset 4d6294424819 (bug 1800641) for causing Bug 1872347 2023-12-29 16:23:18 +02:00
Nicolas B. Pierron
8a851d2266 Bug 1800641 - Move some ScriptLoadRequest fields into LoadedScript. r=yulia
We are looking into caching loaded script in memory. To do so we need something
to cache.

At the moment, the `ScriptLoadRequest` structure hold all the fields which are
loaded, and used before executing JavaScript code. Then, the `ScriptLoadRequest`
is not guaranteed to out-live the first execution.

Therefore, we have to move fields out of the `ScriptLoadRequest` such that they
can later be used by any caching mechanism. The `LoadedScript` is the closest
existing structure which exists which fit the description.

This patch moves fields out of the ScriptLoadRequest into the `LoadedScript`,
which already has a `LoadedScript` field.

The `LoadedScript` field is initialized sooner, when the `ScriptLoadRequest` is
created, to be subsituted later by a real cache implementation. At the moment
the function `ScriptLoadRequest::NoCacheEntryFound` is used as a placeholder to
change the state of the `ScriptLoadRequest` from `CheckingCache` to `Fetching`.
Existing initializations are replaced by assertions to fail in debug build if
the current patch does not reproduce the expected state properly.

The `LoadedScript` get fields such as the source text, the text length, the
bytecode buffer (which also contains SRI), and the offset at which the bytecode
starts within the bytecode buffer. As these fields are no longer reachable by
name, multiple accessors are added to work-around the issue. Using this as an
opportunity to add extra assertions as part of these accessors.

A new class named `LoadedScriptDelegate` is added to re-add, by inheritance, all
the accessors which used to be part of `ScriptLoadRequest` as methods which are
delegating to the field which is holding the `LoadedScript`. This class is using
templates to avoid virtual inheritance which might hinder inlining, especially
since `ScriptLoadRequest` cannot be made final, as `ModuleLoadRequest` extends
it.

The `ScriptFetchOptions` structure is moved to its own file to solve C++ include
issues.

Differential Revision: https://phabricator.services.mozilla.com/D163615
2023-12-25 09:46:54 +00:00
Cosmin Sabou
a9cb718ef1 Backed out changeset f69f493b2f3c (bug 1800641) for causing non-unified build bustages on LoadedScript.cpp. CLOSED TREE 2023-12-25 08:38:51 +02:00
Nicolas B. Pierron
7b23c511de Bug 1800641 - Move some ScriptLoadRequest fields into LoadedScript. r=yulia
We are looking into caching loaded script in memory. To do so we need something
to cache.

At the moment, the `ScriptLoadRequest` structure hold all the fields which are
loaded, and used before executing JavaScript code. Then, the `ScriptLoadRequest`
is not guaranteed to out-live the first execution.

Therefore, we have to move fields out of the `ScriptLoadRequest` such that they
can later be used by any caching mechanism. The `LoadedScript` is the closest
existing structure which exists which fit the description.

This patch moves fields out of the ScriptLoadRequest into the `LoadedScript`,
which already has a `LoadedScript` field.

The `LoadedScript` field is initialized sooner, when the `ScriptLoadRequest` is
created, to be subsituted later by a real cache implementation. At the moment
the function `ScriptLoadRequest::NoCacheEntryFound` is used as a placeholder to
change the state of the `ScriptLoadRequest` from `CheckingCache` to `Fetching`.
Existing initializations are replaced by assertions to fail in debug build if
the current patch does not reproduce the expected state properly.

The `LoadedScript` get fields such as the source text, the text length, the
bytecode buffer (which also contains SRI), and the offset at which the bytecode
starts within the bytecode buffer. As these fields are no longer reachable by
name, multiple accessors are added to work-around the issue. Using this as an
opportunity to add extra assertions as part of these accessors.

A new class named `LoadedScriptDelegate` is added to re-add, by inheritance, all
the accessors which used to be part of `ScriptLoadRequest` as methods which are
delegating to the field which is holding the `LoadedScript`. This class is using
templates to avoid virtual inheritance which might hinder inlining, especially
since `ScriptLoadRequest` cannot be made final, as `ModuleLoadRequest` extends
it.

The `ScriptFetchOptions` structure is moved to its own file to solve C++ include
issues.

Differential Revision: https://phabricator.services.mozilla.com/D163615
2023-12-25 05:50:53 +00:00
Jon Coppeard
c095a8dbd4 Bug 1865410 - Part 1: Don't use preload requests after an import map is registered r=smaug
We stop speculative preloading of module scripts after seeing an import map.
However it can still happen that we see a preload request for script element
after an import map is registered because a script can dynamically insert an
import map after preloading has happened.

Don't use these preloads as they may have incorrectly resolved module
specifiers.

We can remove the previous way of dealing with this issue where we removed
preloaded modules from the module map if we later loaded an import map. This is
not safe as modules could be present in the module map for other valid reasons,
e.g. if they have been imported by another script.

Differential Revision: https://phabricator.services.mozilla.com/D194766
2023-12-02 08:49:59 +00:00
Denis Palmeiro
596fcfcea7 Bug 1865929: Apply delazify strategy to small scripts in ScriptLoader. r=nbp
Differential Revision: https://phabricator.services.mozilla.com/D194647
2023-11-24 19:50:45 +00:00
Mirko Brodesser
135eba69cf Bug 1865610: part 4) Add fetchpriority attribute support for rel=modulepreload and rel=preload as=script. r=smaug,valentin
Differential Revision: https://phabricator.services.mozilla.com/D192331
2023-11-23 14:45:21 +00:00
Mirko Brodesser
ac16c226e0 Bug 1865610: part 1) Add partial support for the "fetchpriority" attribute for loading style sheets from <link> elements or Link header fields. r=smaug,emilio,valentin
Includes only support for dynamically loading style sheets from `<link>`
elements and `Link` header fields.
The remaining support, including preloading, is completed in part 3.

Differential Revision: https://phabricator.services.mozilla.com/D191745
2023-11-23 14:36:11 +00:00
Tooru Fujisawa
e550bdfb92 Bug 1864168 - Part 6: Use 1-origin column number in ScriptLoader and nsIScriptElement. r=smaug,devtools-reviewers,hsivonen,ochameau
Also fix opSetScriptLineAndColumnNumberAndFreeze::mColumnNumber to point the
first character of the script source, instead of '>' of the start tag.

Differential Revision: https://phabricator.services.mozilla.com/D193374
2023-11-22 12:31:32 +00:00
Tooru Fujisawa
8c59289f4f Bug 1864168 - Part 1: Use 1-origin column number in nsIContentSecurityPolicy. r=smaug,devtools-reviewers,ochameau,ckerschb
Differential Revision: https://phabricator.services.mozilla.com/D193369
2023-11-22 12:31:30 +00:00
Natalia Csoregi
705aa81869 Backed out 14 changesets (bug 1865005, bug 1864168, bug 1864155, bug 1862814, bug 1862693) for causing bustage on nsRFPService.cpp. CLOSED TREE
Backed out changeset a4f3e7625abf (bug 1865005)
Backed out changeset ab38141e470b (bug 1862814)
Backed out changeset a679b50dc4a9 (bug 1862814)
Backed out changeset e340886ce62a (bug 1862814)
Backed out changeset 1378502e64b0 (bug 1862814)
Backed out changeset 8ee94e5e79c2 (bug 1862814)
Backed out changeset 6d4ef1cdfabb (bug 1864168)
Backed out changeset 2c30c4d757fc (bug 1864168)
Backed out changeset d4db9576559b (bug 1864168)
Backed out changeset 8ffec0d83028 (bug 1864168)
Backed out changeset fa77d852b494 (bug 1864168)
Backed out changeset f6646771a26a (bug 1864168)
Backed out changeset 7bd0ff6986df (bug 1864155)
Backed out changeset 39867b503289 (bug 1862693)
2023-11-22 14:01:55 +02:00
Tooru Fujisawa
78e7224834 Bug 1864168 - Part 6: Use 1-origin column number in ScriptLoader and nsIScriptElement. r=smaug,devtools-reviewers,hsivonen,ochameau
Also fix opSetScriptLineAndColumnNumberAndFreeze::mColumnNumber to point the
first character of the script source, instead of '>' of the start tag.

Differential Revision: https://phabricator.services.mozilla.com/D193374
2023-11-22 11:13:56 +00:00
Tooru Fujisawa
a4a513ad86 Bug 1864168 - Part 1: Use 1-origin column number in nsIContentSecurityPolicy. r=smaug,devtools-reviewers,ochameau,ckerschb
Differential Revision: https://phabricator.services.mozilla.com/D193369
2023-11-22 11:13:54 +00:00
Tooru Fujisawa
cf99b67c05 Bug 1862692 - Part 20: Stop using 0-origin column number types. r=iain
Differential Revision: https://phabricator.services.mozilla.com/D193033
2023-11-09 11:41:12 +00:00
Tooru Fujisawa
f4a1cb246a Bug 1862692 - Part 17: Use 1-origin column number type in JS::ReadOnlyCompileOptions. r=iain
Differential Revision: https://phabricator.services.mozilla.com/D193030
2023-11-09 11:41:11 +00:00
Tooru Fujisawa
62e38eaac8 Bug 1853881 - Part 1: Add JS::ThreadStackQuotaForSize and use it everywhere. r=nbp
Differential Revision: https://phabricator.services.mozilla.com/D191905
2023-10-26 14:10:55 +00:00
Mirko Brodesser
dc52b1401a Bug 1839315: part 6) Lift code for fetchpriority attribute from nsGenericHTMLElementWithFetchPriorityAttribute to nsGenericHTMLElement. r=smaug
As requested in the review of part 1.

Differential Revision: https://phabricator.services.mozilla.com/D191274
2023-10-23 08:14:51 +00:00
Mirko Brodesser
5ccc34b836 Bug 1839315: part 1) Lift code for fetchpriority attribute from HTMLScriptElement to nsGenericHTMLElementWithFetchPriorityAttribute. r=smaug
Since the HTMLLinkElement requires it too, see part 2.

Differential Revision: https://phabricator.services.mozilla.com/D189935
2023-10-23 08:14:49 +00:00
Tooru Fujisawa
5d9a5df4e1 Bug 1846407 - Use enum class for Task::Run return value. r=bas,win-reviewers,rkraesig
Differential Revision: https://phabricator.services.mozilla.com/D185043
2023-10-18 15:23:29 +00:00
Noemi Erli
c3c92500ef Backed out changeset 7718734e95b1 (bug 1846407) for causing bustages in nsWindow.cpp CLOSED TREE 2023-10-18 05:31:49 +03:00
Tooru Fujisawa
0054ab3127 Bug 1846407 - Use enum class for Task::Run return value. r=bas,win-reviewers,rkraesig
Differential Revision: https://phabricator.services.mozilla.com/D185043
2023-10-18 01:54:43 +00:00
Sylvestre Ledru
d0f6c7fc66 Bug 1856795 - Remove redundant member init r=emilio
Done with:
./mach static-analysis check --checks="-*, readability-redundant-member-init" --fix .

https://clang.llvm.org/extra/clang-tidy/checks/readability/redundant-member-init.html

Differential Revision: https://phabricator.services.mozilla.com/D190002
2023-10-15 15:29:02 +00:00
Cristina Horotan
6a90f5eded Backed out 2 changesets (bug 1856795) for causing build bustage at BasicEvents.h CLOSED TREE
Backed out changeset 1d98b028923a (bug 1856795)
Backed out changeset eae2ac93e17c (bug 1856795)
2023-10-14 21:42:14 +03:00
Sylvestre Ledru
cc8a0ee742 Bug 1856795 - Remove redundant member init r=emilio
Done with:
./mach static-analysis check --checks="-*, readability-redundant-member-init" --fix .

https://clang.llvm.org/extra/clang-tidy/checks/readability/redundant-member-init.html

Differential Revision: https://phabricator.services.mozilla.com/D190002
2023-10-14 17:34:26 +00:00
Emilio Cobos Álvarez
25c0d10932 Bug 1624819 - Remove TaskCategory and other quantum dom remnants. r=smaug,media-playback-reviewers,credential-management-reviewers,cookie-reviewers,places-reviewers,win-reviewers,valentin,mhowell,sgalich,alwu
Sorry this is not a particularly easy patch to review. But it should be
mostly straight-forward.

I kept Document::Dispatch mostly for convenience, but could be
cleaned-up too / changed by SchedulerGroup::Dispatch. Similarly maybe
that can just be NS_DispatchToMainThread if we add an NS_IsMainThread
check there or something (to preserve shutdown semantics).

Differential Revision: https://phabricator.services.mozilla.com/D190450
2023-10-10 08:51:12 +00:00
Yoshi Cheng-Hao Huang
b758eaeb68 Bug 1841859 - Part 2: Parse the referrer policy from http header and update the referrer policy. r=jonco,smaug
This implementes the following requirement from the spec:

https://html.spec.whatwg.org/#fetch-a-single-module-script

12. In both cases, let processResponseConsumeBody given response response and null, failure, or a byte sequence bodyBytes be the following algorithm:

  5. Let referrerPolicy be the result of parsing the `Referrer-Policy` header given response.
  6. If referrerPolicy is not the empty string, set options's referrer policy to referrerPolicy.

Differential Revision: https://phabricator.services.mozilla.com/D186944
2023-09-20 17:32:15 +00:00
Yoshi Cheng-Hao Huang
cd69bc3c65 Bug 1841859 - Part 1: Move ReferrerPolicy to ScriptLoadRequest and LoadedScript. r=jonco,smaug
Suggested by jonco during review,
https://phabricator.services.mozilla.com/D186944#inline-1036982

Differential Revision: https://phabricator.services.mozilla.com/D187385
2023-09-20 17:32:15 +00:00
Mirko Brodesser
8e5580d60e Bug 1839316: part 12) Adjust nsISupportsPriority's value to fetch priority in ScriptLoader. r=valentin
Differential Revision: https://phabricator.services.mozilla.com/D187438
2023-09-19 13:13:27 +00:00
Tooru Fujisawa
eaf4a57860 Bug 1853480 - Part 1: Use TaskController thread stack size as JS stack quota in ScriptLoader off-thread compilation. r=nbp
Differential Revision: https://phabricator.services.mozilla.com/D188556
2023-09-19 11:12:52 +00:00
Narcis Beleuzu
4ddc9496d3 Backed out 4 changesets (bug 1853480) for bustages on ScriptPreloader.cpp . CLOSED TREE
Backed out changeset 153828203749 (bug 1853480)
Backed out changeset f686d2dccfd6 (bug 1853480)
Backed out changeset 975251abd222 (bug 1853480)
Backed out changeset d29bfc33c3e8 (bug 1853480)
2023-09-19 13:44:52 +03:00
Tooru Fujisawa
a10325d739 Bug 1853480 - Part 1: Use TaskController thread stack size as JS stack quota in ScriptLoader off-thread compilation. r=nbp
Differential Revision: https://phabricator.services.mozilla.com/D188556
2023-09-19 09:46:25 +00:00
Henri Sivonen
2ea4ba1cf2 Bug 1846178 - Use the async/defer (non-blocking) HTML parser code path for module scripts. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D185797
2023-09-15 07:53:16 +00:00
Mirko Brodesser
06c09b51d1 Bug 1839316: part 11) Factor preparing the incremental stream loader out of StartLoadInternal. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D187181
2023-09-05 12:07:20 +00:00
Mirko Brodesser
6ab61c105c Bug 1839316: part 10) Factor preparing the HTTP request and initiator type out of StartLoadInternal. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D187177
2023-09-05 12:07:20 +00:00
Mirko Brodesser
a4bcc60a60 Bug 1839316: part 9) Factor preparing request priority and request dependencies out of StartLoadInternal. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D187176
2023-09-05 12:07:20 +00:00
Mirko Brodesser
5044b90fb7 Bug 1839316: part 8) Factor details of preparing load info and preparing the cache info out of ScriptLoader::StartLoadInternal. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D187175
2023-09-04 09:05:10 +00:00
Tooru Fujisawa
ce72fea4a7 Bug 1846194 - Remove off-thread compilation and decode API. r=nbp
Differential Revision: https://phabricator.services.mozilla.com/D185125
2023-09-01 03:43:21 +00:00
Mirko Brodesser
69e061faaa Bug 1850713: remove duplicated setting of early hint preloader id in ScriptLoader::StartLoadInternal. r=kershaw,manuel
Happens already at
<https://searchfox.org/mozilla-central/rev/e7b8d13b7513b6fbd97d69e882d7faeed05309d0/dom/script/ScriptLoader.cpp#620-628>.

Differential Revision: https://phabricator.services.mozilla.com/D187105
2023-08-30 14:58:21 +00:00
Mirko Brodesser
29a4be0f8b Bug 1839316: part 7) Factor creating channel for script loading out of ScriptLoader::StartLoadInternal. r=kershaw
Abstracts details away. Simplifies extending `StartLoadInternal`.

Differential Revision: https://phabricator.services.mozilla.com/D187093
2023-08-30 10:33:40 +00:00
Tooru Fujisawa
d5ad45d022 Bug 1845668 - Part 2: Move OffThreadCompilationCompleteTask::Run into class definition. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D184899
2023-08-29 12:07:18 +00:00
Tooru Fujisawa
7436d5d4b4 Bug 1845668 - Part 1: Rewrite OffThreadCompilationCompleteRunnable based on Task. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D184898
2023-08-29 12:07:18 +00:00
Tooru Fujisawa
1398b6d4be Bug 1845638 - Part 2: Include the pending time of OffThreadCompilationCompleteRunnable to the profiler timing. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D184897
2023-08-29 12:07:18 +00:00
Tooru Fujisawa
70c40a1658 Bug 1845638 - Part 1: Use JS::FrontendContext APIs and TaskController in compilation and decode in ScriptLoader. r=smaug,bthrall
Differential Revision: https://phabricator.services.mozilla.com/D184896
2023-08-29 12:07:18 +00:00
Mirko Brodesser
2966a909e7 Bug 1839316: part 4) Add RequestPriority to ScriptFetchOptions and ScriptLoadRequest. r=smaug
The request priority isn't propagated from `ScriptFetchOptions`, so
setting it has no effect for end-users. That will be implemented in a
following part.

Differential Revision: https://phabricator.services.mozilla.com/D183483
2023-08-28 11:56:34 +00:00
Norisz Fay
c5e74dfe84 Backed out changeset 4a4d5e64aec5 (bug 1846178) for causing mochitest failures on test_script_loader_js_cache.html/cache_module.html CLOSED TREE 2023-08-23 11:19:39 +03:00
Henri Sivonen
acc51e7036 Bug 1846178 - Use the async/defer (non-blocking) HTML parser code path for module scripts. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D185797
2023-08-23 07:11:47 +00:00
Tooru Fujisawa
70cc38532e Bug 1847469 - Part 26: Use column number types in JS::CompileOptions. r=iain
Differential Revision: https://phabricator.services.mozilla.com/D185764
2023-08-16 17:31:42 +00:00
Cristian Tuns
4fe9ed8f30 Backed out 27 changesets (bug 1847469) for causing spidermonkey bustages in Script.cpp CLOSED TREE
Backed out changeset 9d6e2651a013 (bug 1847469)
Backed out changeset 9b72d668efd2 (bug 1847469)
Backed out changeset 86abf5cf0a22 (bug 1847469)
Backed out changeset 46833087f8ac (bug 1847469)
Backed out changeset f3e2207fdeec (bug 1847469)
Backed out changeset aed75776cfff (bug 1847469)
Backed out changeset 8292a38bd99f (bug 1847469)
Backed out changeset 1320f83fb8c7 (bug 1847469)
Backed out changeset df9f925f9837 (bug 1847469)
Backed out changeset 69f32cf1862a (bug 1847469)
Backed out changeset b2ddddec8818 (bug 1847469)
Backed out changeset 056eed7abc97 (bug 1847469)
Backed out changeset 5df4f43ac0bf (bug 1847469)
Backed out changeset cb57923f6532 (bug 1847469)
Backed out changeset a0993f2a2195 (bug 1847469)
Backed out changeset 782499fbedf2 (bug 1847469)
Backed out changeset cf84fb98c5e1 (bug 1847469)
Backed out changeset 1fa5ab59814b (bug 1847469)
Backed out changeset f5f78944df81 (bug 1847469)
Backed out changeset aa14337bf5c6 (bug 1847469)
Backed out changeset 6757db4575d7 (bug 1847469)
Backed out changeset 236ff135701e (bug 1847469)
Backed out changeset 9b4d5b435020 (bug 1847469)
Backed out changeset a0f789621bc8 (bug 1847469)
Backed out changeset c19b81f48055 (bug 1847469)
Backed out changeset b4521e546d7e (bug 1847469)
Backed out changeset f26a10289316 (bug 1847469)
2023-08-16 07:08:01 -04:00