From be01689f43cf6882cf670d33df49ead1f570c53a Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Sun, 27 May 2012 21:51:42 +0200 Subject: Imported WebKit commit 8d6c5efc74f0222dfc7bcce8d845d4a2707ed9e6 (http://svn.webkit.org/repository/webkit/trunk@118629) --- Source/JavaScriptCore/bytecode/ValueProfile.h | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'Source/JavaScriptCore/bytecode/ValueProfile.h') diff --git a/Source/JavaScriptCore/bytecode/ValueProfile.h b/Source/JavaScriptCore/bytecode/ValueProfile.h index 73e363a8b..47fa8b72c 100644 --- a/Source/JavaScriptCore/bytecode/ValueProfile.h +++ b/Source/JavaScriptCore/bytecode/ValueProfile.h @@ -33,6 +33,7 @@ #if ENABLE(VALUE_PROFILER) +#include "Heap.h" #include "JSArray.h" #include "PredictedType.h" #include "Structure.h" @@ -51,6 +52,7 @@ struct ValueProfileBase { : m_bytecodeOffset(-1) , m_prediction(PredictNone) , m_numberOfSamplesInPrediction(0) + , m_singletonValueIsTop(false) { for (unsigned i = 0; i < totalNumberOfBuckets; ++i) m_buckets[i] = JSValue::encode(JSValue()); @@ -60,6 +62,7 @@ struct ValueProfileBase { : m_bytecodeOffset(bytecodeOffset) , m_prediction(PredictNone) , m_numberOfSamplesInPrediction(0) + , m_singletonValueIsTop(false) { for (unsigned i = 0; i < totalNumberOfBuckets; ++i) m_buckets[i] = JSValue::encode(JSValue()); @@ -112,6 +115,11 @@ struct ValueProfileBase { "samples = %u, prediction = %s", totalNumberOfSamples(), predictionToString(m_prediction)); + fprintf(out, ", value = "); + if (m_singletonValueIsTop) + fprintf(out, "TOP"); + else + fprintf(out, "%s", m_singletonValue.description()); bool first = true; for (unsigned i = 0; i < totalNumberOfBuckets; ++i) { JSValue value = JSValue::decode(m_buckets[i]); @@ -127,7 +135,7 @@ struct ValueProfileBase { } // Updates the prediction and returns the new one. - PredictedType computeUpdatedPrediction() + PredictedType computeUpdatedPrediction(OperationInProgress operation = NoOperation) { for (unsigned i = 0; i < totalNumberOfBuckets; ++i) { JSValue value = JSValue::decode(m_buckets[i]); @@ -137,9 +145,23 @@ struct ValueProfileBase { m_numberOfSamplesInPrediction++; mergePrediction(m_prediction, predictionFromValue(value)); + if (!m_singletonValueIsTop && !!value) { + if (!m_singletonValue) + m_singletonValue = value; + else if (m_singletonValue != value) + m_singletonValueIsTop = true; + } + m_buckets[i] = JSValue::encode(JSValue()); } + if (operation == Collection + && !m_singletonValueIsTop + && !!m_singletonValue + && m_singletonValue.isCell() + && !Heap::isMarked(m_singletonValue.asCell())) + m_singletonValueIsTop = true; + return m_prediction; } @@ -148,6 +170,9 @@ struct ValueProfileBase { PredictedType m_prediction; unsigned m_numberOfSamplesInPrediction; + bool m_singletonValueIsTop; + JSValue m_singletonValue; + EncodedJSValue m_buckets[totalNumberOfBuckets]; }; -- cgit v1.2.1