| 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 <deque> | 8 #include <deque> |
| 9 | 9 |
| 10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 class MarkCompactCollector { | 281 class MarkCompactCollector { |
| 282 public: | 282 public: |
| 283 class Evacuator; | 283 class Evacuator; |
| 284 | 284 |
| 285 class Sweeper { | 285 class Sweeper { |
| 286 public: | 286 public: |
| 287 class SweeperTask; | 287 class SweeperTask; |
| 288 | 288 |
| 289 enum FreeListRebuildingMode { REBUILD_FREE_LIST, IGNORE_FREE_LIST }; | 289 enum FreeListRebuildingMode { REBUILD_FREE_LIST, IGNORE_FREE_LIST }; |
| 290 enum FreeSpaceTreatmentMode { IGNORE_FREE_SPACE, ZAP_FREE_SPACE }; | 290 enum FreeSpaceTreatmentMode { IGNORE_FREE_SPACE, ZAP_FREE_SPACE }; |
| 291 enum ClearOldToNewSlotsMode { |
| 292 DO_NOT_CLEAR, |
| 293 CLEAR_REGULAR_SLOTS, |
| 294 CLEAR_TYPED_SLOTS |
| 295 }; |
| 291 | 296 |
| 292 typedef std::deque<Page*> SweepingList; | 297 typedef std::deque<Page*> SweepingList; |
| 293 typedef List<Page*> SweptList; | 298 typedef List<Page*> SweptList; |
| 294 | 299 |
| 295 static int RawSweep(Page* p, FreeListRebuildingMode free_list_mode, | 300 static int RawSweep(Page* p, FreeListRebuildingMode free_list_mode, |
| 296 FreeSpaceTreatmentMode free_space_mode); | 301 FreeSpaceTreatmentMode free_space_mode); |
| 297 | 302 |
| 298 explicit Sweeper(Heap* heap) | 303 explicit Sweeper(Heap* heap) |
| 299 : heap_(heap), | 304 : heap_(heap), |
| 300 pending_sweeper_tasks_semaphore_(0), | 305 pending_sweeper_tasks_semaphore_(0), |
| (...skipping 18 matching lines...) Expand all Loading... |
| 319 bool AreSweeperTasksRunning(); | 324 bool AreSweeperTasksRunning(); |
| 320 bool IsSweepingCompleted(AllocationSpace space); | 325 bool IsSweepingCompleted(AllocationSpace space); |
| 321 void SweepOrWaitUntilSweepingCompleted(Page* page); | 326 void SweepOrWaitUntilSweepingCompleted(Page* page); |
| 322 | 327 |
| 323 void AddSweptPageSafe(PagedSpace* space, Page* page); | 328 void AddSweptPageSafe(PagedSpace* space, Page* page); |
| 324 Page* GetSweptPageSafe(PagedSpace* space); | 329 Page* GetSweptPageSafe(PagedSpace* space); |
| 325 | 330 |
| 326 private: | 331 private: |
| 327 static const int kAllocationSpaces = LAST_PAGED_SPACE + 1; | 332 static const int kAllocationSpaces = LAST_PAGED_SPACE + 1; |
| 328 | 333 |
| 334 static ClearOldToNewSlotsMode GetClearOldToNewSlotsMode(Page* p); |
| 335 |
| 329 template <typename Callback> | 336 template <typename Callback> |
| 330 void ForAllSweepingSpaces(Callback callback) { | 337 void ForAllSweepingSpaces(Callback callback) { |
| 331 for (int i = 0; i < kAllocationSpaces; i++) { | 338 for (int i = 0; i < kAllocationSpaces; i++) { |
| 332 callback(static_cast<AllocationSpace>(i)); | 339 callback(static_cast<AllocationSpace>(i)); |
| 333 } | 340 } |
| 334 } | 341 } |
| 335 | 342 |
| 336 Page* GetSweepingPageSafe(AllocationSpace space); | 343 Page* GetSweepingPageSafe(AllocationSpace space); |
| 337 void AddSweepingPageSafe(AllocationSpace space, Page* page); | 344 void AddSweepingPageSafe(AllocationSpace space, Page* page); |
| 338 | 345 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 EnsureMarkingDequeIsCommitted(max_size); | 478 EnsureMarkingDequeIsCommitted(max_size); |
| 472 InitializeMarkingDeque(); | 479 InitializeMarkingDeque(); |
| 473 } | 480 } |
| 474 } | 481 } |
| 475 | 482 |
| 476 void EnsureMarkingDequeIsCommitted(size_t max_size); | 483 void EnsureMarkingDequeIsCommitted(size_t max_size); |
| 477 void EnsureMarkingDequeIsReserved(); | 484 void EnsureMarkingDequeIsReserved(); |
| 478 | 485 |
| 479 void InitializeMarkingDeque(); | 486 void InitializeMarkingDeque(); |
| 480 | 487 |
| 481 // The following two methods can just be called after marking, when the | |
| 482 // whole transitive closure is known. They must be called before sweeping | |
| 483 // when mark bits are still intact. | |
| 484 bool IsSlotInBlackObject(MemoryChunk* p, Address slot); | |
| 485 HeapObject* FindBlackObjectBySlotSlow(Address slot); | |
| 486 | |
| 487 // Removes all the slots in the slot buffers that are within the given | |
| 488 // address range. | |
| 489 void RemoveObjectSlots(Address start_slot, Address end_slot); | |
| 490 | |
| 491 Sweeper& sweeper() { return sweeper_; } | 488 Sweeper& sweeper() { return sweeper_; } |
| 492 | 489 |
| 493 private: | 490 private: |
| 494 class EvacuateNewSpacePageVisitor; | 491 class EvacuateNewSpacePageVisitor; |
| 495 class EvacuateNewSpaceVisitor; | 492 class EvacuateNewSpaceVisitor; |
| 496 class EvacuateOldSpaceVisitor; | 493 class EvacuateOldSpaceVisitor; |
| 497 class EvacuateRecordOnlyVisitor; | 494 class EvacuateRecordOnlyVisitor; |
| 498 class EvacuateVisitorBase; | 495 class EvacuateVisitorBase; |
| 499 class HeapObjectVisitor; | 496 class HeapObjectVisitor; |
| 500 class ObjectStatsVisitor; | 497 class ObjectStatsVisitor; |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 | 735 |
| 739 private: | 736 private: |
| 740 MarkCompactCollector* collector_; | 737 MarkCompactCollector* collector_; |
| 741 }; | 738 }; |
| 742 | 739 |
| 743 V8_EXPORT_PRIVATE const char* AllocationSpaceName(AllocationSpace space); | 740 V8_EXPORT_PRIVATE const char* AllocationSpaceName(AllocationSpace space); |
| 744 } // namespace internal | 741 } // namespace internal |
| 745 } // namespace v8 | 742 } // namespace v8 |
| 746 | 743 |
| 747 #endif // V8_HEAP_MARK_COMPACT_H_ | 744 #endif // V8_HEAP_MARK_COMPACT_H_ |
| OLD | NEW |