⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 244578 in webkit


Ignore:
Timestamp:
Apr 23, 2019, 6:50:50 PM (7 years ago)
Author:
ysuzuki@apple.com
Message:

[JSC] Use node index as DFG::MinifiedID
https://bugs.webkit.org/show_bug.cgi?id=197186

Reviewed by Saam Barati.

DFG Nodes can be identified with index if the graph is given. We should use unsigned index as a DFG::MinifiedID's underlying
source instead of Node* to reduce the size of VariableEvent from 16 to 12. Vector<VariableEvent> is the main data in DFG's OSR
tracking. It is kept after DFG compilation is done to make OSR work. We saw that this is allocated with large size in GMail.

  • JavaScriptCore.xcodeproj/project.pbxproj:
  • bytecode/DataFormat.h:
  • bytecode/ValueRecovery.h:
  • dfg/DFGGenerationInfo.h:
  • dfg/DFGMinifiedID.h:

(JSC::DFG::MinifiedID::MinifiedID):
(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::fromBits):
(JSC::DFG::MinifiedID::bits const):
(JSC::DFG::MinifiedID::invalidIndex):
(JSC::DFG::MinifiedID::otherInvalidIndex):
(JSC::DFG::MinifiedID::node const): Deleted.
(JSC::DFG::MinifiedID::invalidID): Deleted.
(JSC::DFG::MinifiedID::otherInvalidID): Deleted.

  • dfg/DFGMinifiedIDInlines.h: Copied from Source/JavaScriptCore/dfg/DFGMinifiedNode.cpp.

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

  • dfg/DFGMinifiedNode.cpp:
  • dfg/DFGValueSource.h:

(JSC::DFG::ValueSource::ValueSource):

  • dfg/DFGVariableEvent.h:

(JSC::DFG::VariableEvent::dataFormat const):

