Title: [240981] trunk/Source
Revision
240981
Author
[email protected]
Date
2019-02-05 10:28:33 -0800 (Tue, 05 Feb 2019)

Log Message

[JSC] Shrink sizeof(UnlinkedCodeBlock)
https://bugs.webkit.org/show_bug.cgi?id=194281

Reviewed by Michael Saboff.

Source/_javascript_Core:

This patch first attempts to reduce the size of UnlinkedCodeBlock in a relatively simpler way. Reordering members, remove unused member, and
move rarely used members to RareData. This changes sizeof(UnlinkedCodeBlock) from 312 to 256.

Still we have several chances to reduce sizeof(UnlinkedCodeBlock). Making more Vectors to RefCountedArrays can be done with some restructuring
of generatorification phase. It would be possible to remove m_sourceURLDirective and m_sourceMappingURLDirective from UnlinkedCodeBlock since
they should be in SourceProvider and that should be enough. These changes require some intrusive modifications and we make them as a future work.

* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::finishCreation):
* bytecode/CodeBlock.h:
(JSC::CodeBlock::bitVectors const): Deleted.
* bytecode/CodeType.h:
* bytecode/UnlinkedCodeBlock.cpp:
(JSC::UnlinkedCodeBlock::UnlinkedCodeBlock):
(JSC::UnlinkedCodeBlock::shrinkToFit):
* bytecode/UnlinkedCodeBlock.h:
(JSC::UnlinkedCodeBlock::bitVector):
(JSC::UnlinkedCodeBlock::addBitVector):
(JSC::UnlinkedCodeBlock::addSetConstant):
(JSC::UnlinkedCodeBlock::constantRegisters):
(JSC::UnlinkedCodeBlock::numberOfConstantIdentifierSets const):
(JSC::UnlinkedCodeBlock::constantIdentifierSets):
(JSC::UnlinkedCodeBlock::codeType const):
(JSC::UnlinkedCodeBlock::didOptimize const):
(JSC::UnlinkedCodeBlock::setDidOptimize):
(JSC::UnlinkedCodeBlock::usesGlobalObject const): Deleted.
(JSC::UnlinkedCodeBlock::setGlobalObjectRegister): Deleted.
(JSC::UnlinkedCodeBlock::globalObjectRegister const): Deleted.
(JSC::UnlinkedCodeBlock::bitVectors const): Deleted.
* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::emitLoad):
(JSC::BytecodeGenerator::emitLoadGlobalObject): Deleted.
* bytecompiler/BytecodeGenerator.h:
* runtime/CachedTypes.cpp:
(JSC::CachedCodeBlockRareData::encode):
(JSC::CachedCodeBlockRareData::decode const):
(JSC::CachedCodeBlock::scopeRegister const):
(JSC::CachedCodeBlock::codeType const):
(JSC::UnlinkedCodeBlock::UnlinkedCodeBlock):
(JSC::CachedCodeBlock<CodeBlockType>::decode const):
(JSC::CachedCodeBlock<CodeBlockType>::encode):
(JSC::CachedCodeBlock::globalObjectRegister const): Deleted.

Source/WTF:

* wtf/TriState.h:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (240980 => 240981)


