Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 1449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1460 | 1460 |
| 1461 int remaining_in_page = static_cast<int>(limit - top); | 1461 int remaining_in_page = static_cast<int>(limit - top); |
| 1462 heap()->CreateFillerObjectAt(top, remaining_in_page); | 1462 heap()->CreateFillerObjectAt(top, remaining_in_page); |
| 1463 pages_used_++; | 1463 pages_used_++; |
| 1464 UpdateAllocationInfo(); | 1464 UpdateAllocationInfo(); |
| 1465 | 1465 |
| 1466 return true; | 1466 return true; |
| 1467 } | 1467 } |
| 1468 | 1468 |
| 1469 | 1469 |
| 1470 AllocationResult NewSpace::SlowAllocateRaw(int size_in_bytes, | 1470 bool NewSpace::EnsureAllocation(int size_in_bytes, |
| 1471 AllocationAlignment alignment) { | 1471 AllocationAlignment alignment) { |
| 1472 Address old_top = allocation_info_.top(); | 1472 Address old_top = allocation_info_.top(); |
| 1473 Address high = to_space_.page_high(); | 1473 Address high = to_space_.page_high(); |
| 1474 if (allocation_info_.limit() < high) { | 1474 if (allocation_info_.limit() < high) { |
|
Hannes Payer (out of office)
2015/07/30 10:38:25
This method should in principle take care of two c
ofrobots
2015/07/30 20:26:17
Done.
| |
| 1475 int alignment_size = Heap::GetFillToAlign(old_top, alignment); | 1475 int alignment_size = Heap::GetFillToAlign(old_top, alignment); |
| 1476 int aligned_size_in_bytes = size_in_bytes + alignment_size; | 1476 int aligned_size_in_bytes = size_in_bytes + alignment_size; |
| 1477 | 1477 |
| 1478 // Either the limit has been lowered because linear allocation was disabled | 1478 // Either the limit has been lowered because linear allocation was disabled |
| 1479 // or because incremental marking wants to get a chance to do a step. Set | 1479 // or because incremental marking wants to get a chance to do a step. Set |
| 1480 // the new limit accordingly. | 1480 // the new limit accordingly. |
| 1481 Address new_top = old_top + aligned_size_in_bytes; | 1481 Address new_top = old_top + aligned_size_in_bytes; |
| 1482 int bytes_allocated = static_cast<int>(new_top - top_on_previous_step_); | 1482 int bytes_allocated = static_cast<int>(new_top - top_on_previous_step_); |
| 1483 heap()->incremental_marking()->Step(bytes_allocated, | 1483 heap()->incremental_marking()->Step(bytes_allocated, |
| 1484 IncrementalMarking::GC_VIA_STACK_GUARD); | 1484 IncrementalMarking::GC_VIA_STACK_GUARD); |
| 1485 UpdateInlineAllocationLimit(aligned_size_in_bytes); | 1485 UpdateInlineAllocationLimit(aligned_size_in_bytes); |
| 1486 top_on_previous_step_ = new_top; | 1486 top_on_previous_step_ = new_top; |
| 1487 if (alignment == kWordAligned) return AllocateRawUnaligned(size_in_bytes); | 1487 return true; |
| 1488 return AllocateRawAligned(size_in_bytes, alignment); | |
| 1489 } else if (AddFreshPage()) { | 1488 } else if (AddFreshPage()) { |
| 1490 // Switched to new page. Try allocating again. | 1489 // Switched to new page. Try allocating again. |
| 1491 int bytes_allocated = static_cast<int>(old_top - top_on_previous_step_); | 1490 int bytes_allocated = static_cast<int>(old_top - top_on_previous_step_); |
| 1492 heap()->incremental_marking()->Step(bytes_allocated, | 1491 heap()->incremental_marking()->Step(bytes_allocated, |
| 1493 IncrementalMarking::GC_VIA_STACK_GUARD); | 1492 IncrementalMarking::GC_VIA_STACK_GUARD); |
| 1494 top_on_previous_step_ = to_space_.page_low(); | 1493 top_on_previous_step_ = to_space_.page_low(); |
| 1495 if (alignment == kWordAligned) return AllocateRawUnaligned(size_in_bytes); | 1494 return true; |
| 1496 return AllocateRawAligned(size_in_bytes, alignment); | |
| 1497 } else { | 1495 } else { |
|
Hannes Payer (out of office)
2015/07/30 10:38:25
Remove the else case and just return false.
| |
| 1498 return AllocationResult::Retry(); | 1496 return false; |
| 1499 } | 1497 } |
| 1500 } | 1498 } |
| 1501 | 1499 |
| 1502 | 1500 |
| 1503 #ifdef VERIFY_HEAP | 1501 #ifdef VERIFY_HEAP |
| 1504 // We do not use the SemiSpaceIterator because verification doesn't assume | 1502 // We do not use the SemiSpaceIterator because verification doesn't assume |
| 1505 // that it works (it depends on the invariants we are checking). | 1503 // that it works (it depends on the invariants we are checking). |
| 1506 void NewSpace::Verify() { | 1504 void NewSpace::Verify() { |
| 1507 // The allocation pointer should be in the space or at the very end. | 1505 // The allocation pointer should be in the space or at the very end. |
| 1508 DCHECK_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_); | 1506 DCHECK_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_); |
| (...skipping 1632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3141 object->ShortPrint(); | 3139 object->ShortPrint(); |
| 3142 PrintF("\n"); | 3140 PrintF("\n"); |
| 3143 } | 3141 } |
| 3144 printf(" --------------------------------------\n"); | 3142 printf(" --------------------------------------\n"); |
| 3145 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3143 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
| 3146 } | 3144 } |
| 3147 | 3145 |
| 3148 #endif // DEBUG | 3146 #endif // DEBUG |
| 3149 } // namespace internal | 3147 } // namespace internal |
| 3150 } // namespace v8 | 3148 } // namespace v8 |
| OLD | NEW |