Bug 1899090 - Part 3: Stop using JS::DuplicateStencil in ScriptLoader. r=nbp
Incremental-encoding API no longer requires exclusive ownership of JS::Stencil, and the consumers no longer need to duplicate. Differential Revision: https://phabricator.services.mozilla.com/D230379
This commit is contained in:
@@ -2745,8 +2745,8 @@ 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,
|
||||
JSContext* aCx, JS::CompileOptions& aCompileOptions, JS::Stencil* aStencil,
|
||||
JS::MutableHandle<JSScript*> aScript,
|
||||
bool& incrementalEncodingAlreadyStarted,
|
||||
JS::Handle<JS::Value> aDebuggerPrivateValue,
|
||||
JS::Handle<JSScript*> aDebuggerIntroductionScript, ErrorResult& aRv,
|
||||
@@ -2783,7 +2783,7 @@ static void InstantiateStencil(
|
||||
void ScriptLoader::InstantiateClassicScriptFromMaybeEncodedSource(
|
||||
JSContext* aCx, JS::CompileOptions& aCompileOptions,
|
||||
ScriptLoadRequest* aRequest, JS::MutableHandle<JSScript*> aScript,
|
||||
bool aKeepStencil, RefPtr<JS::Stencil>& aStencilDup,
|
||||
RefPtr<JS::Stencil>& aStencilOut,
|
||||
JS::Handle<JS::Value> aDebuggerPrivateValue,
|
||||
JS::Handle<JSScript*> aDebuggerIntroductionScript, ErrorResult& aRv) {
|
||||
nsAutoCString profilerLabelString;
|
||||
@@ -2802,18 +2802,12 @@ void ScriptLoader::InstantiateClassicScriptFromMaybeEncodedSource(
|
||||
aRv.NoteJSContextException(aCx);
|
||||
return;
|
||||
}
|
||||
if (!aRv.Failed() && aKeepStencil) {
|
||||
aStencilDup = JS::DuplicateStencil(aCx, stencil.get());
|
||||
if (!aStencilDup) {
|
||||
aRv.NoteJSContextException(aCx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
aStencilOut = stencil.get();
|
||||
|
||||
bool unused;
|
||||
InstantiateStencil(aCx, aCompileOptions, std::move(stencil), aScript,
|
||||
unused, aDebuggerPrivateValue,
|
||||
aDebuggerIntroductionScript, aRv, false, &storage);
|
||||
InstantiateStencil(aCx, aCompileOptions, stencil, aScript, unused,
|
||||
aDebuggerPrivateValue, aDebuggerIntroductionScript,
|
||||
aRv, false, &storage);
|
||||
} else {
|
||||
LOG(("ScriptLoadRequest (%p): Decode Bytecode and Execute", aRequest));
|
||||
AUTO_PROFILER_MARKER_TEXT("BytecodeDecodeMainThread", JS,
|
||||
@@ -2822,19 +2816,13 @@ void ScriptLoader::InstantiateClassicScriptFromMaybeEncodedSource(
|
||||
|
||||
RefPtr<JS::Stencil> stencil;
|
||||
Decode(aCx, aCompileOptions, aRequest->Bytecode(), stencil, aRv);
|
||||
if (!aRv.Failed() && aKeepStencil) {
|
||||
aStencilDup = JS::DuplicateStencil(aCx, stencil.get());
|
||||
if (!aStencilDup) {
|
||||
aRv.NoteJSContextException(aCx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
aStencilOut = stencil.get();
|
||||
|
||||
if (stencil) {
|
||||
bool unused;
|
||||
InstantiateStencil(aCx, aCompileOptions, std::move(stencil), aScript,
|
||||
unused, aDebuggerPrivateValue,
|
||||
aDebuggerIntroductionScript, aRv);
|
||||
InstantiateStencil(aCx, aCompileOptions, stencil, aScript, unused,
|
||||
aDebuggerPrivateValue, aDebuggerIntroductionScript,
|
||||
aRv);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2864,19 +2852,12 @@ void ScriptLoader::InstantiateClassicScriptFromMaybeEncodedSource(
|
||||
aRv.NoteJSContextException(aCx);
|
||||
return;
|
||||
}
|
||||
if (!aRv.Failed() && aKeepStencil) {
|
||||
aStencilDup = JS::DuplicateStencil(aCx, stencil.get());
|
||||
if (!aStencilDup) {
|
||||
aRv.NoteJSContextException(aCx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
aStencilOut = stencil.get();
|
||||
|
||||
bool unused;
|
||||
InstantiateStencil(aCx, aCompileOptions, std::move(stencil), aScript,
|
||||
unused, aDebuggerPrivateValue,
|
||||
aDebuggerIntroductionScript, aRv, encodeBytecode,
|
||||
&storage);
|
||||
InstantiateStencil(aCx, aCompileOptions, stencil, aScript, unused,
|
||||
aDebuggerPrivateValue, aDebuggerIntroductionScript, aRv,
|
||||
encodeBytecode, &storage);
|
||||
} else {
|
||||
// Main thread parsing (inline and small scripts)
|
||||
LOG(("ScriptLoadRequest (%p): Compile And Exec", aRequest));
|
||||
@@ -2901,18 +2882,13 @@ void ScriptLoader::InstantiateClassicScriptFromMaybeEncodedSource(
|
||||
MOZ_ASSERT(!maybeSource.empty());
|
||||
TimeStamp startTime = TimeStamp::Now();
|
||||
maybeSource.mapNonEmpty(compile);
|
||||
if (!erv.Failed() && aKeepStencil) {
|
||||
aStencilDup = JS::DuplicateStencil(aCx, stencil.get());
|
||||
if (!aStencilDup) {
|
||||
erv.NoteJSContextException(aCx);
|
||||
}
|
||||
}
|
||||
aStencilOut = stencil.get();
|
||||
|
||||
if (stencil) {
|
||||
bool unused;
|
||||
InstantiateStencil(aCx, aCompileOptions, std::move(stencil), aScript,
|
||||
unused, aDebuggerPrivateValue,
|
||||
aDebuggerIntroductionScript, erv, encodeBytecode);
|
||||
InstantiateStencil(aCx, aCompileOptions, stencil, aScript, unused,
|
||||
aDebuggerPrivateValue, aDebuggerIntroductionScript,
|
||||
erv, encodeBytecode);
|
||||
}
|
||||
|
||||
mMainThreadParseTime += TimeStamp::Now() - startTime;
|
||||
@@ -2927,14 +2903,8 @@ void ScriptLoader::InstantiateClassicScriptFromCachedStencil(
|
||||
JS::MutableHandle<JSScript*> aScript,
|
||||
JS::Handle<JS::Value> aDebuggerPrivateValue,
|
||||
JS::Handle<JSScript*> aDebuggerIntroductionScript, ErrorResult& aRv) {
|
||||
RefPtr<JS::Stencil> stencil = JS::DuplicateStencil(aCx, aStencil);
|
||||
if (!stencil) {
|
||||
aRv = NS_ERROR_FAILURE;
|
||||
return;
|
||||
}
|
||||
|
||||
bool incrementalEncodingAlreadyStarted = false;
|
||||
InstantiateStencil(aCx, aCompileOptions, std::move(stencil), aScript,
|
||||
InstantiateStencil(aCx, aCompileOptions, aStencil, aScript,
|
||||
incrementalEncodingAlreadyStarted, aDebuggerPrivateValue,
|
||||
aDebuggerIntroductionScript, aRv,
|
||||
/* aEncodeBytecode */ true);
|
||||
@@ -2969,15 +2939,15 @@ void ScriptLoader::InstantiateClassicScriptFromAny(
|
||||
}
|
||||
}
|
||||
|
||||
RefPtr<JS::Stencil> stencilDup;
|
||||
RefPtr<JS::Stencil> stencil;
|
||||
InstantiateClassicScriptFromMaybeEncodedSource(
|
||||
aCx, aCompileOptions, aRequest, aScript, createCache, stencilDup,
|
||||
aDebuggerPrivateValue, aDebuggerIntroductionScript, aRv);
|
||||
aCx, aCompileOptions, aRequest, aScript, stencil, aDebuggerPrivateValue,
|
||||
aDebuggerIntroductionScript, aRv);
|
||||
if (!aRv.Failed()) {
|
||||
if (createCache) {
|
||||
MOZ_ASSERT(mCache);
|
||||
MOZ_ASSERT(stencilDup);
|
||||
aRequest->SetStencil(stencilDup.forget());
|
||||
MOZ_ASSERT(stencil);
|
||||
aRequest->SetStencil(stencil.forget());
|
||||
auto loadData = MakeRefPtr<ScriptLoadData>(this, aRequest);
|
||||
mCache->Insert(*loadData);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user