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

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

Issue 1274453002: improve allocation accounting for incremental mark (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 4 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/spaces.h ('k') | no next file » | 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/v8.h" 5 #include "src/v8.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/mark-compact.h" 10 #include "src/heap/mark-compact.h"
(...skipping 1378 matching lines...) Expand 10 before | Expand all | Expand 10 after
1389 void NewSpace::UpdateAllocationInfo() { 1389 void NewSpace::UpdateAllocationInfo() {
1390 MemoryChunk::UpdateHighWaterMark(allocation_info_.top()); 1390 MemoryChunk::UpdateHighWaterMark(allocation_info_.top());
1391 allocation_info_.set_top(to_space_.page_low()); 1391 allocation_info_.set_top(to_space_.page_low());
1392 allocation_info_.set_limit(to_space_.page_high()); 1392 allocation_info_.set_limit(to_space_.page_high());
1393 UpdateInlineAllocationLimit(0); 1393 UpdateInlineAllocationLimit(0);
1394 DCHECK_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_); 1394 DCHECK_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_);
1395 } 1395 }
1396 1396
1397 1397
1398 void NewSpace::ResetAllocationInfo() { 1398 void NewSpace::ResetAllocationInfo() {
1399 Address old_top = allocation_info_.top();
1399 to_space_.Reset(); 1400 to_space_.Reset();
1400 UpdateAllocationInfo(); 1401 UpdateAllocationInfo();
1401 pages_used_ = 0; 1402 pages_used_ = 0;
1402 // Clear all mark-bits in the to-space. 1403 // Clear all mark-bits in the to-space.
1403 NewSpacePageIterator it(&to_space_); 1404 NewSpacePageIterator it(&to_space_);
1404 while (it.has_next()) { 1405 while (it.has_next()) {
1405 Bitmap::Clear(it.next()); 1406 Bitmap::Clear(it.next());
1406 } 1407 }
1408 if (top_on_previous_step_) {
1409 int bytes_allocated = static_cast<int>(old_top - top_on_previous_step_);
1410 heap()->incremental_marking()->Step(bytes_allocated,
Hannes Payer (out of office) 2015/08/14 05:26:30 Calling step is is a no-op in this case. ResetAllo
ofrobots 2015/08/14 15:26:18 The objective is to make accounting of the allocat
Hannes Payer (out of office) 2015/08/17 17:56:16 SGTM with the refactoring.
1411 IncrementalMarking::GC_VIA_STACK_GUARD);
1412 top_on_previous_step_ = allocation_info_.top();
1413 }
1407 } 1414 }
1408 1415
1409 1416
1410 void NewSpace::UpdateInlineAllocationLimit(int size_in_bytes) { 1417 void NewSpace::UpdateInlineAllocationLimit(int size_in_bytes) {
1411 if (heap()->inline_allocation_disabled()) { 1418 if (heap()->inline_allocation_disabled()) {
1412 // Lowest limit when linear allocation was disabled. 1419 // Lowest limit when linear allocation was disabled.
1413 Address high = to_space_.page_high(); 1420 Address high = to_space_.page_high();
1414 Address new_top = allocation_info_.top() + size_in_bytes; 1421 Address new_top = allocation_info_.top() + size_in_bytes;
1415 allocation_info_.set_limit(Min(new_top, high)); 1422 allocation_info_.set_limit(Min(new_top, high));
1416 } else if (inline_allocation_limit_step() == 0) { 1423 } else if (inline_allocation_limit_step() == 0) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1475 Address high = to_space_.page_high(); 1482 Address high = to_space_.page_high();
1476 int filler_size = Heap::GetFillToAlign(old_top, alignment); 1483 int filler_size = Heap::GetFillToAlign(old_top, alignment);
1477 int aligned_size_in_bytes = size_in_bytes + filler_size; 1484 int aligned_size_in_bytes = size_in_bytes + filler_size;
1478 1485
1479 if (old_top + aligned_size_in_bytes >= high) { 1486 if (old_top + aligned_size_in_bytes >= high) {
1480 // Not enough room in the page, try to allocate a new one. 1487 // Not enough room in the page, try to allocate a new one.
1481 if (!AddFreshPage()) { 1488 if (!AddFreshPage()) {
1482 return false; 1489 return false;
1483 } 1490 }
1484 1491
1485 // Do a step for the bytes allocated on the last page. 1492 if (top_on_previous_step_) {
1486 int bytes_allocated = static_cast<int>(old_top - top_on_previous_step_); 1493 // Do a step for the bytes allocated on the last page.
1487 heap()->incremental_marking()->Step(bytes_allocated, 1494 int bytes_allocated = static_cast<int>(old_top - top_on_previous_step_);
1488 IncrementalMarking::GC_VIA_STACK_GUARD); 1495 heap()->incremental_marking()->Step(
1496 bytes_allocated, IncrementalMarking::GC_VIA_STACK_GUARD);
1497 top_on_previous_step_ = allocation_info_.top();
1498 }
1499
1489 old_top = allocation_info_.top(); 1500 old_top = allocation_info_.top();
1490 top_on_previous_step_ = old_top;
1491
1492 high = to_space_.page_high(); 1501 high = to_space_.page_high();
1493 filler_size = Heap::GetFillToAlign(old_top, alignment); 1502 filler_size = Heap::GetFillToAlign(old_top, alignment);
1494 aligned_size_in_bytes = size_in_bytes + filler_size; 1503 aligned_size_in_bytes = size_in_bytes + filler_size;
1495 } 1504 }
1496 1505
1497 DCHECK(old_top + aligned_size_in_bytes < high); 1506 DCHECK(old_top + aligned_size_in_bytes < high);
1498 1507
1499 if (allocation_info_.limit() < high) { 1508 if (allocation_info_.limit() < high) {
1500 // Either the limit has been lowered because linear allocation was disabled 1509 // Either the limit has been lowered because linear allocation was disabled
1501 // or because incremental marking wants to get a chance to do a step. Set 1510 // or because incremental marking wants to get a chance to do a step. Set
1502 // the new limit accordingly. 1511 // the new limit accordingly.
1503 Address new_top = old_top + aligned_size_in_bytes; 1512 if (top_on_previous_step_) {
1504 int bytes_allocated = static_cast<int>(new_top - top_on_previous_step_); 1513 Address new_top = old_top + aligned_size_in_bytes;
1505 heap()->incremental_marking()->Step(bytes_allocated, 1514 int bytes_allocated = static_cast<int>(new_top - top_on_previous_step_);
1506 IncrementalMarking::GC_VIA_STACK_GUARD); 1515 heap()->incremental_marking()->Step(
1516 bytes_allocated, IncrementalMarking::GC_VIA_STACK_GUARD);
1517 top_on_previous_step_ = new_top;
ofrobots 2015/08/04 19:37:11 I think it might be good to refactor this into a n
Hannes Payer (out of office) 2015/08/14 05:26:30 Yes, good idea.
1518 }
1507 UpdateInlineAllocationLimit(aligned_size_in_bytes); 1519 UpdateInlineAllocationLimit(aligned_size_in_bytes);
1508 top_on_previous_step_ = new_top;
1509 } 1520 }
1510 return true; 1521 return true;
1511 } 1522 }
1512 1523
1513 1524
1514 #ifdef VERIFY_HEAP 1525 #ifdef VERIFY_HEAP
1515 // We do not use the SemiSpaceIterator because verification doesn't assume 1526 // We do not use the SemiSpaceIterator because verification doesn't assume
1516 // that it works (it depends on the invariants we are checking). 1527 // that it works (it depends on the invariants we are checking).
1517 void NewSpace::Verify() { 1528 void NewSpace::Verify() {
1518 // The allocation pointer should be in the space or at the very end. 1529 // The allocation pointer should be in the space or at the very end.
(...skipping 1633 matching lines...) Expand 10 before | Expand all | Expand 10 after
3152 object->ShortPrint(); 3163 object->ShortPrint();
3153 PrintF("\n"); 3164 PrintF("\n");
3154 } 3165 }
3155 printf(" --------------------------------------\n"); 3166 printf(" --------------------------------------\n");
3156 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); 3167 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes());
3157 } 3168 }
3158 3169
3159 #endif // DEBUG 3170 #endif // DEBUG
3160 } // namespace internal 3171 } // namespace internal
3161 } // namespace v8 3172 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/spaces.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698