Bug 1724236 - Move InstantiateStencil call out of JoinOffThread r=arai
Differential Revision: https://phabricator.services.mozilla.com/D225361
This commit is contained in:
@@ -86,33 +86,28 @@ JSExecutionContext::JSExecutionContext(
|
||||
void JSExecutionContext::JoinOffThread(JSContext* aCx,
|
||||
JS::CompileOptions& aCompileOptions,
|
||||
ScriptLoadContext* aContext,
|
||||
JS::MutableHandle<JSScript*> aScript,
|
||||
ErrorResult& aRv,
|
||||
bool aEncodeBytecode /* = false */) {
|
||||
RefPtr<JS::Stencil>& aStencil,
|
||||
JS::InstantiationStorage& aStorage,
|
||||
ErrorResult& aRv) {
|
||||
MOZ_ASSERT(!mSkip);
|
||||
|
||||
MOZ_ASSERT(aCompileOptions.noScriptRval);
|
||||
|
||||
JS::InstantiationStorage storage;
|
||||
RefPtr<JS::Stencil> stencil = aContext->StealOffThreadResult(aCx, &storage);
|
||||
if (!stencil) {
|
||||
aStencil = aContext->StealOffThreadResult(aCx, &aStorage);
|
||||
if (!aStencil) {
|
||||
mSkip = true;
|
||||
aRv.NoteJSContextException(aCx);
|
||||
return;
|
||||
}
|
||||
|
||||
if (mKeepStencil) {
|
||||
mStencil = JS::DuplicateStencil(aCx, stencil.get());
|
||||
mStencil = JS::DuplicateStencil(aCx, aStencil.get());
|
||||
if (!mStencil) {
|
||||
mSkip = true;
|
||||
aRv.NoteJSContextException(aCx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
bool unused;
|
||||
InstantiateStencil(aCx, aCompileOptions, std::move(stencil), aScript, unused,
|
||||
aRv, aEncodeBytecode, &storage);
|
||||
}
|
||||
|
||||
template <typename Unit>
|
||||
|
||||
@@ -89,9 +89,8 @@ class MOZ_STACK_CLASS JSExecutionContext final {
|
||||
// this function will take the result of the off-thread operation and move it
|
||||
// to the main thread.
|
||||
void JoinOffThread(JSContext* aCx, JS::CompileOptions& aCompileOptions,
|
||||
ScriptLoadContext* aContext,
|
||||
JS::MutableHandle<JSScript*> aScript, ErrorResult& aRv,
|
||||
bool aEncodeBytecode = false);
|
||||
ScriptLoadContext* aContext, RefPtr<JS::Stencil>& aStencil,
|
||||
JS::InstantiationStorage& aStorage, ErrorResult& aRv);
|
||||
|
||||
// Compile a script contained in a SourceText.
|
||||
void Compile(JSContext* aCx, JS::CompileOptions& aCompileOptions,
|
||||
|
||||
@@ -2732,8 +2732,16 @@ void ScriptLoader::InstantiateClassicScriptFromMaybeEncodedSource(
|
||||
if (aRequest->GetScriptLoadContext()->mCompileOrDecodeTask) {
|
||||
LOG(("ScriptLoadRequest (%p): Decode Bytecode & instantiate and Execute",
|
||||
aRequest));
|
||||
RefPtr<JS::Stencil> stencil;
|
||||
JS::InstantiationStorage storage;
|
||||
aExec.JoinOffThread(aCx, aCompileOptions,
|
||||
aRequest->GetScriptLoadContext(), aScript, aRv);
|
||||
aRequest->GetScriptLoadContext(), stencil, storage,
|
||||
aRv);
|
||||
if (stencil) {
|
||||
bool unused;
|
||||
aExec.InstantiateStencil(aCx, aCompileOptions, std::move(stencil),
|
||||
aScript, unused, aRv, false, &storage);
|
||||
}
|
||||
} else {
|
||||
LOG(("ScriptLoadRequest (%p): Decode Bytecode and Execute", aRequest));
|
||||
AUTO_PROFILER_MARKER_TEXT("BytecodeDecodeMainThread", JS,
|
||||
@@ -2766,8 +2774,15 @@ void ScriptLoader::InstantiateClassicScriptFromMaybeEncodedSource(
|
||||
"Execute",
|
||||
aRequest));
|
||||
MOZ_ASSERT(aRequest->IsTextSource());
|
||||
RefPtr<JS::Stencil> stencil;
|
||||
JS::InstantiationStorage storage;
|
||||
aExec.JoinOffThread(aCx, aCompileOptions, aRequest->GetScriptLoadContext(),
|
||||
aScript, aRv, encodeBytecode);
|
||||
stencil, storage, aRv);
|
||||
if (stencil) {
|
||||
bool unused;
|
||||
aExec.InstantiateStencil(aCx, aCompileOptions, std::move(stencil),
|
||||
aScript, unused, aRv, encodeBytecode, &storage);
|
||||
}
|
||||
} else {
|
||||
// Main thread parsing (inline and small scripts)
|
||||
LOG(("ScriptLoadRequest (%p): Compile And Exec", aRequest));
|
||||
|
||||
Reference in New Issue
Block a user