OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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_SPACES_H_ | 5 #ifndef V8_HEAP_SPACES_H_ |
6 #define V8_HEAP_SPACES_H_ | 6 #define V8_HEAP_SPACES_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 | 9 |
10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
418 // Large objects can have a progress bar in their page header. These object | 418 // Large objects can have a progress bar in their page header. These object |
419 // are scanned in increments and will be kept black while being scanned. | 419 // are scanned in increments and will be kept black while being scanned. |
420 // Even if the mutator writes to them they will be kept black and a white | 420 // Even if the mutator writes to them they will be kept black and a white |
421 // to grey transition is performed in the value. | 421 // to grey transition is performed in the value. |
422 HAS_PROGRESS_BAR, | 422 HAS_PROGRESS_BAR, |
423 | 423 |
424 // |PAGE_NEW_OLD_PROMOTION|: A page tagged with this flag has been promoted | 424 // |PAGE_NEW_OLD_PROMOTION|: A page tagged with this flag has been promoted |
425 // from new to old space during evacuation. | 425 // from new to old space during evacuation. |
426 PAGE_NEW_OLD_PROMOTION, | 426 PAGE_NEW_OLD_PROMOTION, |
427 | 427 |
428 // |PAGE_NEW_NEW_PROMITION|: A page tagged with this flag has been moved | |
ulan
2016/06/14 15:38:51
typo PAGE_NEW_NEW_PROMOTION
Michael Lippautz
2016/06/15 06:49:30
Done.
| |
429 // within the new space during evacuation. | |
430 PAGE_NEW_NEW_PROMOTION, | |
431 | |
428 // A black page has all mark bits set to 1 (black). A black page currently | 432 // A black page has all mark bits set to 1 (black). A black page currently |
429 // cannot be iterated because it is not swept. Moreover live bytes are also | 433 // cannot be iterated because it is not swept. Moreover live bytes are also |
430 // not updated. | 434 // not updated. |
431 BLACK_PAGE, | 435 BLACK_PAGE, |
432 | 436 |
433 // This flag is intended to be used for testing. Works only when both | 437 // This flag is intended to be used for testing. Works only when both |
434 // FLAG_stress_compaction and FLAG_manual_evacuation_candidates_selection | 438 // FLAG_stress_compaction and FLAG_manual_evacuation_candidates_selection |
435 // are set. It forces the page to become an evacuation candidate at next | 439 // are set. It forces the page to become an evacuation candidate at next |
436 // candidates selection cycle. | 440 // candidates selection cycle. |
437 FORCE_EVACUATION_CANDIDATE_FOR_TESTING, | 441 FORCE_EVACUATION_CANDIDATE_FOR_TESTING, |
(...skipping 1995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2433 | 2437 |
2434 // Returns the start address of the first page of the space. | 2438 // Returns the start address of the first page of the space. |
2435 Address space_start() { | 2439 Address space_start() { |
2436 DCHECK_NE(anchor_.next_page(), anchor()); | 2440 DCHECK_NE(anchor_.next_page(), anchor()); |
2437 return anchor_.next_page()->area_start(); | 2441 return anchor_.next_page()->area_start(); |
2438 } | 2442 } |
2439 | 2443 |
2440 Page* first_page() { return anchor_.next_page(); } | 2444 Page* first_page() { return anchor_.next_page(); } |
2441 Page* current_page() { return current_page_; } | 2445 Page* current_page() { return current_page_; } |
2442 | 2446 |
2447 bool OnLastPage() { return current_page() == anchor()->prev_page(); } | |
2448 | |
2443 // Returns one past the end address of the space. | 2449 // Returns one past the end address of the space. |
2444 Address space_end() { return anchor_.prev_page()->area_end(); } | 2450 Address space_end() { return anchor_.prev_page()->area_end(); } |
2445 | 2451 |
2446 // Returns the start address of the current page of the space. | 2452 // Returns the start address of the current page of the space. |
2447 Address page_low() { return current_page_->area_start(); } | 2453 Address page_low() { return current_page_->area_start(); } |
2448 | 2454 |
2449 // Returns one past the end address of the current page of the space. | 2455 // Returns one past the end address of the current page of the space. |
2450 Address page_high() { return current_page_->area_end(); } | 2456 Address page_high() { return current_page_->area_end(); } |
2451 | 2457 |
2452 bool AdvancePage() { | 2458 bool AdvancePage() { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2528 | 2534 |
2529 // Used to govern object promotion during mark-compact collection. | 2535 // Used to govern object promotion during mark-compact collection. |
2530 Address age_mark_; | 2536 Address age_mark_; |
2531 | 2537 |
2532 bool committed_; | 2538 bool committed_; |
2533 SemiSpaceId id_; | 2539 SemiSpaceId id_; |
2534 | 2540 |
2535 Page anchor_; | 2541 Page anchor_; |
2536 Page* current_page_; | 2542 Page* current_page_; |
2537 | 2543 |
2544 friend class NewSpace; | |
2545 friend class NewSpacePageIterator; | |
2538 friend class SemiSpaceIterator; | 2546 friend class SemiSpaceIterator; |
2539 friend class NewSpacePageIterator; | |
2540 }; | 2547 }; |
2541 | 2548 |
2542 | 2549 |
2543 // A SemiSpaceIterator is an ObjectIterator that iterates over the active | 2550 // A SemiSpaceIterator is an ObjectIterator that iterates over the active |
2544 // semispace of the heap's new space. It iterates over the objects in the | 2551 // semispace of the heap's new space. It iterates over the objects in the |
2545 // semispace from a given start address (defaulting to the bottom of the | 2552 // semispace from a given start address (defaulting to the bottom of the |
2546 // semispace) to the top of the semispace. New objects allocated after the | 2553 // semispace) to the top of the semispace. New objects allocated after the |
2547 // iterator is created are not iterated. | 2554 // iterator is created are not iterated. |
2548 class SemiSpaceIterator : public ObjectIterator { | 2555 class SemiSpaceIterator : public ObjectIterator { |
2549 public: | 2556 public: |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2714 DCHECK_LE(allocated, Size()); | 2721 DCHECK_LE(allocated, Size()); |
2715 return static_cast<size_t>(allocated); | 2722 return static_cast<size_t>(allocated); |
2716 } | 2723 } |
2717 | 2724 |
2718 bool ReplaceWithEmptyPage(Page* page) { | 2725 bool ReplaceWithEmptyPage(Page* page) { |
2719 // This method is called after flipping the semispace. | 2726 // This method is called after flipping the semispace. |
2720 DCHECK(page->InFromSpace()); | 2727 DCHECK(page->InFromSpace()); |
2721 return from_space_.ReplaceWithEmptyPage(page); | 2728 return from_space_.ReplaceWithEmptyPage(page); |
2722 } | 2729 } |
2723 | 2730 |
2731 // Swaps the given |from_space_page| with a proper page in *to* space. The | |
2732 // method should only be called during evacuation. | |
2733 void SwapFromSpacePageWithToSpacePage(Page* from_space_page); | |
2734 | |
2735 // Swaps |from_space_page| with |to_space_page| by swapping their interiors | |
2736 // and inserting them at |from_target| and |to_target| respectively. Note | |
2737 // that this implies that |from_target| is in *to* space and vice versa. | |
2738 void SwapPages(Page* from_space_page, Page* to_space_page, Page* from_target, | |
2739 Page* to_target); | |
2740 | |
2724 // Return the maximum capacity of a semispace. | 2741 // Return the maximum capacity of a semispace. |
2725 int MaximumCapacity() { | 2742 int MaximumCapacity() { |
2726 DCHECK(to_space_.maximum_capacity() == from_space_.maximum_capacity()); | 2743 DCHECK(to_space_.maximum_capacity() == from_space_.maximum_capacity()); |
2727 return to_space_.maximum_capacity(); | 2744 return to_space_.maximum_capacity(); |
2728 } | 2745 } |
2729 | 2746 |
2730 bool IsAtMaximumCapacity() { return TotalCapacity() == MaximumCapacity(); } | 2747 bool IsAtMaximumCapacity() { return TotalCapacity() == MaximumCapacity(); } |
2731 | 2748 |
2732 // Returns the initial capacity of a semispace. | 2749 // Returns the initial capacity of a semispace. |
2733 int InitialTotalCapacity() { | 2750 int InitialTotalCapacity() { |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3148 count = 0; | 3165 count = 0; |
3149 } | 3166 } |
3150 // Must be small, since an iteration is used for lookup. | 3167 // Must be small, since an iteration is used for lookup. |
3151 static const int kMaxComments = 64; | 3168 static const int kMaxComments = 64; |
3152 }; | 3169 }; |
3153 #endif | 3170 #endif |
3154 } // namespace internal | 3171 } // namespace internal |
3155 } // namespace v8 | 3172 } // namespace v8 |
3156 | 3173 |
3157 #endif // V8_HEAP_SPACES_H_ | 3174 #endif // V8_HEAP_SPACES_H_ |
OLD | NEW |