Commit e7c235fa authored by yangguo's avatar yangguo Committed by Commit bot

Track code cache reject reason via histogram buckets.

R=vogelheim@chromium.org
BUG=chromium:441896
LOG=N

Review URL: https://codereview.chromium.org/922573003

Cr-Commit-Position: refs/heads/master@{#26660}
parent 15c269b7
...@@ -362,7 +362,9 @@ class AggregatedHistogramTimerScope { ...@@ -362,7 +362,9 @@ class AggregatedHistogramTimerScope {
/* Generic range histograms */ \ /* Generic range histograms */ \
HR(gc_idle_time_allotted_in_ms, V8.GCIdleTimeAllottedInMS, 0, 10000, 101) \ HR(gc_idle_time_allotted_in_ms, V8.GCIdleTimeAllottedInMS, 0, 10000, 101) \
HR(gc_idle_time_limit_overshot, V8.GCIdleTimeLimit.Overshot, 0, 10000, 101) \ HR(gc_idle_time_limit_overshot, V8.GCIdleTimeLimit.Overshot, 0, 10000, 101) \
HR(gc_idle_time_limit_undershot, V8.GCIdleTimeLimit.Undershot, 0, 10000, 101) HR(gc_idle_time_limit_undershot, V8.GCIdleTimeLimit.Undershot, 0, 10000, \
101) \
HR(code_cache_reject_reason, V8.CodeCacheRejectReason, 1, 6, 6)
#define HISTOGRAM_TIMER_LIST(HT) \ #define HISTOGRAM_TIMER_LIST(HT) \
/* Garbage collection timers. */ \ /* Garbage collection timers. */ \
......
...@@ -2567,6 +2567,7 @@ SerializedCodeData::SerializedCodeData(const List<byte>& payload, ...@@ -2567,6 +2567,7 @@ SerializedCodeData::SerializedCodeData(const List<byte>& payload,
AllocateData(size); AllocateData(size);
// Set header values. // Set header values.
SetHeaderValue(kMagicNumberOffset, kMagicNumber);
SetHeaderValue(kVersionHashOffset, Version::Hash()); SetHeaderValue(kVersionHashOffset, Version::Hash());
SetHeaderValue(kSourceHashOffset, SourceHash(cs.source())); SetHeaderValue(kSourceHashOffset, SourceHash(cs.source()));
SetHeaderValue(kCpuFeaturesOffset, SetHeaderValue(kCpuFeaturesOffset,
...@@ -2597,14 +2598,24 @@ SerializedCodeData::SerializedCodeData(const List<byte>& payload, ...@@ -2597,14 +2598,24 @@ SerializedCodeData::SerializedCodeData(const List<byte>& payload,
} }
bool SerializedCodeData::IsSane(String* source) const { SerializedCodeData::SanityCheckResult SerializedCodeData::SanityCheck(
return GetHeaderValue(kVersionHashOffset) == Version::Hash() && String* source) const {
GetHeaderValue(kSourceHashOffset) == SourceHash(source) && uint32_t magic_number = GetHeaderValue(kMagicNumberOffset);
GetHeaderValue(kCpuFeaturesOffset) == uint32_t version_hash = GetHeaderValue(kVersionHashOffset);
static_cast<uint32_t>(CpuFeatures::SupportedFeatures()) && uint32_t source_hash = GetHeaderValue(kSourceHashOffset);
GetHeaderValue(kFlagHashOffset) == FlagList::Hash() && uint32_t cpu_features = GetHeaderValue(kCpuFeaturesOffset);
Checksum(Payload()).Check(GetHeaderValue(kChecksum1Offset), uint32_t flags_hash = GetHeaderValue(kFlagHashOffset);
GetHeaderValue(kChecksum2Offset)); uint32_t c1 = GetHeaderValue(kChecksum1Offset);
uint32_t c2 = GetHeaderValue(kChecksum2Offset);
if (magic_number != kMagicNumber) return MAGIC_NUMBER_MISMATCH;
if (version_hash != Version::Hash()) return VERSION_MISMATCH;
if (source_hash != SourceHash(source)) return SOURCE_MISMATCH;
if (cpu_features != static_cast<uint32_t>(CpuFeatures::SupportedFeatures())) {
return CPU_FEATURES_MISMATCH;
}
if (flags_hash != FlagList::Hash()) return FLAGS_MISMATCH;
if (!Checksum(Payload()).Check(c1, c2)) return CHECKSUM_MISMATCH;
return CHECK_SUCCESS;
} }
...@@ -2660,8 +2671,10 @@ SerializedCodeData* SerializedCodeData::FromCachedData(ScriptData* cached_data, ...@@ -2660,8 +2671,10 @@ SerializedCodeData* SerializedCodeData::FromCachedData(ScriptData* cached_data,
String* source) { String* source) {
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
SerializedCodeData* scd = new SerializedCodeData(cached_data); SerializedCodeData* scd = new SerializedCodeData(cached_data);
if (scd->IsSane(source)) return scd; SanityCheckResult r = scd->SanityCheck(source);
if (r == CHECK_SUCCESS) return scd;
cached_data->Reject(); cached_data->Reject();
source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r);
delete scd; delete scd;
return NULL; return NULL;
} }
......
...@@ -949,25 +949,39 @@ class SerializedCodeData : public SerializedData { ...@@ -949,25 +949,39 @@ class SerializedCodeData : public SerializedData {
private: private:
explicit SerializedCodeData(ScriptData* data); explicit SerializedCodeData(ScriptData* data);
bool IsSane(String* source) const; enum SanityCheckResult {
CHECK_SUCCESS = 0,
MAGIC_NUMBER_MISMATCH = 1,
VERSION_MISMATCH = 2,
SOURCE_MISMATCH = 3,
CPU_FEATURES_MISMATCH = 4,
FLAGS_MISMATCH = 5,
CHECKSUM_MISMATCH = 6,
};
SanityCheckResult SanityCheck(String* source) const;
uint32_t SourceHash(String* source) const { return source->length(); } uint32_t SourceHash(String* source) const { return source->length(); }
static const uint32_t kMagicNumber = 0xC0D1F1ED;
// The data header consists of uint32_t-sized entries: // The data header consists of uint32_t-sized entries:
// [0] version hash // [ 0] magic number
// [1] source hash // [ 1] version hash
// [2] cpu features // [ 2] source hash
// [3] flag hash // [ 3] cpu features
// [4] number of internalized strings // [ 4] flag hash
// [5] number of code stub keys // [ 5] number of internalized strings
// [6] number of reservation size entries // [ 6] number of code stub keys
// [7] payload length // [ 7] number of reservation size entries
// [8] payload checksum part 1 // [ 8] payload length
// [9] payload checksum part 2 // [ 9] payload checksum part 1
// ... reservations // [10] payload checksum part 2
// ... code stub keys // ... reservations
// ... serialized payload // ... code stub keys
static const int kVersionHashOffset = 0; // ... serialized payload
static const int kMagicNumberOffset = 0;
static const int kVersionHashOffset = kMagicNumberOffset + kInt32Size;
static const int kSourceHashOffset = kVersionHashOffset + kInt32Size; static const int kSourceHashOffset = kVersionHashOffset + kInt32Size;
static const int kCpuFeaturesOffset = kSourceHashOffset + kInt32Size; static const int kCpuFeaturesOffset = kSourceHashOffset + kInt32Size;
static const int kFlagHashOffset = kCpuFeaturesOffset + kInt32Size; static const int kFlagHashOffset = kCpuFeaturesOffset + kInt32Size;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment