diff --git a/src/heapdump.cpp b/src/heapdump.cpp index 8d69b7eb1f..6d17d82e5a 100644 --- a/src/heapdump.cpp +++ b/src/heapdump.cpp @@ -323,7 +323,7 @@ dumpHeap(Thread* t, FILE* out) add(&context, 0)->number = 0; - visitRoots(t, &v); + visitRoots(t->m, &v); } } // namespace vm diff --git a/src/machine.cpp b/src/machine.cpp index efa840449b..20ecead92d 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -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); } } diff --git a/src/machine.h b/src/machine.h index ea2784442a..c2c4eed50d 100644 --- a/src/machine.h +++ b/src/machine.h @@ -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)