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

Unified Diff: src/heap/spaces.h

Issue 1125193005: Make new space allocation throughput estimation more accurate. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 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
« src/heap/heap.h ('K') | « src/heap/heap.cc ('k') | src/heap/spaces.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/spaces.h
diff --git a/src/heap/spaces.h b/src/heap/spaces.h
index 494d05c9c792e144fcce1849533fca4a27138826..20aed774d1515fc35cd78004875472b2870df0e2 100644
--- a/src/heap/spaces.h
+++ b/src/heap/spaces.h
@@ -2435,6 +2435,25 @@ class NewSpace : public Space {
// Return the available bytes without growing.
intptr_t Available() override { return Capacity() - Size(); }
+ intptr_t PagesFromStart(Address addr) {
+ return static_cast<int>(addr - bottom()) / Page::kPageSize;
Hannes Payer (out of office) 2015/05/12 17:04:17 cast to intptr_t
ulan 2015/05/18 12:45:51 Done.
+ }
+
+ size_t AllocatedSinceLastGC() {
+ intptr_t allocated = top() - to_space_.age_mark();
+ if (allocated < 0) {
+ // Runtime has lowered the top below the age mark.
+ return 0;
+ }
+ // Correctly account for non-allocatable regions at the beginning of
+ // each page from the age_mark() to the top().
+ intptr_t pages =
+ PagesFromStart(top()) - PagesFromStart(to_space_.age_mark());
+ allocated -= pages * (NewSpacePage::kObjectStartOffset);
+ DCHECK(0 <= allocated && allocated <= Size());
+ return static_cast<size_t>(allocated);
+ }
+
// Return the maximum capacity of a semispace.
int MaximumCapacity() {
DCHECK(to_space_.MaximumTotalCapacity() ==
« src/heap/heap.h ('K') | « src/heap/heap.cc ('k') | src/heap/spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698