Title: [102978] trunk/Source/_javascript_Core
Revision
102978
Author
[email protected]
Date
2011-12-15 13:29:37 -0800 (Thu, 15 Dec 2011)

Log 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.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (102977 => 102978)


--- trunk/Source/_javascript_Core/ChangeLog	2011-12-15 21:07:14 UTC (rev 102977)
+++ trunk/Source/_javascript_Core/ChangeLog	2011-12-15 21:29:37 UTC (rev 102978)
@@ -1,3 +1,15 @@
+2011-12-15  Andy Wingo  <[email protected]>
+
+        Use more macrology in JSC::Options
+        https://bugs.webkit.org/show_bug.cgi?id=72938
+
+        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.
+
 2011-12-15  Anders Carlsson  <[email protected]>
 
         Add ScrollingCoordinator class and ENABLE_THREADED_SCROLLING define

Modified: trunk/Source/_javascript_Core/runtime/Options.cpp (102977 => 102978)


--- trunk/Source/_javascript_Core/runtime/Options.cpp	2011-12-15 21:07:14 UTC (rev 102977)
+++ trunk/Source/_javascript_Core/runtime/Options.cpp	2011-12-15 21:29:37 UTC (rev 102978)
@@ -44,52 +44,10 @@
 
 namespace JSC { namespace Options {
 
-unsigned maximumOptimizationCandidateInstructionCount;
+#define DEFINE(type, cname, default_val) type cname;
+FOR_EACH_OPTION(DEFINE)
+#undef DEFINE
 
-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)
 {
@@ -129,67 +87,35 @@
 
 void initializeOptions()
 {
-    SET(maximumOptimizationCandidateInstructionCount, 1000);
-    
-    SET(maximumFunctionForCallInlineCandidateInstructionCount, 150);
-    SET(maximumFunctionForConstructInlineCandidateInstructionCount, 80);
-    
-    SET(maximumInliningDepth, 5);
+#define INIT(type, cname, default_val) SET(cname, default_val);
+    FOR_EACH_OPTION(INIT)
+#undef INIT
 
-    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);
+    if (!gcMarkStackSegmentSize)
+        gcMarkStackSegmentSize = pageSize();
 
-    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);
-
-    SET(largeFailCountThresholdBase,        20);
-    SET(largeFailCountThresholdBaseForLoop, 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 (!numberOfGCMarkers) {
+        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;
-    
-    SET(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;
 
+        numberOfGCMarkers = cpusToUse;
+    }
+    
     ASSERT(executionCounterValueForDontOptimizeAnytimeSoon <= executionCounterValueForOptimizeAfterLongWarmUp);
     ASSERT(executionCounterValueForOptimizeAfterLongWarmUp <= executionCounterValueForOptimizeAfterWarmUp);
     ASSERT(executionCounterValueForOptimizeAfterWarmUp <= executionCounterValueForOptimizeSoon);

Modified: trunk/Source/_javascript_Core/runtime/Options.h (102977 => 102978)


--- trunk/Source/_javascript_Core/runtime/Options.h	2011-12-15 21:07:14 UTC (rev 102977)
+++ trunk/Source/_javascript_Core/runtime/Options.h	2011-12-15 21:29:37 UTC (rev 102978)
@@ -30,52 +30,66 @@
 
 namespace JSC { namespace Options {
 
-extern unsigned maximumOptimizationCandidateInstructionCount;
+// maximumInliningDepth is the maximum depth of inline stack, so 1 = no
+// inlining, 2 = one level, etc
 
-extern unsigned maximumFunctionForCallInlineCandidateInstructionCount;
-extern unsigned maximumFunctionForConstructInlineCandidateInstructionCount;
+// couldTakeSlowCaseThreshold shouldn't be zero because some ops will spuriously
+// take slow case, for example for linking or caching.
 
-extern unsigned maximumInliningDepth; // Depth of inline stack, so 1 = no inlining, 2 = one level, etc.
+#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)
 
-extern int32_t executionCounterValueForOptimizeAfterWarmUp;
-extern int32_t executionCounterValueForOptimizeAfterLongWarmUp;
-extern int32_t executionCounterValueForDontOptimizeAnytimeSoon;
-extern int32_t executionCounterValueForOptimizeSoon;
-extern int32_t executionCounterValueForOptimizeNextInvocation;
+#define FOR_EACH_OPTION(m) \
+    FOR_EACH_HEURISTIC(m)
 
-extern int32_t executionCounterIncrementForLoop;
-extern int32_t executionCounterIncrementForReturn;
+#define DECLARE(type, cname, default_val) extern type cname;
+FOR_EACH_OPTION(DECLARE)
+#undef DECLARE
 
-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();
 
 } } // namespace JSC::Options
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to