Commit graph

92 commits

Author SHA1 Message Date
Tooru Fujisawa
cff9da24d5 Bug 1899172 - Part 3: Add ScriptLoadContext::GetHintCharset. r=nbp
Differential Revision: https://phabricator.services.mozilla.com/D211903
2024-05-30 05:01:15 +00:00
Tooru Fujisawa
24265d53c5 Bug 1899172 - Part 1: Cleanup TRACE_FOR_TEST macros. r=nbp
Differential Revision: https://phabricator.services.mozilla.com/D211901
2024-05-30 05:01:14 +00:00
Tooru Fujisawa
976c794ad0 Bug 1800641 - Part 8: Add LoadContextBase* parameter to ScriptLoadRequest methods which is going to be moved to LoadedScriptDelegate. r=nbp
Depends on D197845

Differential Revision: https://phabricator.services.mozilla.com/D197846
2024-01-08 14:57:38 +00:00
Tooru Fujisawa
0e1541fc80 Bug 1800641 - Part 6: Add ScriptLoadRequest::{,Set}ReceivedScriptTextLength. r=nbp
Depends on D197843

Differential Revision: https://phabricator.services.mozilla.com/D197844
2024-01-08 14:57:38 +00:00
Tooru Fujisawa
51d2ccfe91 Bug 1800641 - Part 4: Add ScriptLoadRequest::{Get,Set}SRILength. r=nbp
Depends on D197841

Differential Revision: https://phabricator.services.mozilla.com/D197842
2024-01-08 14:57:37 +00:00
Tooru Fujisawa
bf69c195cd Bug 1800641 - Part 3: Add ScriptLoadRequest::SRIAndBytecode. r=nbp
Depends on D197840

Differential Revision: https://phabricator.services.mozilla.com/D197841
2024-01-08 14:57:36 +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
Yulia Startsev
2ed9b59d0c Bug 1742438 - Part 7: Make ScriptDecoder an independent class rather than a base class; r=arai
Now that the Worker ScriptLoader largely conforms to the same shape as the DOM ScriptLoader, and
represents requests in the same way, we can start sharing some code. The ScriptLoadHandler isn't
entirely common to both cases, as it handles preloads (which are not possible in workers). This
patch splits out the common class, ScriptDecoder, as it's own thing. A demonstration of its use is
in Part 8 of this patch queue.

Differential Revision: https://phabricator.services.mozilla.com/D146213
2022-07-14 17:07:27 +00:00
Yulia Startsev
bf6529d7e4 Bug 1742438 - Part 6: Factor out ScriptDecoder class from ScriptLoadHandler; r=arai
This patch splits out the decoding from the ScriptLoadHandler. This will be reused by the worker
ScriptLoader for loading scripts via both NetworkLoadHandler and CacheLoadHandler.

Differential Revision: https://phabricator.services.mozilla.com/D146178
2022-07-14 17:07:26 +00:00
Bryan Thrall
edc0fa2360 Bug 1757833 - Add PerfStat probes for bytecode cache reads, writes, compression, and decompression r=nbp,necko-reviewers,kershaw
Differential Revision: https://phabricator.services.mozilla.com/D145012
2022-05-20 18:25:42 +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
Iulian Moraru
c49f9ffda3 Backed out 6 changesets (bug 1757833) for causing multiple crashes with MOZ_Z_inflateInit2_. CLOSED TREE
Backed out changeset 6a7d3034db0a (bug 1757833)
Backed out changeset faa0393886db (bug 1757833)
Backed out changeset 4bffe0cf490e (bug 1757833)
Backed out changeset 189b81cc13fd (bug 1757833)
Backed out changeset a59c66e4fb68 (bug 1757833)
Backed out changeset 2b5d9869fbcb (bug 1757833)
2022-05-19 01:14:05 +03:00
Bryan Thrall
98850ac71c Bug 1757833 - Add PerfStat probes for bytecode cache reads, writes, compression, and decompression r=nbp,necko-reviewers,kershaw
Differential Revision: https://phabricator.services.mozilla.com/D145012
2022-05-18 21:03:49 +00:00
Bryan Thrall
84ef677639 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-18 21:03:48 +00:00
Bryan Thrall
76e71f6f2c 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-18 21:03:47 +00:00
Sebastian Hengst
825a31e539 Backed out 6 changesets (bug 1757833) for Linux base toolchains build failure
Backed out changeset c8117edaf054 (bug 1757833)
Backed out changeset a46efd9967d0 (bug 1757833)
Backed out changeset f33955b6a7cc (bug 1757833)
Backed out changeset 71f1afa82581 (bug 1757833)
Backed out changeset 868407dccba9 (bug 1757833)
Backed out changeset 79873d83d02b (bug 1757833)
2022-05-17 19:46:50 +02:00
Bryan Thrall
47bd5772df Bug 1757833 - Add PerfStat probes for bytecode cache reads, writes, compression, and decompression r=nbp,necko-reviewers,kershaw
Differential Revision: https://phabricator.services.mozilla.com/D145012
2022-05-17 16:29:05 +00:00
Bryan Thrall
c88e06a519 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-17 16:29:03 +00:00
Bryan Thrall
0fcf6504f4 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-17 16:29:03 +00:00
Kagami Sascha Rosylight
544bfe11bc Bug 1768189 - Part 26: Apply modernize-concat-nested-namespaces to dom/reporting/ReportingHeader.cpp ... r=andi
Depends on D145759

