Commit afd9493a authored by Dan Elphick's avatar Dan Elphick Committed by Commit Bot

[heap] Remove FreeList when sealing RO_SPACE

This releases the FreeListCategories for each MemoryChunk when sealing
the ReadOnlySpace and deletes the FreeList.

Additionally this also calls
ReleaseAllocatedMemoryNeededForWritableChunk for each MemoryChunk when
sealing when pointer compression is enabled even if no memory is to be
shared.

Bug: v8:10454
Change-Id: I45aec59f6d4fddedeb713e13095f58974cda279e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2184292Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Dan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67598}
parent b0209337
......@@ -354,6 +354,10 @@ class MemoryChunk : public BasicMemoryChunk {
return &possibly_empty_buckets_;
}
// Release memory allocated by the chunk, except that which is needed by
// read-only space chunks.
void ReleaseAllocatedMemoryNeededForWritableChunk();
protected:
static MemoryChunk* Initialize(Heap* heap, Address base, size_t size,
Address area_start, Address area_end,
......@@ -363,9 +367,6 @@ class MemoryChunk : public BasicMemoryChunk {
// Release all memory allocated by the chunk. Should be called when memory
// chunk is about to be freed.
void ReleaseAllAllocatedMemory();
// Release memory allocated by the chunk, except that which is needed by
// read-only space chunks.
void ReleaseAllocatedMemoryNeededForWritableChunk();
// Sets the requested page permissions only if the write unprotect counter
// has reached 0.
......
......@@ -153,8 +153,14 @@ void ReadOnlySpace::Seal(SealMode ro_mode) {
memory_allocator->UnregisterMemory(p);
static_cast<ReadOnlyPage*>(p)->MakeHeaderRelocatable();
}
} else {
for (Page* p : *this) {
p->ReleaseAllocatedMemoryNeededForWritableChunk();
}
}
free_list_.reset();
SetPermissionsForPages(memory_allocator, PageAllocator::kRead);
}
......
......@@ -1248,14 +1248,14 @@ void MemoryChunk::ReleaseAllocatedMemoryNeededForWritableChunk() {
if (local_tracker_ != nullptr) ReleaseLocalTracker();
if (young_generation_bitmap_ != nullptr) ReleaseYoungGenerationBitmap();
}
void MemoryChunk::ReleaseAllAllocatedMemory() {
if (!IsLargePage()) {
Page* page = static_cast<Page*>(this);
page->ReleaseFreeListCategories();
}
}
void MemoryChunk::ReleaseAllAllocatedMemory() {
ReleaseAllocatedMemoryNeededForWritableChunk();
if (marking_bitmap_ != nullptr) ReleaseMarkingBitmap();
}
......
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