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
This commit is contained in:
Bryan Thrall
2022-05-18 21:03:48 +00:00
parent b528dbd218
commit 55ed1fd8f6
6 changed files with 221 additions and 93 deletions

View File

@@ -325,7 +325,8 @@ class ScriptLoadRequest
size_t mScriptTextLength;
// Holds the SRI serialized hash and the script bytecode for non-inline
// scripts.
// scripts. The data is laid out according to ScriptBytecodeDataLayout
// or, if compression is enabled, ScriptBytecodeCompressedDataLayout.
mozilla::Vector<uint8_t> mScriptBytecode;
uint32_t mBytecodeOffset; // Offset of the bytecode in mScriptBytecode