 Chromium Code Reviews
 Chromium Code Reviews Issue 1125193005:
  Make new space allocation throughput estimation more accurate.  (Closed) 
  Base URL: https://chromium.googlesource.com/v8/v8.git@master
    
  
    Issue 1125193005:
  Make new space allocation throughput estimation more accurate.  (Closed) 
  Base URL: https://chromium.googlesource.com/v8/v8.git@master| 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() == |