| 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 "v8.h" | 5 #include "v8.h" |
| 6 | 6 |
| 7 #include "full-codegen.h" | 7 #include "full-codegen.h" |
| 8 #include "macro-assembler.h" | 8 #include "macro-assembler.h" |
| 9 #include "mark-compact.h" | 9 #include "mark-compact.h" |
| 10 #include "msan.h" | 10 #include "msan.h" |
| (...skipping 1379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1390 | 1390 |
| 1391 int remaining_in_page = static_cast<int>(limit - top); | 1391 int remaining_in_page = static_cast<int>(limit - top); |
| 1392 heap()->CreateFillerObjectAt(top, remaining_in_page); | 1392 heap()->CreateFillerObjectAt(top, remaining_in_page); |
| 1393 pages_used_++; | 1393 pages_used_++; |
| 1394 UpdateAllocationInfo(); | 1394 UpdateAllocationInfo(); |
| 1395 | 1395 |
| 1396 return true; | 1396 return true; |
| 1397 } | 1397 } |
| 1398 | 1398 |
| 1399 | 1399 |
| 1400 MaybeObject* NewSpace::SlowAllocateRaw(int size_in_bytes) { | 1400 AllocationResult NewSpace::SlowAllocateRaw(int size_in_bytes) { |
| 1401 Address old_top = allocation_info_.top(); | 1401 Address old_top = allocation_info_.top(); |
| 1402 Address high = to_space_.page_high(); | 1402 Address high = to_space_.page_high(); |
| 1403 if (allocation_info_.limit() < high) { | 1403 if (allocation_info_.limit() < high) { |
| 1404 // Either the limit has been lowered because linear allocation was disabled | 1404 // Either the limit has been lowered because linear allocation was disabled |
| 1405 // or because incremental marking wants to get a chance to do a step. Set | 1405 // or because incremental marking wants to get a chance to do a step. Set |
| 1406 // the new limit accordingly. | 1406 // the new limit accordingly. |
| 1407 Address new_top = old_top + size_in_bytes; | 1407 Address new_top = old_top + size_in_bytes; |
| 1408 int bytes_allocated = static_cast<int>(new_top - top_on_previous_step_); | 1408 int bytes_allocated = static_cast<int>(new_top - top_on_previous_step_); |
| 1409 heap()->incremental_marking()->Step( | 1409 heap()->incremental_marking()->Step( |
| 1410 bytes_allocated, IncrementalMarking::GC_VIA_STACK_GUARD); | 1410 bytes_allocated, IncrementalMarking::GC_VIA_STACK_GUARD); |
| 1411 UpdateInlineAllocationLimit(size_in_bytes); | 1411 UpdateInlineAllocationLimit(size_in_bytes); |
| 1412 top_on_previous_step_ = new_top; | 1412 top_on_previous_step_ = new_top; |
| 1413 return AllocateRaw(size_in_bytes); | 1413 return AllocateRaw(size_in_bytes); |
| 1414 } else if (AddFreshPage()) { | 1414 } else if (AddFreshPage()) { |
| 1415 // Switched to new page. Try allocating again. | 1415 // Switched to new page. Try allocating again. |
| 1416 int bytes_allocated = static_cast<int>(old_top - top_on_previous_step_); | 1416 int bytes_allocated = static_cast<int>(old_top - top_on_previous_step_); |
| 1417 heap()->incremental_marking()->Step( | 1417 heap()->incremental_marking()->Step( |
| 1418 bytes_allocated, IncrementalMarking::GC_VIA_STACK_GUARD); | 1418 bytes_allocated, IncrementalMarking::GC_VIA_STACK_GUARD); |
| 1419 top_on_previous_step_ = to_space_.page_low(); | 1419 top_on_previous_step_ = to_space_.page_low(); |
| 1420 return AllocateRaw(size_in_bytes); | 1420 return AllocateRaw(size_in_bytes); |
| 1421 } else { | 1421 } else { |
| 1422 return Failure::RetryAfterGC(); | 1422 return AllocationResult::Retry(); |
| 1423 } | 1423 } |
| 1424 } | 1424 } |
| 1425 | 1425 |
| 1426 | 1426 |
| 1427 #ifdef VERIFY_HEAP | 1427 #ifdef VERIFY_HEAP |
| 1428 // We do not use the SemiSpaceIterator because verification doesn't assume | 1428 // We do not use the SemiSpaceIterator because verification doesn't assume |
| 1429 // that it works (it depends on the invariants we are checking). | 1429 // that it works (it depends on the invariants we are checking). |
| 1430 void NewSpace::Verify() { | 1430 void NewSpace::Verify() { |
| 1431 // The allocation pointer should be in the space or at the very end. | 1431 // The allocation pointer should be in the space or at the very end. |
| 1432 ASSERT_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_); | 1432 ASSERT_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_); |
| (...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2835 | 2835 |
| 2836 ObjectSpace space = static_cast<ObjectSpace>(1 << identity()); | 2836 ObjectSpace space = static_cast<ObjectSpace>(1 << identity()); |
| 2837 heap()->isolate()->memory_allocator()->PerformAllocationCallback( | 2837 heap()->isolate()->memory_allocator()->PerformAllocationCallback( |
| 2838 space, kAllocationActionFree, page->size()); | 2838 space, kAllocationActionFree, page->size()); |
| 2839 heap()->isolate()->memory_allocator()->Free(page); | 2839 heap()->isolate()->memory_allocator()->Free(page); |
| 2840 } | 2840 } |
| 2841 SetUp(); | 2841 SetUp(); |
| 2842 } | 2842 } |
| 2843 | 2843 |
| 2844 | 2844 |
| 2845 MaybeObject* LargeObjectSpace::AllocateRaw(int object_size, | 2845 AllocationResult LargeObjectSpace::AllocateRaw(int object_size, |
| 2846 Executability executable) { | 2846 Executability executable) { |
| 2847 // Check if we want to force a GC before growing the old space further. | 2847 // Check if we want to force a GC before growing the old space further. |
| 2848 // If so, fail the allocation. | 2848 // If so, fail the allocation. |
| 2849 if (!heap()->always_allocate() && | 2849 if (!heap()->always_allocate() && |
| 2850 heap()->OldGenerationAllocationLimitReached()) { | 2850 heap()->OldGenerationAllocationLimitReached()) { |
| 2851 return Failure::RetryAfterGC(identity()); | 2851 return AllocationResult::Retry(identity()); |
| 2852 } | 2852 } |
| 2853 | 2853 |
| 2854 if (Size() + object_size > max_capacity_) { | 2854 if (Size() + object_size > max_capacity_) { |
| 2855 return Failure::RetryAfterGC(identity()); | 2855 return AllocationResult::Retry(identity()); |
| 2856 } | 2856 } |
| 2857 | 2857 |
| 2858 LargePage* page = heap()->isolate()->memory_allocator()-> | 2858 LargePage* page = heap()->isolate()->memory_allocator()-> |
| 2859 AllocateLargePage(object_size, this, executable); | 2859 AllocateLargePage(object_size, this, executable); |
| 2860 if (page == NULL) return Failure::RetryAfterGC(identity()); | 2860 if (page == NULL) return AllocationResult::Retry(identity()); |
| 2861 ASSERT(page->area_size() >= object_size); | 2861 ASSERT(page->area_size() >= object_size); |
| 2862 | 2862 |
| 2863 size_ += static_cast<int>(page->size()); | 2863 size_ += static_cast<int>(page->size()); |
| 2864 objects_size_ += object_size; | 2864 objects_size_ += object_size; |
| 2865 page_count_++; | 2865 page_count_++; |
| 2866 page->set_next_page(first_page_); | 2866 page->set_next_page(first_page_); |
| 2867 first_page_ = page; | 2867 first_page_ = page; |
| 2868 | 2868 |
| 2869 if (size_ > maximum_committed_) { | 2869 if (size_ > maximum_committed_) { |
| 2870 maximum_committed_ = size_; | 2870 maximum_committed_ = size_; |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3109 object->ShortPrint(); | 3109 object->ShortPrint(); |
| 3110 PrintF("\n"); | 3110 PrintF("\n"); |
| 3111 } | 3111 } |
| 3112 printf(" --------------------------------------\n"); | 3112 printf(" --------------------------------------\n"); |
| 3113 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3113 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
| 3114 } | 3114 } |
| 3115 | 3115 |
| 3116 #endif // DEBUG | 3116 #endif // DEBUG |
| 3117 | 3117 |
| 3118 } } // namespace v8::internal | 3118 } } // namespace v8::internal |
| OLD | NEW |