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

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

Issue 1427973006: [heap] make inline allocation step size dynamic (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 5 years, 1 month 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/spaces.h ('k') | test/cctest/test-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 #include "src/heap/spaces.h" 5 #include "src/heap/spaces.h"
6 6
7 #include "src/base/bits.h" 7 #include "src/base/bits.h"
8 #include "src/base/platform/platform.h" 8 #include "src/base/platform/platform.h"
9 #include "src/full-codegen/full-codegen.h" 9 #include "src/full-codegen/full-codegen.h"
10 #include "src/heap/slots-buffer.h" 10 #include "src/heap/slots-buffer.h"
(...skipping 1498 matching lines...) Expand 10 before | Expand all | Expand 10 after
1509 Address high = to_space_.page_high(); 1509 Address high = to_space_.page_high();
1510 Address new_top = allocation_info_.top() + size_in_bytes; 1510 Address new_top = allocation_info_.top() + size_in_bytes;
1511 allocation_info_.set_limit(Min(new_top, high)); 1511 allocation_info_.set_limit(Min(new_top, high));
1512 } else if (top_on_previous_step_ == 0) { 1512 } else if (top_on_previous_step_ == 0) {
1513 // Normal limit is the end of the current page. 1513 // Normal limit is the end of the current page.
1514 allocation_info_.set_limit(to_space_.page_high()); 1514 allocation_info_.set_limit(to_space_.page_high());
1515 } else { 1515 } else {
1516 // Lower limit during incremental marking. 1516 // Lower limit during incremental marking.
1517 Address high = to_space_.page_high(); 1517 Address high = to_space_.page_high();
1518 Address new_top = allocation_info_.top() + size_in_bytes; 1518 Address new_top = allocation_info_.top() + size_in_bytes;
1519 Address new_limit = new_top + inline_allocation_limit_step_; 1519 Address new_limit = new_top + GetNextInlineAllocationStepSize();
1520 allocation_info_.set_limit(Min(new_limit, high)); 1520 allocation_info_.set_limit(Min(new_limit, high));
1521 } 1521 }
1522 DCHECK_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_); 1522 DCHECK_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_);
1523 } 1523 }
1524 1524
1525 1525
1526 bool NewSpace::AddFreshPage() { 1526 bool NewSpace::AddFreshPage() {
1527 Address top = allocation_info_.top(); 1527 Address top = allocation_info_.top();
1528 if (NewSpacePage::IsAtStart(top)) { 1528 if (NewSpacePage::IsAtStart(top)) {
1529 // The current page is already empty. Don't try to make another. 1529 // The current page is already empty. Don't try to make another.
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1594 // or because idle scavenge job wants to get a chance to post a task. 1594 // or because idle scavenge job wants to get a chance to post a task.
1595 // Set the new limit accordingly. 1595 // Set the new limit accordingly.
1596 Address new_top = old_top + aligned_size_in_bytes; 1596 Address new_top = old_top + aligned_size_in_bytes;
1597 InlineAllocationStep(new_top, new_top); 1597 InlineAllocationStep(new_top, new_top);
1598 UpdateInlineAllocationLimit(aligned_size_in_bytes); 1598 UpdateInlineAllocationLimit(aligned_size_in_bytes);
1599 } 1599 }
1600 return true; 1600 return true;
1601 } 1601 }
1602 1602
1603 1603
1604 void NewSpace::UpdateInlineAllocationLimitStep() { 1604 void NewSpace::StartNextInlineAllocationStep() {
1605 intptr_t step = 0; 1605 top_on_previous_step_ =
1606 inline_allocation_observers_.length() ? allocation_info_.top() : 0;
1607 UpdateInlineAllocationLimit(0);
1608 }
1609
1610
1611 intptr_t NewSpace::GetNextInlineAllocationStepSize() {
1612 intptr_t next_step = 0;
1606 for (int i = 0; i < inline_allocation_observers_.length(); ++i) { 1613 for (int i = 0; i < inline_allocation_observers_.length(); ++i) {
1607 InlineAllocationObserver* observer = inline_allocation_observers_[i]; 1614 InlineAllocationObserver* o = inline_allocation_observers_[i];
1608 step = step ? Min(step, observer->step_size()) : observer->step_size(); 1615 next_step = next_step ? Min(next_step, o->bytes_to_next_step())
1616 : o->bytes_to_next_step();
1609 } 1617 }
1610 inline_allocation_limit_step_ = step; 1618 DCHECK(inline_allocation_observers_.length() == 0 || next_step != 0);
1611 top_on_previous_step_ = step ? allocation_info_.top() : 0; 1619 return next_step;
1612 UpdateInlineAllocationLimit(0);
1613 } 1620 }
1614 1621
1615 1622
1616 void NewSpace::AddInlineAllocationObserver(InlineAllocationObserver* observer) { 1623 void NewSpace::AddInlineAllocationObserver(InlineAllocationObserver* observer) {
1617 inline_allocation_observers_.Add(observer); 1624 inline_allocation_observers_.Add(observer);
1618 UpdateInlineAllocationLimitStep(); 1625 StartNextInlineAllocationStep();
1619 } 1626 }
1620 1627
1621 1628
1622 void NewSpace::RemoveInlineAllocationObserver( 1629 void NewSpace::RemoveInlineAllocationObserver(
1623 InlineAllocationObserver* observer) { 1630 InlineAllocationObserver* observer) {
1624 bool removed = inline_allocation_observers_.RemoveElement(observer); 1631 bool removed = inline_allocation_observers_.RemoveElement(observer);
1625 // Only used in assertion. Suppress unused variable warning. 1632 // Only used in assertion. Suppress unused variable warning.
1626 static_cast<void>(removed); 1633 static_cast<void>(removed);
1627 DCHECK(removed); 1634 DCHECK(removed);
1628 UpdateInlineAllocationLimitStep(); 1635 StartNextInlineAllocationStep();
1629 } 1636 }
1630 1637
1631 1638
1632 void NewSpace::InlineAllocationStep(Address top, Address new_top) { 1639 void NewSpace::InlineAllocationStep(Address top, Address new_top) {
1633 if (top_on_previous_step_) { 1640 if (top_on_previous_step_) {
1634 int bytes_allocated = static_cast<int>(top - top_on_previous_step_); 1641 int bytes_allocated = static_cast<int>(top - top_on_previous_step_);
1635 for (int i = 0; i < inline_allocation_observers_.length(); ++i) { 1642 for (int i = 0; i < inline_allocation_observers_.length(); ++i) {
1636 inline_allocation_observers_[i]->InlineAllocationStep(bytes_allocated); 1643 inline_allocation_observers_[i]->InlineAllocationStep(bytes_allocated);
1637 } 1644 }
1638 top_on_previous_step_ = new_top; 1645 top_on_previous_step_ = new_top;
(...skipping 1659 matching lines...) Expand 10 before | Expand all | Expand 10 after
3298 object->ShortPrint(); 3305 object->ShortPrint();
3299 PrintF("\n"); 3306 PrintF("\n");
3300 } 3307 }
3301 printf(" --------------------------------------\n"); 3308 printf(" --------------------------------------\n");
3302 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); 3309 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes());
3303 } 3310 }
3304 3311
3305 #endif // DEBUG 3312 #endif // DEBUG
3306 } // namespace internal 3313 } // namespace internal
3307 } // namespace v8 3314 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/spaces.h ('k') | test/cctest/test-spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698