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 913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 924 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::NEW_SPACE) == | 924 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::NEW_SPACE) == |
| 925 ObjectSpace::kObjectSpaceNewSpace); | 925 ObjectSpace::kObjectSpaceNewSpace); |
| 926 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::OLD_SPACE) == | 926 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::OLD_SPACE) == |
| 927 ObjectSpace::kObjectSpaceOldSpace); | 927 ObjectSpace::kObjectSpaceOldSpace); |
| 928 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::CODE_SPACE) == | 928 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::CODE_SPACE) == |
| 929 ObjectSpace::kObjectSpaceCodeSpace); | 929 ObjectSpace::kObjectSpaceCodeSpace); |
| 930 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::MAP_SPACE) == | 930 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::MAP_SPACE) == |
| 931 ObjectSpace::kObjectSpaceMapSpace); | 931 ObjectSpace::kObjectSpaceMapSpace); |
| 932 | 932 |
| 933 | 933 |
| 934 PagedSpace::PagedSpace(Heap* heap, intptr_t max_capacity, AllocationSpace space, | 934 PagedSpace::PagedSpace(Heap* heap, AllocationSpace space, |
| 935 Executability executable) | 935 Executability executable) |
| 936 : Space(heap, space, executable), | 936 : Space(heap, space, executable), |
| 937 free_list_(this), | 937 free_list_(this), |
| 938 unswept_free_bytes_(0), | 938 unswept_free_bytes_(0), |
| 939 end_of_unswept_pages_(NULL), | 939 end_of_unswept_pages_(NULL), |
| 940 emergency_memory_(NULL) { | 940 emergency_memory_(NULL) { |
| 941 area_size_ = MemoryAllocator::PageAreaSize(space); | 941 area_size_ = MemoryAllocator::PageAreaSize(space); |
| 942 max_capacity_ = | |
| 943 (RoundDown(max_capacity, Page::kPageSize) / Page::kPageSize) * AreaSize(); | |
| 944 accounting_stats_.Clear(); | 942 accounting_stats_.Clear(); |
| 945 | 943 |
| 946 allocation_info_.set_top(NULL); | 944 allocation_info_.set_top(NULL); |
| 947 allocation_info_.set_limit(NULL); | 945 allocation_info_.set_limit(NULL); |
| 948 | 946 |
| 949 anchor_.InitializeAsAnchor(this); | 947 anchor_.InitializeAsAnchor(this); |
| 950 } | 948 } |
| 951 | 949 |
| 952 | 950 |
| 953 bool PagedSpace::SetUp() { return true; } | 951 bool PagedSpace::SetUp() { return true; } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1002 Address next = cur + obj->Size(); | 1000 Address next = cur + obj->Size(); |
| 1003 if ((cur <= addr) && (addr < next)) return obj; | 1001 if ((cur <= addr) && (addr < next)) return obj; |
| 1004 } | 1002 } |
| 1005 | 1003 |
| 1006 UNREACHABLE(); | 1004 UNREACHABLE(); |
| 1007 return Smi::FromInt(0); | 1005 return Smi::FromInt(0); |
| 1008 } | 1006 } |
| 1009 | 1007 |
| 1010 | 1008 |
| 1011 bool PagedSpace::CanExpand() { | 1009 bool PagedSpace::CanExpand() { |
| 1012 DCHECK(max_capacity_ % AreaSize() == 0); | |
| 1013 DCHECK(heap()->mark_compact_collector()->is_compacting() || | 1010 DCHECK(heap()->mark_compact_collector()->is_compacting() || |
| 1014 Capacity() <= heap()->MaxOldGenerationSize()); | 1011 Capacity() <= heap()->MaxOldGenerationSize()); |
| 1015 DCHECK(heap()->CommittedOldGenerationMemory() <= | 1012 DCHECK(heap()->CommittedOldGenerationMemory() <= |
| 1016 heap()->MaxOldGenerationSize() + | 1013 heap()->MaxOldGenerationSize() + |
| 1017 PagedSpace::MaxEmergencyMemoryAllocated()); | 1014 PagedSpace::MaxEmergencyMemoryAllocated()); |
| 1018 | 1015 |
| 1019 // Are we going to exceed capacity for this space? | 1016 // Are we going to exceed capacity for this space? |
| 1020 if (!heap()->CanExpandOldGeneration(Page::kPageSize)) return false; | 1017 if (!heap()->CanExpandOldGeneration(Page::kPageSize)) return false; |
| 1021 | 1018 |
| 1022 return true; | 1019 return true; |
| (...skipping 1778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2801 current_ = current_->next_page(); | 2798 current_ = current_->next_page(); |
| 2802 return object; | 2799 return object; |
| 2803 } | 2800 } |
| 2804 | 2801 |
| 2805 | 2802 |
| 2806 // ----------------------------------------------------------------------------- | 2803 // ----------------------------------------------------------------------------- |
| 2807 // LargeObjectSpace | 2804 // LargeObjectSpace |
| 2808 static bool ComparePointers(void* key1, void* key2) { return key1 == key2; } | 2805 static bool ComparePointers(void* key1, void* key2) { return key1 == key2; } |
| 2809 | 2806 |
| 2810 | 2807 |
| 2811 LargeObjectSpace::LargeObjectSpace(Heap* heap, intptr_t max_capacity, | 2808 LargeObjectSpace::LargeObjectSpace(Heap* heap, AllocationSpace id) |
| 2812 AllocationSpace id) | |
| 2813 : Space(heap, id, NOT_EXECUTABLE), // Managed on a per-allocation basis | 2809 : Space(heap, id, NOT_EXECUTABLE), // Managed on a per-allocation basis |
| 2814 max_capacity_(max_capacity), | |
| 2815 first_page_(NULL), | 2810 first_page_(NULL), |
| 2816 size_(0), | 2811 size_(0), |
| 2817 page_count_(0), | 2812 page_count_(0), |
| 2818 objects_size_(0), | 2813 objects_size_(0), |
| 2819 chunk_map_(ComparePointers, 1024) {} | 2814 chunk_map_(ComparePointers, 1024) {} |
| 2820 | 2815 |
| 2821 | 2816 |
| 2822 bool LargeObjectSpace::SetUp() { | 2817 bool LargeObjectSpace::SetUp() { |
| 2823 first_page_ = NULL; | 2818 first_page_ = NULL; |
| 2824 size_ = 0; | 2819 size_ = 0; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 2843 } | 2838 } |
| 2844 SetUp(); | 2839 SetUp(); |
| 2845 } | 2840 } |
| 2846 | 2841 |
| 2847 | 2842 |
| 2848 AllocationResult LargeObjectSpace::AllocateRaw(int object_size, | 2843 AllocationResult LargeObjectSpace::AllocateRaw(int object_size, |
| 2849 Executability executable) { | 2844 Executability executable) { |
| 2850 // Check if we want to force a GC before growing the old space further. | 2845 // Check if we want to force a GC before growing the old space further. |
| 2851 // If so, fail the allocation. | 2846 // If so, fail the allocation. |
| 2852 if (!heap()->always_allocate() && | 2847 if (!heap()->always_allocate() && |
| 2853 heap()->OldGenerationAllocationLimitReached()) { | 2848 heap()->incremental_marking()->IsStopped() && |
|
Hannes Payer (out of office)
2015/08/11 11:20:44
We cannot allow incremental marking to go over the
| |
| 2849 !heap()->CanExpandOldGeneration(object_size)) { | |
| 2854 return AllocationResult::Retry(identity()); | 2850 return AllocationResult::Retry(identity()); |
| 2855 } | 2851 } |
| 2856 | 2852 |
| 2857 if (!CanAllocateSize(object_size)) return AllocationResult::Retry(identity()); | |
| 2858 | |
| 2859 LargePage* page = heap()->isolate()->memory_allocator()->AllocateLargePage( | 2853 LargePage* page = heap()->isolate()->memory_allocator()->AllocateLargePage( |
| 2860 object_size, this, executable); | 2854 object_size, this, executable); |
| 2861 if (page == NULL) return AllocationResult::Retry(identity()); | 2855 if (page == NULL) return AllocationResult::Retry(identity()); |
| 2862 DCHECK(page->area_size() >= object_size); | 2856 DCHECK(page->area_size() >= object_size); |
| 2863 | 2857 |
| 2864 size_ += static_cast<int>(page->size()); | 2858 size_ += static_cast<int>(page->size()); |
| 2865 objects_size_ += object_size; | 2859 objects_size_ += object_size; |
| 2866 page_count_++; | 2860 page_count_++; |
| 2867 page->set_next_page(first_page_); | 2861 page->set_next_page(first_page_); |
| 2868 first_page_ = page; | 2862 first_page_ = page; |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3114 object->ShortPrint(); | 3108 object->ShortPrint(); |
| 3115 PrintF("\n"); | 3109 PrintF("\n"); |
| 3116 } | 3110 } |
| 3117 printf(" --------------------------------------\n"); | 3111 printf(" --------------------------------------\n"); |
| 3118 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3112 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
| 3119 } | 3113 } |
| 3120 | 3114 |
| 3121 #endif // DEBUG | 3115 #endif // DEBUG |
| 3122 } // namespace internal | 3116 } // namespace internal |
| 3123 } // namespace v8 | 3117 } // namespace v8 |
| OLD | NEW |