X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/6fe7ccc865dc7d7541b93c5bcaf6368d2c98a174..ef99ff287df9046eb88937225e0554eabb00e33c:/bytecode/ValueProfile.h diff --git a/bytecode/ValueProfile.h b/bytecode/ValueProfile.h index 73e363a..99a9516 100644 --- a/bytecode/ValueProfile.h +++ b/bytecode/ValueProfile.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. + * Copyright (C) 2011, 2012, 2013 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -10,7 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * 3. Neither the name of Apple Inc. ("Apple") nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * @@ -29,14 +29,14 @@ #ifndef ValueProfile_h #define ValueProfile_h -#include - -#if ENABLE(VALUE_PROFILER) - +#include "ConcurrentJITLock.h" +#include "Heap.h" #include "JSArray.h" -#include "PredictedType.h" +#include "SpeculatedType.h" #include "Structure.h" #include "WriteBarrier.h" +#include +#include namespace JSC { @@ -49,7 +49,7 @@ struct ValueProfileBase { ValueProfileBase() : m_bytecodeOffset(-1) - , m_prediction(PredictNone) + , m_prediction(SpecNone) , m_numberOfSamplesInPrediction(0) { for (unsigned i = 0; i < totalNumberOfBuckets; ++i) @@ -58,7 +58,7 @@ struct ValueProfileBase { ValueProfileBase(int bytecodeOffset) : m_bytecodeOffset(bytecodeOffset) - , m_prediction(PredictNone) + , m_prediction(SpecNone) , m_numberOfSamplesInPrediction(0) { for (unsigned i = 0; i < totalNumberOfBuckets; ++i) @@ -106,28 +106,35 @@ struct ValueProfileBase { return false; } - void dump(FILE* out) + CString briefDescription(const ConcurrentJITLocker& locker) { - fprintf(out, - "samples = %u, prediction = %s", - totalNumberOfSamples(), - predictionToString(m_prediction)); + computeUpdatedPrediction(locker); + + StringPrintStream out; + out.print("predicting ", SpeculationDump(m_prediction)); + return out.toCString(); + } + + void dump(PrintStream& out) + { + out.print("samples = ", totalNumberOfSamples(), " prediction = ", SpeculationDump(m_prediction)); bool first = true; for (unsigned i = 0; i < totalNumberOfBuckets; ++i) { JSValue value = JSValue::decode(m_buckets[i]); if (!!value) { if (first) { - fprintf(out, ": "); + out.printf(": "); first = false; } else - fprintf(out, ", "); - fprintf(out, "%s", value.description()); + out.printf(", "); + out.print(value); } } } - // Updates the prediction and returns the new one. - PredictedType computeUpdatedPrediction() + // Updates the prediction and returns the new one. Never call this from any thread + // that isn't executing the code. + SpeculatedType computeUpdatedPrediction(const ConcurrentJITLocker&) { for (unsigned i = 0; i < totalNumberOfBuckets; ++i) { JSValue value = JSValue::decode(m_buckets[i]); @@ -135,7 +142,7 @@ struct ValueProfileBase { continue; m_numberOfSamplesInPrediction++; - mergePrediction(m_prediction, predictionFromValue(value)); + mergeSpeculation(m_prediction, speculationFromValue(value)); m_buckets[i] = JSValue::encode(JSValue()); } @@ -145,7 +152,7 @@ struct ValueProfileBase { int m_bytecodeOffset; // -1 for prologue - PredictedType m_prediction; + SpeculatedType m_prediction; unsigned m_numberOfSamplesInPrediction; EncodedJSValue m_buckets[totalNumberOfBuckets]; @@ -201,7 +208,5 @@ inline int getRareCaseProfileBytecodeOffset(RareCaseProfile* rareCaseProfile) } // namespace JSC -#endif // ENABLE(VALUE_PROFILER) - #endif // ValueProfile_h