[heap] Do not evict invalidated free list category.

Bug: chromium:792520
Change-Id: Ibc030a08898434c1b5c7a2e8dd14730bfebc7309
Reviewed-on: https://chromium-review.googlesource.com/811504
Reviewed-by: Ali Ijaz Sheikh <ofrobots@google.com>
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49910}
This commit is contained in:
Ulan Degenbaev 2017-12-06 19:05:16 +01:00 committed by Commit Bot
parent 40d5a8c7e1
commit 75c1c6c682

View File

@ -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) {
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) {
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.