fix heap dump facility to visit all roots

This commit is contained in:
Joel Dice 2008-10-24 18:48:10 -06:00
parent 708d2f1c0c
commit 003afdc918
3 changed files with 33 additions and 27 deletions

View File

@ -323,7 +323,7 @@ dumpHeap(Thread* t, FILE* out)
add(&context, 0)->number = 0; add(&context, 0)->number = 0;
visitRoots(t, &v); visitRoots(t->m, &v);
} }
} // namespace vm } // namespace vm

View File

@ -177,6 +177,25 @@ footprint(Thread* t)
return n; return n;
} }
void
visitRoots(Thread* t, Heap::Visitor* v)
{
if (t->state != Thread::ZombieState) {
v->visit(&(t->javaThread));
v->visit(&(t->exception));
t->m->processor->visitObjects(t, v);
for (Thread::Protector* p = t->protector; p; p = p->next) {
p->visit(v);
}
}
for (Thread* c = t->child; c; c = c->peer) {
visitRoots(c, v);
}
}
void void
walk(Thread*, Heap::Walker* w, uint32_t* mask, unsigned fixedSize, walk(Thread*, Heap::Walker* w, uint32_t* mask, unsigned fixedSize,
unsigned arrayElementSize, unsigned arrayLength, unsigned start) unsigned arrayElementSize, unsigned arrayLength, unsigned start)
@ -1526,20 +1545,7 @@ class HeapClient: public Heap::Client {
HeapClient(Machine* m): m(m) { } HeapClient(Machine* m): m(m) { }
virtual void visitRoots(Heap::Visitor* v) { virtual void visitRoots(Heap::Visitor* v) {
v->visit(&(m->loader)); ::visitRoots(m, v);
v->visit(&(m->bootstrapClassMap));
v->visit(&(m->monitorMap));
v->visit(&(m->stringMap));
v->visit(&(m->types));
v->visit(&(m->jniMethodTable));
for (Reference* r = m->jniReferences; r; r = r->next) {
v->visit(&(r->target));
}
for (Thread* t = m->rootThread; t; t = t->peer) {
::visitRoots(t, v);
}
postVisit(m->rootThread, v); postVisit(m->rootThread, v);
} }
@ -2784,21 +2790,21 @@ walkNext(Thread* t, object o, int previous)
} }
void void
visitRoots(Thread* t, Heap::Visitor* v) visitRoots(Machine* m, Heap::Visitor* v)
{ {
if (t->state != Thread::ZombieState) { v->visit(&(m->loader));
v->visit(&(t->javaThread)); v->visit(&(m->bootstrapClassMap));
v->visit(&(t->exception)); v->visit(&(m->monitorMap));
v->visit(&(m->stringMap));
v->visit(&(m->types));
v->visit(&(m->jniMethodTable));
t->m->processor->visitObjects(t, v); for (Reference* r = m->jniReferences; r; r = r->next) {
v->visit(&(r->target));
for (Thread::Protector* p = t->protector; p; p = p->next) {
p->visit(v);
}
} }
for (Thread* c = t->child; c; c = c->peer) { for (Thread* t = m->rootThread; t; t = t->peer) {
visitRoots(c, v); ::visitRoots(t, v);
} }
} }

View File

@ -2208,7 +2208,7 @@ int
walkNext(Thread* t, object o, int previous); walkNext(Thread* t, object o, int previous);
void void
visitRoots(Thread* t, Heap::Visitor* v); visitRoots(Machine* m, Heap::Visitor* v);
inline jobject inline jobject
makeLocalReference(Thread* t, object o) makeLocalReference(Thread* t, object o)