Index: src/spaces.h |
diff --git a/src/spaces.h b/src/spaces.h |
index 2062f5fea5788131ca68585271c27424395ec71c..001bedb93d1cdf8018f9a4f3416e9922f8c22e87 100644 |
--- a/src/spaces.h |
+++ b/src/spaces.h |
@@ -489,7 +489,7 @@ class MemoryChunk { |
static const size_t kSlotsBufferOffset = kLiveBytesOffset + kIntSize; |
static const size_t kHeaderSize = |
- kSlotsBufferOffset + kPointerSize + kPointerSize; |
+ kSlotsBufferOffset + kPointerSize + kPointerSize + kPointerSize; |
static const int kBodyOffset = |
CODE_POINTER_ALIGN(MAP_POINTER_ALIGN(kHeaderSize + Bitmap::kSize)); |
@@ -601,6 +601,13 @@ class MemoryChunk { |
return static_cast<int>(area_end() - area_start()); |
} |
+ // Approximate amount of physical memory committed for this chunk. |
+ size_t CommittedPhysicalMemory() { |
+ return high_water_mark_; |
+ } |
+ |
+ static inline void UpdateHighWaterMark(Address mark); |
+ |
protected: |
MemoryChunk* next_chunk_; |
MemoryChunk* prev_chunk_; |
@@ -625,6 +632,9 @@ class MemoryChunk { |
int live_byte_count_; |
SlotsBuffer* slots_buffer_; |
SkipList* skip_list_; |
+ // Assuming the initial allocation on a page is sequential, |
+ // count highest number of bytes ever allocated on the page. |
+ int high_water_mark_; |
static MemoryChunk* Initialize(Heap* heap, |
Address base, |
@@ -1474,6 +1484,9 @@ class PagedSpace : public Space { |
// spaces this equals the capacity. |
intptr_t CommittedMemory() { return Capacity(); } |
+ // Approximate amount of physical memory committed for this space. |
+ size_t CommittedPhysicalMemory(); |
+ |
// Sets the capacity, the available space and the wasted space to zero. |
// The stats are rebuilt during sweeping by adding each page to the |
// capacity and the size when it is encountered. As free spaces are |
@@ -1534,6 +1547,7 @@ class PagedSpace : public Space { |
void SetTop(Address top, Address limit) { |
ASSERT(top == limit || |
Page::FromAddress(top) == Page::FromAddress(limit - 1)); |
+ MemoryChunk::UpdateHighWaterMark(allocation_info_.top); |
allocation_info_.top = top; |
allocation_info_.limit = limit; |
} |
@@ -1940,6 +1954,9 @@ class SemiSpace : public Space { |
static void Swap(SemiSpace* from, SemiSpace* to); |
+ // Approximate amount of physical memory committed for this space. |
+ size_t CommittedPhysicalMemory(); |
+ |
private: |
// Flips the semispace between being from-space and to-space. |
// Copies the flags into the masked positions on all pages in the space. |
@@ -2137,6 +2154,9 @@ class NewSpace : public Space { |
return Capacity(); |
} |
+ // Approximate amount of physical memory committed for this space. |
+ size_t CommittedPhysicalMemory(); |
+ |
// Return the available bytes without growing. |
intptr_t Available() { |
return Capacity() - Size(); |
@@ -2504,6 +2524,9 @@ class LargeObjectSpace : public Space { |
return Size(); |
} |
+ // Approximate amount of physical memory committed for this space. |
+ size_t CommittedPhysicalMemory(); |
+ |
int PageCount() { |
return page_count_; |
} |