Changeset 245270 in webkit


Ignore:
Timestamp:
May 13, 2019 7:34:28 PM (5 years ago)
Author:
ysuzuki@apple.com
Message:

[JSC] Compress JIT related data more by using Packed<>
https://bugs.webkit.org/show_bug.cgi?id=197866

Reviewed by Saam Barati.

This patch leverages Packed<> more to reduce JIT related data size. When we measure memory usage on Gmail, we found that a lot of memory is
consumed in DFG data. This patch attempts to reduce that size by using Packed<> to make various data structure's alignment 1.

  • dfg/DFGCommonData.cpp:

(JSC::DFG::CommonData::shrinkToFit): Add more shrinkToFit.

  • dfg/DFGMinifiedID.h: Make alignment = 1.

(JSC::DFG::MinifiedID::operator! const):
(JSC::DFG::MinifiedID::operator== const):
(JSC::DFG::MinifiedID::operator!= const):
(JSC::DFG::MinifiedID::operator< const):
(JSC::DFG::MinifiedID::operator> const):
(JSC::DFG::MinifiedID::operator<= const):
(JSC::DFG::MinifiedID::operator>= const):
(JSC::DFG::MinifiedID::hash const):
(JSC::DFG::MinifiedID::dump const):
(JSC::DFG::MinifiedID::isHashTableDeletedValue const):
(JSC::DFG::MinifiedID::bits const):

  • dfg/DFGMinifiedIDInlines.h:

(JSC::DFG::MinifiedID::MinifiedID):

  • dfg/DFGMinifiedNode.cpp:

(JSC::DFG::MinifiedNode::fromNode): Make sizeof(MinifiedNode) from 16 to 13 with alignment = 1.

  • dfg/DFGMinifiedNode.h:

(JSC::DFG::MinifiedNode::id const):
(JSC::DFG::MinifiedNode::hasConstant const):
(JSC::DFG::MinifiedNode::constant const):
(JSC::DFG::MinifiedNode::isPhantomDirectArguments const):
(JSC::DFG::MinifiedNode::isPhantomClonedArguments const):
(JSC::DFG::MinifiedNode::hasInlineCallFrame const):
(JSC::DFG::MinifiedNode::inlineCallFrame const):
(JSC::DFG::MinifiedNode::op const): Deleted.
(JSC::DFG::MinifiedNode::hasInlineCallFrame): Deleted.

  • dfg/DFGVariableEvent.h: Make sizeof(VariableEvent) from 12 to 10 with alignment = 1.

(JSC::DFG::VariableEvent::fillGPR):
(JSC::DFG::VariableEvent::fillPair):
(JSC::DFG::VariableEvent::fillFPR):
(JSC::DFG::VariableEvent::birth):
(JSC::DFG::VariableEvent::spill):
(JSC::DFG::VariableEvent::death):
(JSC::DFG::VariableEvent::setLocal):
(JSC::DFG::VariableEvent::movHint):
(JSC::DFG::VariableEvent::id const):
(JSC::DFG::VariableEvent::gpr const):
(JSC::DFG::VariableEvent::tagGPR const):
(JSC::DFG::VariableEvent::payloadGPR const):
(JSC::DFG::VariableEvent::fpr const):
(JSC::DFG::VariableEvent::spillRegister const):
(JSC::DFG::VariableEvent::bytecodeRegister const):
(JSC::DFG::VariableEvent::machineRegister const):
(JSC::DFG::VariableEvent::variableRepresentation const):

  • dfg/DFGVariableEventStream.cpp:

(JSC::DFG::tryToSetConstantRecovery):

