| 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_SERIALIZER_COMMON_H_ | 5 #ifndef V8_SNAPSHOT_SERIALIZER_COMMON_H_ |
| 6 #define V8_SNAPSHOT_SERIALIZER_COMMON_H_ | 6 #define V8_SNAPSHOT_SERIALIZER_COMMON_H_ |
| 7 | 7 |
| 8 #include "src/address-map.h" | 8 #include "src/address-map.h" |
| 9 #include "src/external-reference-table.h" | 9 #include "src/external-reference-table.h" |
| 10 #include "src/globals.h" | 10 #include "src/globals.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 DISALLOW_COPY_AND_ASSIGN(ExternalReferenceEncoder); | 33 DISALLOW_COPY_AND_ASSIGN(ExternalReferenceEncoder); |
| 34 }; | 34 }; |
| 35 | 35 |
| 36 class HotObjectsList { | 36 class HotObjectsList { |
| 37 public: | 37 public: |
| 38 HotObjectsList() : index_(0) { | 38 HotObjectsList() : index_(0) { |
| 39 for (int i = 0; i < kSize; i++) circular_queue_[i] = NULL; | 39 for (int i = 0; i < kSize; i++) circular_queue_[i] = NULL; |
| 40 } | 40 } |
| 41 | 41 |
| 42 void Add(HeapObject* object) { | 42 void Add(HeapObject* object) { |
| 43 DCHECK(!AllowHeapAllocation::IsAllowed()); |
| 43 circular_queue_[index_] = object; | 44 circular_queue_[index_] = object; |
| 44 index_ = (index_ + 1) & kSizeMask; | 45 index_ = (index_ + 1) & kSizeMask; |
| 45 } | 46 } |
| 46 | 47 |
| 47 HeapObject* Get(int index) { | 48 HeapObject* Get(int index) { |
| 49 DCHECK(!AllowHeapAllocation::IsAllowed()); |
| 48 DCHECK_NOT_NULL(circular_queue_[index]); | 50 DCHECK_NOT_NULL(circular_queue_[index]); |
| 49 return circular_queue_[index]; | 51 return circular_queue_[index]; |
| 50 } | 52 } |
| 51 | 53 |
| 52 static const int kNotFound = -1; | 54 static const int kNotFound = -1; |
| 53 | 55 |
| 54 int Find(HeapObject* object) { | 56 int Find(HeapObject* object) { |
| 57 DCHECK(!AllowHeapAllocation::IsAllowed()); |
| 55 for (int i = 0; i < kSize; i++) { | 58 for (int i = 0; i < kSize; i++) { |
| 56 if (circular_queue_[i] == object) return i; | 59 if (circular_queue_[i] == object) return i; |
| 57 } | 60 } |
| 58 return kNotFound; | 61 return kNotFound; |
| 59 } | 62 } |
| 60 | 63 |
| 61 static const int kSize = 8; | 64 static const int kSize = 8; |
| 62 | 65 |
| 63 private: | 66 private: |
| 64 STATIC_ASSERT(IS_POWER_OF_TWO(kSize)); | 67 STATIC_ASSERT(IS_POWER_OF_TWO(kSize)); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 // 0xf0..0xff | 207 // 0xf0..0xff |
| 205 static const int kFixedRepeat = 0xf0; | 208 static const int kFixedRepeat = 0xf0; |
| 206 static const int kFixedRepeatStart = kFixedRepeat - 1; | 209 static const int kFixedRepeatStart = kFixedRepeat - 1; |
| 207 | 210 |
| 208 // ---------- special values ---------- | 211 // ---------- special values ---------- |
| 209 static const int kAnyOldSpace = -1; | 212 static const int kAnyOldSpace = -1; |
| 210 | 213 |
| 211 // Sentinel after a new object to indicate that double alignment is needed. | 214 // Sentinel after a new object to indicate that double alignment is needed. |
| 212 static const int kDoubleAlignmentSentinel = 0; | 215 static const int kDoubleAlignmentSentinel = 0; |
| 213 | 216 |
| 214 // Used as index for the attached reference representing the source object. | |
| 215 static const int kSourceObjectReference = 0; | |
| 216 | |
| 217 // Used as index for the attached reference representing the global proxy. | |
| 218 static const int kGlobalProxyReference = 0; | |
| 219 | |
| 220 // ---------- member variable ---------- | 217 // ---------- member variable ---------- |
| 221 HotObjectsList hot_objects_; | 218 HotObjectsList hot_objects_; |
| 222 }; | 219 }; |
| 223 | 220 |
| 224 class SerializedData { | 221 class SerializedData { |
| 225 public: | 222 public: |
| 226 class Reservation { | 223 class Reservation { |
| 227 public: | 224 public: |
| 228 explicit Reservation(uint32_t size) | 225 explicit Reservation(uint32_t size) |
| 229 : reservation_(ChunkSizeBits::encode(size)) {} | 226 : reservation_(ChunkSizeBits::encode(size)) {} |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 | 278 |
| 282 byte* data_; | 279 byte* data_; |
| 283 int size_; | 280 int size_; |
| 284 bool owns_data_; | 281 bool owns_data_; |
| 285 }; | 282 }; |
| 286 | 283 |
| 287 } // namespace internal | 284 } // namespace internal |
| 288 } // namespace v8 | 285 } // namespace v8 |
| 289 | 286 |
| 290 #endif // V8_SNAPSHOT_SERIALIZER_COMMON_H_ | 287 #endif // V8_SNAPSHOT_SERIALIZER_COMMON_H_ |
| OLD | NEW |