Changeset 190213 in webkit


Ignore:
Timestamp:
Sep 24, 2015 11:38:35 AM (9 years ago)
Author:
mark.lam@apple.com
Message:

We should only expect a RareCaseProfile to exist if the rare case actually exists.
https://bugs.webkit.org/show_bug.cgi?id=149531

Reviewed by Saam Barati.

The current code that calls rareCaseProfileForBytecodeOffset() assumes that it
will always return a non-null RareCaseProfile. As a result, op_add in the
baseline JIT is forced to add a dummy slow case that will never be taken, only to
ensure that the RareCaseProfile for that bytecode is created. This profile will
always produce a counter value of 0 (since that path will never be taken).

Instead, we'll make the callers of rareCaseProfileForBytecodeOffset() check if
the profile actually exist before dereferencing it.

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::rareCaseProfileForBytecodeOffset):
(JSC::CodeBlock::rareCaseProfileCountForBytecodeOffset):
(JSC::CodeBlock::capabilityLevel):

  • bytecode/CodeBlock.h:

(JSC::CodeBlock::addRareCaseProfile):
(JSC::CodeBlock::numberOfRareCaseProfiles):
(JSC::CodeBlock::likelyToTakeSlowCase):
(JSC::CodeBlock::couldTakeSlowCase):
(JSC::CodeBlock::likelyToTakeDeepestSlowCase):
(JSC::CodeBlock::likelyToTakeAnySlowCase):
(JSC::CodeBlock::rareCaseProfile): Deleted.

  • jit/JITArithmetic.cpp:

(JSC::JIT::emit_op_add):
(JSC::JIT::emitSlow_op_add):

  • jit/JITArithmetic32_64.cpp:

(JSC::JIT::emit_op_add):
(JSC::JIT::emitSlow_op_add):

