Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(363)

Unified Diff: src/serialize.cc

Issue 922573003: Track code cache reject reason via histogram buckets. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rename Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/serialize.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/serialize.cc
diff --git a/src/serialize.cc b/src/serialize.cc
index 62b200581b466c6d44a7ec3b3472aa0f47ba2f46..da39ff0e5673108b52d922b0f2f081aef40077f7 100644
--- a/src/serialize.cc
+++ b/src/serialize.cc
@@ -2569,6 +2569,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,
@@ -2599,14 +2600,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;
}
@@ -2662,8 +2673,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);
vogelheim 2015/02/16 12:01:36 Just curious: Why count only the failures, and not
delete scd;
return NULL;
}
« no previous file with comments | « src/serialize.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698