Bug 1444956 - Support BinAST decoding in the script loader r=baku
This commit is contained in:
@@ -5,7 +5,10 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "ModuleLoadRequest.h"
|
||||
|
||||
#include "mozilla/HoldDropJSObjects.h"
|
||||
#include "mozilla/Unused.h"
|
||||
|
||||
#include "nsICacheInfoChannel.h"
|
||||
#include "ScriptLoadRequest.h"
|
||||
#include "ScriptSettings.h"
|
||||
@@ -63,7 +66,6 @@ ScriptLoadRequest::ScriptLoadRequest(ScriptKind aKind,
|
||||
, mWasCompiledOMT(false)
|
||||
, mIsTracking(false)
|
||||
, mOffThreadToken(nullptr)
|
||||
, mScriptText()
|
||||
, mScriptBytecode()
|
||||
, mBytecodeOffset(0)
|
||||
, mURI(aURI)
|
||||
@@ -152,6 +154,67 @@ ScriptLoadRequest::SetScriptMode(bool aDeferAttr, bool aAsyncAttr)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ScriptLoadRequest::SetUnknownDataType()
|
||||
{
|
||||
mDataType = DataType::eUnknown;
|
||||
mScriptData.reset();
|
||||
}
|
||||
|
||||
void
|
||||
ScriptLoadRequest::SetTextSource()
|
||||
{
|
||||
MOZ_ASSERT(IsUnknownDataType());
|
||||
mDataType = DataType::eTextSource;
|
||||
mScriptData.emplace(VariantType<Vector<char16_t>>());
|
||||
}
|
||||
|
||||
void
|
||||
ScriptLoadRequest::SetBinASTSource()
|
||||
{
|
||||
#ifdef JS_BUILD_BINAST
|
||||
MOZ_ASSERT(IsUnknownDataType());
|
||||
mDataType = DataType::eBinASTSource;
|
||||
mScriptData.emplace(VariantType<Vector<uint8_t>>());
|
||||
#else
|
||||
MOZ_CRASH("BinAST not supported");
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
ScriptLoadRequest::SetBytecode()
|
||||
{
|
||||
MOZ_ASSERT(IsUnknownDataType());
|
||||
mDataType = DataType::eBytecode;
|
||||
}
|
||||
|
||||
bool
|
||||
ScriptLoadRequest::ShouldAcceptBinASTEncoding() const
|
||||
{
|
||||
#ifdef JS_BUILD_BINAST
|
||||
// We accept the BinAST encoding if we're using a secure connection.
|
||||
|
||||
bool isHTTPS = false;
|
||||
nsresult rv = mURI->SchemeIs("https", &isHTTPS);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
Unused << rv;
|
||||
|
||||
return isHTTPS;
|
||||
#else
|
||||
MOZ_CRASH("BinAST not supported");
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
ScriptLoadRequest::ClearScriptSource()
|
||||
{
|
||||
if (IsTextSource()) {
|
||||
ScriptText().clearAndFree();
|
||||
} else if (IsBinASTSource()) {
|
||||
ScriptBinASTData().clearAndFree();
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// ScriptLoadRequestList
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user