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/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/slot-set.h" | 10 #include "src/heap/slot-set.h" |
(...skipping 1483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1494 } | 1494 } |
1495 | 1495 |
1496 | 1496 |
1497 bool NewSpace::EnsureAllocation(int size_in_bytes, | 1497 bool NewSpace::EnsureAllocation(int size_in_bytes, |
1498 AllocationAlignment alignment) { | 1498 AllocationAlignment alignment) { |
1499 Address old_top = allocation_info_.top(); | 1499 Address old_top = allocation_info_.top(); |
1500 Address high = to_space_.page_high(); | 1500 Address high = to_space_.page_high(); |
1501 int filler_size = Heap::GetFillToAlign(old_top, alignment); | 1501 int filler_size = Heap::GetFillToAlign(old_top, alignment); |
1502 int aligned_size_in_bytes = size_in_bytes + filler_size; | 1502 int aligned_size_in_bytes = size_in_bytes + filler_size; |
1503 | 1503 |
1504 if (old_top + aligned_size_in_bytes >= high) { | 1504 if (old_top + aligned_size_in_bytes > high) { |
1505 // Not enough room in the page, try to allocate a new one. | 1505 // Not enough room in the page, try to allocate a new one. |
1506 if (!AddFreshPage()) { | 1506 if (!AddFreshPage()) { |
1507 return false; | 1507 return false; |
1508 } | 1508 } |
1509 | 1509 |
1510 InlineAllocationStep(old_top, allocation_info_.top(), nullptr, 0); | 1510 InlineAllocationStep(old_top, allocation_info_.top(), nullptr, 0); |
1511 | 1511 |
1512 old_top = allocation_info_.top(); | 1512 old_top = allocation_info_.top(); |
1513 high = to_space_.page_high(); | 1513 high = to_space_.page_high(); |
1514 filler_size = Heap::GetFillToAlign(old_top, alignment); | 1514 filler_size = Heap::GetFillToAlign(old_top, alignment); |
1515 aligned_size_in_bytes = size_in_bytes + filler_size; | |
1516 } | 1515 } |
1517 | 1516 |
1518 DCHECK(old_top + aligned_size_in_bytes < high); | 1517 DCHECK(old_top + aligned_size_in_bytes <= high); |
1519 | 1518 |
1520 if (allocation_info_.limit() < high) { | 1519 if (allocation_info_.limit() < high) { |
1521 // Either the limit has been lowered because linear allocation was disabled | 1520 // Either the limit has been lowered because linear allocation was disabled |
1522 // or because incremental marking wants to get a chance to do a step, | 1521 // or because incremental marking wants to get a chance to do a step, |
1523 // or because idle scavenge job wants to get a chance to post a task. | 1522 // or because idle scavenge job wants to get a chance to post a task. |
1524 // Set the new limit accordingly. | 1523 // Set the new limit accordingly. |
1525 Address new_top = old_top + aligned_size_in_bytes; | 1524 Address new_top = old_top + aligned_size_in_bytes; |
1526 Address soon_object = old_top + filler_size; | 1525 Address soon_object = old_top + filler_size; |
1527 InlineAllocationStep(new_top, new_top, soon_object, size_in_bytes); | 1526 InlineAllocationStep(new_top, new_top, soon_object, size_in_bytes); |
1528 UpdateInlineAllocationLimit(aligned_size_in_bytes); | 1527 UpdateInlineAllocationLimit(aligned_size_in_bytes); |
(...skipping 1598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3127 object->ShortPrint(); | 3126 object->ShortPrint(); |
3128 PrintF("\n"); | 3127 PrintF("\n"); |
3129 } | 3128 } |
3130 printf(" --------------------------------------\n"); | 3129 printf(" --------------------------------------\n"); |
3131 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3130 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
3132 } | 3131 } |
3133 | 3132 |
3134 #endif // DEBUG | 3133 #endif // DEBUG |
3135 } // namespace internal | 3134 } // namespace internal |
3136 } // namespace v8 | 3135 } // namespace v8 |
OLD | NEW |