Changeset 245239 in webkit


Ignore:
Timestamp:
May 13, 2019 10:32:31 AM (5 years ago)
Author:
ysuzuki@apple.com
Message:

[JSC] Compress miscelaneous JIT related data structures with Packed<>
https://bugs.webkit.org/show_bug.cgi?id=197830

Reviewed by Saam Barati.

Source/JavaScriptCore:

This patch leverages Packed<> to compress miscelaneous data structures related to JIT.

  1. JIT IC data structures
  1. ValueRecovery

We use Packed<> for EncodedJSValue in ValueRecovery. This means that conservative GC cannot find
these values. But this is OK anyway since ValueRecovery's constant should be already registered
in DFG graph. From 16 (alignment 8) to 9 (alignment 1).

  1. FTL::ExitValue

We use Packed<> for EncodedJSValue in FTL::ExitValue. This is also OK since this constant should
be already registered by DFG/FTL graph. From 16 (alignment 8) to 9 (alignment 1).

  • assembler/CodeLocation.h:
  • bytecode/ByValInfo.h:
  • bytecode/CallLinkInfo.cpp:

(JSC::CallLinkInfo::CallLinkInfo):
(JSC::CallLinkInfo::callReturnLocation):

  • bytecode/CallLinkInfo.h:

(JSC::CallLinkInfo::nearCallMode const):

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::addJITAddIC):
(JSC::CodeBlock::addJITMulIC):
(JSC::CodeBlock::addJITSubIC):
(JSC::CodeBlock::addJITNegIC):

  • bytecode/CodeBlock.h:

(JSC::CodeBlock::addMathIC):

  • bytecode/InlineCallFrame.h:

(JSC::InlineCallFrame::InlineCallFrame):

  • bytecode/ValueRecovery.h:

(JSC::ValueRecovery::inGPR):
(JSC::ValueRecovery::inPair):
(JSC::ValueRecovery::inFPR):
(JSC::ValueRecovery::displacedInJSStack):
(JSC::ValueRecovery::constant):
(JSC::ValueRecovery::directArgumentsThatWereNotCreated):
(JSC::ValueRecovery::clonedArgumentsThatWereNotCreated):
(JSC::ValueRecovery::gpr const):
(JSC::ValueRecovery::tagGPR const):
(JSC::ValueRecovery::payloadGPR const):
(JSC::ValueRecovery::fpr const):
(JSC::ValueRecovery::virtualRegister const):
(JSC::ValueRecovery::withLocalsOffset const):
(JSC::ValueRecovery::constant const):
(JSC::ValueRecovery::nodeID const):

  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::compileValueAdd):
(JSC::DFG::SpeculativeJIT::compileValueSub):
(JSC::DFG::SpeculativeJIT::compileValueNegate):
(JSC::DFG::SpeculativeJIT::compileValueMul):

  • ftl/FTLExitValue.cpp:

(JSC::FTL::ExitValue::materializeNewObject):

  • ftl/FTLExitValue.h:

(JSC::FTL::ExitValue::inJSStack):
(JSC::FTL::ExitValue::inJSStackAsInt32):
(JSC::FTL::ExitValue::inJSStackAsInt52):
(JSC::FTL::ExitValue::inJSStackAsDouble):
(JSC::FTL::ExitValue::constant):
(JSC::FTL::ExitValue::exitArgument):
(JSC::FTL::ExitValue::exitArgument const):
(JSC::FTL::ExitValue::adjustStackmapLocationsIndexByOffset):
(JSC::FTL::ExitValue::constant const):
(JSC::FTL::ExitValue::virtualRegister const):
(JSC::FTL::ExitValue::objectMaterialization const):
(JSC::FTL::ExitValue::withVirtualRegister const):

  • ftl/FTLLowerDFGToB3.cpp:

(JSC::FTL::DFG::LowerDFGToB3::compileValueAdd):
(JSC::FTL::DFG::LowerDFGToB3::compileValueSub):
(JSC::FTL::DFG::LowerDFGToB3::compileValueMul):
(JSC::FTL::DFG::LowerDFGToB3::compileUnaryMathIC):
(JSC::FTL::DFG::LowerDFGToB3::compileBinaryMathIC):
(JSC::FTL::DFG::LowerDFGToB3::compileArithAddOrSub):
(JSC::FTL::DFG::LowerDFGToB3::compileValueNegate):

  • jit/CachedRecovery.h:
  • jit/CallFrameShuffleData.h:
  • jit/JITArithmetic.cpp:

(JSC::JIT::emit_op_negate):
(JSC::JIT::emit_op_add):
(JSC::JIT::emit_op_mul):
(JSC::JIT::emit_op_sub):

  • jit/JITMathIC.h:

(JSC::isProfileEmpty):
(JSC::JITBinaryMathIC::JITBinaryMathIC):
(JSC::JITUnaryMathIC::JITUnaryMathIC):

  • jit/PolymorphicCallStubRoutine.h:

(JSC::PolymorphicCallNode::hasCallLinkInfo):

  • jit/SnippetOperand.h:

(JSC::SnippetOperand::asRawBits const):
(JSC::SnippetOperand::asConstInt32 const):
(JSC::SnippetOperand::asConstDouble const):
(JSC::SnippetOperand::setConstInt32):
(JSC::SnippetOperand::setConstDouble):

Source/WTF:

  • wtf/Packed.h:

(WTF::alignof):

