Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(762)

Side by Side Diff: src/heap/spaces.cc

Issue 2010243003: Move hashmap into base/. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/heap/spaces.h ('k') | src/isolate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2911 matching lines...) Expand 10 before | Expand all | Expand 10 after
2922 2922
2923 HeapObject* object = current_->GetObject(); 2923 HeapObject* object = current_->GetObject();
2924 current_ = current_->next_page(); 2924 current_ = current_->next_page();
2925 return object; 2925 return object;
2926 } 2926 }
2927 2927
2928 2928
2929 // ----------------------------------------------------------------------------- 2929 // -----------------------------------------------------------------------------
2930 // LargeObjectSpace 2930 // LargeObjectSpace
2931 2931
2932
2933 LargeObjectSpace::LargeObjectSpace(Heap* heap, AllocationSpace id) 2932 LargeObjectSpace::LargeObjectSpace(Heap* heap, AllocationSpace id)
2934 : Space(heap, id, NOT_EXECUTABLE), // Managed on a per-allocation basis 2933 : Space(heap, id, NOT_EXECUTABLE), // Managed on a per-allocation basis
2935 first_page_(NULL), 2934 first_page_(NULL),
2936 size_(0), 2935 size_(0),
2937 page_count_(0), 2936 page_count_(0),
2938 objects_size_(0), 2937 objects_size_(0),
2939 chunk_map_(HashMap::PointersMatch, 1024) {} 2938 chunk_map_(base::HashMap::PointersMatch, 1024) {}
2940
2941 2939
2942 LargeObjectSpace::~LargeObjectSpace() {} 2940 LargeObjectSpace::~LargeObjectSpace() {}
2943 2941
2944 2942
2945 bool LargeObjectSpace::SetUp() { 2943 bool LargeObjectSpace::SetUp() {
2946 first_page_ = NULL; 2944 first_page_ = NULL;
2947 size_ = 0; 2945 size_ = 0;
2948 page_count_ = 0; 2946 page_count_ = 0;
2949 objects_size_ = 0; 2947 objects_size_ = 0;
2950 chunk_map_.Clear(); 2948 chunk_map_.Clear();
(...skipping 30 matching lines...) Expand all
2981 objects_size_ += object_size; 2979 objects_size_ += object_size;
2982 page_count_++; 2980 page_count_++;
2983 page->set_next_page(first_page_); 2981 page->set_next_page(first_page_);
2984 first_page_ = page; 2982 first_page_ = page;
2985 2983
2986 // Register all MemoryChunk::kAlignment-aligned chunks covered by 2984 // Register all MemoryChunk::kAlignment-aligned chunks covered by
2987 // this large page in the chunk map. 2985 // this large page in the chunk map.
2988 uintptr_t base = reinterpret_cast<uintptr_t>(page) / MemoryChunk::kAlignment; 2986 uintptr_t base = reinterpret_cast<uintptr_t>(page) / MemoryChunk::kAlignment;
2989 uintptr_t limit = base + (page->size() - 1) / MemoryChunk::kAlignment; 2987 uintptr_t limit = base + (page->size() - 1) / MemoryChunk::kAlignment;
2990 for (uintptr_t key = base; key <= limit; key++) { 2988 for (uintptr_t key = base; key <= limit; key++) {
2991 HashMap::Entry* entry = chunk_map_.LookupOrInsert( 2989 base::HashMap::Entry* entry = chunk_map_.LookupOrInsert(
2992 reinterpret_cast<void*>(key), static_cast<uint32_t>(key)); 2990 reinterpret_cast<void*>(key), static_cast<uint32_t>(key));
2993 DCHECK(entry != NULL); 2991 DCHECK(entry != NULL);
2994 entry->value = page; 2992 entry->value = page;
2995 } 2993 }
2996 2994
2997 HeapObject* object = page->GetObject(); 2995 HeapObject* object = page->GetObject();
2998 MSAN_ALLOCATED_UNINITIALIZED_MEMORY(object->address(), object_size); 2996 MSAN_ALLOCATED_UNINITIALIZED_MEMORY(object->address(), object_size);
2999 2997
3000 if (Heap::ShouldZapGarbage()) { 2998 if (Heap::ShouldZapGarbage()) {
3001 // Make the object consistent so the heap can be verified in OldSpaceStep. 2999 // Make the object consistent so the heap can be verified in OldSpaceStep.
(...skipping 22 matching lines...) Expand all
3024 LargePage* page = FindPage(a); 3022 LargePage* page = FindPage(a);
3025 if (page != NULL) { 3023 if (page != NULL) {
3026 return page->GetObject(); 3024 return page->GetObject();
3027 } 3025 }
3028 return Smi::FromInt(0); // Signaling not found. 3026 return Smi::FromInt(0); // Signaling not found.
3029 } 3027 }
3030 3028
3031 3029
3032 LargePage* LargeObjectSpace::FindPage(Address a) { 3030 LargePage* LargeObjectSpace::FindPage(Address a) {
3033 uintptr_t key = reinterpret_cast<uintptr_t>(a) / MemoryChunk::kAlignment; 3031 uintptr_t key = reinterpret_cast<uintptr_t>(a) / MemoryChunk::kAlignment;
3034 HashMap::Entry* e = chunk_map_.Lookup(reinterpret_cast<void*>(key), 3032 base::HashMap::Entry* e = chunk_map_.Lookup(reinterpret_cast<void*>(key),
3035 static_cast<uint32_t>(key)); 3033 static_cast<uint32_t>(key));
3036 if (e != NULL) { 3034 if (e != NULL) {
3037 DCHECK(e->value != NULL); 3035 DCHECK(e->value != NULL);
3038 LargePage* page = reinterpret_cast<LargePage*>(e->value); 3036 LargePage* page = reinterpret_cast<LargePage*>(e->value);
3039 DCHECK(LargePage::IsValid(page)); 3037 DCHECK(LargePage::IsValid(page));
3040 if (page->Contains(a)) { 3038 if (page->Contains(a)) {
3041 return page; 3039 return page;
3042 } 3040 }
3043 } 3041 }
3044 return NULL; 3042 return NULL;
3045 } 3043 }
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
3222 object->ShortPrint(); 3220 object->ShortPrint();
3223 PrintF("\n"); 3221 PrintF("\n");
3224 } 3222 }
3225 printf(" --------------------------------------\n"); 3223 printf(" --------------------------------------\n");
3226 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); 3224 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes());
3227 } 3225 }
3228 3226
3229 #endif // DEBUG 3227 #endif // DEBUG
3230 } // namespace internal 3228 } // namespace internal
3231 } // namespace v8 3229 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/spaces.h ('k') | src/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698