Skip to content

Commit

Permalink
Add debugging mode that clears memory to Immix
Browse files Browse the repository at this point in the history
This overwrites memory with all 1's in immix when a line is not used.
This makes it easier to debug because objects will be seen as invalid
later if they haven't been properly marked.
  • Loading branch information
dbussink committed May 29, 2013
1 parent c6791e7 commit 509e739
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions vm/util/immix.hpp
Expand Up @@ -147,6 +147,22 @@ namespace immix {
lines_[0] = 1;
}

/**
* Overwrites memory inside the blocks that is not used according to
* the lines found.
* Is used for debugging purposes to see easier when an object
* isn't properly marked.
*/
void clear_memory() {
Address start = address_;
for(int i = 0; i < cLineTableSize; ++i) {
if(!lines_[i]) {
memset((void*)start.address_, 0xFF, cLineSize);
}
start += cLineSize;
}
}

/**
* Sets the location of the memory managed by this Block.
*/
Expand Down Expand Up @@ -1005,6 +1021,13 @@ namespace immix {
block->set_status(cFree);
}
}
#ifdef RBX_GC_DEBUG
AllBlockIterator iter(block_allocator_.chunks());

while(Block* block = iter.next()) {
block->clear_memory();
}
#endif

block_allocator_.reset();
}
Expand Down

0 comments on commit 509e739

Please sign in to comment.