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.h" | 9 #include "src/full-codegen.h" |
10 #include "src/heap/mark-compact.h" | 10 #include "src/heap/mark-compact.h" |
(...skipping 1440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1451 | 1451 |
1452 int remaining_in_page = static_cast<int>(limit - top); | 1452 int remaining_in_page = static_cast<int>(limit - top); |
1453 heap()->CreateFillerObjectAt(top, remaining_in_page); | 1453 heap()->CreateFillerObjectAt(top, remaining_in_page); |
1454 pages_used_++; | 1454 pages_used_++; |
1455 UpdateAllocationInfo(); | 1455 UpdateAllocationInfo(); |
1456 | 1456 |
1457 return true; | 1457 return true; |
1458 } | 1458 } |
1459 | 1459 |
1460 | 1460 |
1461 AllocationResult NewSpace::SlowAllocateRaw(int size_in_bytes) { | 1461 AllocationResult NewSpace::SlowAllocateRaw(int size_in_bytes, |
| 1462 bool double_aligned) { |
1462 Address old_top = allocation_info_.top(); | 1463 Address old_top = allocation_info_.top(); |
1463 Address high = to_space_.page_high(); | 1464 Address high = to_space_.page_high(); |
1464 if (allocation_info_.limit() < high) { | 1465 if (allocation_info_.limit() < high) { |
1465 // Either the limit has been lowered because linear allocation was disabled | 1466 // Either the limit has been lowered because linear allocation was disabled |
1466 // or because incremental marking wants to get a chance to do a step. Set | 1467 // or because incremental marking wants to get a chance to do a step. Set |
1467 // the new limit accordingly. | 1468 // the new limit accordingly. |
1468 Address new_top = old_top + size_in_bytes; | 1469 int aligned_size = size_in_bytes; |
| 1470 aligned_size += (double_aligned ? kPointerSize : 0); |
| 1471 Address new_top = old_top + aligned_size; |
1469 int bytes_allocated = static_cast<int>(new_top - top_on_previous_step_); | 1472 int bytes_allocated = static_cast<int>(new_top - top_on_previous_step_); |
1470 heap()->incremental_marking()->Step(bytes_allocated, | 1473 heap()->incremental_marking()->Step(bytes_allocated, |
1471 IncrementalMarking::GC_VIA_STACK_GUARD); | 1474 IncrementalMarking::GC_VIA_STACK_GUARD); |
1472 UpdateInlineAllocationLimit(size_in_bytes); | 1475 UpdateInlineAllocationLimit(aligned_size); |
1473 top_on_previous_step_ = new_top; | 1476 top_on_previous_step_ = new_top; |
| 1477 if (double_aligned) return AllocateRawDoubleAligned(size_in_bytes); |
1474 return AllocateRaw(size_in_bytes); | 1478 return AllocateRaw(size_in_bytes); |
1475 } else if (AddFreshPage()) { | 1479 } else if (AddFreshPage()) { |
1476 // Switched to new page. Try allocating again. | 1480 // Switched to new page. Try allocating again. |
1477 int bytes_allocated = static_cast<int>(old_top - top_on_previous_step_); | 1481 int bytes_allocated = static_cast<int>(old_top - top_on_previous_step_); |
1478 heap()->incremental_marking()->Step(bytes_allocated, | 1482 heap()->incremental_marking()->Step(bytes_allocated, |
1479 IncrementalMarking::GC_VIA_STACK_GUARD); | 1483 IncrementalMarking::GC_VIA_STACK_GUARD); |
1480 top_on_previous_step_ = to_space_.page_low(); | 1484 top_on_previous_step_ = to_space_.page_low(); |
| 1485 if (double_aligned) return AllocateRawDoubleAligned(size_in_bytes); |
1481 return AllocateRaw(size_in_bytes); | 1486 return AllocateRaw(size_in_bytes); |
1482 } else { | 1487 } else { |
1483 return AllocationResult::Retry(); | 1488 return AllocationResult::Retry(); |
1484 } | 1489 } |
1485 } | 1490 } |
1486 | 1491 |
1487 | 1492 |
1488 #ifdef VERIFY_HEAP | 1493 #ifdef VERIFY_HEAP |
1489 // We do not use the SemiSpaceIterator because verification doesn't assume | 1494 // We do not use the SemiSpaceIterator because verification doesn't assume |
1490 // that it works (it depends on the invariants we are checking). | 1495 // that it works (it depends on the invariants we are checking). |
(...skipping 1631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3122 object->ShortPrint(); | 3127 object->ShortPrint(); |
3123 PrintF("\n"); | 3128 PrintF("\n"); |
3124 } | 3129 } |
3125 printf(" --------------------------------------\n"); | 3130 printf(" --------------------------------------\n"); |
3126 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3131 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
3127 } | 3132 } |
3128 | 3133 |
3129 #endif // DEBUG | 3134 #endif // DEBUG |
3130 } | 3135 } |
3131 } // namespace v8::internal | 3136 } // namespace v8::internal |
OLD | NEW |