| Index: src/heap/spaces.h
|
| diff --git a/src/heap/spaces.h b/src/heap/spaces.h
|
| index 6831a64565f643d31c08401df3e94afdfedde369..5647a520f585b72b0ba30baa243716b5a46f5f58 100644
|
| --- a/src/heap/spaces.h
|
| +++ b/src/heap/spaces.h
|
| @@ -908,7 +908,11 @@ class LargePage : public MemoryChunk {
|
| class Space : public Malloced {
|
| public:
|
| Space(Heap* heap, AllocationSpace id, Executability executable)
|
| - : heap_(heap), id_(id), executable_(executable) {}
|
| + : heap_(heap),
|
| + id_(id),
|
| + executable_(executable),
|
| + committed_(0),
|
| + max_committed_(0) {}
|
|
|
| virtual ~Space() {}
|
|
|
| @@ -920,6 +924,12 @@ class Space : public Malloced {
|
| // Identity used in error reporting.
|
| AllocationSpace identity() { return id_; }
|
|
|
| + // Return the total amount committed memory for this space, i.e., allocatable
|
| + // memory and page headers.
|
| + virtual intptr_t CommittedMemory() { return committed_; }
|
| +
|
| + virtual intptr_t MaximumCommittedMemory() { return max_committed_; }
|
| +
|
| // Returns allocated size.
|
| virtual intptr_t Size() = 0;
|
|
|
| @@ -927,9 +937,6 @@ class Space : public Malloced {
|
| // (e.g. see LargeObjectSpace).
|
| virtual intptr_t SizeOfObjects() { return Size(); }
|
|
|
| - // Return the total amount of memory committed for new space.
|
| - virtual intptr_t CommittedMemory() = 0;
|
| -
|
| // Approximate amount of physical memory committed for this space.
|
| virtual size_t CommittedPhysicalMemory() = 0;
|
|
|
| @@ -948,10 +955,29 @@ class Space : public Malloced {
|
| virtual void Print() = 0;
|
| #endif
|
|
|
| + protected:
|
| + void AccountCommitted(intptr_t bytes) {
|
| + DCHECK_GE(bytes, 0);
|
| + committed_ += bytes;
|
| + if (committed_ > max_committed_) {
|
| + max_committed_ = committed_;
|
| + }
|
| + }
|
| +
|
| + void AccountUncommitted(intptr_t bytes) {
|
| + DCHECK_GE(bytes, 0);
|
| + committed_ -= bytes;
|
| + DCHECK_GE(committed_, 0);
|
| + }
|
| +
|
| private:
|
| Heap* heap_;
|
| AllocationSpace id_;
|
| Executability executable_;
|
| +
|
| + // Keeps track of committed memory in a space.
|
| + intptr_t committed_;
|
| + intptr_t max_committed_;
|
| };
|
|
|
|
|
| @@ -1811,13 +1837,6 @@ class PagedSpace : public Space {
|
| // Current capacity without growing (Size() + Available()).
|
| intptr_t Capacity() { return accounting_stats_.Capacity(); }
|
|
|
| - // Total amount of memory committed for this space. For paged
|
| - // spaces this equals the capacity.
|
| - intptr_t CommittedMemory() override { return Capacity(); }
|
| -
|
| - // The maximum amount of memory ever committed for this space.
|
| - intptr_t MaximumCommittedMemory() { return accounting_stats_.MaxCapacity(); }
|
| -
|
| // Approximate amount of physical memory committed for this space.
|
| size_t CommittedPhysicalMemory() override;
|
|
|
| @@ -2285,11 +2304,6 @@ class SemiSpace : public Space {
|
|
|
| intptr_t SizeOfObjects() override { return Size(); }
|
|
|
| - intptr_t CommittedMemory() override {
|
| - UNREACHABLE();
|
| - return 0;
|
| - }
|
| -
|
| intptr_t Available() override {
|
| UNREACHABLE();
|
| return 0;
|
| @@ -2334,9 +2348,6 @@ class SemiSpace : public Space {
|
|
|
| static void Swap(SemiSpace* from, SemiSpace* to);
|
|
|
| - // Returns the maximum amount of memory ever committed by the semi space.
|
| - size_t MaximumCommittedMemory() { return maximum_committed_; }
|
| -
|
| // Approximate amount of physical memory committed for this space.
|
| size_t CommittedPhysicalMemory() override;
|
|
|
| @@ -2356,8 +2367,6 @@ class SemiSpace : public Space {
|
| int maximum_total_capacity_;
|
| int initial_total_capacity_;
|
|
|
| - intptr_t maximum_committed_;
|
| -
|
| // The start address of the space.
|
| Address start_;
|
| // Used to govern object promotion during mark-compact collection.
|
| @@ -2511,16 +2520,15 @@ class NewSpace : public Space {
|
| return to_space_.TotalCapacity();
|
| }
|
|
|
| - // Return the total amount of memory committed for new space.
|
| + // Committed memory for NewSpace is the committed memory of both semi-spaces
|
| + // combined.
|
| intptr_t CommittedMemory() override {
|
| - if (from_space_.is_committed()) return 2 * Capacity();
|
| - return TotalCapacity();
|
| + return from_space_.CommittedMemory() + to_space_.CommittedMemory();
|
| }
|
|
|
| - // Return the total amount of memory committed for new space.
|
| - intptr_t MaximumCommittedMemory() {
|
| - return to_space_.MaximumCommittedMemory() +
|
| - from_space_.MaximumCommittedMemory();
|
| + intptr_t MaximumCommittedMemory() override {
|
| + return from_space_.MaximumCommittedMemory() +
|
| + to_space_.MaximumCommittedMemory();
|
| }
|
|
|
| // Approximate amount of physical memory committed for this space.
|
| @@ -2888,10 +2896,6 @@ class LargeObjectSpace : public Space {
|
|
|
| intptr_t SizeOfObjects() override { return objects_size_; }
|
|
|
| - intptr_t MaximumCommittedMemory() { return maximum_committed_; }
|
| -
|
| - intptr_t CommittedMemory() override { return Size(); }
|
| -
|
| // Approximate amount of physical memory committed for this space.
|
| size_t CommittedPhysicalMemory() override;
|
|
|
| @@ -2934,7 +2938,6 @@ class LargeObjectSpace : public Space {
|
| bool SlowContains(Address addr) { return FindObject(addr)->IsHeapObject(); }
|
|
|
| private:
|
| - intptr_t maximum_committed_;
|
| // The head of the linked list of large object chunks.
|
| LargePage* first_page_;
|
| intptr_t size_; // allocated bytes
|
|
|