Location:
trunk/Source/JavaScriptCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r245258 r245270  
     12019-05-13  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Compress JIT related data more by using Packed<>
     4        https://bugs.webkit.org/show_bug.cgi?id=197866
     5
     6        Reviewed by Saam Barati.
     7
     8        This patch leverages Packed<> more to reduce JIT related data size. When we measure memory usage on Gmail, we found that a lot of memory is
     9        consumed in DFG data. This patch attempts to reduce that size by using Packed<> to make various data structure's alignment 1.
     10
     11        * dfg/DFGCommonData.cpp:
     12        (JSC::DFG::CommonData::shrinkToFit): Add more shrinkToFit.
     13        * dfg/DFGMinifiedID.h: Make alignment = 1.
     14        (JSC::DFG::MinifiedID::operator! const):
     15        (JSC::DFG::MinifiedID::operator== const):
     16        (JSC::DFG::MinifiedID::operator!= const):
     17        (JSC::DFG::MinifiedID::operator< const):
     18        (JSC::DFG::MinifiedID::operator> const):
     19        (JSC::DFG::MinifiedID::operator<= const):
     20        (JSC::DFG::MinifiedID::operator>= const):
     21        (JSC::DFG::MinifiedID::hash const):
     22        (JSC::DFG::MinifiedID::dump const):
     23        (JSC::DFG::MinifiedID::isHashTableDeletedValue const):
     24        (JSC::DFG::MinifiedID::bits const):
     25        * dfg/DFGMinifiedIDInlines.h:
     26        (JSC::DFG::MinifiedID::MinifiedID):
     27        * dfg/DFGMinifiedNode.cpp:
     28        (JSC::DFG::MinifiedNode::fromNode): Make sizeof(MinifiedNode) from 16 to 13 with alignment = 1.
     29        * dfg/DFGMinifiedNode.h:
     30        (JSC::DFG::MinifiedNode::id const):
     31        (JSC::DFG::MinifiedNode::hasConstant const):
     32        (JSC::DFG::MinifiedNode::constant const):
     33        (JSC::DFG::MinifiedNode::isPhantomDirectArguments const):
     34        (JSC::DFG::MinifiedNode::isPhantomClonedArguments const):
     35        (JSC::DFG::MinifiedNode::hasInlineCallFrame const):
     36        (JSC::DFG::MinifiedNode::inlineCallFrame const):
     37        (JSC::DFG::MinifiedNode::op const): Deleted.
     38        (JSC::DFG::MinifiedNode::hasInlineCallFrame): Deleted.
     39        * dfg/DFGVariableEvent.h: Make sizeof(VariableEvent) from 12 to 10 with alignment = 1.
     40        (JSC::DFG::VariableEvent::fillGPR):
     41        (JSC::DFG::VariableEvent::fillPair):
     42        (JSC::DFG::VariableEvent::fillFPR):
     43        (JSC::DFG::VariableEvent::birth):
     44        (JSC::DFG::VariableEvent::spill):
     45        (JSC::DFG::VariableEvent::death):
     46        (JSC::DFG::VariableEvent::setLocal):
     47        (JSC::DFG::VariableEvent::movHint):
     48        (JSC::DFG::VariableEvent::id const):
     49        (JSC::DFG::VariableEvent::gpr const):
     50        (JSC::DFG::VariableEvent::tagGPR const):
     51        (JSC::DFG::VariableEvent::payloadGPR const):
     52        (JSC::DFG::VariableEvent::fpr const):
     53        (JSC::DFG::VariableEvent::spillRegister const):
     54        (JSC::DFG::VariableEvent::bytecodeRegister const):
     55        (JSC::DFG::VariableEvent::machineRegister const):
     56        (JSC::DFG::VariableEvent::variableRepresentation const):
     57        * dfg/DFGVariableEventStream.cpp:
     58        (JSC::DFG::tryToSetConstantRecovery):
     59
    1602019-05-13  Yusuke Suzuki  <ysuzuki@apple.com>
    261
  • trunk/Source/JavaScriptCore/dfg/DFGCommonData.cpp

    r241613 r245270  
    8686{
    8787    codeOrigins.shrinkToFit();
     88    dfgIdentifiers.shrinkToFit();
    8889    weakReferences.shrinkToFit();
     90    weakStructureReferences.shrinkToFit();
    8991    transitions.shrinkToFit();
    9092    catchEntrypoints.shrinkToFit();
     93    jumpReplacements.shrinkToFit();
    9194}
    9295
  • trunk/Source/JavaScriptCore/dfg/DFGMinifiedID.h

    r244578 r245270  
    4343    explicit MinifiedID(Node* node);
    4444   
    45     bool operator!() const { return m_index == invalidIndex(); }
     45    bool operator!() const { return m_index.get() == invalidIndex(); }
    4646   
    47     bool operator==(const MinifiedID& other) const { return m_index == other.m_index; }
    48     bool operator!=(const MinifiedID& other) const { return m_index != other.m_index; }
    49     bool operator<(const MinifiedID& other) const { return m_index < other.m_index; }
    50     bool operator>(const MinifiedID& other) const { return m_index > other.m_index; }
    51     bool operator<=(const MinifiedID& other) const { return m_index <= other.m_index; }
    52     bool operator>=(const MinifiedID& other) const { return m_index >= other.m_index; }
     47    bool operator==(const MinifiedID& other) const { return m_index.get() == other.m_index.get(); }
     48    bool operator!=(const MinifiedID& other) const { return m_index.get() != other.m_index.get(); }
     49    bool operator<(const MinifiedID& other) const { return m_index.get() < other.m_index.get(); }
     50    bool operator>(const MinifiedID& other) const { return m_index.get() > other.m_index.get(); }
     51    bool operator<=(const MinifiedID& other) const { return m_index.get() <= other.m_index.get(); }
     52    bool operator>=(const MinifiedID& other) const { return m_index.get() >= other.m_index.get(); }
    5353   
    54     unsigned hash() const { return WTF::IntHash<unsigned>::hash(m_index); }
     54    unsigned hash() const { return WTF::IntHash<unsigned>::hash(m_index.get()); }
    5555   
    56     void dump(PrintStream& out) const { out.print(m_index); }
     56    void dump(PrintStream& out) const { out.print(m_index.get()); }
    5757   
    58     bool isHashTableDeletedValue() const { return m_index == otherInvalidIndex(); }
     58    bool isHashTableDeletedValue() const { return m_index.get() == otherInvalidIndex(); }
    5959   
    6060    static MinifiedID fromBits(unsigned value)
     
    6565    }
    6666   
    67     unsigned bits() const { return m_index; }
     67    unsigned bits() const { return m_index.get(); }
    6868
    6969private:
     
    7373    static constexpr unsigned otherInvalidIndex() { return static_cast<unsigned>(-2); }
    7474   
    75     unsigned m_index { invalidIndex() };
     75    Packed<unsigned> m_index { invalidIndex() };
    7676};
    7777
  • trunk/Source/JavaScriptCore/dfg/DFGMinifiedIDInlines.h

    r244578 r245270  
    3636    : m_index(node->index())
    3737{
    38     RELEASE_ASSERT(m_index != invalidIndex() && m_index != otherInvalidIndex());
     38    RELEASE_ASSERT(m_index.get() != invalidIndex() && m_index.get() != otherInvalidIndex());
    3939}
    4040
  • trunk/Source/JavaScriptCore/dfg/DFGMinifiedNode.cpp

    r244578 r245270  
    4040    MinifiedNode result;
    4141    result.m_id = MinifiedID(node);
    42     result.m_op = node->op();
     42    result.m_hasConstant = hasConstant(node->op());
     43    result.m_isPhantomDirectArguments = node->op() == PhantomDirectArguments;
     44    result.m_isPhantomClonedArguments = node->op() == PhantomClonedArguments;
    4345    if (hasConstant(node->op()))
    4446        result.m_info = JSValue::encode(node->asJSValue());
  • trunk/Source/JavaScriptCore/dfg/DFGMinifiedNode.h

    r244580 r245270  
    5858   
    5959    MinifiedID id() const { return m_id; }
    60     NodeType op() const { return m_op; }
    6160   
    62     bool hasConstant() const { return hasConstant(m_op); }
     61    bool hasConstant() const { return m_hasConstant; }
    6362   
    6463    JSValue constant() const
    6564    {
    66         return JSValue::decode(bitwise_cast<EncodedJSValue>(m_info));
     65        return JSValue::decode(bitwise_cast<EncodedJSValue>(m_info.get()));
    6766    }
    6867   
    69     bool hasInlineCallFrame() const { return hasInlineCallFrame(m_op); }
     68    bool isPhantomDirectArguments() const { return m_isPhantomDirectArguments; }
     69    bool isPhantomClonedArguments() const { return m_isPhantomClonedArguments; }
     70    bool hasInlineCallFrame() const { return m_isPhantomDirectArguments || m_isPhantomClonedArguments; }
    7071   
    7172    InlineCallFrame* inlineCallFrame() const
    7273    {
    73         return bitwise_cast<InlineCallFrame*>(static_cast<uintptr_t>(m_info));
     74        return bitwise_cast<InlineCallFrame*>(static_cast<uintptr_t>(m_info.get()));
    7475    }
    7576   
     
    8687    }
    8788   
    88     static bool hasInlineCallFrame(NodeType type)
    89     {
    90         return type == PhantomDirectArguments || type == PhantomClonedArguments;
    91     }
    92    
    93     uint64_t m_info;
     89    Packed<uint64_t> m_info;
    9490    MinifiedID m_id;
    95     NodeType m_op;
     91    bool m_hasConstant : 1;
     92    bool m_isPhantomDirectArguments : 1;
     93    bool m_isPhantomClonedArguments : 1;
    9694};
    9795
  • trunk/Source/JavaScriptCore/dfg/DFGVariableEvent.h

    r244578 r245270  
    3636namespace JSC { namespace DFG {
    3737
    38 enum VariableEventKind {
     38enum VariableEventKind : uint8_t {
    3939    // Marks the beginning of a checkpoint. If you interpret the variable
    4040    // events starting at a Reset point then you'll get everything you need.
     
    102102#endif
    103103        VariableEvent event;
    104         event.m_which.id = id.bits();
    105         event.m_representation.gpr = gpr;
     104        WhichType which;
     105        which.id = id.bits();
     106        VariableRepresentation representation;
     107        representation.gpr = gpr;
    106108        event.m_kind = kind;
    107109        event.m_dataFormat = dataFormat;
     110        event.m_which = WTFMove(which);
     111        event.m_representation = WTFMove(representation);
    108112        return event;
    109113    }
     
    114118        ASSERT(kind == BirthToFill || kind == Fill);
    115119        VariableEvent event;
    116         event.m_which.id = id.bits();
    117         event.m_representation.pair.tagGPR = tagGPR;
    118         event.m_representation.pair.payloadGPR = payloadGPR;
     120        WhichType which;
     121        which.id = id.bits();
     122        VariableRepresentation representation;
     123        representation.pair.tagGPR = tagGPR;
     124        representation.pair.payloadGPR = payloadGPR;
    119125        event.m_kind = kind;
    120126        event.m_dataFormat = DataFormatJS;
     127        event.m_which = WTFMove(which);
     128        event.m_representation = WTFMove(representation);
    121129        return event;
    122130    }
     
    127135        ASSERT(kind == BirthToFill || kind == Fill);
    128136        VariableEvent event;
    129         event.m_which.id = id.bits();
    130         event.m_representation.fpr = fpr;
     137        WhichType which;
     138        which.id = id.bits();
     139        VariableRepresentation representation;
     140        representation.fpr = fpr;
    131141        event.m_kind = kind;
    132142        event.m_dataFormat = DataFormatDouble;
     143        event.m_which = WTFMove(which);
     144        event.m_representation = WTFMove(representation);
    133145        return event;
    134146    }
     
    137149    {
    138150        VariableEvent event;
    139         event.m_which.id = id.bits();
     151        WhichType which;
     152        which.id = id.bits();
    140153        event.m_kind = Birth;
     154        event.m_which = WTFMove(which);
    141155        return event;
    142156    }
     
    146160        ASSERT(kind == BirthToSpill || kind == Spill);
    147161        VariableEvent event;
    148         event.m_which.id = id.bits();
    149         event.m_representation.virtualReg = virtualRegister.offset();
     162        WhichType which;
     163        which.id = id.bits();
     164        VariableRepresentation representation;
     165        representation.virtualReg = virtualRegister.offset();
    150166        event.m_kind = kind;
    151167        event.m_dataFormat = format;
     168        event.m_which = WTFMove(which);
     169        event.m_representation = WTFMove(representation);
    152170        return event;
    153171    }
     
    156174    {
    157175        VariableEvent event;
    158         event.m_which.id = id.bits();
     176        WhichType which;
     177        which.id = id.bits();
    159178        event.m_kind = Death;
     179        event.m_which = WTFMove(which);
    160180        return event;
    161181    }
     
    165185    {
    166186        VariableEvent event;
    167         event.m_which.virtualReg = machineReg.offset();
    168         event.m_representation.virtualReg = bytecodeReg.offset();
     187        WhichType which;
     188        which.virtualReg = machineReg.offset();
     189        VariableRepresentation representation;
     190        representation.virtualReg = bytecodeReg.offset();
    169191        event.m_kind = SetLocalEvent;
    170192        event.m_dataFormat = format;
     193        event.m_which = WTFMove(which);
     194        event.m_representation = WTFMove(representation);
    171195        return event;
    172196    }
     
    175199    {
    176200        VariableEvent event;
    177         event.m_which.id = id.bits();
    178         event.m_representation.virtualReg = bytecodeReg.offset();
     201        WhichType which;
     202        which.id = id.bits();
     203        VariableRepresentation representation;
     204        representation.virtualReg = bytecodeReg.offset();
    179205        event.m_kind = MovHintEvent;
     206        event.m_which = WTFMove(which);
     207        event.m_representation = WTFMove(representation);
    180208        return event;
    181209    }
     
    191219            m_kind == BirthToFill || m_kind == Fill || m_kind == BirthToSpill || m_kind == Spill
    192220            || m_kind == Death || m_kind == MovHintEvent || m_kind == Birth);
    193         return MinifiedID::fromBits(m_which.id);
     221        return MinifiedID::fromBits(m_which.get().id);
    194222    }
    195223   
     
    210238        ASSERT(!(m_dataFormat & DataFormatJS));
    211239#endif
    212         return m_representation.gpr;
     240        return m_representation.get().gpr;
    213241    }
    214242   
     
    218246        ASSERT(m_kind == BirthToFill || m_kind == Fill);
    219247        ASSERT(m_dataFormat & DataFormatJS);
    220         return m_representation.pair.tagGPR;
     248        return m_representation.get().pair.tagGPR;
    221249    }
    222250    MacroAssembler::RegisterID payloadGPR() const
     
    224252        ASSERT(m_kind == BirthToFill || m_kind == Fill);
    225253        ASSERT(m_dataFormat & DataFormatJS);
    226         return m_representation.pair.payloadGPR;
     254        return m_representation.get().pair.payloadGPR;
    227255    }
    228256#endif // USE(JSVALUE32_64)
     
    232260        ASSERT(m_kind == BirthToFill || m_kind == Fill);
    233261        ASSERT(m_dataFormat == DataFormatDouble);
    234         return m_representation.fpr;
     262        return m_representation.get().fpr;
    235263    }
    236264   
     
    238266    {
    239267        ASSERT(m_kind == BirthToSpill || m_kind == Spill);
    240         return VirtualRegister(m_representation.virtualReg);
     268        return VirtualRegister(m_representation.get().virtualReg);
    241269    }
    242270   
     
    244272    {
    245273        ASSERT(m_kind == SetLocalEvent || m_kind == MovHintEvent);
    246         return VirtualRegister(m_representation.virtualReg);
     274        return VirtualRegister(m_representation.get().virtualReg);
    247275    }
    248276   
     
    250278    {
    251279        ASSERT(m_kind == SetLocalEvent);
    252         return VirtualRegister(m_which.virtualReg);
    253     }
    254    
    255     const VariableRepresentation& variableRepresentation() const { return m_representation; }
     280        return VirtualRegister(m_which.get().virtualReg);
     281    }
     282   
     283    VariableRepresentation variableRepresentation() const { return m_representation.get(); }
    256284   
    257285    void dump(PrintStream&) const;
     
    261289    void dumpSpillInfo(const char* name, PrintStream&) const;
    262290   
    263     union {
     291    union WhichType {
    264292        int virtualReg;
    265293        unsigned id;
    266     } m_which;
     294    };
     295    Packed<WhichType> m_which;
    267296   
    268297    // For BirthToFill, Fill:
     
    274303    // For Death:
    275304    //   - Unused.
    276     VariableRepresentation m_representation;
    277    
    278     int8_t m_kind;
     305    Packed<VariableRepresentation> m_representation;
     306   
     307    VariableEventKind m_kind;
    279308    DataFormat m_dataFormat { DataFormatNone };
    280309};
  • trunk/Source/JavaScriptCore/dfg/DFGVariableEventStream.cpp

    r244764 r245270  
    102102    }
    103103   
    104     if (node->op() == PhantomDirectArguments) {
     104    if (node->isPhantomDirectArguments()) {
    105105        recovery = ValueRecovery::directArgumentsThatWereNotCreated(node->id());
    106106        return true;
    107107    }
    108108   
    109     if (node->op() == PhantomClonedArguments) {
     109    if (node->isPhantomClonedArguments()) {
    110110        recovery = ValueRecovery::clonedArgumentsThatWereNotCreated(node->id());
    111111        return true;
Note: See TracChangeset for help on using the changeset viewer.