[serializer] checksum a larger part of the code snapshot.

So far we only snapshot the payload data for the deserializer, but
not the data for heap reservation or the code stub keys.

At the same time this change turns some CHECKs that fail in the wild
to DCHECKs. We can try turning them back to CHECKs some other time.

TBR=ahaas@chromium.org
BUG=chromium:636876

Review-Url: https://codereview.chromium.org/2237883002
Cr-Commit-Position: refs/heads/master@{#38594}
This commit is contained in:
yangguo 2016-08-11 22:09:39 -07:00 committed by Commit bot
parent 63dd16849f
commit c84b850954
3 changed files with 11 additions and 5 deletions

View File

@ -315,10 +315,6 @@ SerializedCodeData::SerializedCodeData(const List<byte>* payload,
SetHeaderValue(kNumCodeStubKeysOffset, num_stub_keys);
SetHeaderValue(kPayloadLengthOffset, payload->length());
Checksum checksum(payload->ToConstVector());
SetHeaderValue(kChecksum1Offset, checksum.a());
SetHeaderValue(kChecksum2Offset, checksum.b());
// Copy reservation chunk sizes.
CopyBytes(data_ + kHeaderSize, reinterpret_cast<byte*>(reservations.begin()),
reservation_size);
@ -332,6 +328,10 @@ SerializedCodeData::SerializedCodeData(const List<byte>* payload,
// Copy serialized data.
CopyBytes(data_ + padded_payload_offset, payload->begin(),
static_cast<size_t>(payload->length()));
Checksum checksum(DataWithoutHeader());
SetHeaderValue(kChecksum1Offset, checksum.a());
SetHeaderValue(kChecksum2Offset, checksum.b());
}
SerializedCodeData::SanityCheckResult SerializedCodeData::SanityCheck(
@ -350,7 +350,7 @@ SerializedCodeData::SanityCheckResult SerializedCodeData::SanityCheck(
return CPU_FEATURES_MISMATCH;
}
if (flags_hash != FlagList::Hash()) return FLAGS_MISMATCH;
if (!Checksum(Payload()).Check(c1, c2)) return CHECKSUM_MISMATCH;
if (!Checksum(DataWithoutHeader()).Check(c1, c2)) return CHECKSUM_MISMATCH;
return CHECK_SUCCESS;
}

View File

@ -115,6 +115,10 @@ class SerializedCodeData : public SerializedData {
SerializedCodeData(const byte* data, int size)
: SerializedData(const_cast<byte*>(data), size) {}
Vector<const byte> DataWithoutHeader() const {
return Vector<const byte>(data_ + kHeaderSize, size_ - kHeaderSize);
}
SanityCheckResult SanityCheck(Isolate* isolate,
uint32_t expected_source_hash) const;
// The data header consists of uint32_t-sized entries:

View File

@ -163,12 +163,14 @@ MaybeHandle<HeapObject> Deserializer::DeserializeObject(Isolate* isolate) {
Deserializer::~Deserializer() {
// TODO(svenpanne) Re-enable this assertion when v8 initialization is fixed.
// DCHECK(source_.AtEOF());
#ifdef DEBUG
for (int space = 0; space < kNumberOfPreallocatedSpaces; space++) {
int chunk_index = current_chunk_[space];
CHECK_EQ(reservations_[space].length(), chunk_index + 1);
CHECK_EQ(reservations_[space][chunk_index].end, high_water_[space]);
}
CHECK_EQ(allocated_maps_.length(), next_map_index_);
#endif // DEBUG
}
// This is called on the roots. It is the driver of the deserialization