--- trunk/Source/_javascript_Core/ChangeLog	2019-02-05 18:23:51 UTC (rev 240980)
+++ trunk/Source/_javascript_Core/ChangeLog	2019-02-05 18:28:33 UTC (rev 240981)
@@ -1,3 +1,53 @@
+2019-02-05  Yusuke Suzuki  <[email protected]>
+
+        [JSC] Shrink sizeof(UnlinkedCodeBlock)
+        https://bugs.webkit.org/show_bug.cgi?id=194281
+
+        Reviewed by Michael Saboff.
+
+        This patch first attempts to reduce the size of UnlinkedCodeBlock in a relatively simpler way. Reordering members, remove unused member, and
+        move rarely used members to RareData. This changes sizeof(UnlinkedCodeBlock) from 312 to 256.
+
+        Still we have several chances to reduce sizeof(UnlinkedCodeBlock). Making more Vectors to RefCountedArrays can be done with some restructuring
+        of generatorification phase. It would be possible to remove m_sourceURLDirective and m_sourceMappingURLDirective from UnlinkedCodeBlock since
+        they should be in SourceProvider and that should be enough. These changes require some intrusive modifications and we make them as a future work.
+
+        * bytecode/CodeBlock.cpp:
+        (JSC::CodeBlock::finishCreation):
+        * bytecode/CodeBlock.h:
+        (JSC::CodeBlock::bitVectors const): Deleted.
+        * bytecode/CodeType.h:
+        * bytecode/UnlinkedCodeBlock.cpp:
+        (JSC::UnlinkedCodeBlock::UnlinkedCodeBlock):
+        (JSC::UnlinkedCodeBlock::shrinkToFit):
+        * bytecode/UnlinkedCodeBlock.h:
+        (JSC::UnlinkedCodeBlock::bitVector):
+        (JSC::UnlinkedCodeBlock::addBitVector):
+        (JSC::UnlinkedCodeBlock::addSetConstant):
+        (JSC::UnlinkedCodeBlock::constantRegisters):
+        (JSC::UnlinkedCodeBlock::numberOfConstantIdentifierSets const):
+        (JSC::UnlinkedCodeBlock::constantIdentifierSets):
+        (JSC::UnlinkedCodeBlock::codeType const):
+        (JSC::UnlinkedCodeBlock::didOptimize const):
+        (JSC::UnlinkedCodeBlock::setDidOptimize):
+        (JSC::UnlinkedCodeBlock::usesGlobalObject const): Deleted.
+        (JSC::UnlinkedCodeBlock::setGlobalObjectRegister): Deleted.
+        (JSC::UnlinkedCodeBlock::globalObjectRegister const): Deleted.
+        (JSC::UnlinkedCodeBlock::bitVectors const): Deleted.
+        * bytecompiler/BytecodeGenerator.cpp:
+        (JSC::BytecodeGenerator::emitLoad):
+        (JSC::BytecodeGenerator::emitLoadGlobalObject): Deleted.
+        * bytecompiler/BytecodeGenerator.h:
+        * runtime/CachedTypes.cpp:
+        (JSC::CachedCodeBlockRareData::encode):
+        (JSC::CachedCodeBlockRareData::decode const):
+        (JSC::CachedCodeBlock::scopeRegister const):
+        (JSC::CachedCodeBlock::codeType const):
+        (JSC::UnlinkedCodeBlock::UnlinkedCodeBlock):
+        (JSC::CachedCodeBlock<CodeBlockType>::decode const):
+        (JSC::CachedCodeBlock<CodeBlockType>::encode):
+        (JSC::CachedCodeBlock::globalObjectRegister const): Deleted.
+
 2019-02-04  Yusuke Suzuki  <[email protected]>
 
         Unreviewed, add missing exception checks after r240637

Modified: trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp (240980 => 240981)


--- trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp	2019-02-05 18:23:51 UTC (rev 240980)
+++ trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp	2019-02-05 18:28:33 UTC (rev 240981)
@@ -416,12 +416,6 @@
     setConstantRegisters(unlinkedCodeBlock->constantRegisters(), unlinkedCodeBlock->constantsSourceCodeRepresentation());
     RETURN_IF_EXCEPTION(throwScope, false);
 
