зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1686174 - Move immutableFlags to ScriptStencilExtra. r=tcampbell
Differential Revision: https://phabricator.services.mozilla.com/D101436
This commit is contained in:
Родитель
d4db9731c9
Коммит
eea573de3b
|
@ -373,6 +373,8 @@ struct CompilationStencil {
|
|||
static_cast<FunctionKey>(extent.sourceEnd);
|
||||
}
|
||||
|
||||
bool isInitialStencil() const { return !scriptExtra.empty(); }
|
||||
|
||||
#if defined(DEBUG) || defined(JS_JITSPEW)
|
||||
void dump();
|
||||
void dump(js::JSONPrinter& json);
|
||||
|
|
|
@ -444,24 +444,25 @@ bool ConvertScriptStencil(JSContext* cx, const SmooshResult& result,
|
|||
ScriptStencilExtra& scriptExtra =
|
||||
compilationInfo.stencil.scriptExtra[scriptIndex];
|
||||
|
||||
script.immutableFlags = smooshScript.immutable_flags;
|
||||
scriptExtra.immutableFlags = smooshScript.immutable_flags;
|
||||
|
||||
// FIXME: The following flags should be set in jsparagus.
|
||||
script.immutableFlags.setFlag(ImmutableFlags::SelfHosted,
|
||||
options.selfHostingMode);
|
||||
script.immutableFlags.setFlag(ImmutableFlags::ForceStrict,
|
||||
options.forceStrictMode());
|
||||
script.immutableFlags.setFlag(ImmutableFlags::HasNonSyntacticScope,
|
||||
options.nonSyntacticScope);
|
||||
scriptExtra.immutableFlags.setFlag(ImmutableFlags::SelfHosted,
|
||||
options.selfHostingMode);
|
||||
scriptExtra.immutableFlags.setFlag(ImmutableFlags::ForceStrict,
|
||||
options.forceStrictMode());
|
||||
scriptExtra.immutableFlags.setFlag(ImmutableFlags::HasNonSyntacticScope,
|
||||
options.nonSyntacticScope);
|
||||
|
||||
if (&smooshScript == &result.scripts.data[0]) {
|
||||
script.immutableFlags.setFlag(ImmutableFlags::TreatAsRunOnce,
|
||||
options.isRunOnce);
|
||||
script.immutableFlags.setFlag(ImmutableFlags::NoScriptRval,
|
||||
options.noScriptRval);
|
||||
scriptExtra.immutableFlags.setFlag(ImmutableFlags::TreatAsRunOnce,
|
||||
options.isRunOnce);
|
||||
scriptExtra.immutableFlags.setFlag(ImmutableFlags::NoScriptRval,
|
||||
options.noScriptRval);
|
||||
}
|
||||
|
||||
bool isFunction = script.immutableFlags.hasFlag(ImmutableFlags::IsFunction);
|
||||
bool isFunction =
|
||||
scriptExtra.immutableFlags.hasFlag(ImmutableFlags::IsFunction);
|
||||
|
||||
if (smooshScript.immutable_script_data.IsSome()) {
|
||||
auto index = smooshScript.immutable_script_data.AsSome();
|
||||
|
|
|
@ -391,15 +391,17 @@ ScriptStencilExtra& FunctionBox::functionExtraStencil() const {
|
|||
return compilationState_.scriptExtra[funcDataIndex_];
|
||||
}
|
||||
|
||||
bool FunctionBox::hasFunctionExtraStencil() const {
|
||||
return funcDataIndex_ < compilationState_.scriptExtra.length();
|
||||
}
|
||||
|
||||
void SharedContext::copyScriptFields(ScriptStencil& script) {
|
||||
MOZ_ASSERT(!isScriptFieldCopiedToStencil);
|
||||
|
||||
script.immutableFlags = immutableFlags_;
|
||||
|
||||
isScriptFieldCopiedToStencil = true;
|
||||
}
|
||||
|
||||
void SharedContext::copyScriptExtraFields(ScriptStencilExtra& scriptExtra) {
|
||||
scriptExtra.immutableFlags = immutableFlags_;
|
||||
scriptExtra.extent = extent_;
|
||||
}
|
||||
|
||||
|
@ -446,8 +448,10 @@ void FunctionBox::copyFunctionExtraFields(ScriptStencilExtra& scriptExtra) {
|
|||
}
|
||||
|
||||
void FunctionBox::copyUpdatedImmutableFlags() {
|
||||
ScriptStencil& script = functionStencil();
|
||||
script.immutableFlags = immutableFlags_;
|
||||
if (hasFunctionExtraStencil()) {
|
||||
ScriptStencilExtra& scriptExtra = functionExtraStencil();
|
||||
scriptExtra.immutableFlags = immutableFlags_;
|
||||
}
|
||||
}
|
||||
|
||||
void FunctionBox::copyUpdatedExtent() {
|
||||
|
|
|
@ -422,6 +422,8 @@ class FunctionBox : public SuspendableContext {
|
|||
ScriptStencil& functionStencil() const;
|
||||
ScriptStencilExtra& functionExtraStencil() const;
|
||||
|
||||
bool hasFunctionExtraStencil() const;
|
||||
|
||||
LexicalScope::ParserData* namedLambdaBindings() {
|
||||
return namedLambdaBindings_;
|
||||
}
|
||||
|
|
|
@ -142,7 +142,8 @@ static bool CreateLazyScript(JSContext* cx, CompilationInput& input,
|
|||
|
||||
Rooted<BaseScript*> lazy(
|
||||
cx, BaseScript::CreateRawLazy(cx, ngcthings, function, sourceObject,
|
||||
scriptExtra.extent, script.immutableFlags));
|
||||
scriptExtra.extent,
|
||||
scriptExtra.immutableFlags));
|
||||
if (!lazy) {
|
||||
return false;
|
||||
}
|
||||
|
@ -166,11 +167,11 @@ static JSFunction* CreateFunction(JSContext* cx, CompilationInput& input,
|
|||
const ScriptStencilExtra& scriptExtra,
|
||||
ScriptIndex functionIndex) {
|
||||
GeneratorKind generatorKind =
|
||||
script.immutableFlags.hasFlag(ImmutableScriptFlagsEnum::IsGenerator)
|
||||
scriptExtra.immutableFlags.hasFlag(ImmutableScriptFlagsEnum::IsGenerator)
|
||||
? GeneratorKind::Generator
|
||||
: GeneratorKind::NotGenerator;
|
||||
FunctionAsyncKind asyncKind =
|
||||
script.immutableFlags.hasFlag(ImmutableScriptFlagsEnum::IsAsync)
|
||||
scriptExtra.immutableFlags.hasFlag(ImmutableScriptFlagsEnum::IsAsync)
|
||||
? FunctionAsyncKind::AsyncFunction
|
||||
: FunctionAsyncKind::SyncFunction;
|
||||
|
||||
|
@ -255,7 +256,7 @@ static bool InstantiateScriptSourceObject(JSContext* cx,
|
|||
static bool MaybeInstantiateModule(JSContext* cx, CompilationInput& input,
|
||||
CompilationStencil& stencil,
|
||||
CompilationGCOutput& gcOutput) {
|
||||
if (stencil.scriptData[CompilationInfo::TopLevelIndex].isModule()) {
|
||||
if (stencil.scriptExtra[CompilationInfo::TopLevelIndex].isModule()) {
|
||||
gcOutput.module = ModuleObject::create(cx);
|
||||
if (!gcOutput.module) {
|
||||
return false;
|
||||
|
@ -420,8 +421,11 @@ static bool InstantiateTopLevel(JSContext* cx, CompilationInput& input,
|
|||
gcOutput.script->setAllowRelazify();
|
||||
}
|
||||
|
||||
const ScriptStencilExtra& scriptExtra =
|
||||
stencil.scriptExtra[CompilationInfo::TopLevelIndex];
|
||||
|
||||
// Finish initializing the ModuleObject if needed.
|
||||
if (scriptStencil.isModule()) {
|
||||
if (scriptExtra.isModule()) {
|
||||
Rooted<JSScript*> script(cx, gcOutput.script);
|
||||
|
||||
gcOutput.module->initScriptSlots(script);
|
||||
|
@ -532,10 +536,6 @@ static void AssertDelazificationFieldsMatch(CompilationStencil& stencil,
|
|||
auto* scriptExtra = item.scriptExtra;
|
||||
auto& fun = item.function;
|
||||
|
||||
BaseScript* script = fun->baseScript();
|
||||
|
||||
MOZ_ASSERT(script->immutableFlags() == scriptStencil.immutableFlags);
|
||||
|
||||
MOZ_ASSERT(scriptExtra == nullptr);
|
||||
|
||||
// Names are updated by UpdateInnerFunctions.
|
||||
|
@ -623,7 +623,7 @@ bool CompilationInfo::instantiateStencilsAfterPreparation(
|
|||
AssertDelazificationFieldsMatch(stencil, gcOutput);
|
||||
#endif
|
||||
} else {
|
||||
if (stencil.scriptData[CompilationInfo::TopLevelIndex].isModule()) {
|
||||
if (stencil.scriptExtra[CompilationInfo::TopLevelIndex].isModule()) {
|
||||
MOZ_ASSERT(input.enclosingScope == nullptr);
|
||||
input.enclosingScope = &cx->global()->emptyGlobalScope();
|
||||
MOZ_ASSERT(input.enclosingScope->environmentChainLength() ==
|
||||
|
@ -1690,10 +1690,6 @@ void ScriptStencil::dump(js::JSONPrinter& json,
|
|||
|
||||
void ScriptStencil::dumpFields(js::JSONPrinter& json,
|
||||
CompilationStencil* compilationStencil) {
|
||||
json.beginListProperty("immutableFlags");
|
||||
DumpImmutableScriptFlags(json, immutableFlags);
|
||||
json.endList();
|
||||
|
||||
if (hasMemberInitializers()) {
|
||||
json.property("memberInitializers", memberInitializers_);
|
||||
}
|
||||
|
@ -1757,6 +1753,10 @@ void ScriptStencilExtra::dump(js::JSONPrinter& json) {
|
|||
}
|
||||
|
||||
void ScriptStencilExtra::dumpFields(js::JSONPrinter& json) {
|
||||
json.beginListProperty("immutableFlags");
|
||||
DumpImmutableScriptFlags(json, immutableFlags);
|
||||
json.endList();
|
||||
|
||||
json.beginObjectProperty("extent");
|
||||
json.property("sourceStart", extent.sourceStart);
|
||||
json.property("sourceEnd", extent.sourceEnd);
|
||||
|
@ -1864,7 +1864,7 @@ void CompilationStencil::dump(js::JSONPrinter& json) {
|
|||
}
|
||||
json.endList();
|
||||
|
||||
if (scriptData[CompilationInfo::TopLevelIndex].isModule()) {
|
||||
if (scriptExtra[CompilationInfo::TopLevelIndex].isModule()) {
|
||||
json.beginObjectProperty("moduleMetadata");
|
||||
moduleMetadata->dumpFields(json, this);
|
||||
json.endObject();
|
||||
|
|
|
@ -638,9 +638,6 @@ class ScriptStencil {
|
|||
// * non-lazy Function (except asm.js module)
|
||||
// * lazy Function (cannot be asm.js module)
|
||||
|
||||
// See `BaseScript::immutableFlags_`.
|
||||
ImmutableScriptFlags immutableFlags;
|
||||
|
||||
uint32_t memberInitializers_ = 0;
|
||||
|
||||
// GCThings are stored into {CompilationState,CompilationStencil}.gcThingData,
|
||||
|
@ -705,12 +702,6 @@ class ScriptStencil {
|
|||
return result;
|
||||
}
|
||||
|
||||
bool isModule() const {
|
||||
bool result = immutableFlags.hasFlag(ImmutableScriptFlagsEnum::IsModule);
|
||||
MOZ_ASSERT_IF(result, !isFunction());
|
||||
return result;
|
||||
}
|
||||
|
||||
bool hasGCThings() const { return gcThingsLength; }
|
||||
|
||||
mozilla::Span<TaggedScriptThingIndex> gcthings(
|
||||
|
@ -776,6 +767,9 @@ class ScriptStencil {
|
|||
// In addition to ScriptStencil, data generated only while initial-parsing.
|
||||
class ScriptStencilExtra {
|
||||
public:
|
||||
// See `BaseScript::immutableFlags_`.
|
||||
ImmutableScriptFlags immutableFlags;
|
||||
|
||||
// The location of this script in the source.
|
||||
SourceExtent extent;
|
||||
|
||||
|
@ -787,6 +781,10 @@ class ScriptStencilExtra {
|
|||
|
||||
ScriptStencilExtra() = default;
|
||||
|
||||
bool isModule() const {
|
||||
return immutableFlags.hasFlag(ImmutableScriptFlagsEnum::IsModule);
|
||||
}
|
||||
|
||||
#if defined(DEBUG) || defined(JS_JITSPEW)
|
||||
void dump();
|
||||
void dump(JSONPrinter& json);
|
||||
|
|
|
@ -558,7 +558,8 @@ XDRResult XDRCompilationStencil(XDRState<mode>* xdr,
|
|||
MOZ_TRY(XDRSpanContent(xdr, stencil.scriptData));
|
||||
MOZ_TRY(XDRSpanContent(xdr, stencil.scriptExtra));
|
||||
|
||||
if (stencil.scriptData[CompilationInfo::TopLevelIndex].isModule()) {
|
||||
if (stencil.isInitialStencil() &&
|
||||
stencil.scriptExtra[CompilationInfo::TopLevelIndex].isModule()) {
|
||||
if (mode == XDR_DECODE) {
|
||||
stencil.moduleMetadata.emplace();
|
||||
}
|
||||
|
|
|
@ -3880,7 +3880,9 @@ bool JSScript::fullyInitFromStencil(
|
|||
|
||||
// Note: These flags should already be correct when the BaseScript was
|
||||
// allocated.
|
||||
MOZ_ASSERT(script->immutableFlags() == scriptStencil.immutableFlags);
|
||||
MOZ_ASSERT_IF(stencil.scriptExtra.size() > scriptIndex.index,
|
||||
script->immutableFlags() ==
|
||||
stencil.scriptExtra[scriptIndex].immutableFlags);
|
||||
|
||||
// Derive initial mutable flags
|
||||
script->resetArgsUsageAnalysis();
|
||||
|
@ -3935,7 +3937,8 @@ JSScript* JSScript::fromStencil(JSContext* cx,
|
|||
frontend::CompilationGCOutput& gcOutput,
|
||||
const js::frontend::ScriptIndex scriptIndex) {
|
||||
js::frontend::ScriptStencil& scriptStencil = stencil.scriptData[scriptIndex];
|
||||
js::SourceExtent& scriptExtent = stencil.scriptExtra[scriptIndex].extent;
|
||||
js::frontend::ScriptStencilExtra& scriptExtra =
|
||||
stencil.scriptExtra[scriptIndex];
|
||||
MOZ_ASSERT(scriptStencil.hasSharedData(),
|
||||
"Need generated bytecode to use JSScript::fromStencil");
|
||||
|
||||
|
@ -3945,8 +3948,9 @@ JSScript* JSScript::fromStencil(JSContext* cx,
|
|||
}
|
||||
|
||||
Rooted<ScriptSourceObject*> sourceObject(cx, gcOutput.sourceObject);
|
||||
RootedScript script(cx, Create(cx, functionOrGlobal, sourceObject,
|
||||
scriptExtent, scriptStencil.immutableFlags));
|
||||
RootedScript script(
|
||||
cx, Create(cx, functionOrGlobal, sourceObject, scriptExtra.extent,
|
||||
scriptExtra.immutableFlags));
|
||||
if (!script) {
|
||||
return nullptr;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче