| 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_HEAP_HEAP_H_ | 5 #ifndef V8_HEAP_HEAP_H_ |
| 6 #define V8_HEAP_HEAP_H_ | 6 #define V8_HEAP_HEAP_H_ |
| 7 | 7 |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <map> | 9 #include <map> |
| 10 | 10 |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 // If the to space top pointer is smaller or equal than the promotion | 349 // If the to space top pointer is smaller or equal than the promotion |
| 350 // queue head, then the to-space objects are below the promotion queue. | 350 // queue head, then the to-space objects are below the promotion queue. |
| 351 return reinterpret_cast<struct Entry*>(to_space_top) <= rear_; | 351 return reinterpret_cast<struct Entry*>(to_space_top) <= rear_; |
| 352 } | 352 } |
| 353 | 353 |
| 354 bool is_empty() { | 354 bool is_empty() { |
| 355 return (front_ == rear_) && | 355 return (front_ == rear_) && |
| 356 (emergency_stack_ == NULL || emergency_stack_->length() == 0); | 356 (emergency_stack_ == NULL || emergency_stack_->length() == 0); |
| 357 } | 357 } |
| 358 | 358 |
| 359 inline void insert(HeapObject* target, intptr_t size); | 359 inline void insert(HeapObject* target, int32_t size, bool was_marked_black); |
| 360 | 360 |
| 361 void remove(HeapObject** target, intptr_t* size) { | 361 void remove(HeapObject** target, int32_t* size, bool* was_marked_black) { |
| 362 DCHECK(!is_empty()); | 362 DCHECK(!is_empty()); |
| 363 if (front_ == rear_) { | 363 if (front_ == rear_) { |
| 364 Entry e = emergency_stack_->RemoveLast(); | 364 Entry e = emergency_stack_->RemoveLast(); |
| 365 *target = e.obj_; | 365 *target = e.obj_; |
| 366 *size = e.size_; | 366 *size = e.size_; |
| 367 *was_marked_black = e.was_marked_black_; |
| 367 return; | 368 return; |
| 368 } | 369 } |
| 369 | 370 |
| 370 struct Entry* entry = reinterpret_cast<struct Entry*>(--front_); | 371 struct Entry* entry = reinterpret_cast<struct Entry*>(--front_); |
| 371 *target = entry->obj_; | 372 *target = entry->obj_; |
| 372 *size = entry->size_; | 373 *size = entry->size_; |
| 374 *was_marked_black = entry->was_marked_black_; |
| 373 | 375 |
| 374 // Assert no underflow. | 376 // Assert no underflow. |
| 375 SemiSpace::AssertValidRange(reinterpret_cast<Address>(rear_), | 377 SemiSpace::AssertValidRange(reinterpret_cast<Address>(rear_), |
| 376 reinterpret_cast<Address>(front_)); | 378 reinterpret_cast<Address>(front_)); |
| 377 } | 379 } |
| 378 | 380 |
| 379 private: | 381 private: |
| 380 static const int kEntrySizeInWords = 2; | |
| 381 | |
| 382 struct Entry { | 382 struct Entry { |
| 383 Entry(HeapObject* obj, intptr_t size) : obj_(obj), size_(size) {} | 383 Entry(HeapObject* obj, int32_t size, bool was_marked_black) |
| 384 : obj_(obj), size_(size), was_marked_black_(was_marked_black) {} |
| 384 | 385 |
| 385 HeapObject* obj_; | 386 HeapObject* obj_; |
| 386 intptr_t size_; | 387 int32_t size_ : 31; |
| 388 bool was_marked_black_ : 1; |
| 387 }; | 389 }; |
| 388 | 390 |
| 391 void RelocateQueueHead(); |
| 392 |
| 389 // The front of the queue is higher in the memory page chain than the rear. | 393 // The front of the queue is higher in the memory page chain than the rear. |
| 390 struct Entry* front_; | 394 struct Entry* front_; |
| 391 struct Entry* rear_; | 395 struct Entry* rear_; |
| 392 struct Entry* limit_; | 396 struct Entry* limit_; |
| 393 | 397 |
| 394 List<Entry>* emergency_stack_; | 398 List<Entry>* emergency_stack_; |
| 395 | 399 |
| 396 Heap* heap_; | 400 Heap* heap_; |
| 397 | 401 |
| 398 void RelocateQueueHead(); | |
| 399 | |
| 400 STATIC_ASSERT(sizeof(struct Entry) == kEntrySizeInWords * kPointerSize); | |
| 401 | |
| 402 DISALLOW_COPY_AND_ASSIGN(PromotionQueue); | 402 DISALLOW_COPY_AND_ASSIGN(PromotionQueue); |
| 403 }; | 403 }; |
| 404 | 404 |
| 405 | 405 |
| 406 enum ArrayStorageAllocationMode { | 406 enum ArrayStorageAllocationMode { |
| 407 DONT_INITIALIZE_ARRAY_ELEMENTS, | 407 DONT_INITIALIZE_ARRAY_ELEMENTS, |
| 408 INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE | 408 INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE |
| 409 }; | 409 }; |
| 410 | 410 |
| 411 enum class ClearRecordedSlots { kYes, kNo }; | 411 enum class ClearRecordedSlots { kYes, kNo }; |
| (...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1040 // Iterates over all roots in the heap. | 1040 // Iterates over all roots in the heap. |
| 1041 void IterateRoots(ObjectVisitor* v, VisitMode mode); | 1041 void IterateRoots(ObjectVisitor* v, VisitMode mode); |
| 1042 // Iterates over all strong roots in the heap. | 1042 // Iterates over all strong roots in the heap. |
| 1043 void IterateStrongRoots(ObjectVisitor* v, VisitMode mode); | 1043 void IterateStrongRoots(ObjectVisitor* v, VisitMode mode); |
| 1044 // Iterates over entries in the smi roots list. Only interesting to the | 1044 // Iterates over entries in the smi roots list. Only interesting to the |
| 1045 // serializer/deserializer, since GC does not care about smis. | 1045 // serializer/deserializer, since GC does not care about smis. |
| 1046 void IterateSmiRoots(ObjectVisitor* v); | 1046 void IterateSmiRoots(ObjectVisitor* v); |
| 1047 // Iterates over all the other roots in the heap. | 1047 // Iterates over all the other roots in the heap. |
| 1048 void IterateWeakRoots(ObjectVisitor* v, VisitMode mode); | 1048 void IterateWeakRoots(ObjectVisitor* v, VisitMode mode); |
| 1049 | 1049 |
| 1050 // Iterate pointers to from semispace of new space found in memory interval | 1050 // Iterate pointers of promoted objects. |
| 1051 // from start to end within |object|. | 1051 void IteratePromotedObject(HeapObject* target, int size, |
| 1052 void IteratePointersToFromSpace(HeapObject* target, int size, | 1052 bool was_marked_black, |
| 1053 ObjectSlotCallback callback); | 1053 ObjectSlotCallback callback); |
| 1054 | 1054 |
| 1055 void IterateAndMarkPointersToFromSpace(HeapObject* object, Address start, | 1055 void IteratePromotedObjectPointers(HeapObject* object, Address start, |
| 1056 Address end, bool record_slots, | 1056 Address end, bool record_slots, |
| 1057 ObjectSlotCallback callback); | 1057 ObjectSlotCallback callback); |
| 1058 | 1058 |
| 1059 // =========================================================================== | 1059 // =========================================================================== |
| 1060 // Store buffer API. ========================================================= | 1060 // Store buffer API. ========================================================= |
| 1061 // =========================================================================== | 1061 // =========================================================================== |
| 1062 | 1062 |
| 1063 // Write barrier support for object[offset] = o; | 1063 // Write barrier support for object[offset] = o; |
| 1064 inline void RecordWrite(Object* object, int offset, Object* o); | 1064 inline void RecordWrite(Object* object, int offset, Object* o); |
| 1065 | 1065 |
| 1066 Address* store_buffer_top_address() { | 1066 Address* store_buffer_top_address() { |
| 1067 return reinterpret_cast<Address*>(&roots_[kStoreBufferTopRootIndex]); | 1067 return reinterpret_cast<Address*>(&roots_[kStoreBufferTopRootIndex]); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1082 // stopped. | 1082 // stopped. |
| 1083 void StartIncrementalMarking(int gc_flags = kNoGCFlags, | 1083 void StartIncrementalMarking(int gc_flags = kNoGCFlags, |
| 1084 const GCCallbackFlags gc_callback_flags = | 1084 const GCCallbackFlags gc_callback_flags = |
| 1085 GCCallbackFlags::kNoGCCallbackFlags, | 1085 GCCallbackFlags::kNoGCCallbackFlags, |
| 1086 const char* reason = nullptr); | 1086 const char* reason = nullptr); |
| 1087 | 1087 |
| 1088 void FinalizeIncrementalMarkingIfComplete(const char* comment); | 1088 void FinalizeIncrementalMarkingIfComplete(const char* comment); |
| 1089 | 1089 |
| 1090 bool TryFinalizeIdleIncrementalMarking(double idle_time_in_ms); | 1090 bool TryFinalizeIdleIncrementalMarking(double idle_time_in_ms); |
| 1091 | 1091 |
| 1092 void RegisterReservationsForBlackAllocation(Reservation* reservations); |
| 1093 |
| 1092 IncrementalMarking* incremental_marking() { return incremental_marking_; } | 1094 IncrementalMarking* incremental_marking() { return incremental_marking_; } |
| 1093 | 1095 |
| 1094 // =========================================================================== | 1096 // =========================================================================== |
| 1095 // External string table API. ================================================ | 1097 // External string table API. ================================================ |
| 1096 // =========================================================================== | 1098 // =========================================================================== |
| 1097 | 1099 |
| 1098 // Registers an external string. | 1100 // Registers an external string. |
| 1099 inline void RegisterExternalString(String* string); | 1101 inline void RegisterExternalString(String* string); |
| 1100 | 1102 |
| 1101 // Finalizes an external string by deleting the associated external | 1103 // Finalizes an external string by deleting the associated external |
| (...skipping 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2212 // Used for testing purposes. | 2214 // Used for testing purposes. |
| 2213 bool force_oom_; | 2215 bool force_oom_; |
| 2214 | 2216 |
| 2215 // Classes in "heap" can be friends. | 2217 // Classes in "heap" can be friends. |
| 2216 friend class AlwaysAllocateScope; | 2218 friend class AlwaysAllocateScope; |
| 2217 friend class GCCallbacksScope; | 2219 friend class GCCallbacksScope; |
| 2218 friend class GCTracer; | 2220 friend class GCTracer; |
| 2219 friend class HeapIterator; | 2221 friend class HeapIterator; |
| 2220 friend class IdleScavengeObserver; | 2222 friend class IdleScavengeObserver; |
| 2221 friend class IncrementalMarking; | 2223 friend class IncrementalMarking; |
| 2222 friend class IteratePointersToFromSpaceVisitor; | 2224 friend class IteratePromotedObjectsVisitor; |
| 2223 friend class MarkCompactCollector; | 2225 friend class MarkCompactCollector; |
| 2224 friend class MarkCompactMarkingVisitor; | 2226 friend class MarkCompactMarkingVisitor; |
| 2225 friend class NewSpace; | 2227 friend class NewSpace; |
| 2226 friend class ObjectStatsVisitor; | 2228 friend class ObjectStatsVisitor; |
| 2227 friend class Page; | 2229 friend class Page; |
| 2228 friend class Scavenger; | 2230 friend class Scavenger; |
| 2229 friend class StoreBuffer; | 2231 friend class StoreBuffer; |
| 2230 | 2232 |
| 2231 // The allocator interface. | 2233 // The allocator interface. |
| 2232 friend class Factory; | 2234 friend class Factory; |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2630 friend class LargeObjectSpace; | 2632 friend class LargeObjectSpace; |
| 2631 friend class NewSpace; | 2633 friend class NewSpace; |
| 2632 friend class PagedSpace; | 2634 friend class PagedSpace; |
| 2633 DISALLOW_COPY_AND_ASSIGN(AllocationObserver); | 2635 DISALLOW_COPY_AND_ASSIGN(AllocationObserver); |
| 2634 }; | 2636 }; |
| 2635 | 2637 |
| 2636 } // namespace internal | 2638 } // namespace internal |
| 2637 } // namespace v8 | 2639 } // namespace v8 |
| 2638 | 2640 |
| 2639 #endif // V8_HEAP_HEAP_H_ | 2641 #endif // V8_HEAP_HEAP_H_ |
| OLD | NEW |