-    setConstantIdentifierSetRegisters(vm, unlinkedCodeBlock->constantIdentifierSets());
-    RETURN_IF_EXCEPTION(throwScope, false);
-
-    if (unlinkedCodeBlock->usesGlobalObject())
-        m_constantRegisters[unlinkedCodeBlock->globalObjectRegister().toConstantIndex()].set(vm, this, m_globalObject.get());
-
     for (unsigned i = 0; i < LinkTimeConstantCount; i++) {
         LinkTimeConstant type = static_cast<LinkTimeConstant>(i);
         if (unsigned registerIndex = unlinkedCodeBlock->registerIndexForLinkTimeConstant(type))
@@ -458,6 +452,10 @@
 
     if (unlinkedCodeBlock->hasRareData()) {
         createRareDataIfNecessary();
+
+        setConstantIdentifierSetRegisters(vm, unlinkedCodeBlock->constantIdentifierSets());
+        RETURN_IF_EXCEPTION(throwScope, false);
+
         if (size_t count = unlinkedCodeBlock->numberOfExceptionHandlers()) {
             m_rareData->m_exceptionHandlers.resizeToFit(count);
             for (size_t i = 0; i < count; i++) {

Modified: trunk/Source/_javascript_Core/bytecode/CodeBlock.h (240980 => 240981)


--- trunk/Source/_javascript_Core/bytecode/CodeBlock.h	2019-02-05 18:23:51 UTC (rev 240980)
+++ trunk/Source/_javascript_Core/bytecode/CodeBlock.h	2019-02-05 18:28:33 UTC (rev 240981)
@@ -569,7 +569,6 @@
     int numberOfFunctionDecls() { return m_functionDecls.size(); }
     FunctionExecutable* functionExpr(int index) { return m_functionExprs[index].get(); }
     
-    const Vector<BitVector>& bitVectors() const { return m_unlinkedCode->bitVectors(); }
     const BitVector& bitVector(size_t i) { return m_unlinkedCode->bitVector(i); }
 
     Heap* heap() const { return &m_vm->heap; }

Modified: trunk/Source/_javascript_Core/bytecode/CodeType.h (240980 => 240981)


--- trunk/Source/_javascript_Core/bytecode/CodeType.h	2019-02-05 18:23:51 UTC (rev 240980)
+++ trunk/Source/_javascript_Core/bytecode/CodeType.h	2019-02-05 18:28:33 UTC (rev 240981)
@@ -27,7 +27,7 @@
 
 namespace JSC {
 
-enum CodeType { GlobalCode, EvalCode, FunctionCode, ModuleCode };
+enum CodeType : uint8_t { GlobalCode, EvalCode, FunctionCode, ModuleCode };
 
 } // namespace JSC
 

Modified: trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.cpp (240980 => 240981)


--- trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.cpp	2019-02-05 18:23:51 UTC (rev 240980)
+++ trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.cpp	2019-02-05 18:28:33 UTC (rev 240981)
@@ -56,8 +56,6 @@
 
 UnlinkedCodeBlock::UnlinkedCodeBlock(VM* vm, Structure* structure, CodeType codeType, const ExecutableInfo& info, DebuggerMode debuggerMode)
     : Base(*vm, structure)
-    , m_globalObjectRegister(VirtualRegister())
-    , m_metadata(UnlinkedMetadataTable::create())
     , m_usesEval(info.usesEval())
     , m_isStrictMode(info.isStrictMode())
     , m_isConstructor(info.isConstructor())
@@ -72,14 +70,16 @@
     , m_derivedContextType(static_cast<unsigned>(info.derivedContextType()))
     , m_evalContextType(static_cast<unsigned>(info.evalContextType()))
     , m_hasTailCalls(false)
-    , m_features(0)
-    , m_didOptimize(MixedTriState)
+    , m_codeType(static_cast<unsigned>(codeType))
+    , m_didOptimize(static_cast<unsigned>(MixedTriState))
     , m_parseMode(info.parseMode())
-    , m_codeType(codeType)
+    , m_metadata(UnlinkedMetadataTable::create())
 {
     for (auto& constantRegisterIndex : m_linkTimeConstants)
         constantRegisterIndex = 0;
     ASSERT(m_constructorKind == static_cast<unsigned>(info.constructorKind()));
+    ASSERT(m_codeType == static_cast<unsigned>(codeType));
+    ASSERT(m_didOptimize == static_cast<unsigned>(MixedTriState));
 }
 
 void UnlinkedCodeBlock::visitChildren(JSCell* cell, SlotVisitor& visitor)
@@ -381,9 +381,7 @@
     m_jumpTargets.shrinkToFit();
     m_propertyAccessInstructions.shrinkToFit();
     m_identifiers.shrinkToFit();
-    m_bitVectors.shrinkToFit();
     m_constantRegisters.shrinkToFit();
-    m_constantIdentifierSets.shrinkToFit();
     m_constantsSourceCodeRepresentation.shrinkToFit();
     m_functionDecls.shrinkToFit();
     m_functionExprs.shrinkToFit();
@@ -395,6 +393,8 @@
         m_rareData->m_stringSwitchJumpTables.shrinkToFit();
         m_rareData->m_expressionInfoFatPositions.shrinkToFit();
         m_rareData->m_opProfileControlFlowBytecodeOffsets.shrinkToFit();
+        m_rareData->m_bitVectors.shrinkToFit();
+        m_rareData->m_constantIdentifierSets.shrinkToFit();
     }
 }
 

Modified: trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.h (240980 => 240981)


--- trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.h	2019-02-05 18:23:51 UTC (rev 240980)
+++ trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.h	2019-02-05 18:28:33 UTC (rev 240981)
@@ -140,10 +140,6 @@
     void setThisRegister(VirtualRegister thisRegister) { m_thisRegister = thisRegister; }
     void setScopeRegister(VirtualRegister scopeRegister) { m_scopeRegister = scopeRegister; }
 
-    bool usesGlobalObject() const { return m_globalObjectRegister.isValid(); }
-    void setGlobalObjectRegister(VirtualRegister globalObjectRegister) { m_globalObjectRegister = globalObjectRegister; }
-    VirtualRegister globalObjectRegister() const { return m_globalObjectRegister; }
-
     // Parameter information
     void setNumParameters(int newValue) { m_numParameters = newValue; }
     void addParameter() { m_numParameters++; }
@@ -156,22 +152,23 @@
     const Identifier& identifier(int index) const { return m_identifiers[index]; }
     const Vector<Identifier>& identifiers() const { return m_identifiers; }
 
-    const Vector<BitVector>& bitVectors() const { return m_bitVectors; }
-    BitVector& bitVector(size_t i) { return m_bitVectors[i]; }
+    BitVector& bitVector(size_t i) { ASSERT(m_rareData); return m_rareData->m_bitVectors[i]; }
     unsigned addBitVector(BitVector&& bitVector)
     {
-        m_bitVectors.append(WTFMove(bitVector));
-        return m_bitVectors.size() - 1;
+        createRareDataIfNecessary();
+        m_rareData->m_bitVectors.append(WTFMove(bitVector));
+        return m_rareData->m_bitVectors.size() - 1;
     }
 
     void addSetConstant(IdentifierSet& set)
     {
+        createRareDataIfNecessary();
         VM& vm = *this->vm();
         auto locker = lockDuringMarking(vm.heap, cellLock());
         unsigned result = m_constantRegisters.size();
         m_constantRegisters.append(WriteBarrier<Unknown>());
         m_constantsSourceCodeRepresentation.append(SourceCodeRepresentation::Other);
-        m_constantIdentifierSets.append(ConstantIdentifierSetEntry(set, result));
+        m_rareData->m_constantIdentifierSets.append(ConstantIdentifierSetEntry(set, result));
     }
 
     unsigned addConstant(JSValue v, SourceCodeRepresentation sourceCodeRepresentation = SourceCodeRepresentation::Other)
@@ -204,13 +201,16 @@
         ASSERT(index < LinkTimeConstantCount);
         return m_linkTimeConstants[index];
     }
+
     const Vector<WriteBarrier<Unknown>>& constantRegisters() { return m_constantRegisters; }
-    const Vector<ConstantIdentifierSetEntry>& constantIdentifierSets() { return m_constantIdentifierSets; }
     const WriteBarrier<Unknown>& constantRegister(int index) const { return m_constantRegisters[index - FirstConstantRegisterIndex]; }
     ALWAYS_INLINE bool isConstantRegisterIndex(int index) const { return index >= FirstConstantRegisterIndex; }
     ALWAYS_INLINE JSValue getConstant(int index) const { return m_constantRegisters[index - FirstConstantRegisterIndex].get(); }
     const Vector<SourceCodeRepresentation>& constantsSourceCodeRepresentation() { return m_constantsSourceCodeRepresentation; }
 
+    unsigned numberOfConstantIdentifierSets() const { return m_rareData ? m_rareData->m_constantIdentifierSets.size() : 0; }
+    const Vector<ConstantIdentifierSetEntry>& constantIdentifierSets() { ASSERT(m_rareData); return m_rareData->m_constantIdentifierSets; }
+
     // Jumps
     size_t numberOfJumpTargets() const { return m_jumpTargets.size(); }
     void addJumpTarget(unsigned jumpTarget) { m_jumpTargets.append(jumpTarget); }
@@ -272,7 +272,7 @@
     void addExceptionHandler(const UnlinkedHandlerInfo& handler) { createRareDataIfNecessary(); return m_rareData->m_exceptionHandlers.append(handler); }
     UnlinkedHandlerInfo& exceptionHandler(int index) { ASSERT(m_rareData); return m_rareData->m_exceptionHandlers[index]; }
 
-    CodeType codeType() const { return m_codeType; }
+    CodeType codeType() const { return static_cast<CodeType>(m_codeType); }
 
     VirtualRegister thisRegister() const { return m_thisRegister; }
     VirtualRegister scopeRegister() const { return m_scopeRegister; }
@@ -333,8 +333,8 @@
 
     bool wasCompiledWithDebuggingOpcodes() const { return m_wasCompiledWithDebuggingOpcodes; }
 
-    TriState didOptimize() const { return m_didOptimize; }
-    void setDidOptimize(TriState didOptimize) { m_didOptimize = didOptimize; }
+    TriState didOptimize() const { return static_cast<TriState>(m_didOptimize); }
+    void setDidOptimize(TriState didOptimize) { m_didOptimize = static_cast<unsigned>(didOptimize); }
 
     void dump(PrintStream&) const;
 
@@ -401,21 +401,11 @@
     void getLineAndColumn(const ExpressionRangeInfo&, unsigned& line, unsigned& column) const;
     BytecodeLivenessAnalysis& livenessAnalysisSlow(CodeBlock*);
 
-    std::unique_ptr<InstructionStream> m_instructions;
-    std::unique_ptr<BytecodeLivenessAnalysis> m_liveness;
-
     VirtualRegister m_thisRegister;
     VirtualRegister m_scopeRegister;
-    VirtualRegister m_globalObjectRegister;
 
-    String m_sourceURLDirective;
-    String m_sourceMappingURLDirective;
-    Ref<UnlinkedMetadataTable> m_metadata;
+    std::array<unsigned, LinkTimeConstantCount> m_linkTimeConstants;
 
-#if ENABLE(DFG_JIT)
-    DFG::ExitProfile m_exitProfile;
-#endif
-
     unsigned m_usesEval : 1;
     unsigned m_isStrictMode : 1;
     unsigned m_isConstructor : 1;
@@ -430,6 +420,13 @@
     unsigned m_derivedContextType : 2;
     unsigned m_evalContextType : 2;
     unsigned m_hasTailCalls : 1;
+    unsigned m_codeType : 2;
+    unsigned m_didOptimize : 2;
+public:
+    ConcurrentJSLock m_lock;
+private:
+    CodeFeatures m_features { 0 };
+    SourceParseMode m_parseMode;
 
     unsigned m_lineCount { 0 };
     unsigned m_endColumn { UINT_MAX };
@@ -438,33 +435,34 @@
     int m_numCalleeLocals { 0 };
     int m_numParameters { 0 };
 
-public:
-    ConcurrentJSLock m_lock;
-private:
-    CodeFeatures m_features { 0 };
-    TriState m_didOptimize;
-    SourceParseMode m_parseMode;
-    CodeType m_codeType;
+    String m_sourceURLDirective;
+    String m_sourceMappingURLDirective;
 
     Vector<InstructionStream::Offset> m_jumpTargets;
+    Ref<UnlinkedMetadataTable> m_metadata;
+    std::unique_ptr<InstructionStream> m_instructions;
+    std::unique_ptr<BytecodeLivenessAnalysis> m_liveness;
 
+
+#if ENABLE(DFG_JIT)
+    DFG::ExitProfile m_exitProfile;
+#endif
+
+
     Vector<InstructionStream::Offset> m_propertyAccessInstructions;
 
     // Constant Pools
     Vector<Identifier> m_identifiers;
-    Vector<BitVector> m_bitVectors;
     Vector<WriteBarrier<Unknown>> m_constantRegisters;
-    Vector<ConstantIdentifierSetEntry> m_constantIdentifierSets;
     Vector<SourceCodeRepresentation> m_constantsSourceCodeRepresentation;
     typedef Vector<WriteBarrier<UnlinkedFunctionExecutable>> FunctionExpressionVector;
     FunctionExpressionVector m_functionDecls;
     FunctionExpressionVector m_functionExprs;
-    std::array<unsigned, LinkTimeConstantCount> m_linkTimeConstants;
 
 public:
     struct RareData {
-        WTF_MAKE_FAST_ALLOCATED;
-    public:
+        WTF_MAKE_STRUCT_FAST_ALLOCATED;
+
         Vector<UnlinkedHandlerInfo> m_exceptionHandlers;
 
         // Jump Tables
@@ -479,6 +477,8 @@
         };
         HashMap<unsigned, TypeProfilerExpressionRange> m_typeProfilerInfoMap;
         Vector<InstructionStream::Offset> m_opProfileControlFlowBytecodeOffsets;
+        Vector<BitVector> m_bitVectors;
+        Vector<ConstantIdentifierSetEntry> m_constantIdentifierSets;
     };
 
     void addOutOfLineJumpTarget(InstructionStream::Offset, int target);

