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

Changeset 194294 in webkit


Ignore:
Timestamp:
Dec 18, 2015, 2:03:30 PM (11 years ago)
Author:
mark.lam@apple.com
Message:

Replace SpecialFastCase profiles with ResultProfiles.
https://bugs.webkit.org/show_bug.cgi?id=152433

Reviewed by Saam Barati.

This is in preparation for upcoming work to enhance the DFG predictions to deal
with untyped operands.

This patch also enhances some of the arithmetic slow paths (for the LLINT and
baseline JIT) to collect result profiling info. This profiling info is not put
to use yet.

(JSC::CodeBlock::dumpRareCaseProfile):
(JSC::CodeBlock::dumpResultProfile):
(JSC::CodeBlock::printLocationAndOp):
(JSC::CodeBlock::dumpBytecode):
(JSC::CodeBlock::shrinkToFit):
(JSC::CodeBlock::dumpValueProfiles):
(JSC::CodeBlock::rareCaseProfileCountForBytecodeOffset):
(JSC::CodeBlock::resultProfileForBytecodeOffset):
(JSC::CodeBlock::updateResultProfileForBytecodeOffset):
(JSC::CodeBlock::capabilityLevel):

  • bytecode/CodeBlock.h:

(JSC::CodeBlock::couldTakeSlowCase):
(JSC::CodeBlock::addResultProfile):
(JSC::CodeBlock::numberOfResultProfiles):
(JSC::CodeBlock::specialFastCaseProfileCountForBytecodeOffset):
(JSC::CodeBlock::couldTakeSpecialFastCase):
(JSC::CodeBlock::addSpecialFastCaseProfile): Deleted.
(JSC::CodeBlock::numberOfSpecialFastCaseProfiles): Deleted.
(JSC::CodeBlock::specialFastCaseProfile): Deleted.
(JSC::CodeBlock::specialFastCaseProfileForBytecodeOffset): Deleted.

  • bytecode/ValueProfile.cpp: Added.

(WTF::printInternal):

  • bytecode/ValueProfile.h:

(JSC::getRareCaseProfileBytecodeOffset):
(JSC::ResultProfile::ResultProfile):
(JSC::ResultProfile::bytecodeOffset):
(JSC::ResultProfile::specialFastPathCount):
(JSC::ResultProfile::didObserveNonInt32):
(JSC::ResultProfile::didObserveDouble):
(JSC::ResultProfile::didObserveNonNegZeroDouble):
(JSC::ResultProfile::didObserveNegZeroDouble):
(JSC::ResultProfile::didObserveNonNumber):
(JSC::ResultProfile::didObserveInt32Overflow):
(JSC::ResultProfile::setObservedNonNegZeroDouble):
(JSC::ResultProfile::setObservedNegZeroDouble):
(JSC::ResultProfile::setObservedNonNumber):
(JSC::ResultProfile::setObservedInt32Overflow):
(JSC::ResultProfile::addressOfFlags):
(JSC::ResultProfile::addressOfSpecialFastPathCount):
(JSC::ResultProfile::hasBits):
(JSC::ResultProfile::setBit):
(JSC::getResultProfileBytecodeOffset):

  • jit/JITArithmetic.cpp:

(JSC::JIT::emit_op_div):
(JSC::JIT::emit_op_mul):

  • jit/JITDivGenerator.cpp:

(JSC::JITDivGenerator::generateFastPath):

  • jit/JITDivGenerator.h:

(JSC::JITDivGenerator::JITDivGenerator):

  • jit/JITMulGenerator.cpp:

(JSC::JITMulGenerator::generateFastPath):

  • jit/JITMulGenerator.h:

(JSC::JITMulGenerator::JITMulGenerator):

  • runtime/CommonSlowPaths.cpp:

(JSC::SLOW_PATH_DECL):

