Commit 73cf88d6 authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

[heap] Fix accounting for partially freed pages in LO space

Bug: chromium:728096
Change-Id: I8f95f15b56cd49f3e199b74b119abb49eadfe2e1
Reviewed-on: https://chromium-review.googlesource.com/519163
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarHannes Payer <hpayer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45624}
parent ad3724eb
......@@ -867,8 +867,8 @@ void Page::DestroyBlackArea(Address start, Address end) {
-static_cast<int>(end - start));
}
void MemoryAllocator::PartialFreeMemory(MemoryChunk* chunk,
Address start_free) {
size_t MemoryAllocator::PartialFreeMemory(MemoryChunk* chunk,
Address start_free) {
// We do not allow partial shrink for code.
DCHECK(chunk->executable() == NOT_EXECUTABLE);
......@@ -886,6 +886,7 @@ void MemoryAllocator::PartialFreeMemory(MemoryChunk* chunk,
chunk->set_size(size - to_free_size);
reservation->ReleasePartial(start_free);
return to_free_size;
}
void MemoryAllocator::PreFreeMemory(MemoryChunk* chunk) {
......@@ -3246,18 +3247,20 @@ void LargeObjectSpace::RemoveChunkMapEntries(LargePage* page,
}
void LargeObjectSpace::FreeUnmarkedObjects() {
LargePage* previous = NULL;
LargePage* previous = nullptr;
LargePage* current = first_page_;
while (current != NULL) {
while (current != nullptr) {
HeapObject* object = current->GetObject();
DCHECK(!ObjectMarking::IsGrey(object, MarkingState::Internal(object)));
if (ObjectMarking::IsBlack(object, MarkingState::Internal(object))) {
Address free_start;
if ((free_start = current->GetAddressToShrink()) != 0) {
// TODO(hpayer): Perform partial free concurrently.
current->ClearOutOfLiveRangeSlots(free_start);
RemoveChunkMapEntries(current, free_start);
heap()->memory_allocator()->PartialFreeMemory(current, free_start);
const size_t freed =
heap()->memory_allocator()->PartialFreeMemory(current, free_start);
size_ -= freed;
AccountUncommitted(freed);
}
previous = current;
current = current->next_page();
......@@ -3265,7 +3268,7 @@ void LargeObjectSpace::FreeUnmarkedObjects() {
LargePage* page = current;
// Cut the chunk out from the chunk list.
current = current->next_page();
if (previous == NULL) {
if (previous == nullptr) {
first_page_ = current;
} else {
previous->set_next_page(current);
......
......@@ -1346,9 +1346,11 @@ class V8_EXPORT_PRIVATE MemoryAllocator {
bool CommitMemory(Address addr, size_t size, Executability executable);
void FreeMemory(base::VirtualMemory* reservation, Executability executable);
void PartialFreeMemory(MemoryChunk* chunk, Address start_free);
void FreeMemory(Address addr, size_t size, Executability executable);
// Returns the size of the freed memory in bytes.
size_t PartialFreeMemory(MemoryChunk* chunk, Address start_free);
// Commit a contiguous block of memory from the initial chunk. Assumes that
// the address is not NULL, the size is greater than zero, and that the
// block is contained in the initial chunk. Returns true if it succeeded
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment