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

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

Issue 2510733002: [heap] Synchronize concurrent chunk map modifications. (Closed)
Patch Set: Created 4 years, 1 month 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/heap/spaces-inl.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 <utility> 7 #include <utility>
8 8
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/base/platform/platform.h" 10 #include "src/base/platform/platform.h"
(...skipping 3014 matching lines...) Expand 10 before | Expand all | Expand 10 after
3025 3025
3026 // GC support 3026 // GC support
3027 Object* LargeObjectSpace::FindObject(Address a) { 3027 Object* LargeObjectSpace::FindObject(Address a) {
3028 LargePage* page = FindPage(a); 3028 LargePage* page = FindPage(a);
3029 if (page != NULL) { 3029 if (page != NULL) {
3030 return page->GetObject(); 3030 return page->GetObject();
3031 } 3031 }
3032 return Smi::kZero; // Signaling not found. 3032 return Smi::kZero; // Signaling not found.
3033 } 3033 }
3034 3034
3035 LargePage* LargeObjectSpace::FindPageThreadSafe(Address a) {
3036 base::LockGuard<base::Mutex> guard(&chunk_map_mutex_);
3037 return FindPage(a);
3038 }
3035 3039
3036 LargePage* LargeObjectSpace::FindPage(Address a) { 3040 LargePage* LargeObjectSpace::FindPage(Address a) {
3037 uintptr_t key = reinterpret_cast<uintptr_t>(a) / MemoryChunk::kAlignment; 3041 uintptr_t key = reinterpret_cast<uintptr_t>(a) / MemoryChunk::kAlignment;
3038 base::HashMap::Entry* e = chunk_map_.Lookup(reinterpret_cast<void*>(key), 3042 base::HashMap::Entry* e = chunk_map_.Lookup(reinterpret_cast<void*>(key),
3039 static_cast<uint32_t>(key)); 3043 static_cast<uint32_t>(key));
3040 if (e != NULL) { 3044 if (e != NULL) {
3041 DCHECK(e->value != NULL); 3045 DCHECK(e->value != NULL);
3042 LargePage* page = reinterpret_cast<LargePage*>(e->value); 3046 LargePage* page = reinterpret_cast<LargePage*>(e->value);
3043 DCHECK(LargePage::IsValid(page)); 3047 DCHECK(LargePage::IsValid(page));
3044 if (page->Contains(a)) { 3048 if (page->Contains(a)) {
(...skipping 16 matching lines...) Expand all
3061 current = current->next_page(); 3065 current = current->next_page();
3062 } 3066 }
3063 } 3067 }
3064 3068
3065 void LargeObjectSpace::InsertChunkMapEntries(LargePage* page) { 3069 void LargeObjectSpace::InsertChunkMapEntries(LargePage* page) {
3066 // Register all MemoryChunk::kAlignment-aligned chunks covered by 3070 // Register all MemoryChunk::kAlignment-aligned chunks covered by
3067 // this large page in the chunk map. 3071 // this large page in the chunk map.
3068 uintptr_t start = reinterpret_cast<uintptr_t>(page) / MemoryChunk::kAlignment; 3072 uintptr_t start = reinterpret_cast<uintptr_t>(page) / MemoryChunk::kAlignment;
3069 uintptr_t limit = (reinterpret_cast<uintptr_t>(page) + (page->size() - 1)) / 3073 uintptr_t limit = (reinterpret_cast<uintptr_t>(page) + (page->size() - 1)) /
3070 MemoryChunk::kAlignment; 3074 MemoryChunk::kAlignment;
3075 // There may be concurrent access on the chunk map. We have to take the lock
3076 // here.
3077 base::LockGuard<base::Mutex> guard(&chunk_map_mutex_);
3071 for (uintptr_t key = start; key <= limit; key++) { 3078 for (uintptr_t key = start; key <= limit; key++) {
3072 base::HashMap::Entry* entry = chunk_map_.InsertNew( 3079 base::HashMap::Entry* entry = chunk_map_.InsertNew(
3073 reinterpret_cast<void*>(key), static_cast<uint32_t>(key)); 3080 reinterpret_cast<void*>(key), static_cast<uint32_t>(key));
3074 DCHECK(entry != NULL); 3081 DCHECK(entry != NULL);
3075 entry->value = page; 3082 entry->value = page;
3076 } 3083 }
3077 } 3084 }
3078 3085
3079 void LargeObjectSpace::RemoveChunkMapEntries(LargePage* page) { 3086 void LargeObjectSpace::RemoveChunkMapEntries(LargePage* page) {
3080 RemoveChunkMapEntries(page, page->address()); 3087 RemoveChunkMapEntries(page, page->address());
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
3240 object->ShortPrint(); 3247 object->ShortPrint();
3241 PrintF("\n"); 3248 PrintF("\n");
3242 } 3249 }
3243 printf(" --------------------------------------\n"); 3250 printf(" --------------------------------------\n");
3244 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); 3251 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes());
3245 } 3252 }
3246 3253
3247 #endif // DEBUG 3254 #endif // DEBUG
3248 } // namespace internal 3255 } // namespace internal
3249 } // namespace v8 3256 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/spaces.h ('k') | src/heap/spaces-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698