Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Revert of [heap] Unregister shrinked large object memory from chunk m…
Browse files Browse the repository at this point in the history
…ap. (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}
  • Loading branch information
hannespayer authored and Commit bot committed Jun 8, 2016
1 parent f576e29 commit 56a9e33
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 49 deletions.
14 changes: 0 additions & 14 deletions src/hashmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -132,17 +129,6 @@ TemplateHashMapImpl<AllocationPolicy>::LookupOrInsert(
return p;
}

return InsertNew(key, hash, allocator);
}

template <class AllocationPolicy>
typename TemplateHashMapImpl<AllocationPolicy>::Entry*
TemplateHashMapImpl<AllocationPolicy>::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;
Expand Down
52 changes: 21 additions & 31 deletions src/heap/spaces.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<uintptr_t>(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<void*>(key), static_cast<uint32_t>(key));
DCHECK(entry != NULL);
entry->value = page;
}

HeapObject* object = page->GetObject();
MSAN_ALLOCATED_UNINITIALIZED_MEMORY(object->address(), object_size);
Expand Down Expand Up @@ -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<uintptr_t>(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<void*>(key),
static_cast<uint32_t>(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<uintptr_t>(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<void*>(key), static_cast<uint32_t>(key));
}
}

void LargeObjectSpace::FreeUnmarkedObjects() {
LargePage* previous = NULL;
LargePage* current = first_page_;
Expand All @@ -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();
Expand All @@ -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<uintptr_t>(page) / alignment;
uintptr_t limit = base + (page->size() - 1) / alignment;
for (uintptr_t key = base; key <= limit; key++) {
chunk_map_.Remove(reinterpret_cast<void*>(key),
static_cast<uint32_t>(key));
}

heap()->memory_allocator()->Free<MemoryAllocator::kPreFreeAndQueue>(page);
}
}
Expand Down
4 changes: 0 additions & 4 deletions src/heap/spaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 56a9e33

Please sign in to comment.