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; | |
106 static const int kSourceHashOffset = kVersionHashOffset + kInt32Size; | 107 static const int kSourceHashOffset = kVersionHashOffset + kInt32Size; |
107 static const int kCpuFeaturesOffset = kSourceHashOffset + kInt32Size; | 108 static const int kCpuFeaturesOffset = kSourceHashOffset + kInt32Size; |
108 static const int kFlagHashOffset = kCpuFeaturesOffset + kInt32Size; | 109 static const int kFlagHashOffset = kCpuFeaturesOffset + kInt32Size; |
109 static const int kNumReservationsOffset = kFlagHashOffset + kInt32Size; | 110 static const int kNumReservationsOffset = kFlagHashOffset + kInt32Size; |
110 static const int kNumCodeStubKeysOffset = kNumReservationsOffset + kInt32Size; | 111 static const int kNumCodeStubKeysOffset = kNumReservationsOffset + kInt32Size; |
111 static const int kPayloadLengthOffset = kNumCodeStubKeysOffset + kInt32Size; | 112 static const int kPayloadLengthOffset = kNumCodeStubKeysOffset + kInt32Size; |
112 static const int kChecksum1Offset = kPayloadLengthOffset + kInt32Size; | 113 static const int kChecksum1Offset = kPayloadLengthOffset + kInt32Size; |
113 static const int kChecksum2Offset = kChecksum1Offset + kInt32Size; | 114 static const int kChecksum2Offset = kChecksum1Offset + kInt32Size; |
114 static const int kHeaderSize = kChecksum2Offset + kInt32Size; | 115 static const int kUnalignedHeaderSize = kChecksum2Offset + kInt32Size; |
| 116 static const int kHeaderSize = POINTER_SIZE_ALIGN(kUnalignedHeaderSize); |
115 | 117 |
116 // Used when consuming. | 118 // Used when consuming. |
117 static const SerializedCodeData FromCachedData( | 119 static const SerializedCodeData FromCachedData( |
118 Isolate* isolate, ScriptData* cached_data, uint32_t expected_source_hash, | 120 Isolate* isolate, ScriptData* cached_data, uint32_t expected_source_hash, |
119 SanityCheckResult* rejection_result); | 121 SanityCheckResult* rejection_result); |
120 | 122 |
121 // Used when producing. | 123 // Used when producing. |
122 SerializedCodeData(const List<byte>* payload, const CodeSerializer* cs); | 124 SerializedCodeData(const List<byte>* payload, const CodeSerializer* cs); |
123 | 125 |
124 // Return ScriptData object and relinquish ownership over it to the caller. | 126 // Return ScriptData object and relinquish ownership over it to the caller. |
(...skipping 16 matching lines...) Expand all Loading... |
141 } | 143 } |
142 | 144 |
143 SanityCheckResult SanityCheck(Isolate* isolate, | 145 SanityCheckResult SanityCheck(Isolate* isolate, |
144 uint32_t expected_source_hash) const; | 146 uint32_t expected_source_hash) const; |
145 }; | 147 }; |
146 | 148 |
147 } // namespace internal | 149 } // namespace internal |
148 } // namespace v8 | 150 } // namespace v8 |
149 | 151 |
150 #endif // V8_SNAPSHOT_CODE_SERIALIZER_H_ | 152 #endif // V8_SNAPSHOT_CODE_SERIALIZER_H_ |
OLD | NEW |