[heap] Fix Unmapper::TearDown to include delayed chunks

Delayed chunks in the unmapper are chunks that should be unmapped but could
potentially still be accessed by the sweeper (page header), hence their
unmapping is delayed.

During TearDown, however, we need to properly unmap those pages, i.e., check
that they can now be unmapped (should always hold) and properly unmap them.

BUG=chromium:656537
R=ulan@chromium.org

Review-Url: https://codereview.chromium.org/2472573003
Cr-Commit-Position: refs/heads/master@{#40698}
This commit is contained in:
mlippautz 2016-11-02 06:10:20 -07:00 committed by Commit bot
parent ea5d4c1525
commit 588641f242
2 changed files with 9 additions and 7 deletions

View File

@ -311,13 +311,7 @@ bool MemoryAllocator::SetUp(intptr_t capacity, intptr_t capacity_executable,
void MemoryAllocator::TearDown() {
unmapper()->WaitUntilCompleted();
MemoryChunk* chunk = nullptr;
while ((chunk = unmapper()->TryGetPooledMemoryChunkSafe()) != nullptr) {
FreeMemory(reinterpret_cast<Address>(chunk), MemoryChunk::kPageSize,
NOT_EXECUTABLE);
}
unmapper()->TearDown();
// Check that spaces were torn down before MemoryAllocator.
DCHECK_EQ(size_.Value(), 0);
@ -384,6 +378,13 @@ void MemoryAllocator::Unmapper::PerformFreeMemoryOnQueuedChunks() {
}
}
void MemoryAllocator::Unmapper::TearDown() {
WaitUntilCompleted();
ReconsiderDelayedChunks();
CHECK(delayed_regular_chunks_.empty());
PerformFreeMemoryOnQueuedChunks();
}
void MemoryAllocator::Unmapper::ReconsiderDelayedChunks() {
std::list<MemoryChunk*> delayed_chunks(std::move(delayed_regular_chunks_));
// Move constructed, so the permanent list should be empty.

View File

@ -1133,6 +1133,7 @@ class MemoryAllocator {
void FreeQueuedChunks();
bool WaitUntilCompleted();
void TearDown();
private:
enum ChunkQueueType {