Location:
trunk/Source/JavaScriptCore
Files:
9 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r244575 r244578  
     12019-04-23  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Use node index as DFG::MinifiedID
     4        https://bugs.webkit.org/show_bug.cgi?id=197186
     5
     6        Reviewed by Saam Barati.
     7
     8        DFG Nodes can be identified with index if the graph is given. We should use unsigned index as a DFG::MinifiedID's underlying
     9        source instead of Node* to reduce the size of VariableEvent from 16 to 12. Vector<VariableEvent> is the main data in DFG's OSR
     10        tracking. It is kept after DFG compilation is done to make OSR work. We saw that this is allocated with large size in GMail.
     11
     12        * JavaScriptCore.xcodeproj/project.pbxproj:
     13        * bytecode/DataFormat.h:
     14        * bytecode/ValueRecovery.h:
     15        * dfg/DFGGenerationInfo.h:
     16        * dfg/DFGMinifiedID.h:
     17        (JSC::DFG::MinifiedID::MinifiedID):
     18        (JSC::DFG::MinifiedID::operator! const):
     19        (JSC::DFG::MinifiedID::operator== const):
     20        (JSC::DFG::MinifiedID::operator!= const):
     21        (JSC::DFG::MinifiedID::operator< const):
     22        (JSC::DFG::MinifiedID::operator> const):
     23        (JSC::DFG::MinifiedID::operator<= const):
     24        (JSC::DFG::MinifiedID::operator>= const):
     25        (JSC::DFG::MinifiedID::hash const):
     26        (JSC::DFG::MinifiedID::dump const):
     27        (JSC::DFG::MinifiedID::isHashTableDeletedValue const):
     28        (JSC::DFG::MinifiedID::fromBits):
     29        (JSC::DFG::MinifiedID::bits const):
     30        (JSC::DFG::MinifiedID::invalidIndex):
     31        (JSC::DFG::MinifiedID::otherInvalidIndex):
     32        (JSC::DFG::MinifiedID::node const): Deleted.
     33        (JSC::DFG::MinifiedID::invalidID): Deleted.
     34        (JSC::DFG::MinifiedID::otherInvalidID): Deleted.
     35        * dfg/DFGMinifiedIDInlines.h: Copied from Source/JavaScriptCore/dfg/DFGMinifiedNode.cpp.
     36        (JSC::DFG::MinifiedID::MinifiedID):
     37        * dfg/DFGMinifiedNode.cpp:
     38        * dfg/DFGValueSource.h:
     39        (JSC::DFG::ValueSource::ValueSource):
     40        * dfg/DFGVariableEvent.h:
     41        (JSC::DFG::VariableEvent::dataFormat const):
     42
    1432019-04-23  Keith Rollin  <krollin@apple.com>
    244
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r244575 r244578  
    17841784                E36CC9472086314F0051FFD6 /* WasmCreationMode.h in Headers */ = {isa = PBXBuildFile; fileRef = E36CC9462086314F0051FFD6 /* WasmCreationMode.h */; settings = {ATTRIBUTES = (Private, ); }; };
    17851785                E3794E761B77EB97005543AE /* ModuleAnalyzer.h in Headers */ = {isa = PBXBuildFile; fileRef = E3794E741B77EB97005543AE /* ModuleAnalyzer.h */; settings = {ATTRIBUTES = (Private, ); }; };
     1786                E3850B15226ED641009ABF9C /* DFGMinifiedIDInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = E3850B14226ED63E009ABF9C /* DFGMinifiedIDInlines.h */; };
    17861787                E3893A1D2203A7C600E79A74 /* AsyncFromSyncIteratorPrototype.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = E3893A1C2203A7C600E79A74 /* AsyncFromSyncIteratorPrototype.lut.h */; };
    17871788                E38D999C221B78BB00D50474 /* JSNonDestructibleProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = E38D999A221B789F00D50474 /* JSNonDestructibleProxy.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    47824783                E380A76B1DCD7195000F89E6 /* MacroAssemblerHelpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacroAssemblerHelpers.h; sourceTree = "<group>"; };
    47834784                E380D66B1F19249D00A59095 /* BuiltinNames.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BuiltinNames.cpp; sourceTree = "<group>"; };
     4785                E3850B14226ED63E009ABF9C /* DFGMinifiedIDInlines.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = DFGMinifiedIDInlines.h; path = dfg/DFGMinifiedIDInlines.h; sourceTree = "<group>"; };
    47844786                E3893A1C2203A7C600E79A74 /* AsyncFromSyncIteratorPrototype.lut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AsyncFromSyncIteratorPrototype.lut.h; sourceTree = "<group>"; };
    47854787                E38D060B1F8E814100649CF2 /* JSScriptFetchParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSScriptFetchParameters.h; sourceTree = "<group>"; };
     
    60036005                                0F7C5FB71D888A010044F5E2 /* MarkedBlockInlines.h */,
    60046006                                141448CA13A176EC00F5BA1A /* MarkedBlockSet.h */,
     6007                                33B2A54522651D53005A0F79 /* MarkedSpace.cpp */,
    60056008                                14D2F3D9139F4BE200491031 /* MarkedSpace.h */,
    60066009                                0F7DF1301E2970D50095951B /* MarkedSpaceInlines.h */,
    6007                                 33B2A54522651D53005A0F79 /* MarkedSpace.cpp */,
    60086010                                0F660E331E0517B70031462C /* MarkingConstraint.cpp */,
    60096011                                0F660E341E0517B70031462C /* MarkingConstraint.h */,
     
    75997601                                0F2BDC3D1522801700CD8910 /* DFGMinifiedGraph.h */,
    76007602                                0FB4B51016B3A964003F696B /* DFGMinifiedID.h */,
     7603                                E3850B14226ED63E009ABF9C /* DFGMinifiedIDInlines.h */,
    76017604                                0F2BDC4C1522818300CD8910 /* DFGMinifiedNode.cpp */,
    76027605                                0F2BDC3E1522801700CD8910 /* DFGMinifiedNode.h */,
     
    85228525                                0FB3878E1BFBC44D00E3AB1E /* AirBlockWorklist.h in Headers */,
    85238526                                0F79C7CA1E74C93B00EB34D1 /* AirBreakCriticalEdges.h in Headers */,
    8524                                 33B2A54722653481005A0F79 /* B3ValueInlines.h in Headers */,
    85258527                                0F61832A1C45BF070072450B /* AirCCallingConvention.h in Headers */,
    85268528                                0FEC85741BDACDC70080FF74 /* AirCCallSpecial.h in Headers */,
     
    87158717                                0FEC85421BDACDAC0080FF74 /* B3Validate.h in Headers */,
    87168718                                0FEC85441BDACDAC0080FF74 /* B3Value.h in Headers */,
     8719                                33B2A54722653481005A0F79 /* B3ValueInlines.h in Headers */,
    87178720                                0F338E151BF0276C0013C88F /* B3ValueKey.h in Headers */,
    87188721                                0F338E161BF0276C0013C88F /* B3ValueKeyInlines.h in Headers */,
     
    89688971                                0F2BDC451522801B00CD8910 /* DFGMinifiedGraph.h in Headers */,
    89698972                                0F2E892D16D02BAF009E4FD2 /* DFGMinifiedID.h in Headers */,
     8973                                E3850B15226ED641009ABF9C /* DFGMinifiedIDInlines.h in Headers */,
    89708974                                0F2BDC461522802000CD8910 /* DFGMinifiedNode.h in Headers */,
    89718975                                0F8F14361ADF090100ED792C /* DFGMovHintRemovalPhase.h in Headers */,
     
    1071910723                                5333BBDB2110F7D2007618EC /* DFGSpeculativeJIT32_64.cpp in Sources */,
    1072010724                                5333BBDD2110F7E1007618EC /* DFGSpeculativeJIT64.cpp in Sources */,
     10725                                33B2A548226543BF005A0F79 /* FTLLowerDFGToB3.cpp in Sources */,
    1072110726                                536B319E1F735F160037FC33 /* LowLevelInterpreter.cpp in Sources */,
    1072210727                                0FF4274A158EBE91004CB9FF /* udis86.c in Sources */,
     
    1085210857                                536B31261F71C5990037FC33 /* UnifiedSource120.cpp in Sources */,
    1085310858                                536B312D1F71C5990037FC33 /* UnifiedSource121.cpp in Sources */,
    10854                                 33B2A548226543BF005A0F79 /* FTLLowerDFGToB3.cpp in Sources */,
    1085510859                                536B31251F71C5990037FC33 /* UnifiedSource122.cpp in Sources */,
    1085610860                                536B311E1F71C5990037FC33 /* UnifiedSource123.cpp in Sources */,
  • trunk/Source/JavaScriptCore/bytecode/DataFormat.h

    r235106 r244578  
    3636// For boxed values, we may know the type of boxing that has taken place.
    3737// (May also need bool, array, object, string types!)
    38 enum DataFormat {
     38enum DataFormat : uint8_t {
    3939    DataFormatNone = 0,
    4040    DataFormatInt32 = 1,
  • trunk/Source/JavaScriptCore/bytecode/ValueRecovery.h

    r207475 r244578  
    420420        int virtualReg;
    421421        EncodedJSValue constant;
    422         uintptr_t nodeID;
     422        unsigned nodeID;
    423423    } m_source;
    424424};
  • trunk/Source/JavaScriptCore/dfg/DFGGenerationInfo.h

    r218794 r244578  
    2828#if ENABLE(DFG_JIT)
    2929
    30 #include "DFGMinifiedID.h"
     30#include "DFGMinifiedIDInlines.h"
    3131#include "DFGVariableEvent.h"
    3232#include "DFGVariableEventStream.h"
  • trunk/Source/JavaScriptCore/dfg/DFGMinifiedID.h

    r206525 r244578  
    3939class MinifiedID {
    4040public:
    41     MinifiedID() : m_id(invalidID()) { }
    42     MinifiedID(WTF::HashTableDeletedValueType) : m_id(otherInvalidID()) { }
    43     explicit MinifiedID(Node* node) : m_id(bitwise_cast<uintptr_t>(node)) { }
     41    MinifiedID() = default;
     42    MinifiedID(WTF::HashTableDeletedValueType) : m_index(otherInvalidIndex()) { }
     43    explicit MinifiedID(Node* node);
    4444   
    45     bool operator!() const { return m_id == invalidID(); }
     45    bool operator!() const { return m_index == invalidIndex(); }
    4646   
    47     // This takes Graph& to remind you, that you should only be calling this method
    48     // when you're in the main compilation pass (i.e. you have a graph) and not later,
    49     // like during OSR exit compilation.
    50     Node* node(const Graph&) const { return bitwise_cast<Node*>(m_id); }
     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; }
    5153   
    52     bool operator==(const MinifiedID& other) const { return m_id == other.m_id; }
    53     bool operator!=(const MinifiedID& other) const { return m_id != other.m_id; }
    54     bool operator<(const MinifiedID& other) const { return m_id < other.m_id; }
    55     bool operator>(const MinifiedID& other) const { return m_id > other.m_id; }
    56     bool operator<=(const MinifiedID& other) const { return m_id <= other.m_id; }
    57     bool operator>=(const MinifiedID& other) const { return m_id >= other.m_id; }
     54    unsigned hash() const { return WTF::IntHash<unsigned>::hash(m_index); }
    5855   
    59     unsigned hash() const { return WTF::IntHash<uintptr_t>::hash(m_id); }
     56    void dump(PrintStream& out) const { out.print(m_index); }
    6057   
    61     void dump(PrintStream& out) const { out.print(RawPointer(reinterpret_cast<void*>(m_id))); }
     58    bool isHashTableDeletedValue() const { return m_index == otherInvalidIndex(); }
    6259   
    63     bool isHashTableDeletedValue() const { return m_id == otherInvalidID(); }
    64    
    65     static MinifiedID fromBits(uintptr_t value)
     60    static MinifiedID fromBits(unsigned value)
    6661    {
    6762        MinifiedID result;
    68         result.m_id = value;
     63        result.m_index = value;
    6964        return result;
    7065    }
    7166   
    72     uintptr_t bits() const { return m_id; }
     67    unsigned bits() const { return m_index; }
    7368
    7469private:
    7570    friend class MinifiedNode;
    7671   
    77     static uintptr_t invalidID() { return static_cast<uintptr_t>(static_cast<intptr_t>(-1)); }
    78     static uintptr_t otherInvalidID() { return static_cast<uintptr_t>(static_cast<intptr_t>(-2)); }
     72    static constexpr unsigned invalidIndex() { return static_cast<unsigned>(-1); }
     73    static constexpr unsigned otherInvalidIndex() { return static_cast<unsigned>(-2); }
    7974   
    80     uintptr_t m_id;
     75    unsigned m_index { invalidIndex() };
    8176};
    8277
  • trunk/Source/JavaScriptCore/dfg/DFGMinifiedIDInlines.h

    r244577 r244578  
    11/*
    2  * Copyright (C) 2012-2015 Apple Inc. All rights reserved.
     2 * Copyright (C) 2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2121 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    2222 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
     23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2424 */
    2525
    26 #include "config.h"
    27 #include "DFGMinifiedNode.h"
     26#pragma once
    2827
    29 #if ENABLE(DFG_JIT)
     28#include "DFGMinifiedID.h"
    3029
    3130#include "DFGNode.h"
    32 #include "JSCInlines.h"
    3331
    34 namespace JSC { namespace DFG {
     32namespace JSC {
     33namespace DFG {
    3534
    36 MinifiedNode MinifiedNode::fromNode(Node* node)
     35inline MinifiedID::MinifiedID(Node* node)
     36    : m_index(node->index())
    3737{
    38     ASSERT(belongsInMinifiedGraph(node->op()));
    39     MinifiedNode result;
    40     result.m_id = MinifiedID(node);
    41     result.m_op = node->op();
    42     if (hasConstant(node->op()))
    43         result.m_info = JSValue::encode(node->asJSValue());
    44     else {
    45         ASSERT(node->op() == PhantomDirectArguments || node->op() == PhantomClonedArguments);
    46         result.m_info = bitwise_cast<uintptr_t>(node->origin.semantic.inlineCallFrame());
    47     }
    48     return result;
     38    RELEASE_ASSERT(m_index != invalidIndex() && m_index != otherInvalidIndex());
    4939}
    5040
    5141} } // namespace JSC::DFG
    52 
    53 #endif // ENABLE(DFG_JIT)
    54 
  • trunk/Source/JavaScriptCore/dfg/DFGMinifiedNode.cpp

    r243232 r244578  
    2929#if ENABLE(DFG_JIT)
    3030
     31#include "DFGMinifiedIDInlines.h"
    3132#include "DFGNode.h"
    3233#include "JSCInlines.h"
  • trunk/Source/JavaScriptCore/dfg/DFGValueSource.h

    r218794 r244578  
    126126    ValueSource(ValueSourceKind valueSourceKind, VirtualRegister where)
    127127        : m_kind(valueSourceKind)
    128         , m_value(static_cast<intptr_t>(where.offset()))
     128        , m_value(where.offset())
    129129    {
    130130        ASSERT(kind() != SourceNotSet);
     
    209209private:
    210210    ValueSourceKind m_kind;
    211     uintptr_t m_value;
     211    unsigned m_value;
    212212};
    213213
  • trunk/Source/JavaScriptCore/dfg/DFGVariableEvent.h

    r218794 r244578  
    199199            m_kind == BirthToFill || m_kind == Fill || m_kind == BirthToSpill || m_kind == Spill
    200200            || m_kind == SetLocalEvent);
    201         return static_cast<DataFormat>(m_dataFormat);
     201        return m_dataFormat;
    202202    }
    203203   
     
    263263    union {
    264264        int virtualReg;
    265         uintptr_t id;
     265        unsigned id;
    266266    } m_which;
    267267   
     
    277277   
    278278    int8_t m_kind;
    279     int8_t m_dataFormat;
     279    DataFormat m_dataFormat { DataFormatNone };
    280280};
    281281
Note: See TracChangeset for help on using the changeset viewer.