Differential Revision: https://phabricator.services.mozilla.com/D145760
2022-05-09 20:41:13 +00:00
Yulia Startsev
a996a1aca2 Bug 1763372 - Rename GetLoadContext to GetScriptLoadContext; r=jonco
Depends on D143068

Differential Revision: https://phabricator.services.mozilla.com/D143037
2022-04-22 13:24:10 +00:00
Yulia Startsev
f1dd84285f Bug 1763372 - Add LoadContextBase; r=jonco,smaug
Differential Revision: https://phabricator.services.mozilla.com/D143036
2022-04-22 13:24:09 +00:00
Jon Coppeard
075e630cb9 Bug 1761432 - Part 4: Rename state accessor methods after the enum values r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D142044
2022-03-25 10:54:17 +00:00
Jon Coppeard
0d945e360c Bug 1761432 - Part 2: Split out script load request state for when we require loading from source r=smaug
This is used when we explicitly don't want to load cached bytecode. It is
better served by a separate flag in the request than a state.

Differential Revision: https://phabricator.services.mozilla.com/D142042
2022-03-25 10:54:16 +00:00
Tooru Fujisawa
0aaa5686d0 Bug 1436400 - Part 4: Add ScriptLoader::BytecodeMimeTypeFor static method to get bytecode MIME type for given request. r=nbp
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.

Differential Revision: https://phabricator.services.mozilla.com/D140292
2022-03-15 19:05:55 +00:00
Csoregi Natalia
6ae31a2e64 Backed out 15 changesets (bug 1757597, bug 1436400) for causing mochitest failures on test_bug1656248.html. CLOSED TREE
Backed out changeset 4be29c1eb5bc (bug 1436400)
Backed out changeset ffd9ddcef6b0 (bug 1436400)
Backed out changeset 5ac844508d8b (bug 1436400)
Backed out changeset 561aeb550892 (bug 1436400)
Backed out changeset 6f473bcf809a (bug 1436400)
Backed out changeset c33620854115 (bug 1436400)
Backed out changeset 8f894ea40eb2 (bug 1436400)
Backed out changeset cce080064d82 (bug 1436400)
Backed out changeset 001d8528ff96 (bug 1436400)
Backed out changeset dd2bb1b46f75 (bug 1436400)
Backed out changeset b1c2084042fa (bug 1436400)
Backed out changeset dd0fea93bcd7 (bug 1436400)
Backed out changeset e38a959648e1 (bug 1436400)
Backed out changeset 40b474d430e9 (bug 1436400)
Backed out changeset 5bef21ef1ba2 (bug 1757597)
2022-03-15 07:23:29 +02:00
Tooru Fujisawa
ea5bbd2533 Bug 1436400 - Part 4: Add ScriptLoader::BytecodeMimeTypeFor static method to get bytecode MIME type for given request. r=nbp
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.

