Bug 1686375 - Part 1: Remove CompilationInput& parameter from JSScript::fromStencil. r=tcampbell

CompilationStencil already contains CompilationInput.

Differential Revision: https://phabricator.services.mozilla.com/D103017
This commit is contained in:
Tooru Fujisawa 2021-01-27 03:22:26 +00:00
parent 349e6f61c6
commit da493ce052
9 changed files with 31 additions and 32 deletions

View File

@ -52,14 +52,14 @@ mozilla::Maybe<ScopeIndex> GCThingList::getScopeIndex(size_t index) const {
}
bool js::frontend::EmitScriptThingsVector(
JSContext* cx, CompilationInput& input,
JSContext* cx, const CompilationInput& input,
const BaseCompilationStencil& stencil, CompilationGCOutput& gcOutput,
mozilla::Span<const TaggedScriptThingIndex> things,
mozilla::Span<JS::GCCellPtr> output) {
MOZ_ASSERT(things.size() <= INDEX_LIMIT);
MOZ_ASSERT(things.size() == output.size());
auto& atomCache = input.atomCache;
const auto& atomCache = input.atomCache;
for (uint32_t i = 0; i < things.size(); i++) {
const auto& thing = things[i];
@ -158,8 +158,8 @@ void CGScopeNoteList::recordEndImpl(uint32_t index, uint32_t offset) {
list[index].length = offset - list[index].start;
}
JSObject* ObjLiteralStencil::create(JSContext* cx,
CompilationAtomCache& atomCache) const {
JSObject* ObjLiteralStencil::create(
JSContext* cx, const CompilationAtomCache& atomCache) const {
return InterpretObjLiteral(cx, atomCache, code_, flags_);
}

View File

@ -130,7 +130,7 @@ struct MOZ_STACK_CLASS GCThingList {
};
MOZ_MUST_USE bool EmitScriptThingsVector(
JSContext* cx, CompilationInput& input,
JSContext* cx, const CompilationInput& input,
const BaseCompilationStencil& stencil, CompilationGCOutput& gcOutput,
mozilla::Span<const TaggedScriptThingIndex> things,
mozilla::Span<JS::GCCellPtr> output);

View File

@ -24,10 +24,9 @@
namespace js {
static void InterpretObjLiteralValue(JSContext* cx,
frontend::CompilationAtomCache& atomCache,
const ObjLiteralInsn& insn,
JS::Value* valOut) {
static void InterpretObjLiteralValue(
JSContext* cx, const frontend::CompilationAtomCache& atomCache,
const ObjLiteralInsn& insn, JS::Value* valOut) {
switch (insn.getOp()) {
case ObjLiteralOpcode::ConstValue:
*valOut = insn.getConstValue();
@ -57,7 +56,7 @@ static void InterpretObjLiteralValue(JSContext* cx,
}
static JSObject* InterpretObjLiteralObj(
JSContext* cx, frontend::CompilationAtomCache& atomCache,
JSContext* cx, const frontend::CompilationAtomCache& atomCache,
const mozilla::Span<const uint8_t> literalInsns, ObjLiteralFlags flags) {
bool singleton = flags.contains(ObjLiteralFlag::Singleton);
@ -95,7 +94,7 @@ static JSObject* InterpretObjLiteralObj(
}
static JSObject* InterpretObjLiteralArray(
JSContext* cx, frontend::CompilationAtomCache& atomCache,
JSContext* cx, const frontend::CompilationAtomCache& atomCache,
const mozilla::Span<const uint8_t> literalInsns, ObjLiteralFlags flags) {
ObjLiteralReader reader(literalInsns);
ObjLiteralInsn insn;
@ -118,7 +117,7 @@ static JSObject* InterpretObjLiteralArray(
}
JSObject* InterpretObjLiteral(JSContext* cx,
frontend::CompilationAtomCache& atomCache,
const frontend::CompilationAtomCache& atomCache,
const mozilla::Span<const uint8_t> literalInsns,
ObjLiteralFlags flags) {
return flags.contains(ObjLiteralFlag::Array)

View File

@ -531,7 +531,7 @@ struct ObjLiteralReader : private ObjLiteralReaderBase {
};
JSObject* InterpretObjLiteral(JSContext* cx,
frontend::CompilationAtomCache& atomCache,
const frontend::CompilationAtomCache& atomCache,
const mozilla::Span<const uint8_t> insns,
ObjLiteralFlags flags);
@ -548,7 +548,7 @@ class ObjLiteralStencil {
: code_(mozilla::Span(code, length)), flags_(flags) {}
JSObject* create(JSContext* cx,
frontend::CompilationAtomCache& atomCache) const;
const frontend::CompilationAtomCache& atomCache) const;
#if defined(DEBUG) || defined(JS_JITSPEW)
void dump();

View File

@ -398,7 +398,7 @@ const ParserAtom* NumericLiteral::toAtom(JSContext* cx,
}
RegExpObject* RegExpStencil::createRegExp(
JSContext* cx, CompilationAtomCache& atomCache) const {
JSContext* cx, const CompilationAtomCache& atomCache) const {
RootedAtom atom(cx, atomCache.getExistingAtomAt(cx, atom_));
return RegExpObject::createSyntaxChecked(cx, atom, flags(), TenuredObject);
}

View File

@ -132,7 +132,7 @@ Scope* ScopeStencil::createScope(JSContext* cx, CompilationInput& input,
return scope;
}
static bool CreateLazyScript(JSContext* cx, CompilationInput& input,
static bool CreateLazyScript(JSContext* cx, const CompilationInput& input,
const BaseCompilationStencil& stencil,
CompilationGCOutput& gcOutput,
const ScriptStencil& script,
@ -421,10 +421,10 @@ static bool InstantiateScopes(JSContext* cx, CompilationInput& input,
// Instantiate js::BaseScripts from ScriptStencils for inner functions of the
// compilation. Note that standalone functions and functions being delazified
// are handled below with other top-levels.
static bool InstantiateScriptStencils(JSContext* cx, CompilationInput& input,
static bool InstantiateScriptStencils(JSContext* cx,
const CompilationStencil& stencil,
CompilationGCOutput& gcOutput) {
MOZ_ASSERT(input.lazy == nullptr);
MOZ_ASSERT(stencil.input.lazy == nullptr);
Rooted<JSFunction*> fun(cx);
for (auto item :
@ -443,8 +443,8 @@ static bool InstantiateScriptStencils(JSContext* cx, CompilationInput& input,
continue;
}
RootedScript script(
cx, JSScript::fromStencil(cx, input, stencil, gcOutput, index));
RootedScript script(cx,
JSScript::fromStencil(cx, stencil, gcOutput, index));
if (!script) {
return false;
}
@ -459,7 +459,7 @@ static bool InstantiateScriptStencils(JSContext* cx, CompilationInput& input,
MOZ_ASSERT(fun->isAsmJSNative());
} else {
MOZ_ASSERT(fun->isIncomplete());
if (!CreateLazyScript(cx, input, stencil, gcOutput, scriptStencil,
if (!CreateLazyScript(cx, stencil.input, stencil, gcOutput, scriptStencil,
*scriptExtra, index, fun)) {
return false;
}
@ -501,8 +501,9 @@ static bool InstantiateTopLevel(JSContext* cx, CompilationInput& input,
return true;
}
MOZ_ASSERT(&stencil.asCompilationStencil().input == &input);
gcOutput.script =
JSScript::fromStencil(cx, input, stencil.asCompilationStencil(), gcOutput,
JSScript::fromStencil(cx, stencil.asCompilationStencil(), gcOutput,
CompilationStencil::TopLevelIndex);
if (!gcOutput.script) {
return false;
@ -746,7 +747,8 @@ bool CompilationStencil::instantiateStencilsAfterPreparation(
// Phase 4: Instantiate (inner) BaseScripts.
if (isInitialParse) {
if (!InstantiateScriptStencils(cx, input, stencil.asCompilationStencil(),
MOZ_ASSERT(&stencil.asCompilationStencil().input == &input);
if (!InstantiateScriptStencils(cx, stencil.asCompilationStencil(),
gcOutput)) {
return false;
}

View File

@ -191,7 +191,7 @@ class RegExpStencil {
JS::RegExpFlags flags() const { return JS::RegExpFlags(flags_); }
RegExpObject* createRegExp(JSContext* cx,
CompilationAtomCache& atomCache) const;
const CompilationAtomCache& atomCache) const;
// This is used by `Reflect.parse` when we need the RegExpObject but are not
// doing a complete instantiation of the BaseCompilationStencil.

View File

@ -3721,7 +3721,7 @@ PrivateScriptData* PrivateScriptData::new_(JSContext* cx, uint32_t ngcthings) {
/* static */
bool PrivateScriptData::InitFromStencil(
JSContext* cx, js::HandleScript script,
js::frontend::CompilationInput& input,
const js::frontend::CompilationInput& input,
const js::frontend::BaseCompilationStencil& stencil,
js::frontend::CompilationGCOutput& gcOutput,
const js::frontend::ScriptIndex scriptIndex) {
@ -3815,7 +3815,7 @@ bool JSScript::createPrivateScriptData(JSContext* cx, HandleScript script,
/* static */
bool JSScript::fullyInitFromStencil(
JSContext* cx, js::frontend::CompilationInput& input,
JSContext* cx, const js::frontend::CompilationInput& input,
const js::frontend::BaseCompilationStencil& stencil,
frontend::CompilationGCOutput& gcOutput, HandleScript script,
const js::frontend::ScriptIndex scriptIndex) {
@ -3937,7 +3937,6 @@ bool JSScript::fullyInitFromStencil(
}
JSScript* JSScript::fromStencil(JSContext* cx,
js::frontend::CompilationInput& input,
const js::frontend::CompilationStencil& stencil,
frontend::CompilationGCOutput& gcOutput,
const js::frontend::ScriptIndex scriptIndex) {
@ -3960,7 +3959,7 @@ JSScript* JSScript::fromStencil(JSContext* cx,
return nullptr;
}
if (!fullyInitFromStencil(cx, input, stencil, gcOutput, script,
if (!fullyInitFromStencil(cx, stencil.input, stencil, gcOutput, script,
scriptIndex)) {
return nullptr;
}

View File

@ -1406,7 +1406,7 @@ class alignas(uintptr_t) PrivateScriptData final : public TrailingArray {
static bool InitFromStencil(
JSContext* cx, js::HandleScript script,
js::frontend::CompilationInput& input,
const js::frontend::CompilationInput& input,
const js::frontend::BaseCompilationStencil& stencil,
js::frontend::CompilationGCOutput& gcOutput,
const js::frontend::ScriptIndex scriptIndex);
@ -1905,7 +1905,7 @@ class JSScript : public js::BaseScript {
friend bool js::PrivateScriptData::InitFromStencil(
JSContext* cx, js::HandleScript script,
js::frontend::CompilationInput& input,
const js::frontend::CompilationInput& input,
const js::frontend::BaseCompilationStencil& stencil,
js::frontend::CompilationGCOutput& gcOutput,
const js::frontend::ScriptIndex scriptIndex);
@ -1933,7 +1933,7 @@ class JSScript : public js::BaseScript {
public:
static bool fullyInitFromStencil(
JSContext* cx, js::frontend::CompilationInput& input,
JSContext* cx, const js::frontend::CompilationInput& input,
const js::frontend::BaseCompilationStencil& stencil,
js::frontend::CompilationGCOutput& gcOutput, js::HandleScript script,
const js::frontend::ScriptIndex scriptIndex);
@ -1941,7 +1941,6 @@ class JSScript : public js::BaseScript {
// Allocate a JSScript and initialize it with bytecode. This consumes
// allocations within the stencil.
static JSScript* fromStencil(JSContext* cx,
js::frontend::CompilationInput& input,
const js::frontend::CompilationStencil& stencil,
js::frontend::CompilationGCOutput& gcOutput,
const js::frontend::ScriptIndex scriptIndex);