It should be possible to change the value of an Options variable without recompiling...
authorfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Dec 2011 01:11:36 +0000 (01:11 +0000)
committerfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Dec 2011 01:11:36 +0000 (01:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=74807

Reviewed by Gavin Barraclough.

* runtime/Options.cpp:
(JSC::Options::initializeOptions):
* runtime/Options.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@103286 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/Options.cpp
Source/JavaScriptCore/runtime/Options.h

index 2c90aa3..40e70ad 100644 (file)
@@ -1,3 +1,14 @@
+2011-12-18  Filip Pizlo  <fpizlo@apple.com>
+
+        It should be possible to change the value of an Options variable without recompiling the world
+        https://bugs.webkit.org/show_bug.cgi?id=74807
+
+        Reviewed by Gavin Barraclough.
+
+        * runtime/Options.cpp:
+        (JSC::Options::initializeOptions):
+        * runtime/Options.h:
+
 2011-12-19  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r103250.
index 899f66e..68d10b7 100644 (file)
 
 namespace JSC { namespace Options {
 
-#define DEFINE(type, cname, default_val) type cname;
-FOR_EACH_OPTION(DEFINE)
-#undef DEFINE
+unsigned maximumOptimizationCandidateInstructionCount;
+
+unsigned maximumFunctionForCallInlineCandidateInstructionCount;
+unsigned maximumFunctionForConstructInlineCandidateInstructionCount;
+
+unsigned maximumInliningDepth;
+
+int32_t executionCounterValueForOptimizeAfterWarmUp;
+int32_t executionCounterValueForOptimizeAfterLongWarmUp;
+int32_t executionCounterValueForDontOptimizeAnytimeSoon;
+int32_t executionCounterValueForOptimizeSoon;
+int32_t executionCounterValueForOptimizeNextInvocation;
+
+int32_t executionCounterIncrementForLoop;
+int32_t executionCounterIncrementForReturn;
+
+unsigned desiredSpeculativeSuccessFailRatio;
+
+double likelyToTakeSlowCaseThreshold;
+double couldTakeSlowCaseThreshold;
+unsigned likelyToTakeSlowCaseMinimumCount;
+unsigned couldTakeSlowCaseMinimumCount;
+
+double osrExitProminenceForFrequentExitSite;
+
+unsigned largeFailCountThresholdBase;
+unsigned largeFailCountThresholdBaseForLoop;
+
+unsigned reoptimizationRetryCounterMax;
+unsigned reoptimizationRetryCounterStep;
+
+unsigned minimumOptimizationDelay;
+unsigned maximumOptimizationDelay;
+double desiredProfileLivenessRate;
+double desiredProfileFullnessRate;
+
+double doubleVoteRatioForDoubleFormat;
+
+unsigned minimumNumberOfScansBetweenRebalance;
+unsigned gcMarkStackSegmentSize;
+unsigned minimumNumberOfCellsToKeep;
+unsigned maximumNumberOfSharedSegments;
+unsigned sharedStackWakeupThreshold;
+unsigned numberOfGCMarkers;
+unsigned opaqueRootMergeThreshold;
 
 #if ENABLE(RUN_TIME_HEURISTICS)
 static bool parse(const char* string, int32_t& value)
@@ -87,35 +129,67 @@ void setHeuristic(T& variable, const char* name, U value)
 
 void initializeOptions()
 {
-#define INIT(type, cname, default_val) SET(cname, default_val);
-    FOR_EACH_OPTION(INIT)
-#undef INIT
+    SET(maximumOptimizationCandidateInstructionCount, 1000);
+    
+    SET(maximumFunctionForCallInlineCandidateInstructionCount, 150);
+    SET(maximumFunctionForConstructInlineCandidateInstructionCount, 80);
+    
+    SET(maximumInliningDepth, 5);
+
+    SET(executionCounterValueForOptimizeAfterWarmUp,     -1000);
+    SET(executionCounterValueForOptimizeAfterLongWarmUp, -5000);
+    SET(executionCounterValueForDontOptimizeAnytimeSoon, std::numeric_limits<int32_t>::min());
+    SET(executionCounterValueForOptimizeSoon,            -1000);
+    SET(executionCounterValueForOptimizeNextInvocation,  0);
 
-    // Now we initialize heuristics whose defaults are not known at
-    // compile-time.
+    SET(executionCounterIncrementForLoop,   1);
+    SET(executionCounterIncrementForReturn, 15);
+
+    SET(desiredSpeculativeSuccessFailRatio, 6);
+    
+    SET(likelyToTakeSlowCaseThreshold,    0.15);
+    SET(couldTakeSlowCaseThreshold,       0.05); // Shouldn't be zero because some ops will spuriously take slow case, for example for linking or caching.
+    SET(likelyToTakeSlowCaseMinimumCount, 100);
+    SET(couldTakeSlowCaseMinimumCount,    10);
+    
+    SET(osrExitProminenceForFrequentExitSite, 0.3);
 
-    if (!gcMarkStackSegmentSize)
-        gcMarkStackSegmentSize = pageSize();
+    SET(largeFailCountThresholdBase,        20);
+    SET(largeFailCountThresholdBaseForLoop, 1);
 
-    if (!numberOfGCMarkers) {
-        int cpusToUse = 1;
+    SET(reoptimizationRetryCounterStep, 1);
+
+    SET(minimumOptimizationDelay,   1);
+    SET(maximumOptimizationDelay,   5);
+    SET(desiredProfileLivenessRate, 0.75);
+    SET(desiredProfileFullnessRate, 0.35);
+    
+    SET(doubleVoteRatioForDoubleFormat, 2);
+    
+    SET(minimumNumberOfScansBetweenRebalance, 10000);
+    SET(gcMarkStackSegmentSize,               pageSize());
+    SET(minimumNumberOfCellsToKeep,           10);
+    SET(maximumNumberOfSharedSegments,        3);
+    SET(sharedStackWakeupThreshold,           1);
+    SET(opaqueRootMergeThreshold,             1000);
+
+    int cpusToUse = 1;
 #if OS(DARWIN) && ENABLE(PARALLEL_GC)
-        int name[2];
-        size_t valueSize = sizeof(cpusToUse);
-        name[0] = CTL_HW;
-        name[1] = HW_AVAILCPU;
-        sysctl(name, 2, &cpusToUse, &valueSize, 0, 0);
+    int name[2];
+    size_t valueSize = sizeof(cpusToUse);
+    name[0] = CTL_HW;
+    name[1] = HW_AVAILCPU;
+    sysctl(name, 2, &cpusToUse, &valueSize, 0, 0);
 #endif
-        // We don't scale so well beyond 4.
-        if (cpusToUse > 4)
-            cpusToUse = 4;
-        // Be paranoid, it is the OS we're dealing with, after all.
-        if (cpusToUse < 1)
-            cpusToUse = 1;
-
-        numberOfGCMarkers = cpusToUse;
-    }
+    // We don't scale so well beyond 4.
+    if (cpusToUse > 4)
+        cpusToUse = 4;
+    // Be paranoid, it is the OS we're dealing with, after all.
+    if (cpusToUse < 1)
+        cpusToUse = 1;
     
+    SET(numberOfGCMarkers, cpusToUse);
+
     ASSERT(executionCounterValueForDontOptimizeAnytimeSoon <= executionCounterValueForOptimizeAfterLongWarmUp);
     ASSERT(executionCounterValueForOptimizeAfterLongWarmUp <= executionCounterValueForOptimizeAfterWarmUp);
     ASSERT(executionCounterValueForOptimizeAfterWarmUp <= executionCounterValueForOptimizeSoon);
index 2f80bf6..f7cc5f4 100644 (file)
 
 namespace JSC { namespace Options {
 
-// maximumInliningDepth is the maximum depth of inline stack, so 1 = no
-// inlining, 2 = one level, etc
-
-// couldTakeSlowCaseThreshold shouldn't be zero because some ops will spuriously
-// take slow case, for example for linking or caching.
-
-#define FOR_EACH_HEURISTIC(m) \
-    m(unsigned, maximumOptimizationCandidateInstructionCount, 1000) \
-    \
-    m(unsigned, maximumFunctionForCallInlineCandidateInstructionCount, 150) \
-    m(unsigned, maximumFunctionForConstructInlineCandidateInstructionCount, 80) \
-    \
-    m(unsigned, maximumInliningDepth, 5)                              \
-    \
-    m(int32_t, executionCounterValueForOptimizeAfterWarmUp,      -1000) \
-    m(int32_t, executionCounterValueForOptimizeAfterLongWarmUp,  -5000) \
-    m(int32_t, executionCounterValueForDontOptimizeAnytimeSoon,  std::numeric_limits<int32_t>::min()) \
-    m(int32_t, executionCounterValueForOptimizeSoon,             -1000) \
-    m(int32_t, executionCounterValueForOptimizeNextInvocation,   0) \
-    \
-    m(int32_t, executionCounterIncrementForLoop,       1) \
-    m(int32_t, executionCounterIncrementForReturn,     15) \
-    \
-    m(unsigned, desiredSpeculativeSuccessFailRatio,    6) \
-    \
-    m(double,   likelyToTakeSlowCaseThreshold,         0.15) \
-    m(double,   couldTakeSlowCaseThreshold,            0.05) \
-    m(unsigned, likelyToTakeSlowCaseMinimumCount,      100) \
-    m(unsigned, couldTakeSlowCaseMinimumCount,         10) \
-    \
-    m(double,   osrExitProminenceForFrequentExitSite,  0.3) \
-    \
-    m(unsigned, largeFailCountThresholdBase,           20) \
-    m(unsigned, largeFailCountThresholdBaseForLoop,    1) \
-    \
-    m(unsigned, reoptimizationRetryCounterMax,         0) \
-    m(unsigned, reoptimizationRetryCounterStep,        1) \
-    \
-    m(unsigned, minimumOptimizationDelay,              1) \
-    m(unsigned, maximumOptimizationDelay,              5) \
-    m(double, desiredProfileLivenessRate,              0.75) \
-    m(double, desiredProfileFullnessRate,              0.35) \
-    \
-    m(double,   doubleVoteRatioForDoubleFormat,        2) \
-    \
-    m(unsigned, minimumNumberOfScansBetweenRebalance,  10000) \
-    m(unsigned, gcMarkStackSegmentSize,                0) \
-    m(unsigned, minimumNumberOfCellsToKeep,            10) \
-    m(unsigned, maximumNumberOfSharedSegments,         3) \
-    m(unsigned, sharedStackWakeupThreshold,            1) \
-    m(unsigned, numberOfGCMarkers,                     0) \
-    m(unsigned, opaqueRootMergeThreshold,              1000)
-
-#define FOR_EACH_OPTION(m) \
-    FOR_EACH_HEURISTIC(m)
-
-#define DECLARE(type, cname, default_val) extern type cname;
-FOR_EACH_OPTION(DECLARE)
-#undef DECLARE
+extern unsigned maximumOptimizationCandidateInstructionCount;
+
+extern unsigned maximumFunctionForCallInlineCandidateInstructionCount;
+extern unsigned maximumFunctionForConstructInlineCandidateInstructionCount;
+
+extern unsigned maximumInliningDepth; // Depth of inline stack, so 1 = no inlining, 2 = one level, etc.
+
+extern int32_t executionCounterValueForOptimizeAfterWarmUp;
+extern int32_t executionCounterValueForOptimizeAfterLongWarmUp;
+extern int32_t executionCounterValueForDontOptimizeAnytimeSoon;
+extern int32_t executionCounterValueForOptimizeSoon;
+extern int32_t executionCounterValueForOptimizeNextInvocation;
+
+extern int32_t executionCounterIncrementForLoop;
+extern int32_t executionCounterIncrementForReturn;
+
+extern unsigned desiredSpeculativeSuccessFailRatio;
+
+extern double likelyToTakeSlowCaseThreshold;
+extern double couldTakeSlowCaseThreshold;
+extern unsigned likelyToTakeSlowCaseMinimumCount;
+extern unsigned couldTakeSlowCaseMinimumCount;
+
+extern double osrExitProminenceForFrequentExitSite;
+
+extern unsigned largeFailCountThresholdBase;
+extern unsigned largeFailCountThresholdBaseForLoop;
+
+extern unsigned reoptimizationRetryCounterMax;
+extern unsigned reoptimizationRetryCounterStep;
+
+extern unsigned minimumOptimizationDelay;
+extern unsigned maximumOptimizationDelay;
+extern double desiredProfileLivenessRate;
+extern double desiredProfileFullnessRate;
+
+extern double doubleVoteRatioForDoubleFormat;
+
+extern unsigned minimumNumberOfScansBetweenRebalance;
+extern unsigned gcMarkStackSegmentSize;
+extern unsigned minimumNumberOfCellsToKeep;
+extern unsigned maximumNumberOfSharedSegments;
+extern unsigned sharedStackWakeupThreshold;
+extern unsigned numberOfGCMarkers;
+extern unsigned opaqueRootMergeThreshold;
 
 void initializeOptions();