Modified: trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp (240980 => 240981)


--- trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp	2019-02-05 18:23:51 UTC (rev 240980)
+++ trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp	2019-02-05 18:28:33 UTC (rev 240981)
@@ -1869,11 +1869,13 @@
 
 RegisterID* BytecodeGenerator::emitLoad(RegisterID* dst, IdentifierSet& set)
 {
-    for (const auto& entry : m_codeBlock->constantIdentifierSets()) {
-        if (entry.first != set)
-            continue;
-        
-        return &m_constantPoolRegisters[entry.second];
+    if (m_codeBlock->numberOfConstantIdentifierSets()) {
+        for (const auto& entry : m_codeBlock->constantIdentifierSets()) {
+            if (entry.first != set)
+                continue;
+            
+            return &m_constantPoolRegisters[entry.second];
+        }
     }
     
     unsigned index = addConstantIndex();
@@ -1886,19 +1888,6 @@
     return m_setRegister;
 }
 
-RegisterID* BytecodeGenerator::emitLoadGlobalObject(RegisterID* dst)
-{
-    if (!m_globalObjectRegister) {
-        int index = addConstantIndex();
-        m_codeBlock->addConstant(JSValue());
-        m_globalObjectRegister = &m_constantPoolRegisters[index];
-        m_codeBlock->setGlobalObjectRegister(VirtualRegister(index));
-    }
-    if (dst)
-        move(dst, m_globalObjectRegister);
-    return m_globalObjectRegister;
-}
-
 template<typename LookUpVarKindFunctor>
 bool BytecodeGenerator::instantiateLexicalVariables(const VariableEnvironment& lexicalVariables, SymbolTable* symbolTable, ScopeRegisterType scopeRegisterType, LookUpVarKindFunctor lookUpVarKind)
 {

Modified: trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.h (240980 => 240981)


--- trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.h	2019-02-05 18:23:51 UTC (rev 240980)
+++ trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.h	2019-02-05 18:28:33 UTC (rev 240981)
@@ -671,7 +671,6 @@
         RegisterID* emitLoad(RegisterID* dst, const Identifier&);
         RegisterID* emitLoad(RegisterID* dst, JSValue, SourceCodeRepresentation = SourceCodeRepresentation::Other);
         RegisterID* emitLoad(RegisterID* dst, IdentifierSet& excludedList);
-        RegisterID* emitLoadGlobalObject(RegisterID* dst);
 
         template<typename UnaryOp, typename = std::enable_if_t<UnaryOp::opcodeID != op_negate>>
         RegisterID* emitUnaryOp(RegisterID* dst, RegisterID* src)
@@ -1241,7 +1240,6 @@
         RegisterID* m_lexicalEnvironmentRegister { nullptr };
         RegisterID* m_generatorRegister { nullptr };
         RegisterID* m_emptyValueRegister { nullptr };
-        RegisterID* m_globalObjectRegister { nullptr };
         RegisterID* m_newTargetRegister { nullptr };
         RegisterID* m_isDerivedConstuctor { nullptr };
         RegisterID* m_linkTimeConstantRegisters[LinkTimeConstantCount];

Modified: trunk/Source/_javascript_Core/runtime/CachedTypes.cpp (240980 => 240981)


--- trunk/Source/_javascript_Core/runtime/CachedTypes.cpp	2019-02-05 18:23:51 UTC (rev 240980)
+++ trunk/Source/_javascript_Core/runtime/CachedTypes.cpp	2019-02-05 18:28:33 UTC (rev 240981)
@@ -733,39 +733,6 @@
     CachedHashMap<CachedRefPtr<CachedStringImpl>, UnlinkedStringJumpTable:: OffsetLocation> m_offsetTable;
 };
 
-class CachedCodeBlockRareData : public CachedObject<UnlinkedCodeBlock::RareData> {
-public:
-    void encode(Encoder& encoder, const UnlinkedCodeBlock::RareData& rareData)
-    {
-        m_exceptionHandlers.encode(encoder, rareData.m_exceptionHandlers);
-        m_switchJumpTables.encode(encoder, rareData.m_switchJumpTables);
-        m_stringSwitchJumpTables.encode(encoder, rareData.m_stringSwitchJumpTables);
-        m_expressionInfoFatPositions.encode(encoder, rareData.m_expressionInfoFatPositions);
-        m_typeProfilerInfoMap.encode(encoder, rareData.m_typeProfilerInfoMap);
-        m_opProfileControlFlowBytecodeOffsets.encode(encoder, rareData.m_opProfileControlFlowBytecodeOffsets);
-    }
-
-    UnlinkedCodeBlock::RareData* decode(Decoder& decoder) const
-    {
-        UnlinkedCodeBlock::RareData* rareData = new UnlinkedCodeBlock::RareData { };
-        m_exceptionHandlers.decode(decoder, rareData->m_exceptionHandlers);
-        m_switchJumpTables.decode(decoder, rareData->m_switchJumpTables);
-        m_stringSwitchJumpTables.decode(decoder, rareData->m_stringSwitchJumpTables);
-        m_expressionInfoFatPositions.decode(decoder, rareData->m_expressionInfoFatPositions);
-        m_typeProfilerInfoMap.decode(decoder, rareData->m_typeProfilerInfoMap);
-        m_opProfileControlFlowBytecodeOffsets.decode(decoder, rareData->m_opProfileControlFlowBytecodeOffsets);
-        return rareData;
-    }
-
-private:
-    CachedVector<UnlinkedHandlerInfo> m_exceptionHandlers;
-    CachedVector<CachedSimpleJumpTable> m_switchJumpTables;
-    CachedVector<CachedStringJumpTable> m_stringSwitchJumpTables;
-    CachedVector<ExpressionRangeInfo::FatPosition> m_expressionInfoFatPositions;
-    CachedHashMap<unsigned, UnlinkedCodeBlock::RareData::TypeProfilerExpressionRange> m_typeProfilerInfoMap;
-    CachedVector<InstructionStream::Offset> m_opProfileControlFlowBytecodeOffsets;
-};
-
 class CachedBitVector : public VariableLengthObject<BitVector> {
 public:
     void encode(Encoder& encoder, const BitVector& bitVector)
@@ -828,6 +795,45 @@
     CachedHashSet<CachedRefPtr<CachedUniquedStringImpl>, IdentifierRepHash> m_set;
 };
 
+class CachedCodeBlockRareData : public CachedObject<UnlinkedCodeBlock::RareData> {
+public:
+    void encode(Encoder& encoder, const UnlinkedCodeBlock::RareData& rareData)
+    {
+        m_exceptionHandlers.encode(encoder, rareData.m_exceptionHandlers);
+        m_switchJumpTables.encode(encoder, rareData.m_switchJumpTables);
+        m_stringSwitchJumpTables.encode(encoder, rareData.m_stringSwitchJumpTables);
+        m_expressionInfoFatPositions.encode(encoder, rareData.m_expressionInfoFatPositions);
+        m_typeProfilerInfoMap.encode(encoder, rareData.m_typeProfilerInfoMap);
+        m_opProfileControlFlowBytecodeOffsets.encode(encoder, rareData.m_opProfileControlFlowBytecodeOffsets);
+        m_bitVectors.encode(encoder, rareData.m_bitVectors);
+        m_constantIdentifierSets.encode(encoder, rareData.m_constantIdentifierSets);
+    }
+
+    UnlinkedCodeBlock::RareData* decode(Decoder& decoder) const
+    {
+        UnlinkedCodeBlock::RareData* rareData = new UnlinkedCodeBlock::RareData { };
+        m_exceptionHandlers.decode(decoder, rareData->m_exceptionHandlers);
+        m_switchJumpTables.decode(decoder, rareData->m_switchJumpTables);
+        m_stringSwitchJumpTables.decode(decoder, rareData->m_stringSwitchJumpTables);
+        m_expressionInfoFatPositions.decode(decoder, rareData->m_expressionInfoFatPositions);
+        m_typeProfilerInfoMap.decode(decoder, rareData->m_typeProfilerInfoMap);
+        m_opProfileControlFlowBytecodeOffsets.decode(decoder, rareData->m_opProfileControlFlowBytecodeOffsets);
+        m_bitVectors.decode(decoder, rareData->m_bitVectors);
+        m_constantIdentifierSets.decode(decoder, rareData->m_constantIdentifierSets);
+        return rareData;
+    }
+
+private:
+    CachedVector<UnlinkedHandlerInfo> m_exceptionHandlers;
+    CachedVector<CachedSimpleJumpTable> m_switchJumpTables;
+    CachedVector<CachedStringJumpTable> m_stringSwitchJumpTables;
+    CachedVector<ExpressionRangeInfo::FatPosition> m_expressionInfoFatPositions;
+    CachedHashMap<unsigned, UnlinkedCodeBlock::RareData::TypeProfilerExpressionRange> m_typeProfilerInfoMap;
+    CachedVector<InstructionStream::Offset> m_opProfileControlFlowBytecodeOffsets;
+    CachedVector<CachedBitVector> m_bitVectors;
+    CachedVector<CachedConstantIdentifierSetEntry> m_constantIdentifierSets;
+};
+
 class CachedVariableEnvironment : public CachedObject<VariableEnvironment> {
 public:
     void encode(Encoder& encoder, const VariableEnvironment& env)
@@ -1472,7 +1478,6 @@
 
     VirtualRegister thisRegister() const { return m_thisRegister; }
     VirtualRegister scopeRegister() const { return m_scopeRegister; }
-    VirtualRegister globalObjectRegister() const { return m_globalObjectRegister; }
 
     String sourceURLDirective(Decoder& decoder) const { return m_sourceURLDirective.decode(decoder); }
     String sourceMappingURLDirective(Decoder& decoder) const { return m_sourceMappingURLDirective.decode(decoder); }
@@ -1502,7 +1507,7 @@
 
     CodeFeatures features() const { return m_features; }
     SourceParseMode parseMode() const { return m_parseMode; }
-    CodeType codeType() const { return m_codeType; }
+    unsigned codeType() const { return m_codeType; }
 
     UnlinkedCodeBlock::RareData* rareData(Decoder& decoder) const { return m_rareData.decodeAsPtr(decoder); }
 
@@ -1509,7 +1514,7 @@
 private:
     VirtualRegister m_thisRegister;
     VirtualRegister m_scopeRegister;
-    VirtualRegister m_globalObjectRegister;
+    std::array<unsigned, LinkTimeConstantCount> m_linkTimeConstants;
 
     unsigned m_usesEval : 1;
     unsigned m_isStrictMode : 1;
@@ -1525,7 +1530,11 @@
     unsigned m_derivedContextType : 2;
     unsigned m_evalContextType : 2;
     unsigned m_hasTailCalls : 1;
+    unsigned m_codeType : 2;
 
+    CodeFeatures m_features;
+    SourceParseMode m_parseMode;
+
     unsigned m_lineCount;
     unsigned m_endColumn;
 
@@ -1533,11 +1542,6 @@
     int m_numCalleeLocals;
     int m_numParameters;
 
-    CodeFeatures m_features;
-    SourceParseMode m_parseMode;
-    CodeType m_codeType;
-
-    std::array<unsigned, LinkTimeConstantCount> m_linkTimeConstants;
     CachedMetadataTable m_metadata;
 
     CachedOptional<CachedCodeBlockRareData> m_rareData;
@@ -1553,9 +1557,7 @@
     CachedVector<ExpressionRangeInfo> m_expressionInfo;
     CachedHashMap<InstructionStream::Offset, int> m_outOfLineJumpTargets;
 
-    CachedVector<CachedConstantIdentifierSetEntry> m_constantIdentifierSets;
     CachedVector<CachedIdentifier> m_identifiers;
-    CachedVector<CachedBitVector> m_bitVectors;
     CachedVector<CachedWriteBarrier<CachedFunctionExecutable>> m_functionDecls;
     CachedVector<CachedWriteBarrier<CachedFunctionExecutable>> m_functionExprs;
 };
@@ -1691,17 +1693,9 @@
 template<typename CodeBlockType>
 ALWAYS_INLINE UnlinkedCodeBlock::UnlinkedCodeBlock(Decoder& decoder, Structure* structure, const CachedCodeBlock<CodeBlockType>& cachedCodeBlock)
     : Base(decoder.vm(), structure)
-    , m_instructions(cachedCodeBlock.instructions(decoder))
-    , m_liveness(nullptr)
     , m_thisRegister(cachedCodeBlock.thisRegister())
     , m_scopeRegister(cachedCodeBlock.scopeRegister())
-    , m_globalObjectRegister(cachedCodeBlock.globalObjectRegister())
 
-    , m_sourceURLDirective(cachedCodeBlock.sourceURLDirective(decoder))
-    , m_sourceMappingURLDirective(cachedCodeBlock.sourceMappingURLDirective(decoder))
-
-    , m_metadata(cachedCodeBlock.metadata(decoder))
-
     , m_usesEval(cachedCodeBlock.usesEval())
     , m_isStrictMode(cachedCodeBlock.isStrictMode())
     , m_isConstructor(cachedCodeBlock.isConstructor())
@@ -1716,14 +1710,23 @@
     , m_derivedContextType(cachedCodeBlock.derivedContextType())
     , m_evalContextType(cachedCodeBlock.evalContextType())
     , m_hasTailCalls(cachedCodeBlock.hasTailCalls())
+    , m_codeType(cachedCodeBlock.codeType())
+
+    , m_features(cachedCodeBlock.features())
+    , m_parseMode(cachedCodeBlock.parseMode())
+
     , m_lineCount(cachedCodeBlock.lineCount())
     , m_endColumn(cachedCodeBlock.endColumn())
     , m_numVars(cachedCodeBlock.numVars())
     , m_numCalleeLocals(cachedCodeBlock.numCalleeLocals())
     , m_numParameters(cachedCodeBlock.numParameters())
-    , m_features(cachedCodeBlock.features())
-    , m_parseMode(cachedCodeBlock.parseMode())
-    , m_codeType(cachedCodeBlock.codeType())
+
+    , m_sourceURLDirective(cachedCodeBlock.sourceURLDirective(decoder))
+    , m_sourceMappingURLDirective(cachedCodeBlock.sourceMappingURLDirective(decoder))
+
+    , m_metadata(cachedCodeBlock.metadata(decoder))
+    , m_instructions(cachedCodeBlock.instructions(decoder))
+
     , m_rareData(cachedCodeBlock.rareData(decoder))
 {
 }
@@ -1740,9 +1743,7 @@
     m_expressionInfo.decode(decoder, codeBlock.m_expressionInfo);
     m_outOfLineJumpTargets.decode(decoder, codeBlock.m_outOfLineJumpTargets);
     m_jumpTargets.decode(decoder, codeBlock.m_jumpTargets);
-    m_constantIdentifierSets.decode(decoder, codeBlock.m_constantIdentifierSets);
     m_identifiers.decode(decoder, codeBlock.m_identifiers);
-    m_bitVectors.decode(decoder, codeBlock.m_bitVectors);
     m_functionDecls.decode(decoder, codeBlock.m_functionDecls, &codeBlock);
     m_functionExprs.decode(decoder, codeBlock.m_functionExprs, &codeBlock);
 }
