Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(287)

Side by Side Diff: src/heap/spaces.h

Issue 2063013005: Revert of [heap] Add page evacuation mode for new->new (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/heap/mark-compact.cc ('k') | src/heap/spaces.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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_PROMOTION|: A page tagged with this flag has been moved
429 // within the new space during evacuation.
430 PAGE_NEW_NEW_PROMOTION,
431
432 // A black page has all mark bits set to 1 (black). A black page currently 428 // A black page has all mark bits set to 1 (black). A black page currently
433 // cannot be iterated because it is not swept. Moreover live bytes are also 429 // cannot be iterated because it is not swept. Moreover live bytes are also
434 // not updated. 430 // not updated.
435 BLACK_PAGE, 431 BLACK_PAGE,
436 432
437 // This flag is intended to be used for testing. Works only when both 433 // This flag is intended to be used for testing. Works only when both
438 // FLAG_stress_compaction and FLAG_manual_evacuation_candidates_selection 434 // FLAG_stress_compaction and FLAG_manual_evacuation_candidates_selection
439 // are set. It forces the page to become an evacuation candidate at next 435 // are set. It forces the page to become an evacuation candidate at next
440 // candidates selection cycle. 436 // candidates selection cycle.
441 FORCE_EVACUATION_CANDIDATE_FOR_TESTING, 437 FORCE_EVACUATION_CANDIDATE_FOR_TESTING,
(...skipping 1986 matching lines...) Expand 10 before | Expand all | Expand 10 after
2428 2424
2429 // Grow the semispace to the new capacity. The new capacity requested must 2425 // Grow the semispace to the new capacity. The new capacity requested must
2430 // be larger than the current capacity and less than the maximum capacity. 2426 // be larger than the current capacity and less than the maximum capacity.
2431 bool GrowTo(int new_capacity); 2427 bool GrowTo(int new_capacity);
2432 2428
2433 // Shrinks the semispace to the new capacity. The new capacity requested 2429 // Shrinks the semispace to the new capacity. The new capacity requested
2434 // must be more than the amount of used memory in the semispace and less 2430 // must be more than the amount of used memory in the semispace and less
2435 // than the current capacity. 2431 // than the current capacity.
2436 bool ShrinkTo(int new_capacity); 2432 bool ShrinkTo(int new_capacity);
2437 2433
2438 bool EnsureCurrentCapacity();
2439
2440 // Returns the start address of the first page of the space. 2434 // Returns the start address of the first page of the space.
2441 Address space_start() { 2435 Address space_start() {
2442 DCHECK_NE(anchor_.next_page(), anchor()); 2436 DCHECK_NE(anchor_.next_page(), anchor());
2443 return anchor_.next_page()->area_start(); 2437 return anchor_.next_page()->area_start();
2444 } 2438 }
2445 2439
2446 Page* first_page() { return anchor_.next_page(); } 2440 Page* first_page() { return anchor_.next_page(); }
2447 Page* current_page() { return current_page_; } 2441 Page* current_page() { return current_page_; }
2448 2442
2449 // Returns one past the end address of the space. 2443 // Returns one past the end address of the space.
2450 Address space_end() { return anchor_.prev_page()->area_end(); } 2444 Address space_end() { return anchor_.prev_page()->area_end(); }
2451 2445
2452 // Returns the start address of the current page of the space. 2446 // Returns the start address of the current page of the space.
2453 Address page_low() { return current_page_->area_start(); } 2447 Address page_low() { return current_page_->area_start(); }
2454 2448
2455 // Returns one past the end address of the current page of the space. 2449 // Returns one past the end address of the current page of the space.
2456 Address page_high() { return current_page_->area_end(); } 2450 Address page_high() { return current_page_->area_end(); }
2457 2451
2458 bool AdvancePage() { 2452 bool AdvancePage() {
2459 Page* next_page = current_page_->next_page(); 2453 Page* next_page = current_page_->next_page();
2460 if (next_page == anchor()) return false; 2454 if (next_page == anchor()) return false;
2461 current_page_ = next_page; 2455 current_page_ = next_page;
2462 return true; 2456 return true;
2463 } 2457 }
2464 2458
2465 // Resets the space to using the first page. 2459 // Resets the space to using the first page.
2466 void Reset(); 2460 void Reset();
2467 2461
2468 void RemovePage(Page* page); 2462 bool ReplaceWithEmptyPage(Page* page);
2469 void PrependPage(Page* page);
2470 2463
2471 // Age mark accessors. 2464 // Age mark accessors.
2472 Address age_mark() { return age_mark_; } 2465 Address age_mark() { return age_mark_; }
2473 void set_age_mark(Address mark); 2466 void set_age_mark(Address mark);
2474 2467
2475 // Returns the current capacity of the semispace. 2468 // Returns the current capacity of the semispace.
2476 int current_capacity() { return current_capacity_; } 2469 int current_capacity() { return current_capacity_; }
2477 2470
2478 // Returns the maximum capacity of the semispace. 2471 // Returns the maximum capacity of the semispace.
2479 int maximum_capacity() { return maximum_capacity_; } 2472 int maximum_capacity() { return maximum_capacity_; }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
2535 2528
2536 // Used to govern object promotion during mark-compact collection. 2529 // Used to govern object promotion during mark-compact collection.
2537 Address age_mark_; 2530 Address age_mark_;
2538 2531
2539 bool committed_; 2532 bool committed_;
2540 SemiSpaceId id_; 2533 SemiSpaceId id_;
2541 2534
2542 Page anchor_; 2535 Page anchor_;
2543 Page* current_page_; 2536 Page* current_page_;
2544 2537
2545 friend class NewSpace; 2538 friend class SemiSpaceIterator;
2546 friend class NewSpacePageIterator; 2539 friend class NewSpacePageIterator;
2547 friend class SemiSpaceIterator;
2548 }; 2540 };
2549 2541
2550 2542
2551 // A SemiSpaceIterator is an ObjectIterator that iterates over the active 2543 // A SemiSpaceIterator is an ObjectIterator that iterates over the active
2552 // semispace of the heap's new space. It iterates over the objects in the 2544 // semispace of the heap's new space. It iterates over the objects in the
2553 // semispace from a given start address (defaulting to the bottom of the 2545 // semispace from a given start address (defaulting to the bottom of the
2554 // semispace) to the top of the semispace. New objects allocated after the 2546 // semispace) to the top of the semispace. New objects allocated after the
2555 // iterator is created are not iterated. 2547 // iterator is created are not iterated.
2556 class SemiSpaceIterator : public ObjectIterator { 2548 class SemiSpaceIterator : public ObjectIterator {
2557 public: 2549 public:
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
2716 while (current_page != last_page) { 2708 while (current_page != last_page) {
2717 allocated += Page::kAllocatableMemory; 2709 allocated += Page::kAllocatableMemory;
2718 current_page = current_page->next_page(); 2710 current_page = current_page->next_page();
2719 } 2711 }
2720 allocated += top() - current_page->area_start(); 2712 allocated += top() - current_page->area_start();
2721 DCHECK_LE(0, allocated); 2713 DCHECK_LE(0, allocated);
2722 DCHECK_LE(allocated, Size()); 2714 DCHECK_LE(allocated, Size());
2723 return static_cast<size_t>(allocated); 2715 return static_cast<size_t>(allocated);
2724 } 2716 }
2725 2717
2726 void MovePageFromSpaceToSpace(Page* page) { 2718 bool ReplaceWithEmptyPage(Page* page) {
2719 // This method is called after flipping the semispace.
2727 DCHECK(page->InFromSpace()); 2720 DCHECK(page->InFromSpace());
2728 from_space_.RemovePage(page); 2721 return from_space_.ReplaceWithEmptyPage(page);
2729 to_space_.PrependPage(page);
2730 pages_used_++;
2731 } 2722 }
2732 2723
2733 bool Rebalance();
2734
2735 // Return the maximum capacity of a semispace. 2724 // Return the maximum capacity of a semispace.
2736 int MaximumCapacity() { 2725 int MaximumCapacity() {
2737 DCHECK(to_space_.maximum_capacity() == from_space_.maximum_capacity()); 2726 DCHECK(to_space_.maximum_capacity() == from_space_.maximum_capacity());
2738 return to_space_.maximum_capacity(); 2727 return to_space_.maximum_capacity();
2739 } 2728 }
2740 2729
2741 bool IsAtMaximumCapacity() { return TotalCapacity() == MaximumCapacity(); } 2730 bool IsAtMaximumCapacity() { return TotalCapacity() == MaximumCapacity(); }
2742 2731
2743 // Returns the initial capacity of a semispace. 2732 // Returns the initial capacity of a semispace.
2744 int InitialTotalCapacity() { 2733 int InitialTotalCapacity() {
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
3159 count = 0; 3148 count = 0;
3160 } 3149 }
3161 // Must be small, since an iteration is used for lookup. 3150 // Must be small, since an iteration is used for lookup.
3162 static const int kMaxComments = 64; 3151 static const int kMaxComments = 64;
3163 }; 3152 };
3164 #endif 3153 #endif
3165 } // namespace internal 3154 } // namespace internal
3166 } // namespace v8 3155 } // namespace v8
3167 3156
3168 #endif // V8_HEAP_SPACES_H_ 3157 #endif // V8_HEAP_SPACES_H_
OLDNEW
« no previous file with comments | « src/heap/mark-compact.cc ('k') | src/heap/spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698