never call wasCollected() on a fixed object, since it will give a random result

This commit is contained in:
Joel Dice 2007-10-29 16:12:16 -06:00
parent 67faa23d83
commit 94bae01b39

View File

@ -19,6 +19,7 @@ const unsigned InitialGen2CapacityInBytes = 4 * 1024 * 1024;
const bool Verbose = false; const bool Verbose = false;
const bool Verbose2 = false; const bool Verbose2 = false;
const bool Debug = false; const bool Debug = false;
const bool DebugFixies = false;
class Context; class Context;
@ -397,8 +398,8 @@ class Fixie {
{ {
memset(mask(size), 0, maskSize(size, hasMask)); memset(mask(size), 0, maskSize(size, hasMask));
add(handle); add(handle);
if (Debug) { if (DebugFixies) {
fprintf(stderr, "make %p\n", this); fprintf(stderr, "make fixie %p\n", this);
} }
} }
@ -668,8 +669,8 @@ free(Context* c, Fixie** fixies)
for (Fixie** p = fixies; *p;) { for (Fixie** p = fixies; *p;) {
Fixie* f = *p; Fixie* f = *p;
*p = f->next; *p = f->next;
if (Debug) { if (DebugFixies) {
fprintf(stderr, "free %p\n", f); fprintf(stderr, "free fixie %p\n", f);
} }
c->system->free(f); c->system->free(f);
} }
@ -700,8 +701,8 @@ sweepFixies(Context* c)
} }
if (f->age == FixieTenureThreshold) { if (f->age == FixieTenureThreshold) {
if (Debug) { if (DebugFixies) {
fprintf(stderr, "tenure %p\n", f); fprintf(stderr, "tenure fixie %p\n", f);
} }
f->move(&(c->tenuredFixies)); f->move(&(c->tenuredFixies));
@ -791,23 +792,23 @@ copy(Context* c, void* o)
void* void*
update3(Context* c, void* o, bool* needsVisit) update3(Context* c, void* o, bool* needsVisit)
{ {
if (wasCollected(c, o)) { if (c->client->isFixed(o)) {
*needsVisit = false;
return follow(c, o);
} else if (c->client->isFixed(o)) {
Fixie* f = fixie(o); Fixie* f = fixie(o);
if ((not f->marked) if ((not f->marked)
and (c->mode == Heap::MajorCollection and (c->mode == Heap::MajorCollection
or f->age < FixieTenureThreshold)) or f->age < FixieTenureThreshold))
{ {
if (Debug) { if (DebugFixies) {
fprintf(stderr, "mark %p\n", f); fprintf(stderr, "mark fixie %p\n", f);
} }
f->marked = true; f->marked = true;
f->move(&(c->markedFixies)); f->move(&(c->markedFixies));
} }
*needsVisit = false; *needsVisit = false;
return o; return o;
} else if (wasCollected(c, o)) {
*needsVisit = false;
return follow(c, o);
} else { } else {
*needsVisit = true; *needsVisit = true;
return copy(c, o); return copy(c, o);
@ -1186,8 +1187,8 @@ visitMarkedFixies(Context* c)
Fixie* f = *p; Fixie* f = *p;
*p = f->next; *p = f->next;
if (Debug) { if (DebugFixies) {
fprintf(stderr, "visit %p\n", f); fprintf(stderr, "visit fixie %p\n", f);
} }
class Walker: public Heap::Walker { class Walker: public Heap::Walker {
@ -1415,7 +1416,9 @@ class MyHeap: public Heap {
} }
virtual void* follow(void* p) { virtual void* follow(void* p) {
if (wasCollected(&c, p)) { if (p == 0 or c.client->isFixed(p)) {
return p;
} else if (wasCollected(&c, p)) {
if (Debug) { if (Debug) {
fprintf(stderr, "follow %p (%s) to %p (%s)\n", fprintf(stderr, "follow %p (%s) to %p (%s)\n",
p, segment(&c, p), p, segment(&c, p),