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

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

Issue 1460063006: [heap] report allocated object to the inline-allocation-observers (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix comments Created 5 years 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 1481 matching lines...) Expand 10 before | Expand all | Expand 10 after
1492 void NewSpace::ResetAllocationInfo() { 1492 void NewSpace::ResetAllocationInfo() {
1493 Address old_top = allocation_info_.top(); 1493 Address old_top = allocation_info_.top();
1494 to_space_.Reset(); 1494 to_space_.Reset();
1495 UpdateAllocationInfo(); 1495 UpdateAllocationInfo();
1496 pages_used_ = 0; 1496 pages_used_ = 0;
1497 // Clear all mark-bits in the to-space. 1497 // Clear all mark-bits in the to-space.
1498 NewSpacePageIterator it(&to_space_); 1498 NewSpacePageIterator it(&to_space_);
1499 while (it.has_next()) { 1499 while (it.has_next()) {
1500 Bitmap::Clear(it.next()); 1500 Bitmap::Clear(it.next());
1501 } 1501 }
1502 InlineAllocationStep(old_top, allocation_info_.top()); 1502 InlineAllocationStep(old_top, allocation_info_.top(), nullptr, 0);
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 (inline_allocation_observers_paused_ || 1512 } else if (inline_allocation_observers_paused_ ||
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1572 Address high = to_space_.page_high(); 1572 Address high = to_space_.page_high();
1573 int filler_size = Heap::GetFillToAlign(old_top, alignment); 1573 int filler_size = Heap::GetFillToAlign(old_top, alignment);
1574 int aligned_size_in_bytes = size_in_bytes + filler_size; 1574 int aligned_size_in_bytes = size_in_bytes + filler_size;
1575 1575
1576 if (old_top + aligned_size_in_bytes >= high) { 1576 if (old_top + aligned_size_in_bytes >= high) {
1577 // Not enough room in the page, try to allocate a new one. 1577 // Not enough room in the page, try to allocate a new one.
1578 if (!AddFreshPage()) { 1578 if (!AddFreshPage()) {
1579 return false; 1579 return false;
1580 } 1580 }
1581 1581
1582 InlineAllocationStep(old_top, allocation_info_.top()); 1582 InlineAllocationStep(old_top, allocation_info_.top(), nullptr, 0);
1583 1583
1584 old_top = allocation_info_.top(); 1584 old_top = allocation_info_.top();
1585 high = to_space_.page_high(); 1585 high = to_space_.page_high();
1586 filler_size = Heap::GetFillToAlign(old_top, alignment); 1586 filler_size = Heap::GetFillToAlign(old_top, alignment);
1587 aligned_size_in_bytes = size_in_bytes + filler_size; 1587 aligned_size_in_bytes = size_in_bytes + filler_size;
1588 } 1588 }
1589 1589
1590 DCHECK(old_top + aligned_size_in_bytes < high); 1590 DCHECK(old_top + aligned_size_in_bytes < high);
1591 1591
1592 if (allocation_info_.limit() < high) { 1592 if (allocation_info_.limit() < high) {
1593 // Either the limit has been lowered because linear allocation was disabled 1593 // Either the limit has been lowered because linear allocation was disabled
1594 // or because incremental marking wants to get a chance to do a step, 1594 // or because incremental marking wants to get a chance to do a step,
1595 // or because idle scavenge job wants to get a chance to post a task. 1595 // or because idle scavenge job wants to get a chance to post a task.
1596 // Set the new limit accordingly. 1596 // Set the new limit accordingly.
1597 Address new_top = old_top + aligned_size_in_bytes; 1597 Address new_top = old_top + aligned_size_in_bytes;
1598 InlineAllocationStep(new_top, new_top); 1598 Address soon_object = old_top + filler_size;
1599 InlineAllocationStep(new_top, new_top, soon_object, size_in_bytes);
1599 UpdateInlineAllocationLimit(aligned_size_in_bytes); 1600 UpdateInlineAllocationLimit(aligned_size_in_bytes);
1600 } 1601 }
1601 return true; 1602 return true;
1602 } 1603 }
1603 1604
1604 1605
1605 void NewSpace::StartNextInlineAllocationStep() { 1606 void NewSpace::StartNextInlineAllocationStep() {
1606 DCHECK(!inline_allocation_observers_paused_); 1607 DCHECK(!inline_allocation_observers_paused_);
1607 top_on_previous_step_ = 1608 top_on_previous_step_ =
1608 inline_allocation_observers_.length() ? allocation_info_.top() : 0; 1609 inline_allocation_observers_.length() ? allocation_info_.top() : 0;
(...skipping 24 matching lines...) Expand all
1633 bool removed = inline_allocation_observers_.RemoveElement(observer); 1634 bool removed = inline_allocation_observers_.RemoveElement(observer);
1634 // Only used in assertion. Suppress unused variable warning. 1635 // Only used in assertion. Suppress unused variable warning.
1635 static_cast<void>(removed); 1636 static_cast<void>(removed);
1636 DCHECK(removed); 1637 DCHECK(removed);
1637 StartNextInlineAllocationStep(); 1638 StartNextInlineAllocationStep();
1638 } 1639 }
1639 1640
1640 1641
1641 void NewSpace::PauseInlineAllocationObservers() { 1642 void NewSpace::PauseInlineAllocationObservers() {
1642 // Do a step to account for memory allocated so far. 1643 // Do a step to account for memory allocated so far.
1643 InlineAllocationStep(top(), top()); 1644 InlineAllocationStep(top(), top(), nullptr, 0);
1644 inline_allocation_observers_paused_ = true; 1645 inline_allocation_observers_paused_ = true;
1645 top_on_previous_step_ = 0; 1646 top_on_previous_step_ = 0;
1646 UpdateInlineAllocationLimit(0); 1647 UpdateInlineAllocationLimit(0);
1647 } 1648 }
1648 1649
1649 1650
1650 void NewSpace::ResumeInlineAllocationObservers() { 1651 void NewSpace::ResumeInlineAllocationObservers() {
1651 DCHECK(top_on_previous_step_ == 0); 1652 DCHECK(top_on_previous_step_ == 0);
1652 inline_allocation_observers_paused_ = false; 1653 inline_allocation_observers_paused_ = false;
1653 StartNextInlineAllocationStep(); 1654 StartNextInlineAllocationStep();
1654 } 1655 }
1655 1656
1656 1657
1657 void NewSpace::InlineAllocationStep(Address top, Address new_top) { 1658 void NewSpace::InlineAllocationStep(Address top, Address new_top,
1659 Address soon_object, size_t size) {
1658 if (top_on_previous_step_) { 1660 if (top_on_previous_step_) {
1659 int bytes_allocated = static_cast<int>(top - top_on_previous_step_); 1661 int bytes_allocated = static_cast<int>(top - top_on_previous_step_);
1660 for (int i = 0; i < inline_allocation_observers_.length(); ++i) { 1662 for (int i = 0; i < inline_allocation_observers_.length(); ++i) {
1661 inline_allocation_observers_[i]->InlineAllocationStep(bytes_allocated); 1663 inline_allocation_observers_[i]->InlineAllocationStep(bytes_allocated,
1664 soon_object, size);
1662 } 1665 }
1663 top_on_previous_step_ = new_top; 1666 top_on_previous_step_ = new_top;
1664 } 1667 }
1665 } 1668 }
1666 1669
1667 #ifdef VERIFY_HEAP 1670 #ifdef VERIFY_HEAP
1668 // We do not use the SemiSpaceIterator because verification doesn't assume 1671 // We do not use the SemiSpaceIterator because verification doesn't assume
1669 // that it works (it depends on the invariants we are checking). 1672 // that it works (it depends on the invariants we are checking).
1670 void NewSpace::Verify() { 1673 void NewSpace::Verify() {
1671 // The allocation pointer should be in the space or at the very end. 1674 // The allocation pointer should be in the space or at the very end.
(...skipping 1647 matching lines...) Expand 10 before | Expand all | Expand 10 after
3319 object->ShortPrint(); 3322 object->ShortPrint();
3320 PrintF("\n"); 3323 PrintF("\n");
3321 } 3324 }
3322 printf(" --------------------------------------\n"); 3325 printf(" --------------------------------------\n");
3323 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); 3326 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes());
3324 } 3327 }
3325 3328
3326 #endif // DEBUG 3329 #endif // DEBUG
3327 } // namespace internal 3330 } // namespace internal
3328 } // namespace v8 3331 } // 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