forked from mirrors/gecko-dev
Bug 1688770 - Make CompilationStencil argument to instantiation const. r=arai
Differential Revision: https://phabricator.services.mozilla.com/D102992
This commit is contained in:
parent
5dda2d92af
commit
b78c5041ef
7 changed files with 45 additions and 42 deletions
|
|
@ -52,8 +52,8 @@ mozilla::Maybe<ScopeIndex> GCThingList::getScopeIndex(size_t index) const {
|
|||
}
|
||||
|
||||
bool js::frontend::EmitScriptThingsVector(
|
||||
JSContext* cx, CompilationInput& input, BaseCompilationStencil& stencil,
|
||||
CompilationGCOutput& gcOutput,
|
||||
JSContext* cx, CompilationInput& input,
|
||||
const BaseCompilationStencil& stencil, CompilationGCOutput& gcOutput,
|
||||
mozilla::Span<const TaggedScriptThingIndex> things,
|
||||
mozilla::Span<JS::GCCellPtr> output) {
|
||||
MOZ_ASSERT(things.size() <= INDEX_LIMIT);
|
||||
|
|
@ -75,7 +75,7 @@ bool js::frontend::EmitScriptThingsVector(
|
|||
output[i] = JS::GCCellPtr(nullptr);
|
||||
break;
|
||||
case TaggedScriptThingIndex::Kind::BigInt: {
|
||||
BigIntStencil& data = stencil.bigIntData[thing.toBigInt()];
|
||||
const BigIntStencil& data = stencil.bigIntData[thing.toBigInt()];
|
||||
BigInt* bi = data.createBigInt(cx);
|
||||
if (!bi) {
|
||||
return false;
|
||||
|
|
@ -84,7 +84,8 @@ bool js::frontend::EmitScriptThingsVector(
|
|||
break;
|
||||
}
|
||||
case TaggedScriptThingIndex::Kind::ObjLiteral: {
|
||||
ObjLiteralStencil& data = stencil.objLiteralData[thing.toObjLiteral()];
|
||||
const ObjLiteralStencil& data =
|
||||
stencil.objLiteralData[thing.toObjLiteral()];
|
||||
JSObject* obj = data.create(cx, atomCache);
|
||||
if (!obj) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -130,8 +130,8 @@ struct MOZ_STACK_CLASS GCThingList {
|
|||
};
|
||||
|
||||
MOZ_MUST_USE bool EmitScriptThingsVector(
|
||||
JSContext* cx, CompilationInput& input, BaseCompilationStencil& stencil,
|
||||
CompilationGCOutput& gcOutput,
|
||||
JSContext* cx, CompilationInput& input,
|
||||
const BaseCompilationStencil& stencil, CompilationGCOutput& gcOutput,
|
||||
mozilla::Span<const TaggedScriptThingIndex> things,
|
||||
mozilla::Span<JS::GCCellPtr> output);
|
||||
|
||||
|
|
|
|||
|
|
@ -320,17 +320,17 @@ struct SharedDataContainer {
|
|||
MOZ_ASSERT(isSingle());
|
||||
}
|
||||
|
||||
SingleSharedDataPtr asSingle() {
|
||||
SingleSharedDataPtr asSingle() const {
|
||||
MOZ_ASSERT(isSingle());
|
||||
MOZ_ASSERT(!isEmpty());
|
||||
static_assert(SingleTag == 0);
|
||||
return reinterpret_cast<SingleSharedDataPtr>(data_);
|
||||
}
|
||||
SharedDataVectorPtr asVector() {
|
||||
SharedDataVectorPtr asVector() const {
|
||||
MOZ_ASSERT(isVector());
|
||||
return reinterpret_cast<SharedDataVectorPtr>(data_ & ~TagMask);
|
||||
}
|
||||
SharedDataMapPtr asMap() {
|
||||
SharedDataMapPtr asMap() const {
|
||||
MOZ_ASSERT(isMap());
|
||||
return reinterpret_cast<SharedDataMapPtr>(data_ & ~TagMask);
|
||||
}
|
||||
|
|
@ -339,7 +339,7 @@ struct SharedDataContainer {
|
|||
size_t allScriptCount);
|
||||
|
||||
// Returns index-th script's shared data, or nullptr if it doesn't have.
|
||||
js::SharedImmutableScriptData* get(ScriptIndex index);
|
||||
js::SharedImmutableScriptData* get(ScriptIndex index) const;
|
||||
|
||||
// Add data for index-th script and share it with VM.
|
||||
bool addAndShare(JSContext* cx, ScriptIndex index,
|
||||
|
|
@ -602,8 +602,8 @@ struct CompilationStencil : public BaseCompilationStencil {
|
|||
CompilationStencil& stencil,
|
||||
CompilationGCOutput& gcOutput);
|
||||
static MOZ_MUST_USE bool instantiateStencilsAfterPreparation(
|
||||
JSContext* cx, CompilationInput& input, BaseCompilationStencil& stencil,
|
||||
CompilationGCOutput& gcOutput);
|
||||
JSContext* cx, CompilationInput& input,
|
||||
const BaseCompilationStencil& stencil, CompilationGCOutput& gcOutput);
|
||||
|
||||
MOZ_MUST_USE bool serializeStencils(JSContext* cx, JS::TranscodeBuffer& buf,
|
||||
bool* succeededOut = nullptr);
|
||||
|
|
@ -624,7 +624,7 @@ struct CompilationStencil : public BaseCompilationStencil {
|
|||
CompilationStencil& operator=(CompilationStencil&&) = delete;
|
||||
|
||||
static ScriptStencilIterable functionScriptStencils(
|
||||
BaseCompilationStencil& stencil, CompilationGCOutput& gcOutput) {
|
||||
const BaseCompilationStencil& stencil, CompilationGCOutput& gcOutput) {
|
||||
return ScriptStencilIterable(stencil, gcOutput);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ Scope* ScopeStencil::createScope(JSContext* cx, CompilationInput& input,
|
|||
}
|
||||
|
||||
static bool CreateLazyScript(JSContext* cx, CompilationInput& input,
|
||||
BaseCompilationStencil& stencil,
|
||||
const BaseCompilationStencil& stencil,
|
||||
CompilationGCOutput& gcOutput,
|
||||
const ScriptStencil& script,
|
||||
const ScriptStencilExtra& scriptExtra,
|
||||
|
|
@ -217,7 +217,7 @@ static JSFunction* CreateFunctionFast(JSContext* cx, CompilationInput& input,
|
|||
}
|
||||
|
||||
static JSFunction* CreateFunction(JSContext* cx, CompilationInput& input,
|
||||
BaseCompilationStencil& stencil,
|
||||
const BaseCompilationStencil& stencil,
|
||||
const ScriptStencil& script,
|
||||
const ScriptStencilExtra& scriptExtra,
|
||||
ScriptIndex functionIndex) {
|
||||
|
|
@ -274,7 +274,7 @@ static JSFunction* CreateFunction(JSContext* cx, CompilationInput& input,
|
|||
}
|
||||
|
||||
static bool InstantiateAtoms(JSContext* cx, CompilationInput& input,
|
||||
BaseCompilationStencil& stencil) {
|
||||
const BaseCompilationStencil& stencil) {
|
||||
return InstantiateMarkedAtoms(cx, stencil.parserAtomData, input.atomCache);
|
||||
}
|
||||
|
||||
|
|
@ -310,7 +310,7 @@ static bool InstantiateScriptSourceObject(JSContext* cx,
|
|||
// Instantiate ModuleObject. Further initialization is done after the associated
|
||||
// BaseScript is instantiated in InstantiateTopLevel.
|
||||
static bool InstantiateModuleObject(JSContext* cx, CompilationInput& input,
|
||||
CompilationStencil& stencil,
|
||||
const CompilationStencil& stencil,
|
||||
CompilationGCOutput& gcOutput) {
|
||||
MOZ_ASSERT(stencil.scriptExtra[CompilationStencil::TopLevelIndex].isModule());
|
||||
|
||||
|
|
@ -325,7 +325,7 @@ static bool InstantiateModuleObject(JSContext* cx, CompilationInput& input,
|
|||
|
||||
// Instantiate JSFunctions for each FunctionBox.
|
||||
static bool InstantiateFunctions(JSContext* cx, CompilationInput& input,
|
||||
BaseCompilationStencil& stencil,
|
||||
const BaseCompilationStencil& stencil,
|
||||
CompilationGCOutput& gcOutput) {
|
||||
using ImmutableFlags = ImmutableScriptFlagsEnum;
|
||||
|
||||
|
|
@ -390,7 +390,7 @@ static bool InstantiateFunctions(JSContext* cx, CompilationInput& input,
|
|||
// associated JSFunction pointer, and also should be called before
|
||||
// InstantiateScriptStencils, given JSScript needs Scope pointer in gc things.
|
||||
static bool InstantiateScopes(JSContext* cx, CompilationInput& input,
|
||||
BaseCompilationStencil& stencil,
|
||||
const BaseCompilationStencil& stencil,
|
||||
CompilationGCOutput& gcOutput) {
|
||||
// While allocating Scope object from ScopeStencil, Scope object for the
|
||||
// enclosing Scope should already be allocated.
|
||||
|
|
@ -422,7 +422,7 @@ static bool InstantiateScopes(JSContext* cx, CompilationInput& input,
|
|||
// compilation. Note that standalone functions and functions being delazified
|
||||
// are handled below with other top-levels.
|
||||
static bool InstantiateScriptStencils(JSContext* cx, CompilationInput& input,
|
||||
CompilationStencil& stencil,
|
||||
const CompilationStencil& stencil,
|
||||
CompilationGCOutput& gcOutput) {
|
||||
MOZ_ASSERT(input.lazy == nullptr);
|
||||
|
||||
|
|
@ -472,7 +472,7 @@ static bool InstantiateScriptStencils(JSContext* cx, CompilationInput& input,
|
|||
// Instantiate the Stencil for the top-level script of the compilation. This
|
||||
// includes standalone functions and functions being delazified.
|
||||
static bool InstantiateTopLevel(JSContext* cx, CompilationInput& input,
|
||||
BaseCompilationStencil& stencil,
|
||||
const BaseCompilationStencil& stencil,
|
||||
CompilationGCOutput& gcOutput) {
|
||||
const ScriptStencil& scriptStencil =
|
||||
stencil.scriptData[CompilationStencil::TopLevelIndex];
|
||||
|
|
@ -546,7 +546,7 @@ static bool InstantiateTopLevel(JSContext* cx, CompilationInput& input,
|
|||
// to both initial and delazification parses. The functions being update may or
|
||||
// may not have bytecode at this point.
|
||||
static void UpdateEmittedInnerFunctions(JSContext* cx, CompilationInput& input,
|
||||
BaseCompilationStencil& stencil,
|
||||
const BaseCompilationStencil& stencil,
|
||||
CompilationGCOutput& gcOutput) {
|
||||
for (auto item :
|
||||
CompilationStencil::functionScriptStencils(stencil, gcOutput)) {
|
||||
|
|
@ -591,7 +591,7 @@ static void UpdateEmittedInnerFunctions(JSContext* cx, CompilationInput& input,
|
|||
|
||||
// During initial parse we must link lazy-functions-inside-lazy-functions to
|
||||
// their enclosing script.
|
||||
static void LinkEnclosingLazyScript(BaseCompilationStencil& stencil,
|
||||
static void LinkEnclosingLazyScript(const BaseCompilationStencil& stencil,
|
||||
CompilationGCOutput& gcOutput) {
|
||||
for (auto item :
|
||||
CompilationStencil::functionScriptStencils(stencil, gcOutput)) {
|
||||
|
|
@ -620,8 +620,8 @@ static void LinkEnclosingLazyScript(BaseCompilationStencil& stencil,
|
|||
#ifdef DEBUG
|
||||
// Some fields aren't used in delazification, given the target functions and
|
||||
// scripts are already instantiated, but they still should match.
|
||||
static void AssertDelazificationFieldsMatch(BaseCompilationStencil& stencil,
|
||||
CompilationGCOutput& gcOutput) {
|
||||
static void AssertDelazificationFieldsMatch(
|
||||
const BaseCompilationStencil& stencil, CompilationGCOutput& gcOutput) {
|
||||
for (auto item :
|
||||
CompilationStencil::functionScriptStencils(stencil, gcOutput)) {
|
||||
auto& scriptStencil = item.script;
|
||||
|
|
@ -686,8 +686,8 @@ bool CompilationStencil::instantiateStencils(JSContext* cx,
|
|||
|
||||
/* static */
|
||||
bool CompilationStencil::instantiateStencilsAfterPreparation(
|
||||
JSContext* cx, CompilationInput& input, BaseCompilationStencil& stencil,
|
||||
CompilationGCOutput& gcOutput) {
|
||||
JSContext* cx, CompilationInput& input,
|
||||
const BaseCompilationStencil& stencil, CompilationGCOutput& gcOutput) {
|
||||
// Distinguish between the initial (possibly lazy) compile and any subsequent
|
||||
// delazification compiles. Delazification will update existing GC things.
|
||||
bool isInitialParse = (input.lazy == nullptr);
|
||||
|
|
@ -699,7 +699,7 @@ bool CompilationStencil::instantiateStencilsAfterPreparation(
|
|||
|
||||
// Phase 2: Instantiate ScriptSourceObject, ModuleObject, JSFunctions.
|
||||
if (isInitialParse) {
|
||||
CompilationStencil& initialStencil = stencil.asCompilationStencil();
|
||||
const CompilationStencil& initialStencil = stencil.asCompilationStencil();
|
||||
|
||||
if (!InstantiateScriptSourceObject(cx, input, gcOutput)) {
|
||||
return false;
|
||||
|
|
@ -1100,7 +1100,8 @@ bool SharedDataContainer::prepareStorageFor(JSContext* cx,
|
|||
return true;
|
||||
}
|
||||
|
||||
js::SharedImmutableScriptData* SharedDataContainer::get(ScriptIndex index) {
|
||||
js::SharedImmutableScriptData* SharedDataContainer::get(
|
||||
ScriptIndex index) const {
|
||||
if (isSingle()) {
|
||||
if (index == CompilationStencil::TopLevelIndex) {
|
||||
return asSingle();
|
||||
|
|
@ -1205,7 +1206,7 @@ bool CompilationState::finish(JSContext* cx, CompilationStencil& stencil) {
|
|||
}
|
||||
|
||||
mozilla::Span<TaggedScriptThingIndex> ScriptStencil::gcthings(
|
||||
BaseCompilationStencil& stencil) const {
|
||||
const BaseCompilationStencil& stencil) const {
|
||||
return stencil.gcThingData.Subspan(gcThingsOffset, gcThingsLength);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -781,7 +781,7 @@ class ScriptStencil {
|
|||
bool hasGCThings() const { return gcThingsLength; }
|
||||
|
||||
mozilla::Span<TaggedScriptThingIndex> gcthings(
|
||||
BaseCompilationStencil& stencil) const;
|
||||
const BaseCompilationStencil& stencil) const;
|
||||
|
||||
bool wasFunctionEmitted() const { return flags_ & WasFunctionEmittedFlag; }
|
||||
|
||||
|
|
|
|||
|
|
@ -3722,7 +3722,7 @@ PrivateScriptData* PrivateScriptData::new_(JSContext* cx, uint32_t ngcthings) {
|
|||
bool PrivateScriptData::InitFromStencil(
|
||||
JSContext* cx, js::HandleScript script,
|
||||
js::frontend::CompilationInput& input,
|
||||
js::frontend::BaseCompilationStencil& stencil,
|
||||
const js::frontend::BaseCompilationStencil& stencil,
|
||||
js::frontend::CompilationGCOutput& gcOutput,
|
||||
const js::frontend::ScriptIndex scriptIndex) {
|
||||
js::frontend::ScriptStencil& scriptStencil = stencil.scriptData[scriptIndex];
|
||||
|
|
@ -3816,7 +3816,7 @@ bool JSScript::createPrivateScriptData(JSContext* cx, HandleScript script,
|
|||
/* static */
|
||||
bool JSScript::fullyInitFromStencil(
|
||||
JSContext* cx, js::frontend::CompilationInput& input,
|
||||
js::frontend::BaseCompilationStencil& stencil,
|
||||
const js::frontend::BaseCompilationStencil& stencil,
|
||||
frontend::CompilationGCOutput& gcOutput, HandleScript script,
|
||||
const js::frontend::ScriptIndex scriptIndex) {
|
||||
MutableScriptFlags lazyMutableFlags;
|
||||
|
|
@ -3938,7 +3938,7 @@ bool JSScript::fullyInitFromStencil(
|
|||
|
||||
JSScript* JSScript::fromStencil(JSContext* cx,
|
||||
js::frontend::CompilationInput& input,
|
||||
js::frontend::CompilationStencil& stencil,
|
||||
const js::frontend::CompilationStencil& stencil,
|
||||
frontend::CompilationGCOutput& gcOutput,
|
||||
const js::frontend::ScriptIndex scriptIndex) {
|
||||
js::frontend::ScriptStencil& scriptStencil = stencil.scriptData[scriptIndex];
|
||||
|
|
|
|||
|
|
@ -1404,11 +1404,12 @@ class alignas(uintptr_t) PrivateScriptData final : public TrailingArray {
|
|||
static bool Clone(JSContext* cx, js::HandleScript src, js::HandleScript dst,
|
||||
js::MutableHandle<JS::GCVector<js::Scope*>> scopes);
|
||||
|
||||
static bool InitFromStencil(JSContext* cx, js::HandleScript script,
|
||||
js::frontend::CompilationInput& input,
|
||||
js::frontend::BaseCompilationStencil& stencil,
|
||||
js::frontend::CompilationGCOutput& gcOutput,
|
||||
const js::frontend::ScriptIndex scriptIndex);
|
||||
static bool InitFromStencil(
|
||||
JSContext* cx, js::HandleScript script,
|
||||
js::frontend::CompilationInput& input,
|
||||
const js::frontend::BaseCompilationStencil& stencil,
|
||||
js::frontend::CompilationGCOutput& gcOutput,
|
||||
const js::frontend::ScriptIndex scriptIndex);
|
||||
|
||||
void trace(JSTracer* trc);
|
||||
|
||||
|
|
@ -1905,7 +1906,7 @@ class JSScript : public js::BaseScript {
|
|||
friend bool js::PrivateScriptData::InitFromStencil(
|
||||
JSContext* cx, js::HandleScript script,
|
||||
js::frontend::CompilationInput& input,
|
||||
js::frontend::BaseCompilationStencil& stencil,
|
||||
const js::frontend::BaseCompilationStencil& stencil,
|
||||
js::frontend::CompilationGCOutput& gcOutput,
|
||||
const js::frontend::ScriptIndex scriptIndex);
|
||||
|
||||
|
|
@ -1933,7 +1934,7 @@ class JSScript : public js::BaseScript {
|
|||
public:
|
||||
static bool fullyInitFromStencil(
|
||||
JSContext* cx, js::frontend::CompilationInput& input,
|
||||
js::frontend::BaseCompilationStencil& stencil,
|
||||
const js::frontend::BaseCompilationStencil& stencil,
|
||||
js::frontend::CompilationGCOutput& gcOutput, js::HandleScript script,
|
||||
const js::frontend::ScriptIndex scriptIndex);
|
||||
|
||||
|
|
@ -1941,7 +1942,7 @@ class JSScript : public js::BaseScript {
|
|||
// allocations within the stencil.
|
||||
static JSScript* fromStencil(JSContext* cx,
|
||||
js::frontend::CompilationInput& input,
|
||||
js::frontend::CompilationStencil& stencil,
|
||||
const js::frontend::CompilationStencil& stencil,
|
||||
js::frontend::CompilationGCOutput& gcOutput,
|
||||
const js::frontend::ScriptIndex scriptIndex);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue