1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-16 07:22:43 +01:00
This commit is contained in:
Eelco Dolstra 2019-04-23 22:50:01 +02:00
parent 35b76b21ee
commit 69adbf5c77
2 changed files with 13 additions and 13 deletions

View file

@ -12,14 +12,14 @@ GC::GC()
nextSize = std::max((size_t) 2, parseSize<size_t>(getEnv("GC_INITIAL_HEAP_SIZE", "131072")) / WORD_SIZE); nextSize = std::max((size_t) 2, parseSize<size_t>(getEnv("GC_INITIAL_HEAP_SIZE", "131072")) / WORD_SIZE);
// FIXME: placement new // FIXME: placement new
frontSentinel = (Ptr<Object> *) malloc(sizeof(Ptr<Object>)); frontPtrSentinel = (Ptr<Object> *) malloc(sizeof(Ptr<Object>));
backSentinel = (Ptr<Object> *) malloc(sizeof(Ptr<Object>)); backPtrSentinel = (Ptr<Object> *) malloc(sizeof(Ptr<Object>));
frontSentinel->prev = nullptr; frontPtrSentinel->prev = nullptr;
frontSentinel->next = backSentinel; frontPtrSentinel->next = backPtrSentinel;
backSentinel->prev = frontSentinel; backPtrSentinel->prev = frontPtrSentinel;
backSentinel->next = nullptr; backPtrSentinel->next = nullptr;
frontRootSentinel = (Root<Object> *) malloc(sizeof(Root<Object>)); frontRootSentinel = (Root<Object> *) malloc(sizeof(Root<Object>));
backRootSentinel = (Root<Object> *) malloc(sizeof(Root<Object>)); backRootSentinel = (Root<Object> *) malloc(sizeof(Root<Object>));
@ -47,7 +47,7 @@ GC::~GC()
debug("allocated %d bytes in total", totalSize * WORD_SIZE); debug("allocated %d bytes in total", totalSize * WORD_SIZE);
size_t n = 0; size_t n = 0;
for (Ptr<Object> * p = frontSentinel->next; p != backSentinel; p = p->next) for (Ptr<Object> * p = frontPtrSentinel->next; p != backPtrSentinel; p = p->next)
n++; n++;
if (n) if (n)
warn("%d GC root pointers still exist on exit", n); warn("%d GC root pointers still exist on exit", n);
@ -58,8 +58,8 @@ GC::~GC()
if (n) if (n)
warn("%d GC root objects still exist on exit", n); warn("%d GC root objects still exist on exit", n);
assert(!frontSentinel->prev); assert(!frontPtrSentinel->prev);
assert(!backSentinel->next); assert(!backPtrSentinel->next);
assert(!frontRootSentinel->prev); assert(!frontRootSentinel->prev);
assert(!backRootSentinel->next); assert(!backRootSentinel->next);
} }
@ -227,7 +227,7 @@ void GC::gc()
processStack(); processStack();
} }
for (Ptr<Object> * p = frontSentinel->next; p != backSentinel; p = p->next) { for (Ptr<Object> * p = frontPtrSentinel->next; p != backPtrSentinel; p = p->next) {
if (!p->value) continue; if (!p->value) continue;
stack.push(p->value); stack.push(p->value);
processStack(); processStack();

View file

@ -136,8 +136,8 @@ struct GC
private: private:
Ptr<Object> * frontSentinel; Ptr<Object> * frontPtrSentinel;
Ptr<Object> * backSentinel; Ptr<Object> * backPtrSentinel;
Root<Object> * frontRootSentinel; Root<Object> * frontRootSentinel;
Root<Object> * backRootSentinel; Root<Object> * backRootSentinel;
@ -295,7 +295,7 @@ private:
void link() void link()
{ {
prev = (Ptr *) gc.frontSentinel; prev = (Ptr *) gc.frontPtrSentinel;
next = prev->next; next = prev->next;
next->prev = this; next->prev = this;
prev->next = this; prev->next = this;