| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 class AddressMapBase { | 143 class AddressMapBase { |
| 144 protected: | 144 protected: |
| 145 static void SetValue(HashMap::Entry* entry, uint32_t v) { | 145 static void SetValue(HashMap::Entry* entry, uint32_t v) { |
| 146 entry->value = reinterpret_cast<void*>(v); | 146 entry->value = reinterpret_cast<void*>(v); |
| 147 } | 147 } |
| 148 | 148 |
| 149 static uint32_t GetValue(HashMap::Entry* entry) { | 149 static uint32_t GetValue(HashMap::Entry* entry) { |
| 150 return static_cast<uint32_t>(reinterpret_cast<intptr_t>(entry->value)); | 150 return static_cast<uint32_t>(reinterpret_cast<intptr_t>(entry->value)); |
| 151 } | 151 } |
| 152 | 152 |
| 153 static HashMap::Entry* LookupEntry(HashMap* map, HeapObject* obj, | 153 inline static HashMap::Entry* LookupEntry(HashMap* map, HeapObject* obj, |
| 154 bool insert) { | 154 bool insert) { |
| 155 return map->Lookup(Key(obj), Hash(obj), insert); | 155 return map->Lookup(Key(obj), Hash(obj), insert); |
| 156 } | 156 } |
| 157 | 157 |
| 158 private: | 158 private: |
| 159 static uint32_t Hash(HeapObject* obj) { | 159 static uint32_t Hash(HeapObject* obj) { |
| 160 return static_cast<int32_t>(reinterpret_cast<intptr_t>(obj->address())); | 160 return static_cast<int32_t>(reinterpret_cast<intptr_t>(obj->address())); |
| 161 } | 161 } |
| 162 | 162 |
| 163 static void* Key(HeapObject* obj) { | 163 static void* Key(HeapObject* obj) { |
| 164 return reinterpret_cast<void*>(obj->address()); | 164 return reinterpret_cast<void*>(obj->address()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 188 | 188 |
| 189 class PartialCacheIndexMap : public AddressMapBase { | 189 class PartialCacheIndexMap : public AddressMapBase { |
| 190 public: | 190 public: |
| 191 PartialCacheIndexMap() : map_(HashMap::PointersMatch) {} | 191 PartialCacheIndexMap() : map_(HashMap::PointersMatch) {} |
| 192 | 192 |
| 193 static const int kInvalidIndex = -1; | 193 static const int kInvalidIndex = -1; |
| 194 | 194 |
| 195 // Lookup object in the map. Return its index if found, or create | 195 // Lookup object in the map. Return its index if found, or create |
| 196 // a new entry with new_index as value, and return kInvalidIndex. | 196 // a new entry with new_index as value, and return kInvalidIndex. |
| 197 int LookupOrInsert(HeapObject* obj, int new_index) { | 197 int LookupOrInsert(HeapObject* obj, int new_index) { |
| 198 HashMap::Entry* entry = LookupEntry(&map_, obj, true); | 198 HashMap::Entry* entry = LookupEntry(&map_, obj, false); |
| 199 if (entry->value != NULL) return GetValue(entry); | 199 if (entry != NULL) return GetValue(entry); |
| 200 SetValue(entry, static_cast<uint32_t>(new_index)); | 200 SetValue(LookupEntry(&map_, obj, true), static_cast<uint32_t>(new_index)); |
| 201 return kInvalidIndex; | 201 return kInvalidIndex; |
| 202 } | 202 } |
| 203 | 203 |
| 204 private: | 204 private: |
| 205 HashMap map_; | 205 HashMap map_; |
| 206 | 206 |
| 207 DISALLOW_COPY_AND_ASSIGN(PartialCacheIndexMap); | 207 DISALLOW_COPY_AND_ASSIGN(PartialCacheIndexMap); |
| 208 }; | 208 }; |
| 209 | 209 |
| 210 | 210 |
| (...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1021 kNumInternalizedStringsOffset + kInt32Size; | 1021 kNumInternalizedStringsOffset + kInt32Size; |
| 1022 static const int kNumCodeStubKeysOffset = kNumReservationsOffset + kInt32Size; | 1022 static const int kNumCodeStubKeysOffset = kNumReservationsOffset + kInt32Size; |
| 1023 static const int kPayloadLengthOffset = kNumCodeStubKeysOffset + kInt32Size; | 1023 static const int kPayloadLengthOffset = kNumCodeStubKeysOffset + kInt32Size; |
| 1024 static const int kChecksum1Offset = kPayloadLengthOffset + kInt32Size; | 1024 static const int kChecksum1Offset = kPayloadLengthOffset + kInt32Size; |
| 1025 static const int kChecksum2Offset = kChecksum1Offset + kInt32Size; | 1025 static const int kChecksum2Offset = kChecksum1Offset + kInt32Size; |
| 1026 static const int kHeaderSize = kChecksum2Offset + kInt32Size; | 1026 static const int kHeaderSize = kChecksum2Offset + kInt32Size; |
| 1027 }; | 1027 }; |
| 1028 } } // namespace v8::internal | 1028 } } // namespace v8::internal |
| 1029 | 1029 |
| 1030 #endif // V8_SERIALIZE_H_ | 1030 #endif // V8_SERIALIZE_H_ |
| OLD | NEW |