Commit 75c1c6c6 authored by Ulan Degenbaev's avatar Ulan Degenbaev Committed by Commit Bot

[heap] Do not evict invalidated free list category.

Bug: chromium:792520
Change-Id: Ibc030a08898434c1b5c7a2e8dd14730bfebc7309
Reviewed-on: https://chromium-review.googlesource.com/811504Reviewed-by: 's avatarAli Ijaz Sheikh <ofrobots@google.com>
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49910}
parent 40d5a8c7
...@@ -3039,13 +3039,16 @@ bool FreeList::Allocate(size_t size_in_bytes) { ...@@ -3039,13 +3039,16 @@ bool FreeList::Allocate(size_t size_in_bytes) {
size_t FreeList::EvictFreeListItems(Page* page) { size_t FreeList::EvictFreeListItems(Page* page) {
size_t sum = 0; size_t sum = 0;
page->ForAllFreeListCategories( page->ForAllFreeListCategories([this, &sum](FreeListCategory* category) {
[this, &sum](FreeListCategory* category) { // The category might have been already evicted
DCHECK_EQ(this, category->owner()); // if the page is an evacuation candidate.
sum += category->available(); if (category->type_ != kInvalidCategory) {
RemoveCategory(category); DCHECK_EQ(this, category->owner());
category->Invalidate(); sum += category->available();
}); RemoveCategory(category);
category->Invalidate();
}
});
return sum; return sum;
} }
...@@ -3067,6 +3070,7 @@ void FreeList::RepairLists(Heap* heap) { ...@@ -3067,6 +3070,7 @@ void FreeList::RepairLists(Heap* heap) {
bool FreeList::AddCategory(FreeListCategory* category) { bool FreeList::AddCategory(FreeListCategory* category) {
FreeListCategoryType type = category->type_; FreeListCategoryType type = category->type_;
DCHECK_LT(type, kNumberOfCategories);
FreeListCategory* top = categories_[type]; FreeListCategory* top = categories_[type];
if (category->is_empty()) return false; if (category->is_empty()) return false;
...@@ -3083,6 +3087,7 @@ bool FreeList::AddCategory(FreeListCategory* category) { ...@@ -3083,6 +3087,7 @@ bool FreeList::AddCategory(FreeListCategory* category) {
void FreeList::RemoveCategory(FreeListCategory* category) { void FreeList::RemoveCategory(FreeListCategory* category) {
FreeListCategoryType type = category->type_; FreeListCategoryType type = category->type_;
DCHECK_LT(type, kNumberOfCategories);
FreeListCategory* top = categories_[type]; FreeListCategory* top = categories_[type];
// Common double-linked list removal. // Common double-linked list removal.
......
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