Changeset 102978 in webkit


Ignore:
Timestamp:
Dec 15, 2011 1:29:37 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Use more macrology in JSC::Options
https://bugs.webkit.org/show_bug.cgi?id=72938

Patch by Andy Wingo <wingo@igalia.com> on 2011-12-15
Reviewed by Filip Pizlo.

  • runtime/Options.cpp:

(JSC::Options::initializeOptions):

  • runtime/Options.h: Use macros to ensure that all heuristics are

declared and have initializers.

Location:
trunk/Source/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r102975 r102978  
     12011-12-15  Andy Wingo  <wingo@igalia.com>
     2
     3        Use more macrology in JSC::Options
     4        https://bugs.webkit.org/show_bug.cgi?id=72938
     5
     6        Reviewed by Filip Pizlo.
     7
     8        * runtime/Options.cpp:
     9        (JSC::Options::initializeOptions):
     10        * runtime/Options.h: Use macros to ensure that all heuristics are
     11        declared and have initializers.
     12
    1132011-12-15  Anders Carlsson  <andersca@apple.com>
    214
  • trunk/Source/JavaScriptCore/runtime/Options.cpp

    r102917 r102978  
    4545namespace JSC { namespace Options {
    4646
    47 unsigned maximumOptimizationCandidateInstructionCount;
    48 
    49 unsigned maximumFunctionForCallInlineCandidateInstructionCount;
    50 unsigned maximumFunctionForConstructInlineCandidateInstructionCount;
    51 
    52 unsigned maximumInliningDepth;
    53 
    54 int32_t executionCounterValueForOptimizeAfterWarmUp;
    55 int32_t executionCounterValueForOptimizeAfterLongWarmUp;
    56 int32_t executionCounterValueForDontOptimizeAnytimeSoon;
    57 int32_t executionCounterValueForOptimizeSoon;
    58 int32_t executionCounterValueForOptimizeNextInvocation;
    59 
    60 int32_t executionCounterIncrementForLoop;
    61 int32_t executionCounterIncrementForReturn;
    62 
    63 unsigned desiredSpeculativeSuccessFailRatio;
    64 
    65 double likelyToTakeSlowCaseThreshold;
    66 double couldTakeSlowCaseThreshold;
    67 unsigned likelyToTakeSlowCaseMinimumCount;
    68 unsigned couldTakeSlowCaseMinimumCount;
    69 
    70 double osrExitProminenceForFrequentExitSite;
    71 
    72 unsigned largeFailCountThresholdBase;
    73 unsigned largeFailCountThresholdBaseForLoop;
    74 
    75 unsigned reoptimizationRetryCounterMax;
    76 unsigned reoptimizationRetryCounterStep;
    77 
    78 unsigned minimumOptimizationDelay;
    79 unsigned maximumOptimizationDelay;
    80 double desiredProfileLivenessRate;
    81 double desiredProfileFullnessRate;
    82 
    83 double doubleVoteRatioForDoubleFormat;
    84 
    85 unsigned minimumNumberOfScansBetweenRebalance;
    86 unsigned gcMarkStackSegmentSize;
    87 unsigned minimumNumberOfCellsToKeep;
    88 unsigned maximumNumberOfSharedSegments;
    89 unsigned sharedStackWakeupThreshold;
    90 unsigned numberOfGCMarkers;
    91 unsigned opaqueRootMergeThreshold;
     47#define DEFINE(type, cname, default_val) type cname;
     48FOR_EACH_OPTION(DEFINE)
     49#undef DEFINE
    9250
    9351#if ENABLE(RUN_TIME_HEURISTICS)
     
    13088void initializeOptions()
    13189{
    132     SET(maximumOptimizationCandidateInstructionCount, 1000);
     90#define INIT(type, cname, default_val) SET(cname, default_val);
     91    FOR_EACH_OPTION(INIT)
     92#undef INIT
     93
     94    // Now we initialize heuristics whose defaults are not known at
     95    // compile-time.
     96
     97    if (!gcMarkStackSegmentSize)
     98        gcMarkStackSegmentSize = pageSize();
     99
     100    if (!numberOfGCMarkers) {
     101        int cpusToUse = 1;
     102#if OS(DARWIN) && ENABLE(PARALLEL_GC)
     103        int name[2];
     104        size_t valueSize = sizeof(cpusToUse);
     105        name[0] = CTL_HW;
     106        name[1] = HW_AVAILCPU;
     107        sysctl(name, 2, &cpusToUse, &valueSize, 0, 0);
     108#endif
     109        // We don't scale so well beyond 4.
     110        if (cpusToUse > 4)
     111            cpusToUse = 4;
     112        // Be paranoid, it is the OS we're dealing with, after all.
     113        if (cpusToUse < 1)
     114            cpusToUse = 1;
     115
     116        numberOfGCMarkers = cpusToUse;
     117    }
    133118   
    134     SET(maximumFunctionForCallInlineCandidateInstructionCount, 150);
    135     SET(maximumFunctionForConstructInlineCandidateInstructionCount, 80);
    136    
    137     SET(maximumInliningDepth, 5);
    138 
    139     SET(executionCounterValueForOptimizeAfterWarmUp,     -1000);
    140     SET(executionCounterValueForOptimizeAfterLongWarmUp, -5000);
    141     SET(executionCounterValueForDontOptimizeAnytimeSoon, std::numeric_limits<int32_t>::min());
    142     SET(executionCounterValueForOptimizeSoon,            -1000);
    143     SET(executionCounterValueForOptimizeNextInvocation,  0);
    144 
    145     SET(executionCounterIncrementForLoop,   1);
    146     SET(executionCounterIncrementForReturn, 15);
    147 
    148     SET(desiredSpeculativeSuccessFailRatio, 6);
    149    
    150     SET(likelyToTakeSlowCaseThreshold,    0.15);
    151     SET(couldTakeSlowCaseThreshold,       0.05); // Shouldn't be zero because some ops will spuriously take slow case, for example for linking or caching.
    152     SET(likelyToTakeSlowCaseMinimumCount, 100);
    153     SET(couldTakeSlowCaseMinimumCount,    10);
    154    
    155     SET(osrExitProminenceForFrequentExitSite, 0.3);
    156 
    157     SET(largeFailCountThresholdBase,        20);
    158     SET(largeFailCountThresholdBaseForLoop, 1);
    159 
    160     SET(reoptimizationRetryCounterStep, 1);
    161 
    162     SET(minimumOptimizationDelay,   1);
    163     SET(maximumOptimizationDelay,   5);
    164     SET(desiredProfileLivenessRate, 0.75);
    165     SET(desiredProfileFullnessRate, 0.35);
    166    
    167     SET(doubleVoteRatioForDoubleFormat, 2);
    168    
    169     SET(minimumNumberOfScansBetweenRebalance, 10000);
    170     SET(gcMarkStackSegmentSize,               pageSize());
    171     SET(minimumNumberOfCellsToKeep,           10);
    172     SET(maximumNumberOfSharedSegments,        3);
    173     SET(sharedStackWakeupThreshold,           1);
    174     SET(opaqueRootMergeThreshold,             1000);
    175 
    176     int cpusToUse = 1;
    177 #if OS(DARWIN) && ENABLE(PARALLEL_GC)
    178     int name[2];
    179     size_t valueSize = sizeof(cpusToUse);
    180     name[0] = CTL_HW;
    181     name[1] = HW_AVAILCPU;
    182     sysctl(name, 2, &cpusToUse, &valueSize, 0, 0);
    183 #endif
    184     // We don't scale so well beyond 4.
    185     if (cpusToUse > 4)
    186         cpusToUse = 4;
    187     // Be paranoid, it is the OS we're dealing with, after all.
    188     if (cpusToUse < 1)
    189         cpusToUse = 1;
    190    
    191     SET(numberOfGCMarkers, cpusToUse);
    192 
    193119    ASSERT(executionCounterValueForDontOptimizeAnytimeSoon <= executionCounterValueForOptimizeAfterLongWarmUp);
    194120    ASSERT(executionCounterValueForOptimizeAfterLongWarmUp <= executionCounterValueForOptimizeAfterWarmUp);
  • trunk/Source/JavaScriptCore/runtime/Options.h

    r102917 r102978  
    3131namespace JSC { namespace Options {
    3232
    33 extern unsigned maximumOptimizationCandidateInstructionCount;
     33// maximumInliningDepth is the maximum depth of inline stack, so 1 = no
     34// inlining, 2 = one level, etc
    3435
    35 extern unsigned maximumFunctionForCallInlineCandidateInstructionCount;
    36 extern unsigned maximumFunctionForConstructInlineCandidateInstructionCount;
     36// couldTakeSlowCaseThreshold shouldn't be zero because some ops will spuriously
     37// take slow case, for example for linking or caching.
    3738
    38 extern unsigned maximumInliningDepth; // Depth of inline stack, so 1 = no inlining, 2 = one level, etc.
     39#define FOR_EACH_HEURISTIC(m) \
     40    m(unsigned, maximumOptimizationCandidateInstructionCount, 1000) \
     41    \
     42    m(unsigned, maximumFunctionForCallInlineCandidateInstructionCount, 150) \
     43    m(unsigned, maximumFunctionForConstructInlineCandidateInstructionCount, 80) \
     44    \
     45    m(unsigned, maximumInliningDepth, 5)                              \
     46    \
     47    m(int32_t, executionCounterValueForOptimizeAfterWarmUp,      -1000) \
     48    m(int32_t, executionCounterValueForOptimizeAfterLongWarmUp,  -5000) \
     49    m(int32_t, executionCounterValueForDontOptimizeAnytimeSoon,  std::numeric_limits<int32_t>::min()) \
     50    m(int32_t, executionCounterValueForOptimizeSoon,             -1000) \
     51    m(int32_t, executionCounterValueForOptimizeNextInvocation,   0) \
     52    \
     53    m(int32_t, executionCounterIncrementForLoop,       1) \
     54    m(int32_t, executionCounterIncrementForReturn,     15) \
     55    \
     56    m(unsigned, desiredSpeculativeSuccessFailRatio,    6) \
     57    \
     58    m(double,   likelyToTakeSlowCaseThreshold,         0.15) \
     59    m(double,   couldTakeSlowCaseThreshold,            0.05) \
     60    m(unsigned, likelyToTakeSlowCaseMinimumCount,      100) \
     61    m(unsigned, couldTakeSlowCaseMinimumCount,         10) \
     62    \
     63    m(double,   osrExitProminenceForFrequentExitSite,  0.3) \
     64    \
     65    m(unsigned, largeFailCountThresholdBase,           20) \
     66    m(unsigned, largeFailCountThresholdBaseForLoop,    1) \
     67    \
     68    m(unsigned, reoptimizationRetryCounterMax,         0) \
     69    m(unsigned, reoptimizationRetryCounterStep,        1) \
     70    \
     71    m(unsigned, minimumOptimizationDelay,              1) \
     72    m(unsigned, maximumOptimizationDelay,              5) \
     73    m(double, desiredProfileLivenessRate,              0.75) \
     74    m(double, desiredProfileFullnessRate,              0.35) \
     75    \
     76    m(double,   doubleVoteRatioForDoubleFormat,        2) \
     77    \
     78    m(unsigned, minimumNumberOfScansBetweenRebalance,  10000) \
     79    m(unsigned, gcMarkStackSegmentSize,                0) \
     80    m(unsigned, minimumNumberOfCellsToKeep,            10) \
     81    m(unsigned, maximumNumberOfSharedSegments,         3) \
     82    m(unsigned, sharedStackWakeupThreshold,            1) \
     83    m(unsigned, numberOfGCMarkers,                     0) \
     84    m(unsigned, opaqueRootMergeThreshold,              1000)
    3985
    40 extern int32_t executionCounterValueForOptimizeAfterWarmUp;
    41 extern int32_t executionCounterValueForOptimizeAfterLongWarmUp;
    42 extern int32_t executionCounterValueForDontOptimizeAnytimeSoon;
    43 extern int32_t executionCounterValueForOptimizeSoon;
    44 extern int32_t executionCounterValueForOptimizeNextInvocation;
     86#define FOR_EACH_OPTION(m) \
     87    FOR_EACH_HEURISTIC(m)
    4588
    46 extern int32_t executionCounterIncrementForLoop;
    47 extern int32_t executionCounterIncrementForReturn;
    48 
    49 extern unsigned desiredSpeculativeSuccessFailRatio;
    50 
    51 extern double likelyToTakeSlowCaseThreshold;
    52 extern double couldTakeSlowCaseThreshold;
    53 extern unsigned likelyToTakeSlowCaseMinimumCount;
    54 extern unsigned couldTakeSlowCaseMinimumCount;
    55 
    56 extern double osrExitProminenceForFrequentExitSite;
    57 
    58 extern unsigned largeFailCountThresholdBase;
    59 extern unsigned largeFailCountThresholdBaseForLoop;
    60 
    61 extern unsigned reoptimizationRetryCounterMax;
    62 extern unsigned reoptimizationRetryCounterStep;
    63 
    64 extern unsigned minimumOptimizationDelay;
    65 extern unsigned maximumOptimizationDelay;
    66 extern double desiredProfileLivenessRate;
    67 extern double desiredProfileFullnessRate;
    68 
    69 extern double doubleVoteRatioForDoubleFormat;
    70 
    71 extern unsigned minimumNumberOfScansBetweenRebalance;
    72 extern unsigned gcMarkStackSegmentSize;
    73 extern unsigned minimumNumberOfCellsToKeep;
    74 extern unsigned maximumNumberOfSharedSegments;
    75 extern unsigned sharedStackWakeupThreshold;
    76 extern unsigned numberOfGCMarkers;
    77 extern unsigned opaqueRootMergeThreshold;
     89#define DECLARE(type, cname, default_val) extern type cname;
     90FOR_EACH_OPTION(DECLARE)
     91#undef DECLARE
    7892
    7993void initializeOptions();
Note: See TracChangeset for help on using the changeset viewer.