Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(952)

Unified Diff: src/heap/spaces-inl.h

Issue 1883933003: [heap] Optimize NewSpace::AllocatedSinceLastGC (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix offset computation Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap/spaces.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/spaces-inl.h
diff --git a/src/heap/spaces-inl.h b/src/heap/spaces-inl.h
index 1593ed87aee97a25a9ab7c0c71dab69053d6d052..db01d0eed99e81690f0e15516b56096fd64de20f 100644
--- a/src/heap/spaces-inl.h
+++ b/src/heap/spaces-inl.h
@@ -243,6 +243,25 @@ 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() {
+ const intptr_t age_mark_offset =
+ NewSpacePage::OffsetInPage(to_space_.age_mark());
+ const intptr_t top_offset =
+ NewSpacePage::OffsetInPage(allocation_info_.top());
+ const intptr_t age_mark_delta =
+ age_mark_offset >= NewSpacePage::kObjectStartOffset
+ ? age_mark_offset - NewSpacePage::kObjectStartOffset
+ : NewSpacePage::kAllocatableMemory;
+ const intptr_t top_delta = top_offset >= NewSpacePage::kObjectStartOffset
+ ? top_offset - NewSpacePage::kObjectStartOffset
+ : NewSpacePage::kAllocatableMemory;
+ DCHECK((allocated_since_last_gc_ > 0) ||
+ (NewSpacePage::FromLimit(allocation_info_.top()) ==
+ NewSpacePage::FromLimit(to_space_.age_mark())));
+ return static_cast<size_t>(allocated_since_last_gc_ + top_delta -
+ age_mark_delta);
+}
+
// --------------------------------------------------------------------------
// AllocationResult
« no previous file with comments | « src/heap/spaces.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698