Commit 619afa4b authored by mlippautz's avatar mlippautz Committed by Commit bot

[heap] AcccountingStats:: int/intptr_t -> size_t

BUG=

Review-Url: https://codereview.chromium.org/2241503002
Cr-Commit-Position: refs/heads/master@{#38652}
parent b07444b1
...@@ -1309,8 +1309,8 @@ void PagedSpace::EmptyAllocationInfo() { ...@@ -1309,8 +1309,8 @@ void PagedSpace::EmptyAllocationInfo() {
Free(current_top, static_cast<int>(current_limit - current_top)); Free(current_top, static_cast<int>(current_limit - current_top));
} }
void PagedSpace::IncreaseCapacity(int size) { void PagedSpace::IncreaseCapacity(size_t bytes) {
accounting_stats_.ExpandSpace(size); accounting_stats_.ExpandSpace(bytes);
} }
void PagedSpace::ReleasePage(Page* page) { void PagedSpace::ReleasePage(Page* page) {
......
...@@ -1592,74 +1592,75 @@ class AllocationStats BASE_EMBEDDED { ...@@ -1592,74 +1592,75 @@ class AllocationStats BASE_EMBEDDED {
void ClearSize() { size_ = capacity_; } void ClearSize() { size_ = capacity_; }
// Accessors for the allocation statistics. // Accessors for the allocation statistics.
intptr_t Capacity() { return capacity_; } size_t Capacity() { return capacity_; }
intptr_t MaxCapacity() { return max_capacity_; } size_t MaxCapacity() { return max_capacity_; }
intptr_t Size() { size_t Size() { return size_; }
CHECK_GE(size_, 0);
return size_;
}
// Grow the space by adding available bytes. They are initially marked as // Grow the space by adding available bytes. They are initially marked as
// being in use (part of the size), but will normally be immediately freed, // being in use (part of the size), but will normally be immediately freed,
// putting them on the free list and removing them from size_. // putting them on the free list and removing them from size_.
void ExpandSpace(int size_in_bytes) { void ExpandSpace(size_t bytes) {
capacity_ += size_in_bytes; DCHECK_GE(size_ + bytes, size_);
size_ += size_in_bytes; DCHECK_GE(capacity_ + bytes, capacity_);
capacity_ += bytes;
size_ += bytes;
if (capacity_ > max_capacity_) { if (capacity_ > max_capacity_) {
max_capacity_ = capacity_; max_capacity_ = capacity_;
} }
CHECK(size_ >= 0);
} }
// Shrink the space by removing available bytes. Since shrinking is done // Shrink the space by removing available bytes. Since shrinking is done
// during sweeping, bytes have been marked as being in use (part of the size) // during sweeping, bytes have been marked as being in use (part of the size)
// and are hereby freed. // and are hereby freed.
void ShrinkSpace(int size_in_bytes) { void ShrinkSpace(size_t bytes) {
capacity_ -= size_in_bytes; DCHECK_GE(capacity_, bytes);
size_ -= size_in_bytes; DCHECK_GE(size_, bytes);
CHECK_GE(size_, 0); capacity_ -= bytes;
size_ -= bytes;
}
void AllocateBytes(size_t bytes) {
DCHECK_GE(size_ + bytes, size_);
size_ += bytes;
}
void DeallocateBytes(size_t bytes) {
DCHECK_GE(size_, bytes);
size_ -= bytes;
} }
// Allocate from available bytes (available -> size). void DecreaseCapacity(size_t bytes) {
void AllocateBytes(intptr_t size_in_bytes) { DCHECK_GE(capacity_, bytes);
size_ += size_in_bytes; DCHECK_GE(capacity_ - bytes, size_);
CHECK_GE(size_, 0); capacity_ -= bytes;
} }
// Free allocated bytes, making them available (size -> available). void IncreaseCapacity(size_t bytes) {
void DeallocateBytes(intptr_t size_in_bytes) { DCHECK_GE(capacity_ + bytes, capacity_);
size_ -= size_in_bytes; capacity_ += bytes;
CHECK_GE(size_, 0);
} }
// Merge {other} into {this}. // Merge |other| into |this|.
void Merge(const AllocationStats& other) { void Merge(const AllocationStats& other) {
DCHECK_GE(capacity_ + other.capacity_, capacity_);
DCHECK_GE(size_ + other.size_, size_);
capacity_ += other.capacity_; capacity_ += other.capacity_;
size_ += other.size_; size_ += other.size_;
if (other.max_capacity_ > max_capacity_) { if (other.max_capacity_ > max_capacity_) {
max_capacity_ = other.max_capacity_; max_capacity_ = other.max_capacity_;
} }
CHECK_GE(size_, 0);
} }
void DecreaseCapacity(intptr_t size_in_bytes) {
capacity_ -= size_in_bytes;
CHECK_GE(capacity_, 0);
CHECK_GE(capacity_, size_);
}
void IncreaseCapacity(intptr_t size_in_bytes) { capacity_ += size_in_bytes; }
private: private:
// |capacity_|: The number of object-area bytes (i.e., not including page // |capacity_|: The number of object-area bytes (i.e., not including page
// bookkeeping structures) currently in the space. // bookkeeping structures) currently in the space.
intptr_t capacity_; size_t capacity_;
// |max_capacity_|: The maximum capacity ever observed. // |max_capacity_|: The maximum capacity ever observed.
intptr_t max_capacity_; size_t max_capacity_;
// |size_|: The number of allocated bytes. // |size_|: The number of allocated bytes.
intptr_t size_; size_t size_;
}; };
// A free list maintaining free blocks of memory. The free list is organized in // A free list maintaining free blocks of memory. The free list is organized in
...@@ -2120,7 +2121,7 @@ class PagedSpace : public Space { ...@@ -2120,7 +2121,7 @@ class PagedSpace : public Space {
void Allocate(int bytes) { accounting_stats_.AllocateBytes(bytes); } void Allocate(int bytes) { accounting_stats_.AllocateBytes(bytes); }
void IncreaseCapacity(int size); void IncreaseCapacity(size_t bytes);
// Releases an unused page and shrinks the space. // Releases an unused page and shrinks the space.
void ReleasePage(Page* page); void ReleasePage(Page* page);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment