1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-15 15:02:42 +01:00

Allow disabling some GC debug checks

This commit is contained in:
Eelco Dolstra 2019-04-23 13:56:38 +02:00
parent a38a7b495c
commit f7f73cf5ae
2 changed files with 11 additions and 9 deletions

View file

@ -295,8 +295,10 @@ std::pair<Size, Size> GC::Arena::freeUnmarked()
obj->unmark(); obj->unmark();
} else { } else {
//debug("FREE OBJECT %x %d %d", obj, obj->type, objSize); //debug("FREE OBJECT %x %d %d", obj, obj->type, objSize);
#if GC_DEBUG
for (Size i = 0; i < objSize; ++i) for (Size i = 0; i < objSize; ++i)
((Word *) obj)[i] = 0xdeadc0dedeadbeefULL; ((Word *) obj)[i] = 0xdeadc0dedeadbeefULL;
#endif
objectsFreed += 1; objectsFreed += 1;
wordsFreed += objSize; wordsFreed += objSize;
if (curFree) { if (curFree) {
@ -333,14 +335,6 @@ bool GC::isObject(void * p)
return false; return false;
} }
void GC::assertObject(void * p)
{
if (!isObject(p)) {
printError("object %p is not an object", p);
abort();
}
}
GC::ArenaList::ArenaList() GC::ArenaList::ArenaList()
{ {
static Size initialHeapSize = std::stol(getEnv("GC_INITIAL_HEAP_SIZE", "1000000")) / WORD_SIZE; static Size initialHeapSize = std::stol(getEnv("GC_INITIAL_HEAP_SIZE", "1000000")) / WORD_SIZE;

View file

@ -277,7 +277,15 @@ public:
bool isObject(void * p); bool isObject(void * p);
void assertObject(void * p); void assertObject(void * p)
{
#if GC_DEBUG
if (!isObject(p)) {
printError("object %p is not an object", p);
abort();
}
#endif
}
}; };
extern GC gc; extern GC gc;