OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_SERIALIZE_H_ | 5 #ifndef V8_SERIALIZE_H_ |
6 #define V8_SERIALIZE_H_ | 6 #define V8_SERIALIZE_H_ |
7 | 7 |
8 #include "src/hashmap.h" | 8 #include "src/hashmap.h" |
9 #include "src/heap-profiler.h" | 9 #include "src/heap-profiler.h" |
10 #include "src/isolate.h" | 10 #include "src/isolate.h" |
(...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
942 | 942 |
943 Vector<const Reservation> Reservations() const; | 943 Vector<const Reservation> Reservations() const; |
944 Vector<const byte> Payload() const; | 944 Vector<const byte> Payload() const; |
945 | 945 |
946 int NumInternalizedStrings() const; | 946 int NumInternalizedStrings() const; |
947 Vector<const uint32_t> CodeStubKeys() const; | 947 Vector<const uint32_t> CodeStubKeys() const; |
948 | 948 |
949 private: | 949 private: |
950 explicit SerializedCodeData(ScriptData* data); | 950 explicit SerializedCodeData(ScriptData* data); |
951 | 951 |
952 bool IsSane(String* source) const; | 952 enum SanityCheckResult { |
| 953 CHECK_SUCCESS = 0, |
| 954 MAGIC_NUMBER_MISMATCH = 1, |
| 955 VERSION_MISMATCH = 2, |
| 956 SOURCE_MISMATCH = 3, |
| 957 CPU_FEATURES_MISMATCH = 4, |
| 958 FLAGS_MISMATCH = 5, |
| 959 CHECKSUM_MISMATCH = 6, |
| 960 }; |
| 961 |
| 962 SanityCheckResult SanityCheck(String* source) const; |
953 | 963 |
954 uint32_t SourceHash(String* source) const { return source->length(); } | 964 uint32_t SourceHash(String* source) const { return source->length(); } |
955 | 965 |
| 966 static const uint32_t kMagicNumber = 0xC0D1F1ED; |
| 967 |
956 // The data header consists of uint32_t-sized entries: | 968 // The data header consists of uint32_t-sized entries: |
957 // [0] version hash | 969 // [ 0] magic number |
958 // [1] source hash | 970 // [ 1] version hash |
959 // [2] cpu features | 971 // [ 2] source hash |
960 // [3] flag hash | 972 // [ 3] cpu features |
961 // [4] number of internalized strings | 973 // [ 4] flag hash |
962 // [5] number of code stub keys | 974 // [ 5] number of internalized strings |
963 // [6] number of reservation size entries | 975 // [ 6] number of code stub keys |
964 // [7] payload length | 976 // [ 7] number of reservation size entries |
965 // [8] payload checksum part 1 | 977 // [ 8] payload length |
966 // [9] payload checksum part 2 | 978 // [ 9] payload checksum part 1 |
967 // ... reservations | 979 // [10] payload checksum part 2 |
968 // ... code stub keys | 980 // ... reservations |
969 // ... serialized payload | 981 // ... code stub keys |
970 static const int kVersionHashOffset = 0; | 982 // ... serialized payload |
| 983 static const int kMagicNumberOffset = 0; |
| 984 static const int kVersionHashOffset = kMagicNumberOffset + kInt32Size; |
971 static const int kSourceHashOffset = kVersionHashOffset + kInt32Size; | 985 static const int kSourceHashOffset = kVersionHashOffset + kInt32Size; |
972 static const int kCpuFeaturesOffset = kSourceHashOffset + kInt32Size; | 986 static const int kCpuFeaturesOffset = kSourceHashOffset + kInt32Size; |
973 static const int kFlagHashOffset = kCpuFeaturesOffset + kInt32Size; | 987 static const int kFlagHashOffset = kCpuFeaturesOffset + kInt32Size; |
974 static const int kNumInternalizedStringsOffset = kFlagHashOffset + kInt32Size; | 988 static const int kNumInternalizedStringsOffset = kFlagHashOffset + kInt32Size; |
975 static const int kNumReservationsOffset = | 989 static const int kNumReservationsOffset = |
976 kNumInternalizedStringsOffset + kInt32Size; | 990 kNumInternalizedStringsOffset + kInt32Size; |
977 static const int kNumCodeStubKeysOffset = kNumReservationsOffset + kInt32Size; | 991 static const int kNumCodeStubKeysOffset = kNumReservationsOffset + kInt32Size; |
978 static const int kPayloadLengthOffset = kNumCodeStubKeysOffset + kInt32Size; | 992 static const int kPayloadLengthOffset = kNumCodeStubKeysOffset + kInt32Size; |
979 static const int kChecksum1Offset = kPayloadLengthOffset + kInt32Size; | 993 static const int kChecksum1Offset = kPayloadLengthOffset + kInt32Size; |
980 static const int kChecksum2Offset = kChecksum1Offset + kInt32Size; | 994 static const int kChecksum2Offset = kChecksum1Offset + kInt32Size; |
981 static const int kHeaderSize = kChecksum2Offset + kInt32Size; | 995 static const int kHeaderSize = kChecksum2Offset + kInt32Size; |
982 }; | 996 }; |
983 } } // namespace v8::internal | 997 } } // namespace v8::internal |
984 | 998 |
985 #endif // V8_SERIALIZE_H_ | 999 #endif // V8_SERIALIZE_H_ |
OLD | NEW |