зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1683623 - Part 5: Remove SharedImmutableScriptData and HandleFunction parameters from JSScript::fromStencil. r=tcampbell
Depends on D100718 Differential Revision: https://phabricator.services.mozilla.com/D100719
This commit is contained in:
Родитель
614ae0a8a1
Коммит
c6f8cd8a1d
|
@ -349,8 +349,6 @@ static bool InstantiateScriptStencils(JSContext* cx, CompilationInput& input,
|
|||
fun = item.function;
|
||||
auto index = item.index;
|
||||
if (scriptStencil.hasSharedData) {
|
||||
auto* sharedData = stencil.sharedData.get(index);
|
||||
|
||||
// If the function was not referenced by enclosing script's bytecode, we
|
||||
// do not generate a BaseScript for it. For example, `(function(){});`.
|
||||
//
|
||||
|
@ -361,8 +359,7 @@ static bool InstantiateScriptStencils(JSContext* cx, CompilationInput& input,
|
|||
}
|
||||
|
||||
RootedScript script(
|
||||
cx, JSScript::fromStencil(cx, input, stencil, gcOutput, index,
|
||||
sharedData, fun));
|
||||
cx, JSScript::fromStencil(cx, input, stencil, gcOutput, index));
|
||||
if (!script) {
|
||||
return false;
|
||||
}
|
||||
|
@ -393,26 +390,18 @@ static bool InstantiateTopLevel(JSContext* cx, CompilationInput& input,
|
|||
CompilationGCOutput& gcOutput) {
|
||||
const ScriptStencil& scriptStencil =
|
||||
stencil.scriptData[CompilationInfo::TopLevelIndex];
|
||||
RootedFunction fun(cx);
|
||||
if (scriptStencil.isFunction()) {
|
||||
fun = gcOutput.functions[CompilationInfo::TopLevelIndex];
|
||||
}
|
||||
|
||||
// Top-level asm.js does not generate a JSScript.
|
||||
if (scriptStencil.functionFlags.isAsmJSNative()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
auto* sharedData = stencil.sharedData.get(CompilationInfo::TopLevelIndex);
|
||||
MOZ_ASSERT(sharedData);
|
||||
|
||||
if (input.lazy) {
|
||||
gcOutput.script = JSScript::CastFromLazy(input.lazy);
|
||||
|
||||
Rooted<JSScript*> script(cx, gcOutput.script);
|
||||
if (!JSScript::fullyInitFromStencil(cx, input, stencil, gcOutput, script,
|
||||
CompilationInfo::TopLevelIndex,
|
||||
sharedData, fun)) {
|
||||
CompilationInfo::TopLevelIndex)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -424,9 +413,8 @@ static bool InstantiateTopLevel(JSContext* cx, CompilationInput& input,
|
|||
return true;
|
||||
}
|
||||
|
||||
gcOutput.script =
|
||||
JSScript::fromStencil(cx, input, stencil, gcOutput,
|
||||
CompilationInfo::TopLevelIndex, sharedData, fun);
|
||||
gcOutput.script = JSScript::fromStencil(cx, input, stencil, gcOutput,
|
||||
CompilationInfo::TopLevelIndex);
|
||||
if (!gcOutput.script) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -3823,14 +3823,11 @@ bool JSScript::createPrivateScriptData(JSContext* cx, HandleScript script,
|
|||
}
|
||||
|
||||
/* static */
|
||||
bool JSScript::fullyInitFromStencil(JSContext* cx,
|
||||
js::frontend::CompilationInput& input,
|
||||
js::frontend::CompilationStencil& stencil,
|
||||
frontend::CompilationGCOutput& gcOutput,
|
||||
HandleScript script,
|
||||
const js::frontend::ScriptIndex scriptIndex,
|
||||
SharedImmutableScriptData* sharedData,
|
||||
HandleFunction fun) {
|
||||
bool JSScript::fullyInitFromStencil(
|
||||
JSContext* cx, js::frontend::CompilationInput& input,
|
||||
js::frontend::CompilationStencil& stencil,
|
||||
frontend::CompilationGCOutput& gcOutput, HandleScript script,
|
||||
const js::frontend::ScriptIndex scriptIndex) {
|
||||
MutableScriptFlags lazyMutableFlags;
|
||||
RootedScope lazyEnclosingScope(cx);
|
||||
|
||||
|
@ -3877,12 +3874,12 @@ bool JSScript::fullyInitFromStencil(JSContext* cx,
|
|||
});
|
||||
|
||||
/* The counts of indexed things must be checked during code generation. */
|
||||
MOZ_ASSERT(stencil.scriptData[scriptIndex].gcThings.size() <= INDEX_LIMIT);
|
||||
js::frontend::ScriptStencil& scriptStencil = stencil.scriptData[scriptIndex];
|
||||
MOZ_ASSERT(scriptStencil.gcThings.size() <= INDEX_LIMIT);
|
||||
|
||||
// Note: These flags should already be correct when the BaseScript was
|
||||
// allocated.
|
||||
MOZ_ASSERT(script->immutableFlags() ==
|
||||
stencil.scriptData[scriptIndex].immutableFlags);
|
||||
MOZ_ASSERT(script->immutableFlags() == scriptStencil.immutableFlags);
|
||||
|
||||
// Derive initial mutable flags
|
||||
script->resetArgsUsageAnalysis();
|
||||
|
@ -3893,13 +3890,14 @@ bool JSScript::fullyInitFromStencil(JSContext* cx,
|
|||
return false;
|
||||
}
|
||||
|
||||
script->initSharedData(sharedData);
|
||||
script->initSharedData(stencil.sharedData.get(scriptIndex));
|
||||
|
||||
// NOTE: JSScript is now constructed and should be linked in.
|
||||
rollbackGuard.release();
|
||||
|
||||
// Link JSFunction to this JSScript.
|
||||
if (fun) {
|
||||
if (scriptStencil.isFunction()) {
|
||||
JSFunction* fun = gcOutput.functions[scriptIndex];
|
||||
if (fun->isIncomplete()) {
|
||||
fun->initScript(script);
|
||||
} else {
|
||||
|
@ -3934,19 +3932,16 @@ JSScript* JSScript::fromStencil(JSContext* cx,
|
|||
js::frontend::CompilationInput& input,
|
||||
js::frontend::CompilationStencil& stencil,
|
||||
frontend::CompilationGCOutput& gcOutput,
|
||||
const js::frontend::ScriptIndex scriptIndex,
|
||||
SharedImmutableScriptData* sharedData,
|
||||
HandleFunction fun) {
|
||||
MOZ_ASSERT(sharedData,
|
||||
const js::frontend::ScriptIndex scriptIndex) {
|
||||
js::frontend::ScriptStencil& scriptStencil = stencil.scriptData[scriptIndex];
|
||||
MOZ_ASSERT(scriptStencil.hasSharedData,
|
||||
"Need generated bytecode to use JSScript::fromStencil");
|
||||
|
||||
RootedObject functionOrGlobal(cx, cx->global());
|
||||
if (fun) {
|
||||
functionOrGlobal = fun;
|
||||
if (scriptStencil.isFunction()) {
|
||||
functionOrGlobal = gcOutput.functions[scriptIndex];
|
||||
}
|
||||
|
||||
js::frontend::ScriptStencil& scriptStencil = stencil.scriptData[scriptIndex];
|
||||
|
||||
Rooted<ScriptSourceObject*> sourceObject(cx, gcOutput.sourceObject);
|
||||
RootedScript script(
|
||||
cx, Create(cx, functionOrGlobal, sourceObject, scriptStencil.extent,
|
||||
|
@ -3955,8 +3950,8 @@ JSScript* JSScript::fromStencil(JSContext* cx,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
if (!fullyInitFromStencil(cx, input, stencil, gcOutput, script, scriptIndex,
|
||||
sharedData, fun)) {
|
||||
if (!fullyInitFromStencil(cx, input, stencil, gcOutput, script,
|
||||
scriptIndex)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -1934,9 +1934,7 @@ class JSScript : public js::BaseScript {
|
|||
js::frontend::CompilationStencil& stencil,
|
||||
js::frontend::CompilationGCOutput& gcOutput,
|
||||
js::HandleScript script,
|
||||
const js::frontend::ScriptIndex scriptIndex,
|
||||
js::SharedImmutableScriptData* sharedData,
|
||||
js::HandleFunction function);
|
||||
const js::frontend::ScriptIndex scriptIndex);
|
||||
|
||||
// Allocate a JSScript and initialize it with bytecode. This consumes
|
||||
// allocations within the stencil.
|
||||
|
@ -1944,9 +1942,7 @@ class JSScript : public js::BaseScript {
|
|||
js::frontend::CompilationInput& input,
|
||||
js::frontend::CompilationStencil& stencil,
|
||||
js::frontend::CompilationGCOutput& gcOutput,
|
||||
const js::frontend::ScriptIndex scriptIndex,
|
||||
js::SharedImmutableScriptData* sharedData,
|
||||
js::HandleFunction function);
|
||||
const js::frontend::ScriptIndex scriptIndex);
|
||||
|
||||
#ifdef DEBUG
|
||||
private:
|
||||
|
|
Загрузка…
Ссылка в новой задаче