diff --git a/src/snapshot/code-serializer.cc b/src/snapshot/code-serializer.cc index 601659a149..8d2f5d9339 100644 --- a/src/snapshot/code-serializer.cc +++ b/src/snapshot/code-serializer.cc @@ -315,10 +315,6 @@ SerializedCodeData::SerializedCodeData(const List* 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(reservations.begin()), reservation_size); @@ -332,6 +328,10 @@ SerializedCodeData::SerializedCodeData(const List* payload, // Copy serialized data. CopyBytes(data_ + padded_payload_offset, payload->begin(), static_cast(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; } diff --git a/src/snapshot/code-serializer.h b/src/snapshot/code-serializer.h index 6a5937d728..e82a7d5dd6 100644 --- a/src/snapshot/code-serializer.h +++ b/src/snapshot/code-serializer.h @@ -115,6 +115,10 @@ class SerializedCodeData : public SerializedData { SerializedCodeData(const byte* data, int size) : SerializedData(const_cast(data), size) {} + Vector DataWithoutHeader() const { + return Vector(data_ + kHeaderSize, size_ - kHeaderSize); + } + SanityCheckResult SanityCheck(Isolate* isolate, uint32_t expected_source_hash) const; // The data header consists of uint32_t-sized entries: diff --git a/src/snapshot/deserializer.cc b/src/snapshot/deserializer.cc index d8df2d0d56..269a9a890d 100644 --- a/src/snapshot/deserializer.cc +++ b/src/snapshot/deserializer.cc @@ -163,12 +163,14 @@ MaybeHandle 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