Bug 1638470 - Move script atoms from RuntimeScriptData to PrivateScriptData. r=mgaudet,jandem

In practice there is not much saved by sharing these atoms in the runtime
these days. Moving this simplifies the script data structures and simplies
the Stencil code.

Depends on D75643

Differential Revision: https://phabricator.services.mozilla.com/D75644
This commit is contained in:
Ted Campbell 2020-05-19 17:24:01 +00:00
parent 88f5773f02
commit 13a54a78a3
5 changed files with 18 additions and 65 deletions

View File

@ -22,7 +22,7 @@ BCEScriptStencil::BCEScriptStencil(BytecodeEmitter& bce,
void BCEScriptStencil::init(BytecodeEmitter& bce,
UniquePtr<ImmutableScriptData> immutableData) {
natoms = bce.perScriptData().atomIndices()->count();
natoms = 0;
immutableFlags = bce.sc->immutableFlags();
@ -55,13 +55,4 @@ void BCEScriptStencil::init(BytecodeEmitter& bce,
} /* isFunctionBox */
}
void BCEScriptStencil::initAtomMap(GCPtrAtom* atoms) const {
const AtomIndexMap& indices = *bce_.perScriptData().atomIndices();
for (AtomIndexMap::Range r = indices.all(); !r.empty(); r.popFront()) {
JSAtom* atom = r.front().key();
uint32_t index = r.front().value();
MOZ_ASSERT(index < indices.count());
atoms[index].init(atom);
}
}
void BCEScriptStencil::initAtomMap(GCPtrAtom* atoms) const {}

View File

@ -258,7 +258,11 @@ struct MOZ_STACK_CLASS BytecodeEmitter {
return true;
}
uint32_t index = perScriptData().atomIndices()->count();
uint32_t index;
if (!perScriptData().gcThingList().append(atom, &index)) {
return false;
}
if (!perScriptData().atomIndices()->add(p, atom, index)) {
ReportOutOfMemory(cx);
return false;

View File

@ -426,21 +426,6 @@ void BaselineInterpreterCodeGen::restoreInterpreterPCReg() {
}
}
template <>
void BaselineCompilerCodeGen::loadScriptAtom(Register index, Register dest) {
MOZ_CRASH("BaselineCompiler shouldn't call loadScriptAtom");
}
template <>
void BaselineInterpreterCodeGen::loadScriptAtom(Register index, Register dest) {
MOZ_ASSERT(index != dest);
loadScript(dest);
masm.loadPtr(Address(dest, JSScript::offsetOfSharedData()), dest);
masm.loadPtr(
BaseIndex(dest, index, ScalePointer, RuntimeScriptData::offsetOfAtoms()),
dest);
}
template <>
void BaselineCompilerCodeGen::emitInitializeLocals() {
// Initialize all locals to |undefined|. Lexical bindings are temporal
@ -902,23 +887,6 @@ void BaselineInterpreterCodeGen::pushBytecodePCArg() {
}
}
template <>
void BaselineCompilerCodeGen::pushScriptNameArg(Register scratch1,
Register scratch2) {
pushArg(ImmGCPtr(handler.script()->getName(handler.pc())));
}
template <>
void BaselineInterpreterCodeGen::pushScriptNameArg(Register scratch1,
Register scratch2) {
MOZ_ASSERT(scratch1 != scratch2);
LoadInt32Operand(masm, scratch1);
loadScriptAtom(scratch1, scratch2);
pushArg(scratch2);
}
static gc::Cell* GetScriptGCThing(JSScript* script, jsbytecode* pc,
ScriptGCThingType type) {
switch (type) {
@ -1016,6 +984,12 @@ void BaselineInterpreterCodeGen::pushScriptGCThingArg(ScriptGCThingType type,
pushArg(scratch1);
}
template <typename Handler>
void BaselineCodeGen<Handler>::pushScriptNameArg(Register scratch1,
Register scratch2) {
pushScriptGCThingArg(ScriptGCThingType::Atom, scratch1, scratch2);
}
template <>
void BaselineCompilerCodeGen::pushUint8BytecodeOperandArg(Register) {
MOZ_ASSERT(JOF_OPTYPE(JSOp(*handler.pc())) == JOF_UINT8);
@ -2500,11 +2474,8 @@ template <>
bool BaselineInterpreterCodeGen::emit_String() {
Register scratch1 = R0.scratchReg();
Register scratch2 = R1.scratchReg();
LoadInt32Operand(masm, scratch1);
loadScriptAtom(scratch1, scratch2);
masm.tagValue(JSVAL_TYPE_STRING, scratch2, R0);
loadScriptGCThing(ScriptGCThingType::Atom, scratch1, scratch2);
masm.tagValue(JSVAL_TYPE_STRING, scratch1, R0);
frame.push(R0);
return true;
}

View File

@ -110,9 +110,6 @@ class BaselineCodeGen {
// Load the |this|-value from the global's lexical environment.
void loadGlobalThisValue(ValueOperand dest);
// Load script atom |index| into |dest|.
void loadScriptAtom(Register index, Register dest);
// Computes the frame size. See BaselineFrame::debugFrameSize_.
void computeFrameSize(Register dest);

View File

@ -2654,21 +2654,11 @@ class JSScript : public js::BaseScript {
return immutableScriptData()->notes();
}
size_t natoms() const {
MOZ_ASSERT(sharedData_);
return sharedData_->natoms();
}
js::GCPtrAtom* atoms() const {
MOZ_ASSERT(sharedData_);
return sharedData_->atoms();
JSAtom* getAtom(size_t index) const {
return &gcthings()[index].as<JSString>().asAtom();
}
js::GCPtrAtom& getAtom(size_t index) const {
MOZ_ASSERT(index < natoms());
return atoms()[index];
}
js::GCPtrAtom& getAtom(jsbytecode* pc) const {
JSAtom* getAtom(jsbytecode* pc) const {
MOZ_ASSERT(containsPC<uint32_t>(pc));
MOZ_ASSERT(js::JOF_OPTYPE((JSOp)*pc) == JOF_ATOM);
return getAtom(GET_UINT32_INDEX(pc));