@@ -1856,7 +1857,6 @@
 {
     m_thisRegister = codeBlock.m_thisRegister;
     m_scopeRegister = codeBlock.m_scopeRegister;
-    m_globalObjectRegister = codeBlock.m_globalObjectRegister;
     m_usesEval = codeBlock.m_usesEval;
     m_isStrictMode = codeBlock.m_isStrictMode;
     m_isConstructor = codeBlock.m_isConstructor;
@@ -1897,9 +1897,7 @@
     m_jumpTargets.encode(encoder, codeBlock.m_jumpTargets);
     m_outOfLineJumpTargets.encode(encoder, codeBlock.m_outOfLineJumpTargets);
 
-    m_constantIdentifierSets.encode(encoder, codeBlock.m_constantIdentifierSets);
     m_identifiers.encode(encoder, codeBlock.m_identifiers);
-    m_bitVectors.encode(encoder, codeBlock.m_bitVectors);
     m_functionDecls.encode(encoder, codeBlock.m_functionDecls);
     m_functionExprs.encode(encoder, codeBlock.m_functionExprs);
 }

Modified: trunk/Source/WTF/ChangeLog (240980 => 240981)


--- trunk/Source/WTF/ChangeLog	2019-02-05 18:23:51 UTC (rev 240980)
+++ trunk/Source/WTF/ChangeLog	2019-02-05 18:28:33 UTC (rev 240981)
@@ -1,3 +1,12 @@
+2019-02-05  Yusuke Suzuki  <[email protected]>
+
+        [JSC] Shrink sizeof(UnlinkedCodeBlock)
+        https://bugs.webkit.org/show_bug.cgi?id=194281
+
+        Reviewed by Michael Saboff.
+
+        * wtf/TriState.h:
+
 2019-02-05  Zan Dobersek  <[email protected]>
 
         [GLib] Stop URI-escaping file system representations

Modified: trunk/Source/WTF/wtf/TriState.h (240980 => 240981)


--- trunk/Source/WTF/wtf/TriState.h	2019-02-05 18:23:51 UTC (rev 240980)
+++ trunk/Source/WTF/wtf/TriState.h	2019-02-05 18:28:33 UTC (rev 240981)
@@ -27,7 +27,7 @@
 
 namespace WTF {
 
-enum TriState : int8_t {
+enum TriState : uint8_t {
     FalseTriState,
     TrueTriState,
     MixedTriState
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to