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;
visitRoots(t, &v);
visitRoots(t->m, &v);
}
} // namespace vm

View File

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

View File

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