From 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Tue, 27 Jun 2017 06:07:23 +0000 Subject: webkitgtk-2.16.5 --- Source/JavaScriptCore/bytecode/ExecutionCounter.h | 63 +++++++++++++++-------- 1 file changed, 41 insertions(+), 22 deletions(-) (limited to 'Source/JavaScriptCore/bytecode/ExecutionCounter.h') diff --git a/Source/JavaScriptCore/bytecode/ExecutionCounter.h b/Source/JavaScriptCore/bytecode/ExecutionCounter.h index a7346691d..f78a9123c 100644 --- a/Source/JavaScriptCore/bytecode/ExecutionCounter.h +++ b/Source/JavaScriptCore/bytecode/ExecutionCounter.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012 Apple Inc. All rights reserved. + * Copyright (C) 2012, 2014 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -23,18 +23,35 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef ExecutionCounter_h -#define ExecutionCounter_h +#pragma once #include "JSGlobalObject.h" #include "Options.h" #include -#include namespace JSC { class CodeBlock; +enum CountingVariant { + CountingForBaseline, + CountingForUpperTiers +}; + +double applyMemoryUsageHeuristics(int32_t value, CodeBlock*); +int32_t applyMemoryUsageHeuristicsAndConvertToInt(int32_t value, CodeBlock*); + +inline int32_t formattedTotalExecutionCount(float value) +{ + union { + int32_t i; + float f; + } u; + u.f = value; + return u.i; +} + +template class ExecutionCounter { public: ExecutionCounter(); @@ -44,31 +61,33 @@ public: void deferIndefinitely(); double count() const { return static_cast(m_totalCount) + m_counter; } void dump(PrintStream&) const; - static double applyMemoryUsageHeuristics(int32_t value, CodeBlock*); - static int32_t applyMemoryUsageHeuristicsAndConvertToInt(int32_t value, CodeBlock*); + + static int32_t maximumExecutionCountsBetweenCheckpoints() + { + switch (countingVariant) { + case CountingForBaseline: + return Options::maximumExecutionCountsBetweenCheckpointsForBaseline(); + case CountingForUpperTiers: + return Options::maximumExecutionCountsBetweenCheckpointsForUpperTiers(); + default: + RELEASE_ASSERT_NOT_REACHED(); + return 0; + } + } + template static T clippedThreshold(JSGlobalObject* globalObject, T threshold) { int32_t maxThreshold; if (Options::randomizeExecutionCountsBetweenCheckpoints()) - maxThreshold = globalObject->weakRandomInteger() % Options::maximumExecutionCountsBetweenCheckpoints(); + maxThreshold = globalObject->weakRandomInteger() % maximumExecutionCountsBetweenCheckpoints(); else - maxThreshold = Options::maximumExecutionCountsBetweenCheckpoints(); + maxThreshold = maximumExecutionCountsBetweenCheckpoints(); if (threshold > maxThreshold) threshold = maxThreshold; return threshold; } - static int32_t formattedTotalCount(float value) - { - union { - int32_t i; - float f; - } u; - u.f = value; - return u.i; - } - private: bool hasCrossedThreshold(CodeBlock*) const; bool setThreshold(CodeBlock*); @@ -89,12 +108,12 @@ public: // m_counter. float m_totalCount; - // This is the threshold we were originally targetting, without any correction for + // This is the threshold we were originally targeting, without any correction for // the memory usage heuristics. int32_t m_activeThreshold; }; -} // namespace JSC - -#endif // ExecutionCounter_h +typedef ExecutionCounter BaselineExecutionCounter; +typedef ExecutionCounter UpperTierExecutionCounter; +} // namespace JSC -- cgit v1.2.1