From 56a9e33802c08563495ce0ef5aa47025fe8f594a Mon Sep 17 00:00:00 2001 From: hpayer Date: Tue, 7 Jun 2016 23:11:38 -0700 Subject: [PATCH] Revert of [heap] Unregister shrinked large object memory from chunk map. (patchset #6 id:100001 of https://codereview.chromium.org/2046953002/ ) Reason for revert: Revert because uncommit of lo is broken. Original issue's description: > [heap] Unregister shrinked large object memory from chunk map. > > BUG=chromium:617883 > LOG=n > > Committed: https://crrev.com/2b38d3121b5fd0e409cdda0071fa2e0ec2846ab2 > Cr-Commit-Position: refs/heads/master@{#36793} TBR=ulan@chromium.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=chromium:617883 Review-Url: https://codereview.chromium.org/2046563008 Cr-Commit-Position: refs/heads/master@{#36806} --- src/hashmap.h | 14 ------------- src/heap/spaces.cc | 52 +++++++++++++++++++--------------------------- src/heap/spaces.h | 4 ---- 3 files changed, 21 insertions(+), 49 deletions(-) diff --git a/src/hashmap.h b/src/hashmap.h index 41e189d67ac..f94def7c3c7 100644 --- a/src/hashmap.h +++ b/src/hashmap.h @@ -51,9 +51,6 @@ class TemplateHashMapImpl { Entry* LookupOrInsert(void* key, uint32_t hash, AllocationPolicy allocator = AllocationPolicy()); - Entry* InsertNew(void* key, uint32_t hash, - AllocationPolicy allocator = AllocationPolicy()); - // Removes the entry with matching key. // It returns the value of the deleted entry // or null if there is no value for such key. @@ -132,17 +129,6 @@ TemplateHashMapImpl::LookupOrInsert( return p; } - return InsertNew(key, hash, allocator); -} - -template -typename TemplateHashMapImpl::Entry* -TemplateHashMapImpl::InsertNew(void* key, uint32_t hash, - AllocationPolicy allocator) { - // Find a matching entry. - Entry* p = Probe(key, hash); - DCHECK(p->key == NULL); - // No entry found; insert one. p->key = key; p->value = NULL; diff --git a/src/heap/spaces.cc b/src/heap/spaces.cc index 7c2789ec196..d0244a85515 100644 --- a/src/heap/spaces.cc +++ b/src/heap/spaces.cc @@ -3021,7 +3021,16 @@ AllocationResult LargeObjectSpace::AllocateRaw(int object_size, page->set_next_page(first_page_); first_page_ = page; - InsertChunkMapEntries(page); + // Register all MemoryChunk::kAlignment-aligned chunks covered by + // this large page in the chunk map. + uintptr_t base = reinterpret_cast(page) / MemoryChunk::kAlignment; + uintptr_t limit = base + (page->size() - 1) / MemoryChunk::kAlignment; + for (uintptr_t key = base; key <= limit; key++) { + HashMap::Entry* entry = chunk_map_.LookupOrInsert( + reinterpret_cast(key), static_cast(key)); + DCHECK(entry != NULL); + entry->value = page; + } HeapObject* object = page->GetObject(); MSAN_ALLOCATED_UNINITIALIZED_MEMORY(object->address(), object_size); @@ -3087,34 +3096,6 @@ void LargeObjectSpace::ClearMarkingStateOfLiveObjects() { } } -void LargeObjectSpace::InsertChunkMapEntries(LargePage* page) { - // Register all MemoryChunk::kAlignment-aligned chunks covered by - // this large page in the chunk map. - uintptr_t start = reinterpret_cast(page) / MemoryChunk::kAlignment; - uintptr_t limit = start + (page->size() - 1) / MemoryChunk::kAlignment; - for (uintptr_t key = start; key <= limit; key++) { - HashMap::Entry* entry = chunk_map_.InsertNew(reinterpret_cast(key), - static_cast(key)); - DCHECK(entry != NULL); - entry->value = page; - } -} - -void LargeObjectSpace::RemoveChunkMapEntries(LargePage* page) { - RemoveChunkMapEntries(page, page->address()); -} - -void LargeObjectSpace::RemoveChunkMapEntries(LargePage* page, - Address free_start) { - uintptr_t start = RoundUp(reinterpret_cast(free_start), - MemoryChunk::kAlignment) / - MemoryChunk::kAlignment; - uintptr_t limit = start + (page->size() - 1) / MemoryChunk::kAlignment; - for (uintptr_t key = start; key <= limit; key++) { - chunk_map_.Remove(reinterpret_cast(key), static_cast(key)); - } -} - void LargeObjectSpace::FreeUnmarkedObjects() { LargePage* previous = NULL; LargePage* current = first_page_; @@ -3127,7 +3108,6 @@ void LargeObjectSpace::FreeUnmarkedObjects() { if ((free_start = current->GetAddressToShrink()) != 0) { // TODO(hpayer): Perform partial free concurrently. heap()->memory_allocator()->PartialFreeMemory(current, free_start); - RemoveChunkMapEntries(current, free_start); } previous = current; current = current->next_page(); @@ -3147,7 +3127,17 @@ void LargeObjectSpace::FreeUnmarkedObjects() { objects_size_ -= object->Size(); page_count_--; - RemoveChunkMapEntries(page); + // Remove entries belonging to this page. + // Use variable alignment to help pass length check (<= 80 characters) + // of single line in tools/presubmit.py. + const intptr_t alignment = MemoryChunk::kAlignment; + uintptr_t base = reinterpret_cast(page) / alignment; + uintptr_t limit = base + (page->size() - 1) / alignment; + for (uintptr_t key = base; key <= limit; key++) { + chunk_map_.Remove(reinterpret_cast(key), + static_cast(key)); + } + heap()->memory_allocator()->Free(page); } } diff --git a/src/heap/spaces.h b/src/heap/spaces.h index 4b2c00861f3..30ffe11f888 100644 --- a/src/heap/spaces.h +++ b/src/heap/spaces.h @@ -3058,10 +3058,6 @@ class LargeObjectSpace : public Space { // Frees unmarked objects. void FreeUnmarkedObjects(); - void InsertChunkMapEntries(LargePage* page); - void RemoveChunkMapEntries(LargePage* page); - void RemoveChunkMapEntries(LargePage* page, Address free_start); - // Checks whether a heap object is in this space; O(1). bool Contains(HeapObject* obj); // Checks whether an address is in the object area in this space. Iterates