Index: src/spaces.h |
diff --git a/src/spaces.h b/src/spaces.h |
index b302568540fbc0c5d5b417878d3e509b2e10da37..c649b04e385da4dd58cc8fc7ba94246f9b7f9e46 100644 |
--- a/src/spaces.h |
+++ b/src/spaces.h |
@@ -452,12 +452,27 @@ class MemoryChunk { |
// Manage live byte count (count of bytes known to be live, |
// because they are marked black). |
void ResetLiveBytes() { |
+ if (FLAG_trace_live_byte_count) { |
+ PrintF("ResetLiveBytes:%p:%x->0\n", |
+ static_cast<void*>(this), live_byte_count_); |
+ } |
live_byte_count_ = 0; |
} |
void IncrementLiveBytes(int by) { |
+ ASSERT_LE(static_cast<unsigned>(live_byte_count_), size_); |
+ if (FLAG_trace_live_byte_count) { |
+ printf("UpdateLiveBytes:%p:%x%c=%x->%x\n", |
+ static_cast<void*>(this), live_byte_count_, |
+ ((by < 0) ? '-' : '+'), ((by < 0) ? -by : by), |
+ live_byte_count_ + by); |
+ } |
live_byte_count_ += by; |
+ ASSERT_LE(static_cast<unsigned>(live_byte_count_), size_); |
+ } |
+ int LiveBytes() { |
+ ASSERT(static_cast<unsigned>(live_byte_count_) <= size_); |
+ return live_byte_count_; |
} |
- int LiveBytes() { return live_byte_count_; } |
static void IncrementLiveBytes(Address address, int by) { |
MemoryChunk::FromAddress(address)->IncrementLiveBytes(by); |
} |
@@ -467,10 +482,11 @@ class MemoryChunk { |
static const intptr_t kAlignmentMask = kAlignment - 1; |
+ static const intptr_t kSizeOffset = kPointerSize + kPointerSize; |
+ |
static const intptr_t kLiveBytesOffset = |
- kPointerSize + kPointerSize + kPointerSize + kPointerSize + |
- kPointerSize + kPointerSize + kPointerSize + kPointerSize + |
- kIntSize; |
+ kSizeOffset + kPointerSize + kPointerSize + kPointerSize + |
+ kPointerSize + kPointerSize + kPointerSize + kIntSize; |
static const size_t kSlotsBufferOffset = kLiveBytesOffset + kIntSize; |
@@ -700,6 +716,10 @@ class Page : public MemoryChunk { |
void ClearSweptPrecisely() { ClearFlag(WAS_SWEPT_PRECISELY); } |
void ClearSweptConservatively() { ClearFlag(WAS_SWEPT_CONSERVATIVELY); } |
+#ifdef DEBUG |
+ void Print(); |
+#endif // DEBUG |
+ |
friend class MemoryAllocator; |
}; |