Ignore:
Timestamp:
Dec 18, 2015, 2:03:30 PM (9 years ago)
Author:
[email protected]
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):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.