Commit 70a31eeb authored by mlippautz's avatar mlippautz Committed by Commit bot

[heap] Refactor AllocatedSinceLastGC

Remove the cases that deal with a top pointer that is reset. We should always
be in a sane state wrt. top and age mark. Also add more DCHECKs.

BUG=chromium:672678

Review-Url: https://codereview.chromium.org/2674493002
Cr-Commit-Position: refs/heads/master@{#42873}
parent 591cc0b4
...@@ -2440,34 +2440,24 @@ class NewSpace : public Space { ...@@ -2440,34 +2440,24 @@ class NewSpace : public Space {
} }
size_t AllocatedSinceLastGC() { size_t AllocatedSinceLastGC() {
bool seen_age_mark = false; const Address age_mark = to_space_.age_mark();
Address age_mark = to_space_.age_mark(); DCHECK_NOT_NULL(age_mark);
Page* current_page = to_space_.first_page(); DCHECK_NOT_NULL(top());
Page* age_mark_page = Page::FromAddress(age_mark); Page* const age_mark_page = Page::FromAllocationAreaAddress(age_mark);
Page* last_page = Page::FromAddress(top() - kPointerSize); Page* const last_page = Page::FromAllocationAreaAddress(top());
if (age_mark_page == last_page) { Page* current_page = age_mark_page;
if (top() - age_mark >= 0) { size_t allocated = 0;
return top() - age_mark; if (current_page != last_page) {
} DCHECK_EQ(current_page, age_mark_page);
// Top was reset at some point, invalidating this metric. DCHECK_GE(age_mark_page->area_end(), age_mark);
return 0; allocated += age_mark_page->area_end() - age_mark;
}
while (current_page != last_page) {
if (current_page == age_mark_page) {
seen_age_mark = true;
break;
}
current_page = current_page->next_page(); current_page = current_page->next_page();
} else {
DCHECK_GE(top(), age_mark);
return top() - age_mark;
} }
if (!seen_age_mark) {
// Top was reset at some point, invalidating this metric.
return 0;
}
DCHECK_GE(age_mark_page->area_end(), age_mark);
size_t allocated = age_mark_page->area_end() - age_mark;
DCHECK_EQ(current_page, age_mark_page);
current_page = age_mark_page->next_page();
while (current_page != last_page) { while (current_page != last_page) {
DCHECK_NE(current_page, age_mark_page);
allocated += Page::kAllocatableMemory; allocated += Page::kAllocatableMemory;
current_page = current_page->next_page(); current_page = current_page->next_page();
} }
......
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