Location:
trunk/Source/JavaScriptCore
Files:
1 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/CMakeLists.txt

    r194242 r194294  
    204204    bytecode/UnlinkedFunctionExecutable.cpp
    205205    bytecode/UnlinkedInstructionStream.cpp
     206    bytecode/ValueProfile.cpp
    206207    bytecode/ValueRecovery.cpp
    207208    bytecode/VariableWriteFireDetail.cpp
  • trunk/Source/JavaScriptCore/ChangeLog

    r194293 r194294  
     12015-12-18  Mark Lam  <mark.lam@apple.com>
     2
     3        Replace SpecialFastCase profiles with ResultProfiles.
     4        https://bugs.webkit.org/show_bug.cgi?id=152433
     5
     6        Reviewed by Saam Barati.
     7
     8        This is in preparation for upcoming work to enhance the DFG predictions to deal
     9        with untyped operands.
     10
     11        This patch also enhances some of the arithmetic slow paths (for the LLINT and
     12        baseline JIT) to collect result profiling info.  This profiling info is not put
     13        to use yet.
     14
     15        * CMakeLists.txt:
     16        * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
     17        * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters:
     18        * JavaScriptCore.xcodeproj/project.pbxproj:
     19        * bytecode/CodeBlock.cpp:
     20        (JSC::CodeBlock::dumpRareCaseProfile):
     21        (JSC::CodeBlock::dumpResultProfile):
     22        (JSC::CodeBlock::printLocationAndOp):
     23        (JSC::CodeBlock::dumpBytecode):
     24        (JSC::CodeBlock::shrinkToFit):
     25        (JSC::CodeBlock::dumpValueProfiles):
     26        (JSC::CodeBlock::rareCaseProfileCountForBytecodeOffset):
     27        (JSC::CodeBlock::resultProfileForBytecodeOffset):
     28        (JSC::CodeBlock::updateResultProfileForBytecodeOffset):
     29        (JSC::CodeBlock::capabilityLevel):
     30        * bytecode/CodeBlock.h:
     31        (JSC::CodeBlock::couldTakeSlowCase):
     32        (JSC::CodeBlock::addResultProfile):
     33        (JSC::CodeBlock::numberOfResultProfiles):
     34        (JSC::CodeBlock::specialFastCaseProfileCountForBytecodeOffset):
     35        (JSC::CodeBlock::couldTakeSpecialFastCase):
     36        (JSC::CodeBlock::addSpecialFastCaseProfile): Deleted.
     37        (JSC::CodeBlock::numberOfSpecialFastCaseProfiles): Deleted.
     38        (JSC::CodeBlock::specialFastCaseProfile): Deleted.
     39        (JSC::CodeBlock::specialFastCaseProfileForBytecodeOffset): Deleted.
     40        * bytecode/ValueProfile.cpp: Added.
     41        (WTF::printInternal):
     42        * bytecode/ValueProfile.h:
     43        (JSC::getRareCaseProfileBytecodeOffset):
     44        (JSC::ResultProfile::ResultProfile):
     45        (JSC::ResultProfile::bytecodeOffset):
     46        (JSC::ResultProfile::specialFastPathCount):
     47        (JSC::ResultProfile::didObserveNonInt32):
     48        (JSC::ResultProfile::didObserveDouble):
     49        (JSC::ResultProfile::didObserveNonNegZeroDouble):
     50        (JSC::ResultProfile::didObserveNegZeroDouble):
     51        (JSC::ResultProfile::didObserveNonNumber):
     52        (JSC::ResultProfile::didObserveInt32Overflow):
     53        (JSC::ResultProfile::setObservedNonNegZeroDouble):
     54        (JSC::ResultProfile::setObservedNegZeroDouble):
     55        (JSC::ResultProfile::setObservedNonNumber):
     56        (JSC::ResultProfile::setObservedInt32Overflow):
     57        (JSC::ResultProfile::addressOfFlags):
     58        (JSC::ResultProfile::addressOfSpecialFastPathCount):
     59        (JSC::ResultProfile::hasBits):
     60        (JSC::ResultProfile::setBit):
     61        (JSC::getResultProfileBytecodeOffset):
     62        * jit/JITArithmetic.cpp:
     63        (JSC::JIT::emit_op_div):
     64        (JSC::JIT::emit_op_mul):
     65        * jit/JITDivGenerator.cpp:
     66        (JSC::JITDivGenerator::generateFastPath):
     67        * jit/JITDivGenerator.h:
     68        (JSC::JITDivGenerator::JITDivGenerator):
     69        * jit/JITMulGenerator.cpp:
     70        (JSC::JITMulGenerator::generateFastPath):
     71        * jit/JITMulGenerator.h:
     72        (JSC::JITMulGenerator::JITMulGenerator):
     73        * runtime/CommonSlowPaths.cpp:
     74        (JSC::SLOW_PATH_DECL):
     75
    1762015-12-18  Keith Miller  <keith_miller@apple.com>
    277
  • trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj

    r193985 r194294  
    363363    <ClCompile Include="..\bytecode\UnlinkedFunctionExecutable.cpp" />
    364364    <ClCompile Include="..\bytecode\UnlinkedInstructionStream.cpp" />
     365    <ClCompile Include="..\bytecode\ValueProfile.cpp" />
    365366    <ClCompile Include="..\bytecode\ValueRecovery.cpp" />
    366367    <ClCompile Include="..\bytecode\VariableWriteFireDetail.cpp" />
  • trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters

    r193985 r194294  
    15251525      <Filter>runtime</Filter>
    15261526    </ClCompile>
     1527    <ClCompile Include="..\bytecode\ValueProfile.cpp">
     1528      <Filter>bytecode</Filter>
     1529    </ClCompile>
    15271530    <ClCompile Include="..\bytecode\ValueRecovery.cpp">
    15281531      <Filter>bytecode</Filter>
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r194242 r194294  
    20552055                FEA08620182B7A0400F6D851 /* Breakpoint.h in Headers */ = {isa = PBXBuildFile; fileRef = FEA0861E182B7A0400F6D851 /* Breakpoint.h */; settings = {ATTRIBUTES = (Private, ); }; };
    20562056                FEA08621182B7A0400F6D851 /* DebuggerPrimitives.h in Headers */ = {isa = PBXBuildFile; fileRef = FEA0861F182B7A0400F6D851 /* DebuggerPrimitives.h */; settings = {ATTRIBUTES = (Private, ); }; };
     2057                FEA1E4391C213A2B00277A16 /* ValueProfile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEA1E4381C213A2600277A16 /* ValueProfile.cpp */; settings = {ASSET_TAGS = (); }; };
    20572058                FEB137571BB11EF900CD5100 /* MacroAssemblerARM64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEB137561BB11EEE00CD5100 /* MacroAssemblerARM64.cpp */; };
    20582059                FEB51F6C1A97B688001F921C /* Regress141809.mm in Sources */ = {isa = PBXBuildFile; fileRef = FEB51F6B1A97B688001F921C /* Regress141809.mm */; };
     
    42594260                FEA0861E182B7A0400F6D851 /* Breakpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Breakpoint.h; sourceTree = "<group>"; };
    42604261                FEA0861F182B7A0400F6D851 /* DebuggerPrimitives.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DebuggerPrimitives.h; sourceTree = "<group>"; };
     4262                FEA1E4381C213A2600277A16 /* ValueProfile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ValueProfile.cpp; sourceTree = "<group>"; };
    42614263                FEB137561BB11EEE00CD5100 /* MacroAssemblerARM64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MacroAssemblerARM64.cpp; sourceTree = "<group>"; };
    42624264                FEB51F6A1A97B688001F921C /* Regress141809.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Regress141809.h; path = API/tests/Regress141809.h; sourceTree = "<group>"; };
     
    65216523                                B59F89381891ADB500D5CCDC /* UnlinkedInstructionStream.cpp */,
    65226524                                B59F89371891AD3300D5CCDC /* UnlinkedInstructionStream.h */,
     6525                                FEA1E4381C213A2600277A16 /* ValueProfile.cpp */,
    65236526                                0F963B3613FC6FDE0002D9B2 /* ValueProfile.h */,
    65246527                                0F24E55717F74EDB00ABB217 /* ValueRecovery.cpp */,
     
    92459248                                0FF42740158EBE8B004CB9FF /* udis86_decode.c in Sources */,
    92469249                                0FF42743158EBE91004CB9FF /* udis86_input.c in Sources */,
     9250                                FEA1E4391C213A2B00277A16 /* ValueProfile.cpp in Sources */,
    92479251                                0FF4274D158EBFE6004CB9FF /* udis86_itab_holder.c in Sources */,
    92489252                                0FF42745158EBE91004CB9FF /* udis86_syn-att.c in Sources */,
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp

    r194248 r194294  
    742742}
    743743
     744void CodeBlock::dumpResultProfile(PrintStream& out, ResultProfile* profile, bool& hasPrintedProfiling)
     745{
     746    if (!profile)
     747        return;
     748   
     749    beginDumpProfiling(out, hasPrintedProfiling);
     750    out.print("results: ", *profile);
     751}
     752
    744753void CodeBlock::printLocationAndOp(PrintStream& out, ExecState*, int location, const Instruction*&, const char* op)
    745754{
     
    16521661
    16531662    dumpRareCaseProfile(out, "rare case: ", rareCaseProfileForBytecodeOffset(location), hasPrintedProfiling);
    1654     dumpRareCaseProfile(out, "special fast case: ", specialFastCaseProfileForBytecodeOffset(location), hasPrintedProfiling);
     1663    dumpResultProfile(out, resultProfileForBytecodeOffset(location), hasPrintedProfiling);
    16551664   
    16561665#if ENABLE(DFG_JIT)
     
    31323141{
    31333142    m_rareCaseProfiles.shrinkToFit();
    3134     m_specialFastCaseProfiles.shrinkToFit();
     3143    m_resultProfiles.shrinkToFit();
    31353144   
    31363145    if (shrinkMode == EarlyShrink) {
     
    39773986        dataLogF("   bc = %d: %u\n", profile->m_bytecodeOffset, profile->m_counter);
    39783987    }
    3979     dataLog("SpecialFastCaseProfile for ", *this, ":\n");
    3980     for (unsigned i = 0; i < numberOfSpecialFastCaseProfiles(); ++i) {
    3981         RareCaseProfile* profile = specialFastCaseProfile(i);
    3982         dataLogF("   bc = %d: %u\n", profile->m_bytecodeOffset, profile->m_counter);
     3988    dataLog("ResultProfile for ", *this, ":\n");
     3989    for (unsigned i = 0; i < numberOfResultProfiles(); ++i) {
     3990        const ResultProfile& profile = *resultProfile(i);
     3991        dataLog("   bc = ", profile.bytecodeOffset(), ": ", profile, "\n");
    39833992    }
    39843993}
     
    41764185        return profile->m_counter;
    41774186    return 0;
     4187}
     4188
     4189ResultProfile* CodeBlock::resultProfileForBytecodeOffset(int bytecodeOffset)
     4190{
     4191    return tryBinarySearch<ResultProfile, int>(
     4192        m_resultProfiles, m_resultProfiles.size(), bytecodeOffset,
     4193        getResultProfileBytecodeOffset);
     4194}
     4195
     4196void CodeBlock::updateResultProfileForBytecodeOffset(int bytecodeOffset, JSValue result)
     4197{
     4198#if ENABLE(DFG_JIT)
     4199    ResultProfile* profile = resultProfileForBytecodeOffset(bytecodeOffset);
     4200    if (!profile)
     4201        profile = addResultProfile(bytecodeOffset);
     4202
     4203    if (result.isNumber()) {
     4204        if (!result.isInt32()) {
     4205            double doubleVal = result.asNumber();
     4206            if (!doubleVal && std::signbit(doubleVal))
     4207                profile->setObservedNegZeroDouble();
     4208            else
     4209                profile->setObservedNonNegZeroDouble();
     4210        }
     4211    } else
     4212        profile->setObservedNonNumber();
     4213#else
     4214    UNUSED_PARAM(bytecodeOffset);
     4215    UNUSED_PARAM(result);
     4216#endif
    41784217}
    41794218
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.h

    r193485 r194294  
    453453    }
    454454
    455     RareCaseProfile* addSpecialFastCaseProfile(int bytecodeOffset)
    456     {
    457         m_specialFastCaseProfiles.append(RareCaseProfile(bytecodeOffset));
    458         return &m_specialFastCaseProfiles.last();
    459     }
    460     unsigned numberOfSpecialFastCaseProfiles() { return m_specialFastCaseProfiles.size(); }
    461     RareCaseProfile* specialFastCaseProfile(int index) { return &m_specialFastCaseProfiles[index]; }
    462     RareCaseProfile* specialFastCaseProfileForBytecodeOffset(int bytecodeOffset)
    463     {
    464         return tryBinarySearch<RareCaseProfile, int>(
    465             m_specialFastCaseProfiles, m_specialFastCaseProfiles.size(), bytecodeOffset,
    466             getRareCaseProfileBytecodeOffset);
    467     }
     455    ResultProfile* addResultProfile(int bytecodeOffset)
     456    {
     457        m_resultProfiles.append(ResultProfile(bytecodeOffset));
     458        return &m_resultProfiles.last();
     459    }
     460    unsigned numberOfResultProfiles() { return m_resultProfiles.size(); }
     461    ResultProfile* resultProfileForBytecodeOffset(int bytecodeOffset);
     462
     463    void updateResultProfileForBytecodeOffset(int bytecodeOffset, JSValue result);
     464
    468465    unsigned specialFastCaseProfileCountForBytecodeOffset(int bytecodeOffset)
    469466    {
    470         RareCaseProfile* profile = specialFastCaseProfileForBytecodeOffset(bytecodeOffset);
     467        ResultProfile* profile = resultProfileForBytecodeOffset(bytecodeOffset);
    471468        if (!profile)
    472469            return 0;
    473         return profile->m_counter;
     470        return profile->specialFastPathCount();
    474471    }
    475472
     
    995992    void dumpArrayProfiling(PrintStream&, const Instruction*&, bool& hasPrintedProfiling);
    996993    void dumpRareCaseProfile(PrintStream&, const char* name, RareCaseProfile*, bool& hasPrintedProfiling);
    997        
     994    void dumpResultProfile(PrintStream&, ResultProfile*, bool& hasPrintedProfiling);
     995
    998996    bool shouldVisitStrongly();
    999997    bool shouldJettisonDueToWeakReference();
     
    10701068    Vector<ValueProfile> m_valueProfiles;
    10711069    SegmentedVector<RareCaseProfile, 8> m_rareCaseProfiles;
    1072     SegmentedVector<RareCaseProfile, 8> m_specialFastCaseProfiles;
     1070    SegmentedVector<ResultProfile, 8> m_resultProfiles;
    10731071    Vector<ArrayAllocationProfile> m_arrayAllocationProfiles;
    10741072    ArrayProfileVector m_arrayProfiles;
  • trunk/Source/JavaScriptCore/bytecode/ValueProfile.h

    r165676 r194294  
    207207}
    208208
     209struct ResultProfile {
     210private:
     211    static const int numberOfFlagBits = 4;
     212
     213public:
     214    ResultProfile(int bytecodeOffset)
     215        : m_bytecodeOffsetAndFlags(bytecodeOffset << numberOfFlagBits)
     216    {
     217        ASSERT(((bytecodeOffset << numberOfFlagBits) >> numberOfFlagBits) == bytecodeOffset);
     218    }
     219
     220    enum ObservedResults {
     221        NonNegZeroDouble = 1 << 0,
     222        NegZeroDouble    = 1 << 1,
     223        NonNumber        = 1 << 2,
     224        Int32Overflow    = 1 << 3,
     225    };
     226
     227    int bytecodeOffset() const { return m_bytecodeOffsetAndFlags >> numberOfFlagBits; }
     228    unsigned specialFastPathCount() const { return m_specialFastPathCount; }
     229
     230    bool didObserveNonInt32() const { return hasBits(NonNegZeroDouble | NegZeroDouble | NonNumber); }
     231    bool didObserveDouble() const { return hasBits(NonNegZeroDouble | NegZeroDouble); }
     232    bool didObserveNonNegZeroDouble() const { return hasBits(NonNegZeroDouble); }
     233    bool didObserveNegZeroDouble() const { return hasBits(NegZeroDouble); }
     234    bool didObserveNonNumber() const { return hasBits(NonNumber); }
     235    bool didObserveInt32Overflow() const { return hasBits(Int32Overflow); }
     236
     237    void setObservedNonNegZeroDouble() { setBit(NonNegZeroDouble); }
     238    void setObservedNegZeroDouble() { setBit(NegZeroDouble); }
     239    void setObservedNonNumber() { setBit(NonNumber); }
     240    void setObservedInt32Overflow() { setBit(Int32Overflow); }
     241
     242    void* addressOfFlags() { return &m_bytecodeOffsetAndFlags; }
     243    void* addressOfSpecialFastPathCount() { return &m_specialFastPathCount; }
     244
     245private:
     246    bool hasBits(int mask) const { return m_bytecodeOffsetAndFlags & mask; }
     247    void setBit(int mask) { m_bytecodeOffsetAndFlags |= mask; }
     248
     249    int m_bytecodeOffsetAndFlags;
     250    unsigned m_specialFastPathCount { 0 };
     251};
     252
     253inline int getResultProfileBytecodeOffset(ResultProfile* profile)
     254{
     255    return profile->bytecodeOffset();
     256}
     257
    209258} // namespace JSC
    210259
     260namespace WTF {
     261
     262void printInternal(PrintStream&, const JSC::ResultProfile&);
     263
     264} // namespace WTF
     265
    211266#endif // ValueProfile_h
    212267
  • trunk/Source/JavaScriptCore/jit/JITArithmetic.cpp

    r194131 r194294  
    756756    FPRReg scratchFPR = fpRegT2;
    757757
    758     uint32_t* profilingCounter = &m_codeBlock->addSpecialFastCaseProfile(m_bytecodeOffset)->m_counter;
     758    ResultProfile* resultProfile = nullptr;
     759    if (shouldEmitProfiling())
     760        resultProfile = m_codeBlock->addResultProfile(m_bytecodeOffset);
    759761
    760762    SnippetOperand leftOperand(types.first());
     
    783785
    784786    JITDivGenerator gen(leftOperand, rightOperand, resultRegs, leftRegs, rightRegs,
    785         fpRegT0, fpRegT1, scratchGPR, scratchFPR, profilingCounter);
     787        fpRegT0, fpRegT1, scratchGPR, scratchFPR, resultProfile);
    786788
    787789    gen.generateFastPath(*this);
     
    829831#endif
    830832
    831     uint32_t* profilingCounter = nullptr;
     833    ResultProfile* resultProfile = nullptr;
    832834    if (shouldEmitProfiling())
    833         profilingCounter = &m_codeBlock->addSpecialFastCaseProfile(m_bytecodeOffset)->m_counter;
     835        resultProfile = m_codeBlock->addResultProfile(m_bytecodeOffset);
    834836
    835837    SnippetOperand leftOperand(types.first());
     
    849851
    850852    JITMulGenerator gen(leftOperand, rightOperand, resultRegs, leftRegs, rightRegs,
    851         fpRegT0, fpRegT1, scratchGPR, scratchFPR, profilingCounter);
     853        fpRegT0, fpRegT1, scratchGPR, scratchFPR, resultProfile);
    852854
    853855    gen.generateFastPath(*this);
  • trunk/Source/JavaScriptCore/jit/JITDivGenerator.cpp

    r192836 r194294  
    107107    notDoubleZero.link(&jit);
    108108#endif
    109     if (m_profilingCounter)
    110         jit.add32(CCallHelpers::TrustedImm32(1), CCallHelpers::AbsoluteAddress(m_profilingCounter));
     109    if (m_resultProfile)
     110        jit.add32(CCallHelpers::TrustedImm32(1), CCallHelpers::AbsoluteAddress(m_resultProfile->addressOfSpecialFastPathCount()));
    111111    jit.boxDouble(m_leftFPR, m_result);
    112112}
  • trunk/Source/JavaScriptCore/jit/JITDivGenerator.h

    r192836 r194294  
    3939        JSValueRegs result, JSValueRegs left, JSValueRegs right,
    4040        FPRReg leftFPR, FPRReg rightFPR, GPRReg scratchGPR, FPRReg scratchFPR,
    41         uint32_t* profilingCounter = nullptr)
     41        ResultProfile* resultProfile = nullptr)
    4242        : m_leftOperand(leftOperand)
    4343        , m_rightOperand(rightOperand)
     
    4949        , m_scratchGPR(scratchGPR)
    5050        , m_scratchFPR(scratchFPR)
    51         , m_profilingCounter(profilingCounter)
     51        , m_resultProfile(resultProfile)
    5252    {
    5353        ASSERT(!m_leftOperand.isConstInt32() || !m_rightOperand.isConstInt32());
     
    7272    GPRReg m_scratchGPR;
    7373    FPRReg m_scratchFPR;
    74     uint32_t* m_profilingCounter;
     74    ResultProfile* m_resultProfile;
    7575    bool m_didEmitFastPath { false };
    7676
  • trunk/Source/JavaScriptCore/jit/JITMulGenerator.cpp

    r192842 r194294  
    9292
    9393        m_slowPathJumpList.append(jit.branchMul32(CCallHelpers::Overflow, m_right.payloadGPR(), m_left.payloadGPR(), m_scratchGPR));
    94         if (!m_profilingCounter) {
     94        if (!m_resultProfile) {
    9595            m_slowPathJumpList.append(jit.branchTest32(CCallHelpers::Zero, m_scratchGPR)); // Go slow if potential negative zero.
    9696
     
    105105            // Record this, so that the speculative JIT knows that we failed speculation
    106106            // because of a negative zero.
    107             jit.add32(CCallHelpers::TrustedImm32(1), CCallHelpers::AbsoluteAddress(m_profilingCounter));
     107            jit.add32(CCallHelpers::TrustedImm32(1), CCallHelpers::AbsoluteAddress(m_resultProfile->addressOfSpecialFastPathCount()));
    108108            m_slowPathJumpList.append(jit.jump());
    109109
  • trunk/Source/JavaScriptCore/jit/JITMulGenerator.h

    r192993 r194294  
    3838    JITMulGenerator(SnippetOperand leftOperand, SnippetOperand rightOperand,
    3939        JSValueRegs result, JSValueRegs left, JSValueRegs right,
    40         FPRReg leftFPR, FPRReg rightFPR, GPRReg scratchGPR, FPRReg scratchFPR, uint32_t* profilingCounter = nullptr)
     40        FPRReg leftFPR, FPRReg rightFPR, GPRReg scratchGPR, FPRReg scratchFPR,
     41        ResultProfile* resultProfile = nullptr)
    4142        : m_leftOperand(leftOperand)
    4243        , m_rightOperand(rightOperand)
     
    4849        , m_scratchGPR(scratchGPR)
    4950        , m_scratchFPR(scratchFPR)
    50         , m_profilingCounter(profilingCounter)
     51        , m_resultProfile(resultProfile)
    5152    {
    5253        ASSERT(!m_leftOperand.isPositiveConstInt32() || !m_rightOperand.isPositiveConstInt32());
     
    6970    GPRReg m_scratchGPR;
    7071    FPRReg m_scratchFPR;
    71     uint32_t* m_profilingCounter;
     72    ResultProfile* m_resultProfile;
    7273    bool m_didEmitFastPath { false };
    7374
  • trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp

    r193603 r194294  
    117117    } while (false)
    118118
    119 #define RETURN(value) do {                \
    120         JSValue rReturnValue = (value);      \
    121         CHECK_EXCEPTION();                \
    122         OP(1) = rReturnValue;          \
    123         END_IMPL();                       \
    124     } while (false)
    125 
    126 #define RETURN_PROFILED(opcode, value) do {                  \
    127         JSValue rpPeturnValue = (value);                     \
    128         CHECK_EXCEPTION();                                   \
    129         OP(1) = rpPeturnValue;                               \
    130         PROFILE_VALUE(opcode, rpPeturnValue);                \
    131         END_IMPL();                                          \
    132     } while (false)
     119#define RETURN_WITH_PROFILING(value__, profilingAction__) do { \
     120        JSValue returnValue__ = (value__);  \
     121        CHECK_EXCEPTION();                  \
     122        OP(1) = returnValue__;              \
     123        profilingAction__;                  \
     124        END_IMPL();                         \
     125    } while (false)
     126
     127#define RETURN(value) \
     128    RETURN_WITH_PROFILING(value, { })
     129
     130#define RETURN_PROFILED(opcode__, value__) \
     131    RETURN_WITH_PROFILING(value__, PROFILE_VALUE(opcode__, returnValue__))
    133132
    134133#define PROFILE_VALUE(opcode, value) do { \
    135134        pc[OPCODE_LENGTH(opcode) - 1].u.profile->m_buckets[0] = \
    136135        JSValue::encode(value);                  \
     136    } while (false)
     137
     138#define RETURN_WITH_RESULT_PROFILING(value__) \
     139    RETURN_WITH_PROFILING(value__, PROFILE_RESULT(returnValue__))
     140   
     141#define PROFILE_RESULT(value__) do { \
     142        CodeBlock* codeBlock = exec->codeBlock();                                   \
     143        unsigned bytecodeOffset = codeBlock->bytecodeOffset(pc);                    \
     144        codeBlock->updateResultProfileForBytecodeOffset(bytecodeOffset, value__);   \
    137145    } while (false)
    138146
     
    358366   
    359367    if (v1.isString() && !v2.isObject())
    360         RETURN(jsString(exec, asString(v1), v2.toString(exec)));
     368        RETURN_WITH_RESULT_PROFILING(jsString(exec, asString(v1), v2.toString(exec)));
    361369   
    362370    if (v1.isNumber() && v2.isNumber())
    363         RETURN(jsNumber(v1.asNumber() + v2.asNumber()));
    364    
    365     RETURN(jsAddSlowCase(exec, v1, v2));
     371        RETURN_WITH_RESULT_PROFILING(jsNumber(v1.asNumber() + v2.asNumber()));
     372   
     373    RETURN_WITH_RESULT_PROFILING(jsAddSlowCase(exec, v1, v2));
    366374}
    367375
     
    375383    double a = OP_C(2).jsValue().toNumber(exec);
    376384    double b = OP_C(3).jsValue().toNumber(exec);
    377     RETURN(jsNumber(a * b));
     385    RETURN_WITH_RESULT_PROFILING(jsNumber(a * b));
    378386}
    379387
     
    383391    double a = OP_C(2).jsValue().toNumber(exec);
    384392    double b = OP_C(3).jsValue().toNumber(exec);
    385     RETURN(jsNumber(a - b));
     393    RETURN_WITH_RESULT_PROFILING(jsNumber(a - b));
    386394}
    387395
     
    391399    double a = OP_C(2).jsValue().toNumber(exec);
    392400    double b = OP_C(3).jsValue().toNumber(exec);
    393     RETURN(jsNumber(a / b));
     401    RETURN_WITH_RESULT_PROFILING(jsNumber(a / b));
    394402}
    395403
Note: See TracChangeset for help on using the changeset viewer.