Location:
trunk/Source/JavaScriptCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r190201 r190213  
     12015-09-24  Mark Lam  <mark.lam@apple.com>
     2
     3        We should only expect a RareCaseProfile to exist if the rare case actually exists.
     4        https://bugs.webkit.org/show_bug.cgi?id=149531
     5
     6        Reviewed by Saam Barati.
     7
     8        The current code that calls rareCaseProfileForBytecodeOffset() assumes that it
     9        will always return a non-null RareCaseProfile.  As a result, op_add in the
     10        baseline JIT is forced to add a dummy slow case that will never be taken, only to
     11        ensure that the RareCaseProfile for that bytecode is created.  This profile will
     12        always produce a counter value of 0 (since that path will never be taken).
     13
     14        Instead, we'll make the callers of rareCaseProfileForBytecodeOffset() check if
     15        the profile actually exist before dereferencing it.
     16
     17        * bytecode/CodeBlock.cpp:
     18        (JSC::CodeBlock::rareCaseProfileForBytecodeOffset):
     19        (JSC::CodeBlock::rareCaseProfileCountForBytecodeOffset):
     20        (JSC::CodeBlock::capabilityLevel):
     21        * bytecode/CodeBlock.h:
     22        (JSC::CodeBlock::addRareCaseProfile):
     23        (JSC::CodeBlock::numberOfRareCaseProfiles):
     24        (JSC::CodeBlock::likelyToTakeSlowCase):
     25        (JSC::CodeBlock::couldTakeSlowCase):
     26        (JSC::CodeBlock::likelyToTakeDeepestSlowCase):
     27        (JSC::CodeBlock::likelyToTakeAnySlowCase):
     28        (JSC::CodeBlock::rareCaseProfile): Deleted.
     29        * jit/JITArithmetic.cpp:
     30        (JSC::JIT::emit_op_add):
     31        (JSC::JIT::emitSlow_op_add):
     32        * jit/JITArithmetic32_64.cpp:
     33        (JSC::JIT::emit_op_add):
     34        (JSC::JIT::emitSlow_op_add):
     35
    1362015-09-24  Ryosuke Niwa  <rniwa@webkit.org>
    237
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp

    r190073 r190213  
    39703970}
    39713971
     3972unsigned CodeBlock::rareCaseProfileCountForBytecodeOffset(int bytecodeOffset)
     3973{
     3974    RareCaseProfile* profile = rareCaseProfileForBytecodeOffset(bytecodeOffset);
     3975    if (profile)
     3976        return profile->m_counter;
     3977    return 0;
     3978}
     3979
    39723980#if ENABLE(JIT)
    39733981DFG::CapabilityLevel CodeBlock::capabilityLevel()
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.h

    r190129 r190213  
    407407    }
    408408    unsigned numberOfRareCaseProfiles() { return m_rareCaseProfiles.size(); }
    409     RareCaseProfile* rareCaseProfile(int index) { return &m_rareCaseProfiles[index]; }
    410409    RareCaseProfile* rareCaseProfileForBytecodeOffset(int bytecodeOffset);
     410    unsigned rareCaseProfileCountForBytecodeOffset(int bytecodeOffset);
    411411
    412412    bool likelyToTakeSlowCase(int bytecodeOffset)
     
    414414        if (!hasBaselineJITProfiling())
    415415            return false;
    416         unsigned value = rareCaseProfileForBytecodeOffset(bytecodeOffset)->m_counter;
     416        unsigned value = rareCaseProfileCountForBytecodeOffset(bytecodeOffset);
    417417        return value >= Options::likelyToTakeSlowCaseMinimumCount();
    418418    }
     
    422422        if (!hasBaselineJITProfiling())
    423423            return false;
    424         unsigned value = rareCaseProfileForBytecodeOffset(bytecodeOffset)->m_counter;
     424        unsigned value = rareCaseProfileCountForBytecodeOffset(bytecodeOffset);
    425425        return value >= Options::couldTakeSlowCaseMinimumCount();
    426426    }
     
    460460        if (!hasBaselineJITProfiling())
    461461            return false;
    462         unsigned slowCaseCount = rareCaseProfileForBytecodeOffset(bytecodeOffset)->m_counter;
     462        unsigned slowCaseCount = rareCaseProfileCountForBytecodeOffset(bytecodeOffset);
    463463        unsigned specialFastCaseCount = specialFastCaseProfileForBytecodeOffset(bytecodeOffset)->m_counter;
    464464        unsigned value = slowCaseCount - specialFastCaseCount;
     
    470470        if (!hasBaselineJITProfiling())
    471471            return false;
    472         unsigned slowCaseCount = rareCaseProfileForBytecodeOffset(bytecodeOffset)->m_counter;
     472        unsigned slowCaseCount = rareCaseProfileCountForBytecodeOffset(bytecodeOffset);
    473473        unsigned specialFastCaseCount = specialFastCaseProfileForBytecodeOffset(bytecodeOffset)->m_counter;
    474474        unsigned value = slowCaseCount + specialFastCaseCount;
  • trunk/Source/JavaScriptCore/jit/JITArithmetic.cpp

    r189444 r190213  
    796796
    797797    if (!types.first().mightBeNumber() || !types.second().mightBeNumber()) {
    798         addSlowCase();
    799798        JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_add);
    800799        slowPathCall.call();
     
    825824    OperandTypes types = OperandTypes::fromInt(currentInstruction[4].u.operand);
    826825
    827     if (!types.first().mightBeNumber() || !types.second().mightBeNumber()) {
    828         linkDummySlowCase(iter);
    829         return;
    830     }
     826    RELEASE_ASSERT(types.first().mightBeNumber() && types.second().mightBeNumber());
    831827
    832828    bool op1HasImmediateIntFastCase = isOperandConstantImmediateInt(op1);
  • trunk/Source/JavaScriptCore/jit/JITArithmetic32_64.cpp

    r189575 r190213  
    490490
    491491    if (!types.first().mightBeNumber() || !types.second().mightBeNumber()) {
    492         addSlowCase();
    493492        JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_add);
    494493        slowPathCall.call();
     
    559558    OperandTypes types = OperandTypes::fromInt(currentInstruction[4].u.operand);
    560559
    561     if (!types.first().mightBeNumber() || !types.second().mightBeNumber()) {
    562         linkDummySlowCase(iter);
    563         return;
    564     }
     560    RELEASE_ASSERT(types.first().mightBeNumber() && types.second().mightBeNumber());
    565561
    566562    int op;
Note: See TracChangeset for help on using the changeset viewer.