Index: src/spaces.cc |
=================================================================== |
--- src/spaces.cc (revision 3725) |
+++ src/spaces.cc (working copy) |
@@ -357,12 +357,19 @@ |
} |
int alloced = static_cast<int>(*allocated); |
size_ += alloced; |
+#ifdef DEBUG |
+ // Is this the problematic one? |
Kevin Millikin (Chromium)
2010/01/28 08:38:02
I'm not sure this comment adds anything.
|
+ ZapBlock(reinterpret_cast<Address>(mem), alloced); |
+#endif |
Counters::memory_allocated.Increment(alloced); |
return mem; |
} |
void MemoryAllocator::FreeRawMemory(void* mem, size_t length) { |
+#ifdef DEBUG |
+ ZapBlock(reinterpret_cast<Address>(mem), length); |
+#endif |
if (CodeRange::contains(static_cast<Address>(mem))) { |
CodeRange::FreeRawMemory(mem, length); |
} else { |
@@ -446,6 +453,9 @@ |
if (!initial_chunk_->Commit(start, size, owner->executable() == EXECUTABLE)) { |
return Page::FromAddress(NULL); |
} |
+#ifdef DEBUG |
+ ZapBlock(start, size); |
+#endif |
Counters::memory_allocated.Increment(static_cast<int>(size)); |
// So long as we correctly overestimated the number of chunks we should not |
@@ -467,10 +477,14 @@ |
ASSERT(InInitialChunk(start + size - 1)); |
if (!initial_chunk_->Commit(start, size, executable)) return false; |
+#ifdef DEBUG |
+ ZapBlock(start, size); |
+#endif |
Counters::memory_allocated.Increment(static_cast<int>(size)); |
return true; |
} |
+ |
bool MemoryAllocator::UncommitBlock(Address start, size_t size) { |
ASSERT(start != NULL); |
ASSERT(size > 0); |
@@ -483,6 +497,14 @@ |
return true; |
} |
+ |
+void MemoryAllocator::ZapBlock(Address start, size_t size) { |
+ for (size_t s = 0; s + kPointerSize <= size; s += kPointerSize) { |
+ Memory::Address_at(start + s) = kZapValue; |
+ } |
+} |
+ |
+ |
Page* MemoryAllocator::InitializePagesInChunk(int chunk_id, int pages_in_chunk, |
PagedSpace* owner) { |
ASSERT(IsValidChunk(chunk_id)); |
@@ -1599,9 +1621,7 @@ |
int OldSpaceFreeList::Free(Address start, int size_in_bytes) { |
#ifdef DEBUG |
- for (int i = 0; i < size_in_bytes; i += kPointerSize) { |
- Memory::Address_at(start + i) = kZapValue; |
- } |
+ MemoryAllocator::ZapBlock(start, size_in_bytes); |
#endif |
FreeListNode* node = FreeListNode::FromAddress(start); |
node->set_size(size_in_bytes); |
@@ -1733,9 +1753,7 @@ |
void FixedSizeFreeList::Free(Address start) { |
#ifdef DEBUG |
- for (int i = 0; i < object_size_; i += kPointerSize) { |
- Memory::Address_at(start + i) = kZapValue; |
- } |
+ MemoryAllocator::ZapBlock(start, object_size_); |
#endif |
// We only use the freelists with mark-sweep. |
ASSERT(!MarkCompactCollector::IsCompacting()); |