Bug 1724236 - Move InstantiateStencil() to ScriptLoader r=arai
Differential Revision: https://phabricator.services.mozilla.com/D222299
This commit is contained in:
@@ -59,41 +59,4 @@ void Compile(JSContext* aCx, JS::CompileOptions& aCompileOptions,
|
||||
}
|
||||
}
|
||||
|
||||
void InstantiateStencil(JSContext* aCx, JS::CompileOptions& aCompileOptions,
|
||||
RefPtr<JS::Stencil>&& aStencil,
|
||||
JS::MutableHandle<JSScript*> aScript,
|
||||
bool& incrementalEncodingAlreadyStarted,
|
||||
JS::Handle<JS::Value> aDebuggerPrivateValue,
|
||||
JS::Handle<JSScript*> aDebuggerIntroductionScript,
|
||||
ErrorResult& aRv, bool aEncodeBytecode /* = false */,
|
||||
JS::InstantiationStorage* aStorage) {
|
||||
JS::InstantiateOptions instantiateOptions(aCompileOptions);
|
||||
JS::Rooted<JSScript*> script(
|
||||
aCx, JS::InstantiateGlobalStencil(aCx, instantiateOptions, aStencil,
|
||||
aStorage));
|
||||
if (!script) {
|
||||
aRv.NoteJSContextException(aCx);
|
||||
return;
|
||||
}
|
||||
|
||||
if (aEncodeBytecode) {
|
||||
if (!JS::StartIncrementalEncoding(aCx, std::move(aStencil),
|
||||
incrementalEncodingAlreadyStarted)) {
|
||||
aRv.NoteJSContextException(aCx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
MOZ_ASSERT(!aScript);
|
||||
aScript.set(script);
|
||||
|
||||
if (instantiateOptions.deferDebugMetadata) {
|
||||
if (!JS::UpdateDebugMetadata(aCx, aScript, instantiateOptions,
|
||||
aDebuggerPrivateValue, nullptr,
|
||||
aDebuggerIntroductionScript, nullptr)) {
|
||||
aRv = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace mozilla::dom
|
||||
|
||||
@@ -7,11 +7,9 @@
|
||||
#ifndef DOM_BASE_JSEXECUTIONUTILS_H_
|
||||
#define DOM_BASE_JSEXECUTIONUTILS_H_
|
||||
|
||||
#include "js/TypeDecls.h" // JSScript, MutableHandle
|
||||
#include "js/Value.h" // JS::UndefinedHandleValue
|
||||
#include "js/TypeDecls.h" // JSScript
|
||||
#include "js/experimental/JSStencil.h" // JS::Stencil
|
||||
#include "js/CompileOptions.h" // JS::CompileOptions
|
||||
#include "js/RootingAPI.h" // JS::Handle
|
||||
#include "mozilla/ErrorResult.h" // ErrorResult
|
||||
#include "nsStringFwd.h" // nsAString
|
||||
|
||||
@@ -24,17 +22,6 @@ void Compile(JSContext* aCx, JS::CompileOptions& aCompileOptions,
|
||||
const nsAString& aScript, RefPtr<JS::Stencil>& aStencil,
|
||||
ErrorResult& aRv);
|
||||
|
||||
// Instantiate (on main-thread) a JS::Stencil generated by off-thread or
|
||||
// main-thread parsing or decoding.
|
||||
void InstantiateStencil(JSContext* aCx, JS::CompileOptions& aCompileOptions,
|
||||
RefPtr<JS::Stencil>&& aStencil,
|
||||
JS::MutableHandle<JSScript*> aScript,
|
||||
bool& incrementalEncodingAlreadyStarted,
|
||||
JS::Handle<JS::Value> aDebuggerPrivateValue,
|
||||
JS::Handle<JSScript*> aDebuggerIntroductionScript,
|
||||
ErrorResult& aRv, bool aEncodeBytecode = false,
|
||||
JS::InstantiationStorage* aStorage = nullptr);
|
||||
|
||||
} // namespace mozilla::dom
|
||||
|
||||
#endif /* DOM_BASE_JSEXECUTIONUTILS_H_ */
|
||||
|
||||
@@ -2742,6 +2742,44 @@ static void Decode(JSContext* aCx, JS::CompileOptions& aCompileOptions,
|
||||
}
|
||||
}
|
||||
|
||||
// Instantiate (on main-thread) a JS::Stencil generated by off-thread or
|
||||
// main-thread parsing or decoding.
|
||||
static void InstantiateStencil(
|
||||
JSContext* aCx, JS::CompileOptions& aCompileOptions,
|
||||
RefPtr<JS::Stencil>&& aStencil, JS::MutableHandle<JSScript*> aScript,
|
||||
bool& incrementalEncodingAlreadyStarted,
|
||||
JS::Handle<JS::Value> aDebuggerPrivateValue,
|
||||
JS::Handle<JSScript*> aDebuggerIntroductionScript, ErrorResult& aRv,
|
||||
bool aEncodeBytecode = false,
|
||||
JS::InstantiationStorage* aStorage = nullptr) {
|
||||
JS::InstantiateOptions instantiateOptions(aCompileOptions);
|
||||
JS::Rooted<JSScript*> script(
|
||||
aCx, JS::InstantiateGlobalStencil(aCx, instantiateOptions, aStencil,
|
||||
aStorage));
|
||||
if (!script) {
|
||||
aRv.NoteJSContextException(aCx);
|
||||
return;
|
||||
}
|
||||
|
||||
if (aEncodeBytecode) {
|
||||
if (!JS::StartIncrementalEncoding(aCx, std::move(aStencil),
|
||||
incrementalEncodingAlreadyStarted)) {
|
||||
aRv.NoteJSContextException(aCx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
aScript.set(script);
|
||||
|
||||
if (instantiateOptions.deferDebugMetadata) {
|
||||
if (!JS::UpdateDebugMetadata(aCx, aScript, instantiateOptions,
|
||||
aDebuggerPrivateValue, nullptr,
|
||||
aDebuggerIntroductionScript, nullptr)) {
|
||||
aRv = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ScriptLoader::InstantiateClassicScriptFromMaybeEncodedSource(
|
||||
JSContext* aCx, JS::CompileOptions& aCompileOptions,
|
||||
ScriptLoadRequest* aRequest, JS::MutableHandle<JSScript*> aScript,
|
||||
|
||||
Reference in New Issue
Block a user