From 13a54a78a34a40fc5a9dcac08278173b5a9f1473 Mon Sep 17 00:00:00 2001 From: Ted Campbell Date: Tue, 19 May 2020 17:24:01 +0000 Subject: [PATCH] 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 --- js/src/frontend/BCEScriptStencil.cpp | 13 ++------ js/src/frontend/BytecodeEmitter.h | 6 +++- js/src/jit/BaselineCodeGen.cpp | 45 +++++----------------------- js/src/jit/BaselineCodeGen.h | 3 -- js/src/vm/JSScript.h | 16 ++-------- 5 files changed, 18 insertions(+), 65 deletions(-) diff --git a/js/src/frontend/BCEScriptStencil.cpp b/js/src/frontend/BCEScriptStencil.cpp index fe57bf17dc9b..d20aafbaa8e3 100644 --- a/js/src/frontend/BCEScriptStencil.cpp +++ b/js/src/frontend/BCEScriptStencil.cpp @@ -22,7 +22,7 @@ BCEScriptStencil::BCEScriptStencil(BytecodeEmitter& bce, void BCEScriptStencil::init(BytecodeEmitter& bce, UniquePtr 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 {} diff --git a/js/src/frontend/BytecodeEmitter.h b/js/src/frontend/BytecodeEmitter.h index 5ed63ca4a589..c2d565cdc81a 100644 --- a/js/src/frontend/BytecodeEmitter.h +++ b/js/src/frontend/BytecodeEmitter.h @@ -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; diff --git a/js/src/jit/BaselineCodeGen.cpp b/js/src/jit/BaselineCodeGen.cpp index 591c4cb76037..00b74c9e9c30 100644 --- a/js/src/jit/BaselineCodeGen.cpp +++ b/js/src/jit/BaselineCodeGen.cpp @@ -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 +void BaselineCodeGen::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; } diff --git a/js/src/jit/BaselineCodeGen.h b/js/src/jit/BaselineCodeGen.h index e76c443bce17..e6a2a5cbde13 100644 --- a/js/src/jit/BaselineCodeGen.h +++ b/js/src/jit/BaselineCodeGen.h @@ -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); diff --git a/js/src/vm/JSScript.h b/js/src/vm/JSScript.h index 62b634652b06..dc34dd494988 100644 --- a/js/src/vm/JSScript.h +++ b/js/src/vm/JSScript.h @@ -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().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(pc)); MOZ_ASSERT(js::JOF_OPTYPE((JSOp)*pc) == JOF_ATOM); return getAtom(GET_UINT32_INDEX(pc));