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,
|
void JSExecutionContext::JoinOffThread(JSContext* aCx,
|
||||||
JS::CompileOptions& aCompileOptions,
|
JS::CompileOptions& aCompileOptions,
|
||||||
ScriptLoadContext* aContext,
|
ScriptLoadContext* aContext,
|
||||||
JS::MutableHandle<JSScript*> aScript,
|
RefPtr<JS::Stencil>& aStencil,
|
||||||
ErrorResult& aRv,
|
JS::InstantiationStorage& aStorage,
|
||||||
bool aEncodeBytecode /* = false */) {
|
ErrorResult& aRv) {
|
||||||
MOZ_ASSERT(!mSkip);
|
MOZ_ASSERT(!mSkip);
|
||||||
|
|
||||||
MOZ_ASSERT(aCompileOptions.noScriptRval);
|
MOZ_ASSERT(aCompileOptions.noScriptRval);
|
||||||
|
|
||||||
JS::InstantiationStorage storage;
|
aStencil = aContext->StealOffThreadResult(aCx, &aStorage);
|
||||||
RefPtr<JS::Stencil> stencil = aContext->StealOffThreadResult(aCx, &storage);
|
if (!aStencil) {
|
||||||
if (!stencil) {
|
|
||||||
mSkip = true;
|
mSkip = true;
|
||||||
aRv.NoteJSContextException(aCx);
|
aRv.NoteJSContextException(aCx);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mKeepStencil) {
|
if (mKeepStencil) {
|
||||||
mStencil = JS::DuplicateStencil(aCx, stencil.get());
|
mStencil = JS::DuplicateStencil(aCx, aStencil.get());
|
||||||
if (!mStencil) {
|
if (!mStencil) {
|
||||||
mSkip = true;
|
mSkip = true;
|
||||||
aRv.NoteJSContextException(aCx);
|
aRv.NoteJSContextException(aCx);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool unused;
|
|
||||||
InstantiateStencil(aCx, aCompileOptions, std::move(stencil), aScript, unused,
|
|
||||||
aRv, aEncodeBytecode, &storage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Unit>
|
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
|
// this function will take the result of the off-thread operation and move it
|
||||||
// to the main thread.
|
// to the main thread.
|
||||||
void JoinOffThread(JSContext* aCx, JS::CompileOptions& aCompileOptions,
|
void JoinOffThread(JSContext* aCx, JS::CompileOptions& aCompileOptions,
|
||||||
ScriptLoadContext* aContext,
|
ScriptLoadContext* aContext, RefPtr<JS::Stencil>& aStencil,
|
||||||
JS::MutableHandle<JSScript*> aScript, ErrorResult& aRv,
|
JS::InstantiationStorage& aStorage, ErrorResult& aRv);
|
||||||
bool aEncodeBytecode = false);
|
|
||||||
|
|
||||||
// Compile a script contained in a SourceText.
|
// Compile a script contained in a SourceText.
|
||||||
void Compile(JSContext* aCx, JS::CompileOptions& aCompileOptions,
|
void Compile(JSContext* aCx, JS::CompileOptions& aCompileOptions,
|
||||||
|
|||||||
@@ -2732,8 +2732,16 @@ void ScriptLoader::InstantiateClassicScriptFromMaybeEncodedSource(
|
|||||||
if (aRequest->GetScriptLoadContext()->mCompileOrDecodeTask) {
|
if (aRequest->GetScriptLoadContext()->mCompileOrDecodeTask) {
|
||||||
LOG(("ScriptLoadRequest (%p): Decode Bytecode & instantiate and Execute",
|
LOG(("ScriptLoadRequest (%p): Decode Bytecode & instantiate and Execute",
|
||||||
aRequest));
|
aRequest));
|
||||||
|
RefPtr<JS::Stencil> stencil;
|
||||||
|
JS::InstantiationStorage storage;
|
||||||
aExec.JoinOffThread(aCx, aCompileOptions,
|
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 {
|
} else {
|
||||||
LOG(("ScriptLoadRequest (%p): Decode Bytecode and Execute", aRequest));
|
LOG(("ScriptLoadRequest (%p): Decode Bytecode and Execute", aRequest));
|
||||||
AUTO_PROFILER_MARKER_TEXT("BytecodeDecodeMainThread", JS,
|
AUTO_PROFILER_MARKER_TEXT("BytecodeDecodeMainThread", JS,
|
||||||
@@ -2766,8 +2774,15 @@ void ScriptLoader::InstantiateClassicScriptFromMaybeEncodedSource(
|
|||||||
"Execute",
|
"Execute",
|
||||||
aRequest));
|
aRequest));
|
||||||
MOZ_ASSERT(aRequest->IsTextSource());
|
MOZ_ASSERT(aRequest->IsTextSource());
|
||||||
|
RefPtr<JS::Stencil> stencil;
|
||||||
|
JS::InstantiationStorage storage;
|
||||||
aExec.JoinOffThread(aCx, aCompileOptions, aRequest->GetScriptLoadContext(),
|
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 {
|
} else {
|
||||||
// Main thread parsing (inline and small scripts)
|
// Main thread parsing (inline and small scripts)
|
||||||
LOG(("ScriptLoadRequest (%p): Compile And Exec", aRequest));
|
LOG(("ScriptLoadRequest (%p): Compile And Exec", aRequest));
|
||||||
|
|||||||
Reference in New Issue
Block a user