Ignore:
Timestamp:
Dec 15, 2011, 1:29:37 PM (13 years ago)
Author:
[email protected]
Message:

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

Patch by Andy Wingo <[email protected]> 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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);
Note: See TracChangeset for help on using the changeset viewer.