diff --git a/js/src/frontend/BytecodeCompilation.h b/js/src/frontend/BytecodeCompilation.h index 16360b1cc906..dbcd5ab17da0 100644 --- a/js/src/frontend/BytecodeCompilation.h +++ b/js/src/frontend/BytecodeCompilation.h @@ -125,13 +125,11 @@ class MOZ_STACK_CLASS GlobalScriptInfo final : public BytecodeCompiler { GlobalSharedContext* sharedContext() { return &globalsc_; } }; -extern JSScript* CompileGlobalScript( - GlobalScriptInfo& info, JS::SourceText& srcBuf, - ScriptSourceObject** sourceObjectOut = nullptr); +extern JSScript* CompileGlobalScript(GlobalScriptInfo& info, + JS::SourceText& srcBuf); -extern JSScript* CompileGlobalScript( - GlobalScriptInfo& info, JS::SourceText& srcBuf, - ScriptSourceObject** sourceObjectOut = nullptr); +extern JSScript* CompileGlobalScript(GlobalScriptInfo& info, + JS::SourceText& srcBuf); class MOZ_STACK_CLASS EvalScriptInfo final : public BytecodeCompiler { JS::Handle environment_; diff --git a/js/src/frontend/BytecodeCompiler.cpp b/js/src/frontend/BytecodeCompiler.cpp index 5c91fe161159..9a309e65f33a 100644 --- a/js/src/frontend/BytecodeCompiler.cpp +++ b/js/src/frontend/BytecodeCompiler.cpp @@ -207,14 +207,12 @@ static void tellDebuggerAboutCompiledScript(JSContext* cx, } template -static JSScript* CreateGlobalScript( - GlobalScriptInfo& info, JS::SourceText& srcBuf, - ScriptSourceObject** sourceObjectOut = nullptr) { +static JSScript* CreateGlobalScript(GlobalScriptInfo& info, + JS::SourceText& srcBuf) { AutoAssertReportedException assertException(info.context()); LifoAllocScope allocScope(&info.context()->tempLifoAlloc()); frontend::ScriptCompiler compiler(srcBuf); - AutoInitializeSourceObject autoSSO(info, sourceObjectOut); if (!compiler.prepareScriptParse(allocScope, info)) { return nullptr; @@ -230,16 +228,14 @@ static JSScript* CreateGlobalScript( return info.getScript(); } -JSScript* frontend::CompileGlobalScript( - GlobalScriptInfo& info, JS::SourceText& srcBuf, - ScriptSourceObject** sourceObjectOut /* = nullptr */) { - return CreateGlobalScript(info, srcBuf, sourceObjectOut); +JSScript* frontend::CompileGlobalScript(GlobalScriptInfo& info, + JS::SourceText& srcBuf) { + return CreateGlobalScript(info, srcBuf); } -JSScript* frontend::CompileGlobalScript( - GlobalScriptInfo& info, JS::SourceText& srcBuf, - ScriptSourceObject** sourceObjectOut /* = nullptr */) { - return CreateGlobalScript(info, srcBuf, sourceObjectOut); +JSScript* frontend::CompileGlobalScript(GlobalScriptInfo& info, + JS::SourceText& srcBuf) { + return CreateGlobalScript(info, srcBuf); } template diff --git a/js/src/vm/HelperThreads.cpp b/js/src/vm/HelperThreads.cpp index 45116098ec10..cc418985d4ce 100644 --- a/js/src/vm/HelperThreads.cpp +++ b/js/src/vm/HelperThreads.cpp @@ -589,34 +589,25 @@ template void ScriptParseTask::parse(JSContext* cx) { MOZ_ASSERT(cx->isHelperThreadContext()); - JSScript* script; - Rooted sourceObject(cx); - - { - ScopeKind scopeKind = - options.nonSyntacticScope ? ScopeKind::NonSyntactic : ScopeKind::Global; - LifoAllocScope allocScope(&cx->tempLifoAlloc()); - frontend::ParseInfo parseInfo(cx, allocScope); - if (!parseInfo.initFromOptions(cx, options)) { - return; - } - - frontend::GlobalScriptInfo info(cx, parseInfo, options, scopeKind); - script = frontend::CompileGlobalScript( - info, data, - /* sourceObjectOut = */ &sourceObject.get()); - } - - if (script) { - scripts.infallibleAppend(script); + ScopeKind scopeKind = + options.nonSyntacticScope ? ScopeKind::NonSyntactic : ScopeKind::Global; + LifoAllocScope allocScope(&cx->tempLifoAlloc()); + frontend::ParseInfo parseInfo(cx, allocScope); + if (!parseInfo.initFromOptions(cx, options)) { + return; } // Whatever happens to the top-level script compilation (even if it fails), // we must finish initializing the SSO. This is because there may be valid // inner scripts observable by the debugger which reference the partially- // initialized SSO. - if (sourceObject) { - sourceObjects.infallibleAppend(sourceObject); + sourceObjects.infallibleAppend(parseInfo.sourceObject); + + frontend::GlobalScriptInfo info(cx, parseInfo, options, scopeKind); + JSScript* script = frontend::CompileGlobalScript(info, data); + + if (script) { + scripts.infallibleAppend(script); } }