Chromium Code Reviews| Index: src/heap/spaces-inl.h |
| diff --git a/src/heap/spaces-inl.h b/src/heap/spaces-inl.h |
| index 0fd69dacfebd7b93b269bd9b093b53e39bca4866..5d444e5751bbafac88b7c5363af8f90ae199eac3 100644 |
| --- a/src/heap/spaces-inl.h |
| +++ b/src/heap/spaces-inl.h |
| @@ -165,6 +165,22 @@ bool NewSpace::FromSpaceContainsSlow(Address a) { |
| bool NewSpace::ToSpaceContains(Object* o) { return to_space_.Contains(o); } |
| bool NewSpace::FromSpaceContains(Object* o) { return from_space_.Contains(o); } |
| +size_t NewSpace::AllocatedSinceLastGC() { |
| + Page* top_page = Page::FromAllocationAreaAddress(top()); |
| + size_t allocated = 0; |
| + // If top gets reset to be in the range of pages that are below the age |
| + // mark, this loop will not trigger and we return 0 (invalid). |
| + for (Page* current_page = top_page; |
| + !current_page->InIntermediateGeneration() && |
| + current_page != to_space_.anchor(); |
| + current_page = current_page->prev_page()) { |
| + allocated += (top_page == current_page) |
| + ? static_cast<size_t>(top() - current_page->area_start()) |
| + : Page::kAllocatableMemory; |
|
Hannes Payer (out of office)
2016/09/27 08:28:31
This method is not precise. Fragmentation at the e
Michael Lippautz
2016/09/27 11:13:47
Ack. Let's try changing this in a different CL as
|
| + } |
| + return allocated; |
| +} |
| + |
| // -------------------------------------------------------------------------- |
| // AllocationResult |