Differential Revision: https://phabricator.services.mozilla.com/D140292
2022-03-15 04:24:50 +00:00
Yulia Startsev
79409316d1 Bug 1742437 - re-scope all generic module/script loader files under js/loader; r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D138133
2022-02-21 15:39:09 +00:00
Yulia Startsev
7ded97bc1a Bug 1742437 - Split ScriptLoadRequest into ScriptLoadRequest and DOMScriptLoadContext; r=jonco,smaug
Differential Revision: https://phabricator.services.mozilla.com/D134041
2022-02-21 15:39:04 +00:00
Norisz Fay
4c85ac47c5 Backed out 12 changesets (bug 1742437) for causing Bp-hybrid bustages on ModuleLoader.obj
Backed out changeset 7d5683180ac3 (bug 1742437)
Backed out changeset a48aff5f2555 (bug 1742437)
Backed out changeset 7e54a223001d (bug 1742437)
Backed out changeset 3a34d557d474 (bug 1742437)
Backed out changeset f29451ea18dc (bug 1742437)
Backed out changeset c0bd1d29be62 (bug 1742437)
Backed out changeset 8b970fb6e4e6 (bug 1742437)
Backed out changeset 729c48e34d6b (bug 1742437)
Backed out changeset 9355004c7f6a (bug 1742437)
Backed out changeset 0a5f61274aed (bug 1742437)
Backed out changeset a50f60a612d3 (bug 1742437)
Backed out changeset 0ac6d9d26e2b (bug 1742437)
2022-02-18 00:00:41 +02:00
Yulia Startsev
499559431e Bug 1742437 - re-scope all generic module/script loader files under js/loader; r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D138133
2022-02-17 15:57:52 +00:00
Yulia Startsev
f212e8a1c1 Bug 1742437 - Split ScriptLoadRequest into ScriptLoadRequest and DOMScriptLoadContext; r=jonco,smaug
Differential Revision: https://phabricator.services.mozilla.com/D134041
2022-02-17 15:57:48 +00:00
ssummar
0992acc367 Bug 1603127 - Replaced mozilla::Tuple with std::tuple and applied structured bindings in mozilla/Encoding.h. r=hsivonen
Differential Revision: https://phabricator.services.mozilla.com/D129920
2021-11-08 08:14:00 +00:00
Cristian Tuns
71486b8924 Backed out changeset 7e8e3747c3f8 (bug 1603127) for causing toolchains build bustages (Bug 1739589). CLOSED TREE 2021-11-05 07:23:45 -04:00
ssummar
508562cc85 Bug 1603127 - Replaced mozilla::Tuple with std::tuple and applied structured bindings in mozilla/Encoding.h. r=hsivonen
Differential Revision: https://phabricator.services.mozilla.com/D129920
2021-11-05 05:33:58 +00:00
ssummar
51c0ff21e5 Bug 1626517 - Replaced mozilla::Unused with mozilla::Ignore in mozilla::Decoder/mozilla::Encoder calls. r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D129022
2021-10-25 12:31:41 +00:00
André Bargull
d2bbf86876 Bug 1726123 - Part 5: Add missing "js/" includes outside of SM. r=arai
In preparation for the next part, add missing includes to "js/" public headers.

Differential Revision: https://phabricator.services.mozilla.com/D122843
2021-08-17 15:45:39 +00:00
Ted Campbell
9b6e632d81 Bug 1700954 - Remove remaining BinAST fragments from ScriptLoader. r=arai,hsivonen,necko-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D109765
2021-03-26 13:01:40 +00:00
Tooru Fujisawa
33a5756351 Bug 1681308 - Add alignment requirement to XDR buffer. r=nbp
Differential Revision: https://phabricator.services.mozilla.com/D101125
2021-01-13 02:18:26 +00:00
Simon Giesecke
c368d437ee Bug 1680269 - Fix includes for ScriptLoadHandler. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D98492
2020-12-07 14:21:35 +00:00
Simon Giesecke
1c53236b70 Bug 1679272 - Include ScopeExit.h exactly where used. r=andi
Differential Revision: https://phabricator.services.mozilla.com/D98888
2020-12-07 14:25:59 +00:00
Simon Giesecke
971b645fe3 Bug 1660470 - Add missing include directives/forward declarations. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D87865
2020-11-23 16:21:38 +00:00
Simon Giesecke
1e02318b49 Bug 1653335 - Replace MakeSpan uses by constructor calls. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D83817
2020-08-07 07:49:47 +00:00
Denis Palmeiro
d1ffff7a12 Bug 1501608 - Remove the ELEMENT_SLOT in the ScriptSourceObject and instead use a callback function to return the script element based on the value of the privateValue in the SSO. r=jonco,smaug
We can reduce the size of the SSO by removing the element slot entirely, and instead retrieve the element through a callback function.  The callback will take in the value in the private slot of the SSO, which is either a LoadedScript* (from the browser) or a JSObject* (from the shell).  In addition, this removes the requirement of having a script dom element ready when parsing a JS script which can open up new opportunities for performance.

Differential Revision: https://phabricator.services.mozilla.com/D70417
2020-05-12 19:28:15 +00:00
Honza Bambas
3af63237fe Bug 1618292 - Make ScriptLoadRequest derive and use PreloaderBase to support new preload as speculative load feature, r=smaug
Depends on D67483

Differential Revision: https://phabricator.services.mozilla.com/D67481
2020-05-11 14:07:24 +00:00
Dorel Luca
159241fe4b Backed out changeset 4107b758e7ae (bug 1501608) as requested by dev 2020-05-02 15:03:19 +03:00