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

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

Issue 1465633002: [heap] pause/resume inline allocation observers around scavenge (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 1491 matching lines...) Expand 10 before | Expand all | Expand 10 after
1502 InlineAllocationStep(old_top, allocation_info_.top()); 1502 InlineAllocationStep(old_top, allocation_info_.top());
1503 } 1503 }
1504 1504
1505 1505
1506 void NewSpace::UpdateInlineAllocationLimit(int size_in_bytes) { 1506 void NewSpace::UpdateInlineAllocationLimit(int size_in_bytes) {
1507 if (heap()->inline_allocation_disabled()) { 1507 if (heap()->inline_allocation_disabled()) {
1508 // Lowest limit when linear allocation was disabled. 1508 // Lowest limit when linear allocation was disabled.
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 (inline_allocation_observers_paused_ ||
1513 top_on_previous_step_ == 0) {
1513 // Normal limit is the end of the current page. 1514 // Normal limit is the end of the current page.
1514 allocation_info_.set_limit(to_space_.page_high()); 1515 allocation_info_.set_limit(to_space_.page_high());
1515 } else { 1516 } else {
1516 // Lower limit during incremental marking. 1517 // Lower limit during incremental marking.
1517 Address high = to_space_.page_high(); 1518 Address high = to_space_.page_high();
1518 Address new_top = allocation_info_.top() + size_in_bytes; 1519 Address new_top = allocation_info_.top() + size_in_bytes;
1519 Address new_limit = new_top + GetNextInlineAllocationStepSize() - 1; 1520 Address new_limit = new_top + GetNextInlineAllocationStepSize() - 1;
1520 allocation_info_.set_limit(Min(new_limit, high)); 1521 allocation_info_.set_limit(Min(new_limit, high));
1521 } 1522 }
1522 DCHECK_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_); 1523 DCHECK_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1595 // Set the new limit accordingly. 1596 // Set the new limit accordingly.
1596 Address new_top = old_top + aligned_size_in_bytes; 1597 Address new_top = old_top + aligned_size_in_bytes;
1597 InlineAllocationStep(new_top, new_top); 1598 InlineAllocationStep(new_top, new_top);
1598 UpdateInlineAllocationLimit(aligned_size_in_bytes); 1599 UpdateInlineAllocationLimit(aligned_size_in_bytes);
1599 } 1600 }
1600 return true; 1601 return true;
1601 } 1602 }
1602 1603
1603 1604
1604 void NewSpace::StartNextInlineAllocationStep() { 1605 void NewSpace::StartNextInlineAllocationStep() {
1606 DCHECK(!inline_allocation_observers_paused_);
1605 top_on_previous_step_ = 1607 top_on_previous_step_ =
1606 inline_allocation_observers_.length() ? allocation_info_.top() : 0; 1608 inline_allocation_observers_.length() ? allocation_info_.top() : 0;
1607 UpdateInlineAllocationLimit(0); 1609 UpdateInlineAllocationLimit(0);
1608 } 1610 }
1609 1611
1610 1612
1611 intptr_t NewSpace::GetNextInlineAllocationStepSize() { 1613 intptr_t NewSpace::GetNextInlineAllocationStepSize() {
1612 intptr_t next_step = 0; 1614 intptr_t next_step = 0;
1613 for (int i = 0; i < inline_allocation_observers_.length(); ++i) { 1615 for (int i = 0; i < inline_allocation_observers_.length(); ++i) {
1614 InlineAllocationObserver* o = inline_allocation_observers_[i]; 1616 InlineAllocationObserver* o = inline_allocation_observers_[i];
(...skipping 14 matching lines...) Expand all
1629 void NewSpace::RemoveInlineAllocationObserver( 1631 void NewSpace::RemoveInlineAllocationObserver(
1630 InlineAllocationObserver* observer) { 1632 InlineAllocationObserver* observer) {
1631 bool removed = inline_allocation_observers_.RemoveElement(observer); 1633 bool removed = inline_allocation_observers_.RemoveElement(observer);
1632 // Only used in assertion. Suppress unused variable warning. 1634 // Only used in assertion. Suppress unused variable warning.
1633 static_cast<void>(removed); 1635 static_cast<void>(removed);
1634 DCHECK(removed); 1636 DCHECK(removed);
1635 StartNextInlineAllocationStep(); 1637 StartNextInlineAllocationStep();
1636 } 1638 }
1637 1639
1638 1640
1641 void NewSpace::PauseInlineAllocationObservers() {
1642 // Do a step to account for memory allocated so far.
1643 InlineAllocationStep(top(), top());
1644 inline_allocation_observers_paused_ = true;
1645 top_on_previous_step_ = 0;
1646 UpdateInlineAllocationLimit(0);
1647 }
1648
1649
1650 void NewSpace::ResumeInlineAllocationObservers() {
1651 DCHECK(top_on_previous_step_ == 0);
1652 inline_allocation_observers_paused_ = false;
1653 StartNextInlineAllocationStep();
1654 }
1655
1656
1639 void NewSpace::InlineAllocationStep(Address top, Address new_top) { 1657 void NewSpace::InlineAllocationStep(Address top, Address new_top) {
1640 if (top_on_previous_step_) { 1658 if (top_on_previous_step_) {
1641 int bytes_allocated = static_cast<int>(top - top_on_previous_step_); 1659 int bytes_allocated = static_cast<int>(top - top_on_previous_step_);
1642 for (int i = 0; i < inline_allocation_observers_.length(); ++i) { 1660 for (int i = 0; i < inline_allocation_observers_.length(); ++i) {
1643 inline_allocation_observers_[i]->InlineAllocationStep(bytes_allocated); 1661 inline_allocation_observers_[i]->InlineAllocationStep(bytes_allocated);
1644 } 1662 }
1645 top_on_previous_step_ = new_top; 1663 top_on_previous_step_ = new_top;
1646 } 1664 }
1647 } 1665 }
1648 1666
(...skipping 1652 matching lines...) Expand 10 before | Expand all | Expand 10 after
3301 object->ShortPrint(); 3319 object->ShortPrint();
3302 PrintF("\n"); 3320 PrintF("\n");
3303 } 3321 }
3304 printf(" --------------------------------------\n"); 3322 printf(" --------------------------------------\n");
3305 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); 3323 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes());
3306 } 3324 }
3307 3325
3308 #endif // DEBUG 3326 #endif // DEBUG
3309 } // namespace internal 3327 } // namespace internal
3310 } // namespace v8 3328 } // 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