[heap] Synchronize concurrent chunk map modifications.
BUG=chromium:664793 Review-Url: https://codereview.chromium.org/2510733002 Cr-Commit-Position: refs/heads/master@{#41042}
This commit is contained in:
parent
1006bd7172
commit
124e77f02b
@ -288,7 +288,7 @@ MemoryChunk* MemoryChunk::FromAnyPointerAddress(Heap* heap, Address addr) {
|
||||
MemoryChunk* chunk = MemoryChunk::FromAddress(addr);
|
||||
uintptr_t offset = addr - chunk->address();
|
||||
if (offset < MemoryChunk::kHeaderSize || !chunk->HasPageHeader()) {
|
||||
chunk = heap->lo_space()->FindPage(addr);
|
||||
chunk = heap->lo_space()->FindPageThreadSafe(addr);
|
||||
}
|
||||
return chunk;
|
||||
}
|
||||
|
@ -3032,6 +3032,10 @@ Object* LargeObjectSpace::FindObject(Address a) {
|
||||
return Smi::kZero; // Signaling not found.
|
||||
}
|
||||
|
||||
LargePage* LargeObjectSpace::FindPageThreadSafe(Address a) {
|
||||
base::LockGuard<base::Mutex> guard(&chunk_map_mutex_);
|
||||
return FindPage(a);
|
||||
}
|
||||
|
||||
LargePage* LargeObjectSpace::FindPage(Address a) {
|
||||
uintptr_t key = reinterpret_cast<uintptr_t>(a) / MemoryChunk::kAlignment;
|
||||
@ -3068,6 +3072,9 @@ void LargeObjectSpace::InsertChunkMapEntries(LargePage* page) {
|
||||
uintptr_t start = reinterpret_cast<uintptr_t>(page) / MemoryChunk::kAlignment;
|
||||
uintptr_t limit = (reinterpret_cast<uintptr_t>(page) + (page->size() - 1)) /
|
||||
MemoryChunk::kAlignment;
|
||||
// There may be concurrent access on the chunk map. We have to take the lock
|
||||
// here.
|
||||
base::LockGuard<base::Mutex> guard(&chunk_map_mutex_);
|
||||
for (uintptr_t key = start; key <= limit; key++) {
|
||||
base::HashMap::Entry* entry = chunk_map_.InsertNew(
|
||||
reinterpret_cast<void*>(key), static_cast<uint32_t>(key));
|
||||
|
@ -2820,6 +2820,9 @@ class LargeObjectSpace : public Space {
|
||||
// The function iterates through all objects in this space, may be slow.
|
||||
Object* FindObject(Address a);
|
||||
|
||||
// Takes the chunk_map_mutex_ and calls FindPage after that.
|
||||
LargePage* FindPageThreadSafe(Address a);
|
||||
|
||||
// Finds a large object page containing the given address, returns NULL
|
||||
// if such a page doesn't exist.
|
||||
LargePage* FindPage(Address a);
|
||||
@ -2870,6 +2873,9 @@ class LargeObjectSpace : public Space {
|
||||
size_t size_; // allocated bytes
|
||||
int page_count_; // number of chunks
|
||||
size_t objects_size_; // size of objects
|
||||
// The chunk_map_mutex_ has to be used when the chunk map is accessed
|
||||
// concurrently.
|
||||
base::Mutex chunk_map_mutex_;
|
||||
// Map MemoryChunk::kAlignment-aligned chunks to large pages covering them
|
||||
base::HashMap chunk_map_;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user