| 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_MARK_COMPACT_H_ | 5 #ifndef V8_HEAP_MARK_COMPACT_H_ |
| 6 #define V8_HEAP_MARK_COMPACT_H_ | 6 #define V8_HEAP_MARK_COMPACT_H_ |
| 7 | 7 |
| 8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
| 9 #include "src/heap/spaces.h" | 9 #include "src/heap/spaces.h" |
| 10 | 10 |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 void Add(ObjectSlot slot) { | 299 void Add(ObjectSlot slot) { |
| 300 DCHECK(0 <= idx_ && idx_ < kNumberOfElements); | 300 DCHECK(0 <= idx_ && idx_ < kNumberOfElements); |
| 301 #ifdef DEBUG | 301 #ifdef DEBUG |
| 302 if (slot >= reinterpret_cast<ObjectSlot>(NUMBER_OF_SLOT_TYPES)) { | 302 if (slot >= reinterpret_cast<ObjectSlot>(NUMBER_OF_SLOT_TYPES)) { |
| 303 DCHECK_NOT_NULL(*slot); | 303 DCHECK_NOT_NULL(*slot); |
| 304 } | 304 } |
| 305 #endif | 305 #endif |
| 306 slots_[idx_++] = slot; | 306 slots_[idx_++] = slot; |
| 307 } | 307 } |
| 308 | 308 |
| 309 // Should be used for testing only. | 309 void Set(intptr_t i, ObjectSlot slot) { slots_[i] = slot; } |
| 310 |
| 310 ObjectSlot Get(intptr_t i) { | 311 ObjectSlot Get(intptr_t i) { |
| 311 DCHECK(i >= 0 && i < kNumberOfElements); | 312 DCHECK(i >= 0 && i < idx_); |
| 312 return slots_[i]; | 313 return slots_[i]; |
| 313 } | 314 } |
| 314 | 315 |
| 316 size_t Size() const { return idx_; } |
| 317 |
| 315 enum SlotType { | 318 enum SlotType { |
| 316 EMBEDDED_OBJECT_SLOT, | 319 EMBEDDED_OBJECT_SLOT, |
| 317 OBJECT_SLOT, | 320 OBJECT_SLOT, |
| 318 RELOCATED_CODE_OBJECT, | 321 RELOCATED_CODE_OBJECT, |
| 319 CELL_TARGET_SLOT, | 322 CELL_TARGET_SLOT, |
| 320 CODE_TARGET_SLOT, | 323 CODE_TARGET_SLOT, |
| 321 CODE_ENTRY_SLOT, | 324 CODE_ENTRY_SLOT, |
| 322 DEBUG_TARGET_SLOT, | 325 DEBUG_TARGET_SLOT, |
| 323 NUMBER_OF_SLOT_TYPES | 326 NUMBER_OF_SLOT_TYPES |
| 324 }; | 327 }; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 buffer->Add(slot); | 392 buffer->Add(slot); |
| 390 return true; | 393 return true; |
| 391 } | 394 } |
| 392 | 395 |
| 393 static bool IsTypedSlot(ObjectSlot slot); | 396 static bool IsTypedSlot(ObjectSlot slot); |
| 394 | 397 |
| 395 static bool AddTo(SlotsBufferAllocator* allocator, | 398 static bool AddTo(SlotsBufferAllocator* allocator, |
| 396 SlotsBuffer** buffer_address, SlotType type, Address addr, | 399 SlotsBuffer** buffer_address, SlotType type, Address addr, |
| 397 AdditionMode mode); | 400 AdditionMode mode); |
| 398 | 401 |
| 399 // Eliminates all stale entries from the slots buffer, i.e., slots that | |
| 400 // are not part of live objects anymore. This method must be called after | |
| 401 // marking, when the whole transitive closure is known and must be called | |
| 402 // before sweeping when mark bits are still intact. | |
| 403 static void RemoveInvalidSlots(Heap* heap, SlotsBuffer* buffer); | |
| 404 | |
| 405 // Eliminate all slots that are within the given address range. | 402 // Eliminate all slots that are within the given address range. |
| 406 static void RemoveObjectSlots(Heap* heap, SlotsBuffer* buffer, | 403 static void RemoveObjectSlots(Heap* heap, SlotsBuffer* buffer, |
| 407 Address start_slot, Address end_slot); | 404 Address start_slot, Address end_slot); |
| 408 | 405 |
| 409 // Ensures that there are no invalid slots in the chain of slots buffers. | |
| 410 static void VerifySlots(Heap* heap, SlotsBuffer* buffer); | |
| 411 | |
| 412 static const int kNumberOfElements = 1021; | 406 static const int kNumberOfElements = 1021; |
| 413 | 407 |
| 414 private: | 408 private: |
| 415 static const int kChainLengthThreshold = 15; | 409 static const int kChainLengthThreshold = 15; |
| 416 | 410 |
| 417 intptr_t idx_; | 411 intptr_t idx_; |
| 418 intptr_t chain_length_; | 412 intptr_t chain_length_; |
| 419 SlotsBuffer* next_; | 413 SlotsBuffer* next_; |
| 420 ObjectSlot slots_[kNumberOfElements]; | 414 ObjectSlot slots_[kNumberOfElements]; |
| 421 }; | 415 }; |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 void RemoveObjectSlots(Address start_slot, Address end_slot); | 671 void RemoveObjectSlots(Address start_slot, Address end_slot); |
| 678 | 672 |
| 679 private: | 673 private: |
| 680 class SweeperTask; | 674 class SweeperTask; |
| 681 | 675 |
| 682 explicit MarkCompactCollector(Heap* heap); | 676 explicit MarkCompactCollector(Heap* heap); |
| 683 ~MarkCompactCollector(); | 677 ~MarkCompactCollector(); |
| 684 | 678 |
| 685 bool WillBeDeoptimized(Code* code); | 679 bool WillBeDeoptimized(Code* code); |
| 686 void EvictPopularEvacuationCandidate(Page* page); | 680 void EvictPopularEvacuationCandidate(Page* page); |
| 681 |
| 682 // Clears invald store buffer and slots buffer entries. This method must |
| 683 // be called after marking, when the whole transitive closure is known and |
| 684 // must be called before sweeping when mark bits are still intact. |
| 687 void ClearInvalidStoreAndSlotsBufferEntries(); | 685 void ClearInvalidStoreAndSlotsBufferEntries(); |
| 688 | 686 |
| 687 // Eliminates all stale entries from the slots buffer, i.e., slots that |
| 688 // are not part of live objects anymore. |
| 689 void ClearInvalidSlotsBufferEntries(SlotsBuffer* buffer); |
| 690 |
| 689 void StartSweeperThreads(); | 691 void StartSweeperThreads(); |
| 690 | 692 |
| 691 #ifdef DEBUG | 693 #ifdef DEBUG |
| 692 enum CollectorState { | 694 enum CollectorState { |
| 693 IDLE, | 695 IDLE, |
| 694 PREPARE_GC, | 696 PREPARE_GC, |
| 695 MARK_LIVE_OBJECTS, | 697 MARK_LIVE_OBJECTS, |
| 696 SWEEP_SPACES, | 698 SWEEP_SPACES, |
| 697 ENCODE_FORWARDING_ADDRESSES, | 699 ENCODE_FORWARDING_ADDRESSES, |
| 698 UPDATE_POINTERS, | 700 UPDATE_POINTERS, |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 977 private: | 979 private: |
| 978 MarkCompactCollector* collector_; | 980 MarkCompactCollector* collector_; |
| 979 }; | 981 }; |
| 980 | 982 |
| 981 | 983 |
| 982 const char* AllocationSpaceName(AllocationSpace space); | 984 const char* AllocationSpaceName(AllocationSpace space); |
| 983 } | 985 } |
| 984 } // namespace v8::internal | 986 } // namespace v8::internal |
| 985 | 987 |
| 986 #endif // V8_HEAP_MARK_COMPACT_H_ | 988 #endif // V8_HEAP_MARK_COMPACT_H_ |
| OLD | NEW |