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; |
+ } |
+ return allocated; |
+} |
+ |
// -------------------------------------------------------------------------- |
// AllocationResult |