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

Unified Diff: src/heap/spaces.h

Issue 1455273003: [heap] Enforce size checks in allocation stats. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « no previous file | 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 b3107df1008bbf8b48ac633a0093b5ef404c5100..00b725226da3ca503ab3a2d208dab212b1aa544b 100644
--- a/src/heap/spaces.h
+++ b/src/heap/spaces.h
@@ -1544,7 +1544,10 @@ class AllocationStats BASE_EMBEDDED {
// Accessors for the allocation statistics.
intptr_t Capacity() { return capacity_; }
intptr_t MaxCapacity() { return max_capacity_; }
- intptr_t Size() { return size_; }
+ intptr_t Size() {
+ CHECK_GE(size_, 0);
+ return size_;
+ }
// 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,
@@ -1555,7 +1558,7 @@ class AllocationStats BASE_EMBEDDED {
if (capacity_ > max_capacity_) {
max_capacity_ = capacity_;
}
- DCHECK(size_ >= 0);
+ CHECK(size_ >= 0);
}
// Shrink the space by removing available bytes. Since shrinking is done
@@ -1564,19 +1567,19 @@ class AllocationStats BASE_EMBEDDED {
void ShrinkSpace(int size_in_bytes) {
capacity_ -= size_in_bytes;
size_ -= size_in_bytes;
- DCHECK(size_ >= 0);
+ CHECK(size_ >= 0);
}
// Allocate from available bytes (available -> size).
void AllocateBytes(intptr_t size_in_bytes) {
size_ += size_in_bytes;
- DCHECK(size_ >= 0);
+ CHECK(size_ >= 0);
}
// Free allocated bytes, making them available (size -> available).
void DeallocateBytes(intptr_t size_in_bytes) {
size_ -= size_in_bytes;
- DCHECK_GE(size_, 0);
+ CHECK_GE(size_, 0);
}
// Merge {other} into {this}.
@@ -1586,12 +1589,13 @@ class AllocationStats BASE_EMBEDDED {
if (other.max_capacity_ > max_capacity_) {
max_capacity_ = other.max_capacity_;
}
+ CHECK_GE(size_, 0);
}
void DecreaseCapacity(intptr_t size_in_bytes) {
capacity_ -= size_in_bytes;
- DCHECK_GE(capacity_, 0);
- DCHECK_GE(capacity_, size_);
+ CHECK_GE(capacity_, 0);
+ CHECK_GE(capacity_, size_);
}
void IncreaseCapacity(intptr_t size_in_bytes) { capacity_ += size_in_bytes; }
« no previous file with comments | « no previous file | src/heap/spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698