Chromium Code Reviews| 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 #ifndef V8_SNAPSHOT_CODE_SERIALIZER_H_ | 5 #ifndef V8_SNAPSHOT_CODE_SERIALIZER_H_ |
| 6 #define V8_SNAPSHOT_CODE_SERIALIZER_H_ | 6 #define V8_SNAPSHOT_CODE_SERIALIZER_H_ |
| 7 | 7 |
| 8 #include "src/parsing/preparse-data.h" | 8 #include "src/parsing/preparse-data.h" |
| 9 #include "src/snapshot/serializer.h" | 9 #include "src/snapshot/serializer.h" |
| 10 | 10 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 class SerializedCodeData : public SerializedData { | 78 class SerializedCodeData : public SerializedData { |
| 79 public: | 79 public: |
| 80 enum SanityCheckResult { | 80 enum SanityCheckResult { |
| 81 CHECK_SUCCESS = 0, | 81 CHECK_SUCCESS = 0, |
| 82 MAGIC_NUMBER_MISMATCH = 1, | 82 MAGIC_NUMBER_MISMATCH = 1, |
| 83 VERSION_MISMATCH = 2, | 83 VERSION_MISMATCH = 2, |
| 84 SOURCE_MISMATCH = 3, | 84 SOURCE_MISMATCH = 3, |
| 85 CPU_FEATURES_MISMATCH = 4, | 85 CPU_FEATURES_MISMATCH = 4, |
| 86 FLAGS_MISMATCH = 5, | 86 FLAGS_MISMATCH = 5, |
| 87 CHECKSUM_MISMATCH = 6, | 87 CHECKSUM_MISMATCH = 6, |
| 88 INVALID_HEADER = 7 | 88 INVALID_HEADER = 7, |
| 89 LENGTH_MISMATCH = 8 | |
| 89 }; | 90 }; |
| 90 | 91 |
| 91 // The data header consists of uint32_t-sized entries: | 92 // The data header consists of uint32_t-sized entries: |
| 92 // [0] magic number and external reference count | 93 // [0] magic number and (internally provided) external reference count |
| 93 // [1] version hash | 94 // [1] extra (API-provided) external reference count |
| 94 // [2] source hash | 95 // [2] version hash |
| 95 // [3] cpu features | 96 // [3] source hash |
| 96 // [4] flag hash | 97 // [4] cpu features |
| 97 // [5] number of code stub keys | 98 // [5] flag hash |
| 98 // [6] number of reservation size entries | 99 // [6] number of code stub keys |
| 99 // [7] payload length | 100 // [7] number of reservation size entries |
| 100 // [8] payload checksum part 1 | 101 // [8] payload length |
| 101 // [9] payload checksum part 2 | 102 // [9] payload checksum part 1 |
| 103 // [10] payload checksum part 2 | |
| 102 // ... reservations | 104 // ... reservations |
| 103 // ... code stub keys | 105 // ... code stub keys |
| 104 // ... serialized payload | 106 // ... serialized payload |
| 105 static const int kVersionHashOffset = kMagicNumberOffset + kInt32Size; | 107 static const int kVersionHashOffset = |
| 108 kExtraExternalReferencesOffset + kInt32Size; | |
| 106 static const int kSourceHashOffset = kVersionHashOffset + kInt32Size; | 109 static const int kSourceHashOffset = kVersionHashOffset + kInt32Size; |
| 107 static const int kCpuFeaturesOffset = kSourceHashOffset + kInt32Size; | 110 static const int kCpuFeaturesOffset = kSourceHashOffset + kInt32Size; |
| 108 static const int kFlagHashOffset = kCpuFeaturesOffset + kInt32Size; | 111 static const int kFlagHashOffset = kCpuFeaturesOffset + kInt32Size; |
| 109 static const int kNumReservationsOffset = kFlagHashOffset + kInt32Size; | 112 static const int kNumReservationsOffset = kFlagHashOffset + kInt32Size; |
| 110 static const int kNumCodeStubKeysOffset = kNumReservationsOffset + kInt32Size; | 113 static const int kNumCodeStubKeysOffset = kNumReservationsOffset + kInt32Size; |
| 111 static const int kPayloadLengthOffset = kNumCodeStubKeysOffset + kInt32Size; | 114 static const int kPayloadLengthOffset = kNumCodeStubKeysOffset + kInt32Size; |
| 112 static const int kChecksum1Offset = kPayloadLengthOffset + kInt32Size; | 115 static const int kChecksum1Offset = kPayloadLengthOffset + kInt32Size; |
| 113 static const int kChecksum2Offset = kChecksum1Offset + kInt32Size; | 116 static const int kChecksum2Offset = kChecksum1Offset + kInt32Size; |
| 114 static const int kHeaderSize = kChecksum2Offset + kInt32Size; | 117 static const int kHeaderSize = kChecksum2Offset + kInt32Size; |
| 115 | 118 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 130 Vector<const uint32_t> CodeStubKeys() const; | 133 Vector<const uint32_t> CodeStubKeys() const; |
| 131 | 134 |
| 132 static uint32_t SourceHash(Handle<String> source); | 135 static uint32_t SourceHash(Handle<String> source); |
| 133 | 136 |
| 134 private: | 137 private: |
| 135 explicit SerializedCodeData(ScriptData* data); | 138 explicit SerializedCodeData(ScriptData* data); |
| 136 SerializedCodeData(const byte* data, int size) | 139 SerializedCodeData(const byte* data, int size) |
| 137 : SerializedData(const_cast<byte*>(data), size) {} | 140 : SerializedData(const_cast<byte*>(data), size) {} |
| 138 | 141 |
| 139 Vector<const byte> DataWithoutHeader() const { | 142 Vector<const byte> DataWithoutHeader() const { |
| 140 return Vector<const byte>(data_ + kHeaderSize, size_ - kHeaderSize); | 143 const int kPaddedStart = POINTER_SIZE_ALIGN(kHeaderSize); |
|
Yang
2017/03/07 11:28:11
Let's define kHeaderSize to be padded. Also see re
Jakob Kummerow
2017/03/07 12:39:15
Done.
| |
| 144 return Vector<const byte>(data_ + kPaddedStart, size_ - kPaddedStart); | |
| 141 } | 145 } |
| 142 | 146 |
| 143 SanityCheckResult SanityCheck(Isolate* isolate, | 147 SanityCheckResult SanityCheck(Isolate* isolate, |
| 144 uint32_t expected_source_hash) const; | 148 uint32_t expected_source_hash) const; |
| 145 }; | 149 }; |
| 146 | 150 |
| 147 } // namespace internal | 151 } // namespace internal |
| 148 } // namespace v8 | 152 } // namespace v8 |
| 149 | 153 |
| 150 #endif // V8_SNAPSHOT_CODE_SERIALIZER_H_ | 154 #endif // V8_SNAPSHOT_CODE_SERIALIZER_H_ |
| OLD | NEW |