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 {
/* Generic range histograms */ \
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_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) \
/* Garbage collection timers. */ \
......
......@@ -2567,6 +2567,7 @@ SerializedCodeData::SerializedCodeData(const List<byte>& payload,
AllocateData(size);
// Set header values.
SetHeaderValue(kMagicNumberOffset, kMagicNumber);
SetHeaderValue(kVersionHashOffset, Version::Hash());
SetHeaderValue(kSourceHashOffset, SourceHash(cs.source()));
SetHeaderValue(kCpuFeaturesOffset,
......@@ -2597,14 +2598,24 @@ SerializedCodeData::SerializedCodeData(const List<byte>& payload,
}
bool SerializedCodeData::IsSane(String* source) const {
return GetHeaderValue(kVersionHashOffset) == Version::Hash() &&
GetHeaderValue(kSourceHashOffset) == SourceHash(source) &&
GetHeaderValue(kCpuFeaturesOffset) ==
static_cast<uint32_t>(CpuFeatures::SupportedFeatures()) &&
GetHeaderValue(kFlagHashOffset) == FlagList::Hash() &&
Checksum(Payload()).Check(GetHeaderValue(kChecksum1Offset),
GetHeaderValue(kChecksum2Offset));
SerializedCodeData::SanityCheckResult SerializedCodeData::SanityCheck(
String* source) const {
uint32_t magic_number = GetHeaderValue(kMagicNumberOffset);
uint32_t version_hash = GetHeaderValue(kVersionHashOffset);
uint32_t source_hash = GetHeaderValue(kSourceHashOffset);
uint32_t cpu_features = GetHeaderValue(kCpuFeaturesOffset);
uint32_t flags_hash = GetHeaderValue(kFlagHashOffset);
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,
String* source) {
DisallowHeapAllocation no_gc;
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();
source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r);
delete scd;
return NULL;
}
......
......@@ -949,25 +949,39 @@ class SerializedCodeData : public SerializedData {
private:
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(); }
static const uint32_t kMagicNumber = 0xC0D1F1ED;
// The data header consists of uint32_t-sized entries:
// [0] version hash
// [1] source hash
// [2] cpu features
// [3] flag hash
// [4] number of internalized strings
// [5] number of code stub keys
// [6] number of reservation size entries
// [7] payload length
// [8] payload checksum part 1
// [9] payload checksum part 2
// ... reservations
// ... code stub keys
// ... serialized payload
static const int kVersionHashOffset = 0;
// [ 0] magic number
// [ 1] version hash
// [ 2] source hash
// [ 3] cpu features
// [ 4] flag hash
// [ 5] number of internalized strings
// [ 6] number of code stub keys
// [ 7] number of reservation size entries
// [ 8] payload length
// [ 9] payload checksum part 1
// [10] payload checksum part 2
// ... reservations
// ... code stub keys
// ... serialized payload
static const int kMagicNumberOffset = 0;
static const int kVersionHashOffset = kMagicNumberOffset + kInt32Size;
static const int kSourceHashOffset = kVersionHashOffset + kInt32Size;
static const int kCpuFeaturesOffset = kSourceHashOffset + 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