OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/snapshot/code-serializer.h" | 5 #include "src/snapshot/code-serializer.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/log.h" | 10 #include "src/log.h" |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 CopyBytes(data_ + padded_payload_offset, payload->begin(), | 333 CopyBytes(data_ + padded_payload_offset, payload->begin(), |
334 static_cast<size_t>(payload->length())); | 334 static_cast<size_t>(payload->length())); |
335 | 335 |
336 Checksum checksum(DataWithoutHeader()); | 336 Checksum checksum(DataWithoutHeader()); |
337 SetHeaderValue(kChecksum1Offset, checksum.a()); | 337 SetHeaderValue(kChecksum1Offset, checksum.a()); |
338 SetHeaderValue(kChecksum2Offset, checksum.b()); | 338 SetHeaderValue(kChecksum2Offset, checksum.b()); |
339 } | 339 } |
340 | 340 |
341 SerializedCodeData::SanityCheckResult SerializedCodeData::SanityCheck( | 341 SerializedCodeData::SanityCheckResult SerializedCodeData::SanityCheck( |
342 Isolate* isolate, uint32_t expected_source_hash) const { | 342 Isolate* isolate, uint32_t expected_source_hash) const { |
| 343 if (this->size_ < kHeaderSize) return INVALID_HEADER; |
343 uint32_t magic_number = GetMagicNumber(); | 344 uint32_t magic_number = GetMagicNumber(); |
344 if (magic_number != ComputeMagicNumber(isolate)) return MAGIC_NUMBER_MISMATCH; | 345 if (magic_number != ComputeMagicNumber(isolate)) return MAGIC_NUMBER_MISMATCH; |
345 uint32_t version_hash = GetHeaderValue(kVersionHashOffset); | 346 uint32_t version_hash = GetHeaderValue(kVersionHashOffset); |
346 uint32_t source_hash = GetHeaderValue(kSourceHashOffset); | 347 uint32_t source_hash = GetHeaderValue(kSourceHashOffset); |
347 uint32_t cpu_features = GetHeaderValue(kCpuFeaturesOffset); | 348 uint32_t cpu_features = GetHeaderValue(kCpuFeaturesOffset); |
348 uint32_t flags_hash = GetHeaderValue(kFlagHashOffset); | 349 uint32_t flags_hash = GetHeaderValue(kFlagHashOffset); |
349 uint32_t c1 = GetHeaderValue(kChecksum1Offset); | 350 uint32_t c1 = GetHeaderValue(kChecksum1Offset); |
350 uint32_t c2 = GetHeaderValue(kChecksum2Offset); | 351 uint32_t c2 = GetHeaderValue(kChecksum2Offset); |
351 if (version_hash != Version::Hash()) return VERSION_MISMATCH; | 352 if (version_hash != Version::Hash()) return VERSION_MISMATCH; |
352 if (source_hash != expected_source_hash) return SOURCE_MISMATCH; | 353 if (source_hash != expected_source_hash) return SOURCE_MISMATCH; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 *rejection_result = scd.SanityCheck(isolate, expected_source_hash); | 410 *rejection_result = scd.SanityCheck(isolate, expected_source_hash); |
410 if (*rejection_result != CHECK_SUCCESS) { | 411 if (*rejection_result != CHECK_SUCCESS) { |
411 cached_data->Reject(); | 412 cached_data->Reject(); |
412 return SerializedCodeData(nullptr, 0); | 413 return SerializedCodeData(nullptr, 0); |
413 } | 414 } |
414 return scd; | 415 return scd; |
415 } | 416 } |
416 | 417 |
417 } // namespace internal | 418 } // namespace internal |
418 } // namespace v8 | 419 } // namespace v8 |
OLD | NEW |