Bug 1724236 - Inline JoinOffThread r=arai
Differential Revision: https://phabricator.services.mozilla.com/D218456
This commit is contained in:
@@ -83,18 +83,6 @@ JSExecutionContext::JSExecutionContext(
|
||||
|
||||
namespace mozilla::dom {
|
||||
|
||||
void JoinOffThread(JSContext* aCx, JS::CompileOptions& aCompileOptions,
|
||||
ScriptLoadContext* aContext, RefPtr<JS::Stencil>& aStencil,
|
||||
JS::InstantiationStorage& aStorage, ErrorResult& aRv) {
|
||||
MOZ_ASSERT(aCompileOptions.noScriptRval);
|
||||
|
||||
aStencil = aContext->StealOffThreadResult(aCx, &aStorage);
|
||||
if (!aStencil) {
|
||||
aRv.NoteJSContextException(aCx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void Compile(JSContext* aCx, JS::CompileOptions& aCompileOptions,
|
||||
const nsAString& aScript, RefPtr<JS::Stencil>& aStencil,
|
||||
ErrorResult& aRv) {
|
||||
|
||||
@@ -64,13 +64,6 @@ class MOZ_STACK_CLASS JSExecutionContext final {
|
||||
}
|
||||
};
|
||||
|
||||
// After getting a notification that an off-thread compile/decode finished,
|
||||
// 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, RefPtr<JS::Stencil>& aStencil,
|
||||
JS::InstantiationStorage& aStorage, ErrorResult& aRv);
|
||||
|
||||
// Compile a script contained in a string.
|
||||
void Compile(JSContext* aCx, JS::CompileOptions& aCompileOptions,
|
||||
const nsAString& aScript, RefPtr<JS::Stencil>& aStencil,
|
||||
|
||||
@@ -2758,8 +2758,13 @@ void ScriptLoader::InstantiateClassicScriptFromMaybeEncodedSource(
|
||||
aRequest));
|
||||
RefPtr<JS::Stencil> stencil;
|
||||
JS::InstantiationStorage storage;
|
||||
JoinOffThread(aCx, aCompileOptions, aRequest->GetScriptLoadContext(),
|
||||
stencil, storage, aRv);
|
||||
MOZ_ASSERT(aCompileOptions.noScriptRval);
|
||||
stencil =
|
||||
aRequest->GetScriptLoadContext()->StealOffThreadResult(aCx, &storage);
|
||||
if (!stencil) {
|
||||
aRv.NoteJSContextException(aCx);
|
||||
return;
|
||||
}
|
||||
if (!aRv.Failed() && aKeepStencil) {
|
||||
aStencilDup = JS::DuplicateStencil(aCx, stencil.get());
|
||||
if (!aStencilDup) {
|
||||
@@ -2767,12 +2772,11 @@ void ScriptLoader::InstantiateClassicScriptFromMaybeEncodedSource(
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (stencil) {
|
||||
bool unused;
|
||||
InstantiateStencil(aCx, aCompileOptions, std::move(stencil), aScript,
|
||||
unused, aDebuggerPrivateValue,
|
||||
aDebuggerIntroductionScript, aRv, false, &storage);
|
||||
}
|
||||
|
||||
bool unused;
|
||||
InstantiateStencil(aCx, aCompileOptions, std::move(stencil), aScript,
|
||||
unused, aDebuggerPrivateValue,
|
||||
aDebuggerIntroductionScript, aRv, false, &storage);
|
||||
} else {
|
||||
LOG(("ScriptLoadRequest (%p): Decode Bytecode and Execute", aRequest));
|
||||
AUTO_PROFILER_MARKER_TEXT("BytecodeDecodeMainThread", JS,
|
||||
@@ -2816,8 +2820,13 @@ void ScriptLoader::InstantiateClassicScriptFromMaybeEncodedSource(
|
||||
MOZ_ASSERT(aRequest->IsTextSource());
|
||||
RefPtr<JS::Stencil> stencil;
|
||||
JS::InstantiationStorage storage;
|
||||
JoinOffThread(aCx, aCompileOptions, aRequest->GetScriptLoadContext(),
|
||||
stencil, storage, aRv);
|
||||
MOZ_ASSERT(aCompileOptions.noScriptRval);
|
||||
stencil =
|
||||
aRequest->GetScriptLoadContext()->StealOffThreadResult(aCx, &storage);
|
||||
if (!stencil) {
|
||||
aRv.NoteJSContextException(aCx);
|
||||
return;
|
||||
}
|
||||
if (!aRv.Failed() && aKeepStencil) {
|
||||
aStencilDup = JS::DuplicateStencil(aCx, stencil.get());
|
||||
if (!aStencilDup) {
|
||||
@@ -2825,13 +2834,12 @@ void ScriptLoader::InstantiateClassicScriptFromMaybeEncodedSource(
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (stencil) {
|
||||
bool unused;
|
||||
InstantiateStencil(aCx, aCompileOptions, std::move(stencil), aScript,
|
||||
unused, aDebuggerPrivateValue,
|
||||
aDebuggerIntroductionScript, aRv, encodeBytecode,
|
||||
&storage);
|
||||
}
|
||||
|
||||
bool unused;
|
||||
InstantiateStencil(aCx, aCompileOptions, std::move(stencil), aScript,
|
||||
unused, aDebuggerPrivateValue,
|
||||
aDebuggerIntroductionScript, 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