| 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/base/platform/semaphore.h" | 9 #include "src/base/platform/semaphore.h" |
| 10 #include "src/full-codegen/full-codegen.h" | 10 #include "src/full-codegen/full-codegen.h" |
| (...skipping 2942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2953 | 2953 |
| 2954 HeapObject* object = current_->GetObject(); | 2954 HeapObject* object = current_->GetObject(); |
| 2955 current_ = current_->next_page(); | 2955 current_ = current_->next_page(); |
| 2956 return object; | 2956 return object; |
| 2957 } | 2957 } |
| 2958 | 2958 |
| 2959 | 2959 |
| 2960 // ----------------------------------------------------------------------------- | 2960 // ----------------------------------------------------------------------------- |
| 2961 // LargeObjectSpace | 2961 // LargeObjectSpace |
| 2962 | 2962 |
| 2963 | |
| 2964 LargeObjectSpace::LargeObjectSpace(Heap* heap, AllocationSpace id) | 2963 LargeObjectSpace::LargeObjectSpace(Heap* heap, AllocationSpace id) |
| 2965 : Space(heap, id, NOT_EXECUTABLE), // Managed on a per-allocation basis | 2964 : Space(heap, id, NOT_EXECUTABLE), // Managed on a per-allocation basis |
| 2966 first_page_(NULL), | 2965 first_page_(NULL), |
| 2967 size_(0), | 2966 size_(0), |
| 2968 page_count_(0), | 2967 page_count_(0), |
| 2969 objects_size_(0), | 2968 objects_size_(0), |
| 2970 chunk_map_(HashMap::PointersMatch, 1024) {} | 2969 chunk_map_(base::HashMap::PointersMatch, 1024) {} |
| 2971 | |
| 2972 | 2970 |
| 2973 LargeObjectSpace::~LargeObjectSpace() {} | 2971 LargeObjectSpace::~LargeObjectSpace() {} |
| 2974 | 2972 |
| 2975 | 2973 |
| 2976 bool LargeObjectSpace::SetUp() { | 2974 bool LargeObjectSpace::SetUp() { |
| 2977 first_page_ = NULL; | 2975 first_page_ = NULL; |
| 2978 size_ = 0; | 2976 size_ = 0; |
| 2979 page_count_ = 0; | 2977 page_count_ = 0; |
| 2980 objects_size_ = 0; | 2978 objects_size_ = 0; |
| 2981 chunk_map_.Clear(); | 2979 chunk_map_.Clear(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3016 objects_size_ += object_size; | 3014 objects_size_ += object_size; |
| 3017 page_count_++; | 3015 page_count_++; |
| 3018 page->set_next_page(first_page_); | 3016 page->set_next_page(first_page_); |
| 3019 first_page_ = page; | 3017 first_page_ = page; |
| 3020 | 3018 |
| 3021 // Register all MemoryChunk::kAlignment-aligned chunks covered by | 3019 // Register all MemoryChunk::kAlignment-aligned chunks covered by |
| 3022 // this large page in the chunk map. | 3020 // this large page in the chunk map. |
| 3023 uintptr_t base = reinterpret_cast<uintptr_t>(page) / MemoryChunk::kAlignment; | 3021 uintptr_t base = reinterpret_cast<uintptr_t>(page) / MemoryChunk::kAlignment; |
| 3024 uintptr_t limit = base + (page->size() - 1) / MemoryChunk::kAlignment; | 3022 uintptr_t limit = base + (page->size() - 1) / MemoryChunk::kAlignment; |
| 3025 for (uintptr_t key = base; key <= limit; key++) { | 3023 for (uintptr_t key = base; key <= limit; key++) { |
| 3026 HashMap::Entry* entry = chunk_map_.LookupOrInsert( | 3024 base::HashMap::Entry* entry = chunk_map_.LookupOrInsert( |
| 3027 reinterpret_cast<void*>(key), static_cast<uint32_t>(key)); | 3025 reinterpret_cast<void*>(key), static_cast<uint32_t>(key)); |
| 3028 DCHECK(entry != NULL); | 3026 DCHECK(entry != NULL); |
| 3029 entry->value = page; | 3027 entry->value = page; |
| 3030 } | 3028 } |
| 3031 | 3029 |
| 3032 HeapObject* object = page->GetObject(); | 3030 HeapObject* object = page->GetObject(); |
| 3033 MSAN_ALLOCATED_UNINITIALIZED_MEMORY(object->address(), object_size); | 3031 MSAN_ALLOCATED_UNINITIALIZED_MEMORY(object->address(), object_size); |
| 3034 | 3032 |
| 3035 if (Heap::ShouldZapGarbage()) { | 3033 if (Heap::ShouldZapGarbage()) { |
| 3036 // Make the object consistent so the heap can be verified in OldSpaceStep. | 3034 // Make the object consistent so the heap can be verified in OldSpaceStep. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 3063 LargePage* page = FindPage(a); | 3061 LargePage* page = FindPage(a); |
| 3064 if (page != NULL) { | 3062 if (page != NULL) { |
| 3065 return page->GetObject(); | 3063 return page->GetObject(); |
| 3066 } | 3064 } |
| 3067 return Smi::FromInt(0); // Signaling not found. | 3065 return Smi::FromInt(0); // Signaling not found. |
| 3068 } | 3066 } |
| 3069 | 3067 |
| 3070 | 3068 |
| 3071 LargePage* LargeObjectSpace::FindPage(Address a) { | 3069 LargePage* LargeObjectSpace::FindPage(Address a) { |
| 3072 uintptr_t key = reinterpret_cast<uintptr_t>(a) / MemoryChunk::kAlignment; | 3070 uintptr_t key = reinterpret_cast<uintptr_t>(a) / MemoryChunk::kAlignment; |
| 3073 HashMap::Entry* e = chunk_map_.Lookup(reinterpret_cast<void*>(key), | 3071 base::HashMap::Entry* e = chunk_map_.Lookup(reinterpret_cast<void*>(key), |
| 3074 static_cast<uint32_t>(key)); | 3072 static_cast<uint32_t>(key)); |
| 3075 if (e != NULL) { | 3073 if (e != NULL) { |
| 3076 DCHECK(e->value != NULL); | 3074 DCHECK(e->value != NULL); |
| 3077 LargePage* page = reinterpret_cast<LargePage*>(e->value); | 3075 LargePage* page = reinterpret_cast<LargePage*>(e->value); |
| 3078 DCHECK(LargePage::IsValid(page)); | 3076 DCHECK(LargePage::IsValid(page)); |
| 3079 if (page->Contains(a)) { | 3077 if (page->Contains(a)) { |
| 3080 return page; | 3078 return page; |
| 3081 } | 3079 } |
| 3082 } | 3080 } |
| 3083 return NULL; | 3081 return NULL; |
| 3084 } | 3082 } |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3261 object->ShortPrint(); | 3259 object->ShortPrint(); |
| 3262 PrintF("\n"); | 3260 PrintF("\n"); |
| 3263 } | 3261 } |
| 3264 printf(" --------------------------------------\n"); | 3262 printf(" --------------------------------------\n"); |
| 3265 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3263 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
| 3266 } | 3264 } |
| 3267 | 3265 |
| 3268 #endif // DEBUG | 3266 #endif // DEBUG |
| 3269 } // namespace internal | 3267 } // namespace internal |
| 3270 } // namespace v8 | 3268 } // namespace v8 |
| OLD | NEW |