Location:
trunk/Source
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r245214 r245239  
     12019-05-13  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Compress miscelaneous JIT related data structures with Packed<>
     4        https://bugs.webkit.org/show_bug.cgi?id=197830
     5
     6        Reviewed by Saam Barati.
     7
     8        This patch leverages Packed<> to compress miscelaneous data structures related to JIT.
     9
     10        1. JIT IC data structures
     11
     12        2. ValueRecovery
     13
     14            We use Packed<> for EncodedJSValue in ValueRecovery. This means that conservative GC cannot find
     15            these values. But this is OK anyway since ValueRecovery's constant should be already registered
     16            in DFG graph. From 16 (alignment 8) to 9 (alignment 1).
     17
     18        3. FTL::ExitValue
     19
     20            We use Packed<> for EncodedJSValue in FTL::ExitValue. This is also OK since this constant should
     21            be already registered by DFG/FTL graph. From 16 (alignment 8) to 9 (alignment 1).
     22
     23        * assembler/CodeLocation.h:
     24        * bytecode/ByValInfo.h:
     25        * bytecode/CallLinkInfo.cpp:
     26        (JSC::CallLinkInfo::CallLinkInfo):
     27        (JSC::CallLinkInfo::callReturnLocation):
     28        * bytecode/CallLinkInfo.h:
     29        (JSC::CallLinkInfo::nearCallMode const):
     30        * bytecode/CodeBlock.cpp:
     31        (JSC::CodeBlock::addJITAddIC):
     32        (JSC::CodeBlock::addJITMulIC):
     33        (JSC::CodeBlock::addJITSubIC):
     34        (JSC::CodeBlock::addJITNegIC):
     35        * bytecode/CodeBlock.h:
     36        (JSC::CodeBlock::addMathIC):
     37        * bytecode/InlineCallFrame.h:
     38        (JSC::InlineCallFrame::InlineCallFrame):
     39        * bytecode/ValueRecovery.h:
     40        (JSC::ValueRecovery::inGPR):
     41        (JSC::ValueRecovery::inPair):
     42        (JSC::ValueRecovery::inFPR):
     43        (JSC::ValueRecovery::displacedInJSStack):
     44        (JSC::ValueRecovery::constant):
     45        (JSC::ValueRecovery::directArgumentsThatWereNotCreated):
     46        (JSC::ValueRecovery::clonedArgumentsThatWereNotCreated):
     47        (JSC::ValueRecovery::gpr const):
     48        (JSC::ValueRecovery::tagGPR const):
     49        (JSC::ValueRecovery::payloadGPR const):
     50        (JSC::ValueRecovery::fpr const):
     51        (JSC::ValueRecovery::virtualRegister const):
     52        (JSC::ValueRecovery::withLocalsOffset const):
     53        (JSC::ValueRecovery::constant const):
     54        (JSC::ValueRecovery::nodeID const):
     55        * dfg/DFGSpeculativeJIT.cpp:
     56        (JSC::DFG::SpeculativeJIT::compileValueAdd):
     57        (JSC::DFG::SpeculativeJIT::compileValueSub):
     58        (JSC::DFG::SpeculativeJIT::compileValueNegate):
     59        (JSC::DFG::SpeculativeJIT::compileValueMul):
     60        * ftl/FTLExitValue.cpp:
     61        (JSC::FTL::ExitValue::materializeNewObject):
     62        * ftl/FTLExitValue.h:
     63        (JSC::FTL::ExitValue::inJSStack):
     64        (JSC::FTL::ExitValue::inJSStackAsInt32):
     65        (JSC::FTL::ExitValue::inJSStackAsInt52):
     66        (JSC::FTL::ExitValue::inJSStackAsDouble):
     67        (JSC::FTL::ExitValue::constant):
     68        (JSC::FTL::ExitValue::exitArgument):
     69        (JSC::FTL::ExitValue::exitArgument const):
     70        (JSC::FTL::ExitValue::adjustStackmapLocationsIndexByOffset):
     71        (JSC::FTL::ExitValue::constant const):
     72        (JSC::FTL::ExitValue::virtualRegister const):
     73        (JSC::FTL::ExitValue::objectMaterialization const):
     74        (JSC::FTL::ExitValue::withVirtualRegister const):
     75        * ftl/FTLLowerDFGToB3.cpp:
     76        (JSC::FTL::DFG::LowerDFGToB3::compileValueAdd):
     77        (JSC::FTL::DFG::LowerDFGToB3::compileValueSub):
     78        (JSC::FTL::DFG::LowerDFGToB3::compileValueMul):
     79        (JSC::FTL::DFG::LowerDFGToB3::compileUnaryMathIC):
     80        (JSC::FTL::DFG::LowerDFGToB3::compileBinaryMathIC):
     81        (JSC::FTL::DFG::LowerDFGToB3::compileArithAddOrSub):
     82        (JSC::FTL::DFG::LowerDFGToB3::compileValueNegate):
     83        * jit/CachedRecovery.h:
     84        * jit/CallFrameShuffleData.h:
     85        * jit/JITArithmetic.cpp:
     86        (JSC::JIT::emit_op_negate):
     87        (JSC::JIT::emit_op_add):
     88        (JSC::JIT::emit_op_mul):
     89        (JSC::JIT::emit_op_sub):
     90        * jit/JITMathIC.h:
     91        (JSC::isProfileEmpty):
     92        (JSC::JITBinaryMathIC::JITBinaryMathIC):
     93        (JSC::JITUnaryMathIC::JITUnaryMathIC):
     94        * jit/PolymorphicCallStubRoutine.h:
     95        (JSC::PolymorphicCallNode::hasCallLinkInfo):
     96        * jit/SnippetOperand.h:
     97        (JSC::SnippetOperand::asRawBits const):
     98        (JSC::SnippetOperand::asConstInt32 const):
     99        (JSC::SnippetOperand::asConstDouble const):
     100        (JSC::SnippetOperand::setConstInt32):
     101        (JSC::SnippetOperand::setConstDouble):
     102
    11032019-05-12  Yusuke Suzuki  <ysuzuki@apple.com>
    2104
  • trunk/Source/JavaScriptCore/assembler/CodeLocation.h

    r233070 r245239  
    3232namespace JSC {
    3333
    34 enum NearCallMode { Regular, Tail };
     34enum class NearCallMode : uint8_t { Regular, Tail };
    3535
    3636template<PtrTag> class CodeLocationInstruction;
     
    154154    NearCallMode callMode() { return m_callMode; }
    155155private:
    156     NearCallMode m_callMode = NearCallMode::Regular;
     156    NearCallMode m_callMode { NearCallMode::Regular };
    157157};
    158158
  • trunk/Source/JavaScriptCore/bytecode/ByValInfo.h

    r243232 r245239  
    4040class StructureStubInfo;
    4141
    42 enum JITArrayMode {
     42enum JITArrayMode : uint8_t {
    4343    JITInt32,
    4444    JITDouble,
  • trunk/Source/JavaScriptCore/bytecode/CallLinkInfo.cpp

    r243966 r245239  
    6464    , m_callType(None)
    6565    , m_calleeGPR(255)
    66     , m_maxNumArguments(0)
    67     , m_slowPathCount(0)
    6866{
    6967}
     
    10199{
    102100    RELEASE_ASSERT(!isDirect());
    103     return CodeLocationNearCall<JSInternalPtrTag>(m_callReturnLocationOrPatchableJump, Regular);
     101    return CodeLocationNearCall<JSInternalPtrTag>(m_callReturnLocationOrPatchableJump, NearCallMode::Regular);
    104102}
    105103
  • trunk/Source/JavaScriptCore/bytecode/CallLinkInfo.h

    r243626 r245239  
    4242struct CallFrameShuffleData;
    4343
    44 class CallLinkInfo : public BasicRawSentinelNode<CallLinkInfo> {
     44class CallLinkInfo : public PackedRawSentinelNode<CallLinkInfo> {
    4545public:
    4646    enum CallType {
     
    147147    NearCallMode nearCallMode() const
    148148    {
    149         return isTailCall() ? Tail : Regular;
     149        return isTailCall() ? NearCallMode::Tail : NearCallMode::Regular;
    150150    }
    151151
     
    348348
    349349private:
     350    uint32_t m_maxNumArguments { 0 }; // For varargs: the profiled maximum number of arguments. For direct: the number of stack slots allocated for arguments.
    350351    CodeLocationLabel<JSInternalPtrTag> m_callReturnLocationOrPatchableJump;
    351352    CodeLocationLabel<JSInternalPtrTag> m_hotPathBeginOrSlowPathStart;
     
    356357    RefPtr<JITStubRoutine> m_slowStub;
    357358    std::unique_ptr<CallFrameShuffleData> m_frameShuffleData;
     359    CodeOrigin m_codeOrigin;
    358360    bool m_hasSeenShouldRepatch : 1;
    359361    bool m_hasSeenClosure : 1;
     
    364366    unsigned m_callType : 4; // CallType
    365367    unsigned m_calleeGPR : 8;
    366     uint32_t m_maxNumArguments; // For varargs: the profiled maximum number of arguments. For direct: the number of stack slots allocated for arguments.
    367     uint32_t m_slowPathCount;
    368     CodeOrigin m_codeOrigin;
     368    uint32_t m_slowPathCount { 0 };
    369369};
    370370
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp

    r245213 r245239  
    14281428}
    14291429
    1430 JITAddIC* CodeBlock::addJITAddIC(ArithProfile* arithProfile, const Instruction* instruction)
     1430JITAddIC* CodeBlock::addJITAddIC(ArithProfile* arithProfile)
    14311431{
    14321432    ConcurrentJSLocker locker(m_lock);
    1433     return ensureJITData(locker).m_addICs.add(arithProfile, instruction);
    1434 }
    1435 
    1436 JITMulIC* CodeBlock::addJITMulIC(ArithProfile* arithProfile, const Instruction* instruction)
     1433    return ensureJITData(locker).m_addICs.add(arithProfile);
     1434}
     1435
     1436JITMulIC* CodeBlock::addJITMulIC(ArithProfile* arithProfile)
    14371437{
    14381438    ConcurrentJSLocker locker(m_lock);
    1439     return ensureJITData(locker).m_mulICs.add(arithProfile, instruction);
    1440 }
    1441 
    1442 JITSubIC* CodeBlock::addJITSubIC(ArithProfile* arithProfile, const Instruction* instruction)
     1439    return ensureJITData(locker).m_mulICs.add(arithProfile);
     1440}
     1441
     1442JITSubIC* CodeBlock::addJITSubIC(ArithProfile* arithProfile)
    14431443{
    14441444    ConcurrentJSLocker locker(m_lock);
    1445     return ensureJITData(locker).m_subICs.add(arithProfile, instruction);
    1446 }
    1447 
    1448 JITNegIC* CodeBlock::addJITNegIC(ArithProfile* arithProfile, const Instruction* instruction)
     1445    return ensureJITData(locker).m_subICs.add(arithProfile);
     1446}
     1447
     1448JITNegIC* CodeBlock::addJITNegIC(ArithProfile* arithProfile)
    14491449{
    14501450    ConcurrentJSLocker locker(m_lock);
    1451     return ensureJITData(locker).m_negICs.add(arithProfile, instruction);
     1451    return ensureJITData(locker).m_negICs.add(arithProfile);
    14521452}
    14531453
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.h

    r245050 r245239  
    262262        Bag<ByValInfo> m_byValInfos;
    263263        Bag<CallLinkInfo> m_callLinkInfos;
    264         SentinelLinkedList<CallLinkInfo, BasicRawSentinelNode<CallLinkInfo>> m_incomingCalls;
    265         SentinelLinkedList<PolymorphicCallNode, BasicRawSentinelNode<PolymorphicCallNode>> m_incomingPolymorphicCalls;
     264        SentinelLinkedList<CallLinkInfo, PackedRawSentinelNode<CallLinkInfo>> m_incomingCalls;
     265        SentinelLinkedList<PolymorphicCallNode, PackedRawSentinelNode<PolymorphicCallNode>> m_incomingPolymorphicCalls;
    266266        SegmentedVector<RareCaseProfile, 8> m_rareCaseProfiles;
    267267        std::unique_ptr<PCToCodeOriginMap> m_pcToCodeOriginMap;
     
    278278    JITData& ensureJITDataSlow(const ConcurrentJSLocker&);
    279279
    280     JITAddIC* addJITAddIC(ArithProfile*, const Instruction*);
    281     JITMulIC* addJITMulIC(ArithProfile*, const Instruction*);
    282     JITNegIC* addJITNegIC(ArithProfile*, const Instruction*);
    283     JITSubIC* addJITSubIC(ArithProfile*, const Instruction*);
     280    JITAddIC* addJITAddIC(ArithProfile*);
     281    JITMulIC* addJITMulIC(ArithProfile*);
     282    JITNegIC* addJITNegIC(ArithProfile*);
     283    JITSubIC* addJITSubIC(ArithProfile*);
    284284
    285285    template <typename Generator, typename = typename std::enable_if<std::is_same<Generator, JITAddGenerator>::value>::type>
    286     JITAddIC* addMathIC(ArithProfile* profile, const Instruction* instruction) { return addJITAddIC(profile, instruction); }
     286    JITAddIC* addMathIC(ArithProfile* profile) { return addJITAddIC(profile); }
    287287
    288288    template <typename Generator, typename = typename std::enable_if<std::is_same<Generator, JITMulGenerator>::value>::type>
    289     JITMulIC* addMathIC(ArithProfile* profile, const Instruction* instruction) { return addJITMulIC(profile, instruction); }
     289    JITMulIC* addMathIC(ArithProfile* profile) { return addJITMulIC(profile); }
    290290
    291291    template <typename Generator, typename = typename std::enable_if<std::is_same<Generator, JITNegGenerator>::value>::type>
    292     JITNegIC* addMathIC(ArithProfile* profile, const Instruction* instruction) { return addJITNegIC(profile, instruction); }
     292    JITNegIC* addMathIC(ArithProfile* profile) { return addJITNegIC(profile); }
    293293
    294294    template <typename Generator, typename = typename std::enable_if<std::is_same<Generator, JITSubGenerator>::value>::type>
    295     JITSubIC* addMathIC(ArithProfile* profile, const Instruction* instruction) { return addJITSubIC(profile, instruction); }
     295    JITSubIC* addMathIC(ArithProfile* profile) { return addJITSubIC(profile); }
    296296
    297297    StructureStubInfo* addStubInfo(AccessType);
  • trunk/Source/JavaScriptCore/bytecode/InlineCallFrame.h

    r244764 r245239  
    178178    Vector<ValueRecovery> argumentsWithFixup; // Includes 'this' and arity fixups.
    179179    WriteBarrier<CodeBlock> baselineCodeBlock;
    180     ValueRecovery calleeRecovery;
    181180    CodeOrigin directCaller;
    182181
    183     unsigned argumentCountIncludingThis; // Do not include fixups.
     182    unsigned argumentCountIncludingThis { 0 }; // Do not include fixups.
    184183    signed stackOffset : 28;
    185184    unsigned kind : 3; // real type is Kind
    186185    bool isClosureCall : 1; // If false then we know that callee/scope are constants and the DFG won't treat them as variables, i.e. they have to be recovered manually.
    187186    VirtualRegister argumentCountRegister; // Only set when we inline a varargs call.
     187
     188    ValueRecovery calleeRecovery;
    188189   
    189190    // There is really no good notion of a "default" set of values for
     
    191192    // we forgot to initialize explicitly.
    192193    InlineCallFrame()
    193         : argumentCountIncludingThis(0)
    194         , stackOffset(0)
     194        : stackOffset(0)
    195195        , kind(Call)
    196196        , isClosureCall(false)
  • trunk/Source/JavaScriptCore/bytecode/ValueRecovery.h

    r244578 r245239  
    4444// Describes how to recover a given bytecode virtual register at a given
    4545// code point.
    46 enum ValueRecoveryTechnique {
     46enum ValueRecoveryTechnique : uint8_t {
    4747    // It's in a register.
    4848    InGPR,
     
    117117        else
    118118            result.m_technique = InGPR;
    119         result.m_source.gpr = gpr;
     119        UnionType u;
     120        u.gpr = gpr;
     121        result.m_source = WTFMove(u);
    120122        return result;
    121123    }
     
    126128        ValueRecovery result;
    127129        result.m_technique = InPair;
    128         result.m_source.pair.tagGPR = tagGPR;
    129         result.m_source.pair.payloadGPR = payloadGPR;
     130        UnionType u;
     131        u.pair.tagGPR = tagGPR;
     132        u.pair.payloadGPR = payloadGPR;
     133        result.m_source = WTFMove(u);
    130134        return result;
    131135    }
     
    140144        else
    141145            result.m_technique = InFPR;
    142         result.m_source.fpr = fpr;
     146        UnionType u;
     147        u.fpr = fpr;
     148        result.m_source = WTFMove(u);
    143149        return result;
    144150    }
     
    177183            break;
    178184        }
    179         result.m_source.virtualReg = virtualReg.offset();
     185        UnionType u;
     186        u.virtualReg = virtualReg.offset();
     187        result.m_source = WTFMove(u);
    180188        return result;
    181189    }
     
    185193        ValueRecovery result;
    186194        result.m_technique = Constant;
    187         result.m_source.constant = JSValue::encode(value);
     195        UnionType u;
     196        u.constant = JSValue::encode(value);
     197        result.m_source = WTFMove(u);
    188198        return result;
    189199    }
     
    193203        ValueRecovery result;
    194204        result.m_technique = DirectArgumentsThatWereNotCreated;
    195         result.m_source.nodeID = id.bits();
     205        UnionType u;
     206        u.nodeID = id.bits();
     207        result.m_source = WTFMove(u);
    196208        return result;
    197209    }
     
    201213        ValueRecovery result;
    202214        result.m_technique = ClonedArgumentsThatWereNotCreated;
    203         result.m_source.nodeID = id.bits();
     215        UnionType u;
     216        u.nodeID = id.bits();
     217        result.m_source = WTFMove(u);
    204218        return result;
    205219    }
     
    293307    {
    294308        ASSERT(isInGPR());
    295         return m_source.gpr;
     309        return m_source.get().gpr;
    296310    }
    297311   
     
    300314    {
    301315        ASSERT(m_technique == InPair);
    302         return m_source.pair.tagGPR;
     316        return m_source.get().pair.tagGPR;
    303317    }
    304318   
     
    306320    {
    307321        ASSERT(m_technique == InPair);
    308         return m_source.pair.payloadGPR;
     322        return m_source.get().pair.payloadGPR;
    309323    }
    310324
     
    331345    {
    332346        ASSERT(isInFPR());
    333         return m_source.fpr;
     347        return m_source.get().fpr;
    334348    }
    335349   
     
    337351    {
    338352        ASSERT(isInJSStack());
    339         return VirtualRegister(m_source.virtualReg);
     353        return VirtualRegister(m_source.get().virtualReg);
    340354    }
    341355   
     
    352366            ValueRecovery result;
    353367            result.m_technique = m_technique;
    354             result.m_source.virtualReg = m_source.virtualReg + offset;
     368            UnionType u;
     369            u.virtualReg = m_source.get().virtualReg + offset;
     370            result.m_source = WTFMove(u);
    355371            return result;
    356372        }
     
    364380    {
    365381        ASSERT(isConstant());
    366         return JSValue::decode(m_source.constant);
     382        return JSValue::decode(m_source.get().constant);
    367383    }
    368384   
     
    370386    {
    371387        ASSERT(m_technique == DirectArgumentsThatWereNotCreated || m_technique == ClonedArgumentsThatWereNotCreated);
    372         return DFG::MinifiedID::fromBits(m_source.nodeID);
     388        return DFG::MinifiedID::fromBits(m_source.get().nodeID);
    373389    }
    374390   
     
    409425private:
    410426    ValueRecoveryTechnique m_technique;
    411     union {
     427    union UnionType {
    412428        MacroAssembler::RegisterID gpr;
    413429        MacroAssembler::FPRegisterID fpr;
     
    421437        EncodedJSValue constant;
    422438        unsigned nodeID;
    423     } m_source;
     439    };
     440    Packed<UnionType> m_source;
    424441};
     442static_assert(alignof(ValueRecovery) == 1);
    425443
    426444} // namespace JSC
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp

    r245064 r245239  
    39543954    unsigned bytecodeIndex = node->origin.semantic.bytecodeIndex();
    39553955    ArithProfile* arithProfile = baselineCodeBlock->arithProfileForBytecodeOffset(bytecodeIndex);
    3956     const Instruction* instruction = baselineCodeBlock->instructions().at(bytecodeIndex).ptr();
    3957     JITAddIC* addIC = m_jit.codeBlock()->addJITAddIC(arithProfile, instruction);
     3956    JITAddIC* addIC = m_jit.codeBlock()->addJITAddIC(arithProfile);
    39583957    auto repatchingFunction = operationValueAddOptimize;
    39593958    auto nonRepatchingFunction = operationValueAdd;
     
    39793978        unsigned bytecodeIndex = node->origin.semantic.bytecodeIndex();
    39803979        ArithProfile* arithProfile = baselineCodeBlock->arithProfileForBytecodeOffset(bytecodeIndex);
    3981         const Instruction* instruction = baselineCodeBlock->instructions().at(bytecodeIndex).ptr();
    3982         JITSubIC* subIC = m_jit.codeBlock()->addJITSubIC(arithProfile, instruction);
     3980        JITSubIC* subIC = m_jit.codeBlock()->addJITSubIC(arithProfile);
    39833981        auto repatchingFunction = operationValueSubOptimize;
    39843982        auto nonRepatchingFunction = operationValueSub;
     
    45744572    unsigned bytecodeIndex = node->origin.semantic.bytecodeIndex();
    45754573    ArithProfile* arithProfile = baselineCodeBlock->arithProfileForBytecodeOffset(bytecodeIndex);
    4576     const Instruction* instruction = baselineCodeBlock->instructions().at(bytecodeIndex).ptr();
    4577     JITNegIC* negIC = m_jit.codeBlock()->addJITNegIC(arithProfile, instruction);
     4574    JITNegIC* negIC = m_jit.codeBlock()->addJITNegIC(arithProfile);
    45784575    auto repatchingFunction = operationArithNegateOptimize;
    45794576    auto nonRepatchingFunction = operationArithNegate;
     
    47984795    unsigned bytecodeIndex = node->origin.semantic.bytecodeIndex();
    47994796    ArithProfile* arithProfile = baselineCodeBlock->arithProfileForBytecodeOffset(bytecodeIndex);
    4800     const Instruction* instruction = baselineCodeBlock->instructions().at(bytecodeIndex).ptr();
    4801     JITMulIC* mulIC = m_jit.codeBlock()->addJITMulIC(arithProfile, instruction);
     4797    JITMulIC* mulIC = m_jit.codeBlock()->addJITMulIC(arithProfile);
    48024798    auto repatchingFunction = operationValueMulOptimize;
    48034799    auto nonRepatchingFunction = operationValueMul;
  • trunk/Source/JavaScriptCore/ftl/FTLExitValue.cpp

    r243959 r245239  
    3939    ExitValue result;
    4040    result.m_kind = ExitValueMaterializeNewObject;
    41     result.u.newObjectMaterializationData = data;
     41    UnionType u;
     42    u.newObjectMaterializationData = data;
     43    result.m_value = WTFMove(u);
    4244    return result;
    4345}
  • trunk/Source/JavaScriptCore/ftl/FTLExitValue.h

    r243959 r245239  
    4646// the call.
    4747
    48 enum ExitValueKind {
     48enum ExitValueKind : uint8_t {
    4949    InvalidExitValue,
    5050    ExitValueDead,
     
    8080        ExitValue result;
    8181        result.m_kind = ExitValueInJSStack;
    82         result.u.virtualRegister = reg.offset();
     82        UnionType u;
     83        u.virtualRegister = reg.offset();
     84        result.m_value = WTFMove(u);
    8385        return result;
    8486    }
     
    8890        ExitValue result;
    8991        result.m_kind = ExitValueInJSStackAsInt32;
    90         result.u.virtualRegister = reg.offset();
     92        UnionType u;
     93        u.virtualRegister = reg.offset();
     94        result.m_value = WTFMove(u);
    9195        return result;
    9296    }
     
    96100        ExitValue result;
    97101        result.m_kind = ExitValueInJSStackAsInt52;
    98         result.u.virtualRegister = reg.offset();
     102        UnionType u;
     103        u.virtualRegister = reg.offset();
     104        result.m_value = WTFMove(u);
    99105        return result;
    100106    }
     
    104110        ExitValue result;
    105111        result.m_kind = ExitValueInJSStackAsDouble;
    106         result.u.virtualRegister = reg.offset();
     112        UnionType u;
     113        u.virtualRegister = reg.offset();
     114        result.m_value = WTFMove(u);
    107115        return result;
    108116    }
     
    112120        ExitValue result;
    113121        result.m_kind = ExitValueConstant;
    114         result.u.constant = JSValue::encode(value);
     122        UnionType u;
     123        u.constant = JSValue::encode(value);
     124        result.m_value = WTFMove(u);
    115125        return result;
    116126    }
     
    120130        ExitValue result;
    121131        result.m_kind = ExitValueArgument;
    122         result.u.argument = argument.representation();
     132        UnionType u;
     133        u.argument = argument.representation();
     134        result.m_value = WTFMove(u);
    123135        return result;
    124136    }
     
    149161    {
    150162        ASSERT(isArgument());
    151         return ExitArgument(u.argument);
     163        return ExitArgument(m_value.get().argument);
    152164    }
    153165   
     
    156168        ASSERT(hasIndexInStackmapLocations());
    157169        ASSERT(isArgument());
     170        UnionType u = m_value.get();
    158171        u.argument.argument += offset;
     172        m_value = WTFMove(u);
    159173    }
    160174   
     
    162176    {
    163177        ASSERT(isConstant());
    164         return JSValue::decode(u.constant);
     178        return JSValue::decode(m_value.get().constant);
    165179    }
    166180   
     
    168182    {
    169183        ASSERT(isInJSStackSomehow());
    170         return VirtualRegister(u.virtualRegister);
     184        return VirtualRegister(m_value.get().virtualRegister);
    171185    }
    172186   
     
    174188    {
    175189        ASSERT(isObjectMaterialization());
    176         return u.newObjectMaterializationData;
     190        return m_value.get().newObjectMaterializationData;
    177191    }
    178192
     
    182196        ExitValue result;
    183197        result.m_kind = m_kind;
    184         result.u.virtualRegister = virtualRegister.offset();
     198        UnionType u;
     199        u.virtualRegister = virtualRegister.offset();
     200        result.m_value = WTFMove(u);
    185201        return result;
    186202    }
     
    201217private:
    202218    ExitValueKind m_kind;
    203     union {
     219    union UnionType {
    204220        ExitArgumentRepresentation argument;
    205221        EncodedJSValue constant;
    206222        int virtualRegister;
    207223        ExitTimeObjectMaterialization* newObjectMaterializationData;
    208     } u;
     224    };
     225    Packed<UnionType> m_value;
    209226};
    210227
  • trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp

    r245168 r245239  
    20712071        unsigned bytecodeIndex = m_node->origin.semantic.bytecodeIndex();
    20722072        ArithProfile* arithProfile = baselineCodeBlock->arithProfileForBytecodeOffset(bytecodeIndex);
    2073         const Instruction* instruction = baselineCodeBlock->instructions().at(bytecodeIndex).ptr();
    20742073        auto repatchingFunction = operationValueAddOptimize;
    20752074        auto nonRepatchingFunction = operationValueAdd;
    2076         compileBinaryMathIC<JITAddGenerator>(arithProfile, instruction, repatchingFunction, nonRepatchingFunction);
     2075        compileBinaryMathIC<JITAddGenerator>(arithProfile, repatchingFunction, nonRepatchingFunction);
    20772076    }
    20782077
     
    20912090        unsigned bytecodeIndex = m_node->origin.semantic.bytecodeIndex();
    20922091        ArithProfile* arithProfile = baselineCodeBlock->arithProfileForBytecodeOffset(bytecodeIndex);
    2093         const Instruction* instruction = baselineCodeBlock->instructions().at(bytecodeIndex).ptr();
    20942092        auto repatchingFunction = operationValueSubOptimize;
    20952093        auto nonRepatchingFunction = operationValueSub;
    2096         compileBinaryMathIC<JITSubGenerator>(arithProfile, instruction, repatchingFunction, nonRepatchingFunction);
     2094        compileBinaryMathIC<JITSubGenerator>(arithProfile, repatchingFunction, nonRepatchingFunction);
    20972095    }
    20982096
     
    21112109        unsigned bytecodeIndex = m_node->origin.semantic.bytecodeIndex();
    21122110        ArithProfile* arithProfile = baselineCodeBlock->arithProfileForBytecodeOffset(bytecodeIndex);
    2113         const Instruction* instruction = baselineCodeBlock->instructions().at(bytecodeIndex).ptr();
    21142111        auto repatchingFunction = operationValueMulOptimize;
    21152112        auto nonRepatchingFunction = operationValueMul;
    2116         compileBinaryMathIC<JITMulGenerator>(arithProfile, instruction, repatchingFunction, nonRepatchingFunction);
     2113        compileBinaryMathIC<JITMulGenerator>(arithProfile, repatchingFunction, nonRepatchingFunction);
    21172114    }
    21182115
    21192116    template <typename Generator, typename Func1, typename Func2,
    21202117        typename = std::enable_if_t<std::is_function<typename std::remove_pointer<Func1>::type>::value && std::is_function<typename std::remove_pointer<Func2>::type>::value>>
    2121     void compileUnaryMathIC(ArithProfile* arithProfile, const Instruction* instruction, Func1 repatchingFunction, Func2 nonRepatchingFunction)
     2118    void compileUnaryMathIC(ArithProfile* arithProfile, Func1 repatchingFunction, Func2 nonRepatchingFunction)
    21222119    {
    21232120        Node* node = m_node;
     
    21452142
    21462143                Box<MathICGenerationState> mathICGenerationState = Box<MathICGenerationState>::create();
    2147                 JITUnaryMathIC<Generator>* mathIC = jit.codeBlock()->addMathIC<Generator>(arithProfile, instruction);
     2144                JITUnaryMathIC<Generator>* mathIC = jit.codeBlock()->addMathIC<Generator>(arithProfile);
    21482145                mathIC->m_generator = Generator(JSValueRegs(params[0].gpr()), JSValueRegs(params[1].gpr()), params.gpScratch(0));
    21492146
     
    22052202    template <typename Generator, typename Func1, typename Func2,
    22062203        typename = std::enable_if_t<std::is_function<typename std::remove_pointer<Func1>::type>::value && std::is_function<typename std::remove_pointer<Func2>::type>::value>>
    2207     void compileBinaryMathIC(ArithProfile* arithProfile, const Instruction* instruction, Func1 repatchingFunction, Func2 nonRepatchingFunction)
     2204    void compileBinaryMathIC(ArithProfile* arithProfile, Func1 repatchingFunction, Func2 nonRepatchingFunction)
    22082205    {
    22092206        Node* node = m_node;
     
    22392236
    22402237                Box<MathICGenerationState> mathICGenerationState = Box<MathICGenerationState>::create();
    2241                 JITBinaryMathIC<Generator>* mathIC = jit.codeBlock()->addMathIC<Generator>(arithProfile, instruction);
     2238                JITBinaryMathIC<Generator>* mathIC = jit.codeBlock()->addMathIC<Generator>(arithProfile);
    22422239                mathIC->m_generator = Generator(leftOperand, rightOperand, JSValueRegs(params[0].gpr()),
    22432240                    JSValueRegs(params[1].gpr()), JSValueRegs(params[2].gpr()), params.fpScratch(0),
     
    23732370            unsigned bytecodeIndex = m_node->origin.semantic.bytecodeIndex();
    23742371            ArithProfile* arithProfile = baselineCodeBlock->arithProfileForBytecodeOffset(bytecodeIndex);
    2375             const Instruction* instruction = baselineCodeBlock->instructions().at(bytecodeIndex).ptr();
    23762372            auto repatchingFunction = operationValueSubOptimize;
    23772373            auto nonRepatchingFunction = operationValueSub;
    2378             compileBinaryMathIC<JITSubGenerator>(arithProfile, instruction, repatchingFunction, nonRepatchingFunction);
     2374            compileBinaryMathIC<JITSubGenerator>(arithProfile, repatchingFunction, nonRepatchingFunction);
    23792375            break;
    23802376        }
     
    30243020        unsigned bytecodeIndex = m_node->origin.semantic.bytecodeIndex();
    30253021        ArithProfile* arithProfile = baselineCodeBlock->arithProfileForBytecodeOffset(bytecodeIndex);
    3026         const Instruction* instruction = baselineCodeBlock->instructions().at(bytecodeIndex).ptr();
    30273022        auto repatchingFunction = operationArithNegateOptimize;
    30283023        auto nonRepatchingFunction = operationArithNegate;
    3029         compileUnaryMathIC<JITNegGenerator>(arithProfile, instruction, repatchingFunction, nonRepatchingFunction);
     3024        compileUnaryMathIC<JITNegGenerator>(arithProfile, repatchingFunction, nonRepatchingFunction);
    30303025    }
    30313026
  • trunk/Source/JavaScriptCore/jit/CachedRecovery.h

    r209764 r245239  
    124124    FPRReg wantedFPR() const { return m_wantedFPR; }
    125125private:
     126    Vector<VirtualRegister, 1> m_targets;
    126127    ValueRecovery m_recovery;
    127128    JSValueRegs m_wantedJSValueRegs;
    128129    FPRReg m_wantedFPR { InvalidFPRReg };
    129     Vector<VirtualRegister, 1> m_targets;
    130130};
    131131
  • trunk/Source/JavaScriptCore/jit/CallFrameShuffleData.h

    r242812 r245239  
    3636    WTF_MAKE_FAST_ALLOCATED;
    3737public:
    38     ValueRecovery callee;
    3938    Vector<ValueRecovery> args;
    4039    unsigned numLocals { UINT_MAX };
     
    4645    void setupCalleeSaveRegisters(CodeBlock*);
    4746#endif
     47    ValueRecovery callee;
    4848};
    4949
  • trunk/Source/JavaScriptCore/jit/JITArithmetic.cpp

    r241849 r245239  
    454454{
    455455    ArithProfile* arithProfile = &currentInstruction->as<OpNegate>().metadata(m_codeBlock).m_arithProfile;
    456     JITNegIC* negateIC = m_codeBlock->addJITNegIC(arithProfile, currentInstruction);
     456    JITNegIC* negateIC = m_codeBlock->addJITNegIC(arithProfile);
    457457    m_instructionToMathIC.add(currentInstruction, negateIC);
    458458    emitMathICFast<OpNegate>(negateIC, currentInstruction, operationArithNegateProfiled, operationArithNegate);
     
    642642{
    643643    ArithProfile* arithProfile = &currentInstruction->as<OpAdd>().metadata(m_codeBlock).m_arithProfile;
    644     JITAddIC* addIC = m_codeBlock->addJITAddIC(arithProfile, currentInstruction);
     644    JITAddIC* addIC = m_codeBlock->addJITAddIC(arithProfile);
    645645    m_instructionToMathIC.add(currentInstruction, addIC);
    646646    emitMathICFast<OpAdd>(addIC, currentInstruction, operationValueAddProfiled, operationValueAdd);
     
    961961{
    962962    ArithProfile* arithProfile = &currentInstruction->as<OpMul>().metadata(m_codeBlock).m_arithProfile;
    963     JITMulIC* mulIC = m_codeBlock->addJITMulIC(arithProfile, currentInstruction);
     963    JITMulIC* mulIC = m_codeBlock->addJITMulIC(arithProfile);
    964964    m_instructionToMathIC.add(currentInstruction, mulIC);
    965965    emitMathICFast<OpMul>(mulIC, currentInstruction, operationValueMulProfiled, operationValueMul);
     
    977977{
    978978    ArithProfile* arithProfile = &currentInstruction->as<OpSub>().metadata(m_codeBlock).m_arithProfile;
    979     JITSubIC* subIC = m_codeBlock->addJITSubIC(arithProfile, currentInstruction);
     979    JITSubIC* subIC = m_codeBlock->addJITSubIC(arithProfile);
    980980    m_instructionToMathIC.add(currentInstruction, subIC);
    981981    emitMathICFast<OpSub>(subIC, currentInstruction, operationValueSubProfiled, operationValueSub);
  • trunk/Source/JavaScriptCore/jit/JITMathIC.h

    r238439 r245239  
    5757    WTF_MAKE_FAST_ALLOCATED;
    5858public:
    59     JITMathIC(ArithProfile* arithProfile, const Instruction* instruction)
     59    JITMathIC(ArithProfile* arithProfile)
    6060        : m_arithProfile(arithProfile)
    61         , m_instruction(instruction)
    6261    {
    6362    }
     
    226225
    227226    ArithProfile* arithProfile() const { return m_arithProfile; }
    228     const Instruction* instruction() const { return m_instruction; }
    229227
    230228#if ENABLE(MATH_IC_STATS)
     
    240238
    241239    ArithProfile* m_arithProfile;
    242     const Instruction* m_instruction;
    243240    MacroAssemblerCodeRef<JITStubRoutinePtrTag> m_code;
    244241    CodeLocationLabel<JSInternalPtrTag> m_inlineStart;
     
    257254class JITBinaryMathIC : public JITMathIC<GeneratorType, isBinaryProfileEmpty> {
    258255public:
    259     JITBinaryMathIC(ArithProfile* arithProfile, const Instruction* instruction)
    260         : JITMathIC<GeneratorType, isBinaryProfileEmpty>(arithProfile, instruction)
     256    JITBinaryMathIC(ArithProfile* arithProfile)
     257        : JITMathIC<GeneratorType, isBinaryProfileEmpty>(arithProfile)
    261258    {
    262259    }
     
    275272class JITUnaryMathIC : public JITMathIC<GeneratorType, isUnaryProfileEmpty> {
    276273public:
    277     JITUnaryMathIC(ArithProfile* arithProfile, const Instruction* instruction)
    278         : JITMathIC<GeneratorType, isUnaryProfileEmpty>(arithProfile, instruction)
     274    JITUnaryMathIC(ArithProfile* arithProfile)
     275        : JITMathIC<GeneratorType, isUnaryProfileEmpty>(arithProfile)
    279276    {
    280277    }
  • trunk/Source/JavaScriptCore/jit/PolymorphicCallStubRoutine.h

    r234086 r245239  
    3939class CallLinkInfo;
    4040
    41 class PolymorphicCallNode : public BasicRawSentinelNode<PolymorphicCallNode> {
     41class PolymorphicCallNode : public PackedRawSentinelNode<PolymorphicCallNode> {
    4242    WTF_MAKE_NONCOPYABLE(PolymorphicCallNode);
    4343public:
     
    5151    void unlink(VM&);
    5252
    53     bool hasCallLinkInfo(CallLinkInfo* info) { return m_callLinkInfo == info; }
     53    bool hasCallLinkInfo(CallLinkInfo* info) { return m_callLinkInfo.get() == info; }
    5454    void clearCallLinkInfo();
    5555   
    5656private:
    57     CallLinkInfo* m_callLinkInfo;
     57    PackedPtr<CallLinkInfo> m_callLinkInfo;
    5858};
    5959
  • trunk/Source/JavaScriptCore/jit/SnippetOperand.h

    r206525 r245239  
    2929
    3030#include "ResultType.h"
     31#include <wtf/Packed.h>
    3132
    3233namespace JSC {
    3334
    3435class SnippetOperand {
    35     enum ConstOrVarType {
     36    enum ConstOrVarType : uint8_t {
    3637        Variable,
    3738        ConstInt32,
     
    5657    bool isPositiveConstInt32() const { return isConstInt32() && asConstInt32() > 0; }
    5758
    58     int64_t asRawBits() const { return m_val.rawBits; }
     59    int64_t asRawBits() const { return m_val.get().rawBits; }
    5960
    6061    int32_t asConstInt32() const
    6162    {
    6263        ASSERT(m_type == ConstInt32);
    63         return m_val.int32Val;
     64        return m_val.get().int32Val;
    6465    }
    6566
     
    6768    {
    6869        ASSERT(m_type == ConstDouble);
    69         return m_val.doubleVal;
     70        return m_val.get().doubleVal;
    7071    }
    7172
     
    8182    {
    8283        m_type = ConstInt32;
    83         m_val.int32Val = value;
     84        UnionType u;
     85        u.int32Val = value;
     86        m_val = WTFMove(u);
    8487    }
    8588
     
    8790    {
    8891        m_type = ConstDouble;
    89         m_val.doubleVal = value;
     92        UnionType u;
     93        u.doubleVal = value;
     94        m_val = WTFMove(u);
    9095    }
    9196
     
    9398    ResultType m_resultType;
    9499    ConstOrVarType m_type { Variable };
    95     union {
     100    union UnionType {
    96101        int32_t int32Val;
    97102        double doubleVal;
    98103        int64_t rawBits;
    99     } m_val;
     104    };
     105    Packed<UnionType> m_val;
    100106};
     107static_assert(alignof(SnippetOperand) == 1);
    101108
    102109} // namespace JSC
  • trunk/Source/WTF/ChangeLog

    r245234 r245239  
     12019-05-13  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Compress miscelaneous JIT related data structures with Packed<>
     4        https://bugs.webkit.org/show_bug.cgi?id=197830
     5
     6        Reviewed by Saam Barati.
     7
     8        * wtf/Packed.h:
     9        (WTF::alignof):
     10
    1112019-05-13  Michael Catanzaro  <mcatanzaro@igalia.com>
    212
  • trunk/Source/WTF/wtf/Packed.h

    r245214 r245239  
    162162    T& operator*() const { return *get(); }
    163163    bool operator!() const { return !get(); }
     164    explicit operator bool() const { return get(); }
    164165
    165166    PackedAlignedPtr& operator=(T* value)
Note: See TracChangeset for help on using the changeset viewer.