Chromium Code Reviews| 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/compiler.h" | 8 #include "src/compiler.h" |
| 9 #include "src/hashmap.h" | 9 #include "src/hashmap.h" |
| 10 #include "src/heap-profiler.h" | 10 #include "src/heap-profiler.h" |
| (...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 905 | 905 |
| 906 Vector<const Reservation> Reservations() const; | 906 Vector<const Reservation> Reservations() const; |
| 907 Vector<const byte> Payload() const; | 907 Vector<const byte> Payload() const; |
| 908 | 908 |
| 909 Vector<const byte> RawData() const { | 909 Vector<const byte> RawData() const { |
| 910 return Vector<const byte>(data_, size_); | 910 return Vector<const byte>(data_, size_); |
| 911 } | 911 } |
| 912 | 912 |
| 913 private: | 913 private: |
| 914 bool IsSane(); | 914 bool IsSane(); |
| 915 // The data header consists of int-sized entries: | 915 // The data header consists of uint32_t-sized entries: |
| 916 // [0] version hash | 916 // [0] version hash |
| 917 // [1] number of reservation size entries | 917 // [1] number of reservation size entries |
| 918 // [2] payload length | 918 // [2] payload length |
| 919 // ... reservations | |
| 920 // ... serialized payload | |
| 919 static const int kCheckSumOffset = 0; | 921 static const int kCheckSumOffset = 0; |
| 920 static const int kReservationsOffset = 1; | 922 static const int kReservationsOffset = 1; |
| 921 static const int kPayloadLengthOffset = 2; | 923 static const int kPayloadLengthOffset = 2; |
| 922 static const int kHeaderSize = (kPayloadLengthOffset + 1) * kIntSize; | 924 static const int kHeaderSize = (kPayloadLengthOffset + 1) * sizeof(uint32_t); |
|
jochen (gone - plz use gerrit)
2015/02/10 09:00:22
if it's supposed to be pointer aligned, why not si
| |
| 923 }; | 925 }; |
| 924 | 926 |
| 925 | 927 |
| 926 // Wrapper around ScriptData to provide code-serializer-specific functionality. | 928 // Wrapper around ScriptData to provide code-serializer-specific functionality. |
| 927 class SerializedCodeData : public SerializedData { | 929 class SerializedCodeData : public SerializedData { |
| 928 public: | 930 public: |
| 929 // Used when consuming. | 931 // Used when consuming. |
| 930 static SerializedCodeData* FromCachedData(ScriptData* cached_data, | 932 static SerializedCodeData* FromCachedData(ScriptData* cached_data, |
| 931 String* source) { | 933 String* source) { |
| 932 DisallowHeapAllocation no_gc; | 934 DisallowHeapAllocation no_gc; |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 950 Vector<const uint32_t> CodeStubKeys() const; | 952 Vector<const uint32_t> CodeStubKeys() const; |
| 951 | 953 |
| 952 private: | 954 private: |
| 953 explicit SerializedCodeData(ScriptData* data) | 955 explicit SerializedCodeData(ScriptData* data) |
| 954 : SerializedData(const_cast<byte*>(data->data()), data->length()) {} | 956 : SerializedData(const_cast<byte*>(data->data()), data->length()) {} |
| 955 | 957 |
| 956 bool IsSane(String* source) const; | 958 bool IsSane(String* source) const; |
| 957 | 959 |
| 958 uint32_t SourceHash(String* source) const { return source->length(); } | 960 uint32_t SourceHash(String* source) const { return source->length(); } |
| 959 | 961 |
| 960 // The data header consists of int-sized entries: | 962 // The data header consists of uint32_t-sized entries: |
| 961 // [0] version hash | 963 // [0] version hash |
| 962 // [1] source hash | 964 // [1] source hash |
| 963 // [2] cpu features | 965 // [2] cpu features |
| 964 // [3] flag hash | 966 // [3] flag hash |
| 965 // [4] number of internalized strings | 967 // [4] number of internalized strings |
| 966 // [5] number of code stub keys | 968 // [5] number of code stub keys |
| 967 // [6] number of reservation size entries | 969 // [6] number of reservation size entries |
| 968 // [7] payload length | 970 // [7] payload length |
| 971 // [8] payload checksum part 1 | |
| 972 // [9] payload checksum part 2 | |
| 973 // ... reservations | |
| 974 // ... code stub keys | |
| 975 // ... serialized payload | |
| 969 static const int kVersionHashOffset = 0; | 976 static const int kVersionHashOffset = 0; |
| 970 static const int kSourceHashOffset = 1; | 977 static const int kSourceHashOffset = 1; |
| 971 static const int kCpuFeaturesOffset = 2; | 978 static const int kCpuFeaturesOffset = 2; |
| 972 static const int kFlagHashOffset = 3; | 979 static const int kFlagHashOffset = 3; |
| 973 static const int kNumInternalizedStringsOffset = 4; | 980 static const int kNumInternalizedStringsOffset = 4; |
| 974 static const int kReservationsOffset = 5; | 981 static const int kReservationsOffset = 5; |
| 975 static const int kNumCodeStubKeysOffset = 6; | 982 static const int kNumCodeStubKeysOffset = 6; |
| 976 static const int kPayloadLengthOffset = 7; | 983 static const int kPayloadLengthOffset = 7; |
| 977 static const int kChecksum1Offset = 8; | 984 static const int kChecksum1Offset = 8; |
| 978 static const int kChecksum2Offset = 9; | 985 static const int kChecksum2Offset = 9; |
| 979 static const int kHeaderSize = | 986 static const int kHeaderSize = (kChecksum2Offset + 1) * sizeof(uint32_t); |
| 980 POINTER_SIZE_ALIGN((kChecksum2Offset + 1) * kIntSize); | |
| 981 }; | 987 }; |
| 982 } } // namespace v8::internal | 988 } } // namespace v8::internal |
| 983 | 989 |
| 984 #endif // V8_SERIALIZE_H_ | 990 #endif // V8_SERIALIZE_H_ |
| OLD | NEW |