diff options
Diffstat (limited to 'Source/JavaScriptCore/bytecode/ExecutionCounter.cpp')
-rw-r--r-- | Source/JavaScriptCore/bytecode/ExecutionCounter.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/Source/JavaScriptCore/bytecode/ExecutionCounter.cpp b/Source/JavaScriptCore/bytecode/ExecutionCounter.cpp index ea335005e..1f2e8260a 100644 --- a/Source/JavaScriptCore/bytecode/ExecutionCounter.cpp +++ b/Source/JavaScriptCore/bytecode/ExecutionCounter.cpp @@ -28,6 +28,7 @@ #include "CodeBlock.h" #include "ExecutableAllocator.h" +#include <wtf/StringExtras.h> namespace JSC { @@ -125,7 +126,7 @@ bool ExecutionCounter::setThreshold(CodeBlock* codeBlock) ASSERT(!hasCrossedThreshold(codeBlock)); // Compute the true total count. - double trueTotalCount = static_cast<double>(m_totalCount) + m_counter; + double trueTotalCount = count(); // Correct the threshold for current memory usage. double threshold = applyMemoryUsageHeuristics(m_activeThreshold, codeBlock); @@ -143,9 +144,14 @@ bool ExecutionCounter::setThreshold(CodeBlock* codeBlock) return true; } - if (threshold > std::numeric_limits<int32_t>::max()) - threshold = std::numeric_limits<int32_t>::max(); - + int32_t maxThreshold; + if (Options::randomizeExecutionCountsBetweenCheckpoints) + maxThreshold = codeBlock->globalObject()->weakRandomInteger() % Options::maximumExecutionCountsBetweenCheckpoints; + else + maxThreshold = Options::maximumExecutionCountsBetweenCheckpoints; + if (threshold > maxThreshold) + threshold = maxThreshold; + m_counter = static_cast<int32_t>(-threshold); m_totalCount = trueTotalCount + threshold; @@ -160,5 +166,12 @@ void ExecutionCounter::reset() m_activeThreshold = 0; } +const char* ExecutionCounter::status() const +{ + static char result[80]; + snprintf(result, sizeof(result), "%lf/%lf, %d", count(), static_cast<double>(m_activeThreshold), m_counter); + return result; +} + } // namespace JSC |