X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=src%2Fmm%2Fcacao-gc%2Frootset.c;h=1eabc815426177d8ffb584aed256b1d6f43a49cb;hb=153f37f8fe9b0af4c93906d77c317f82e9d0a9a5;hp=4dce00d9822d6eba5ebaf23b7fce29cd6ef3cc4e;hpb=531b2e6a82408a0119f2bbc7d589254607ee1dac;p=cacao.git diff --git a/src/mm/cacao-gc/rootset.c b/src/mm/cacao-gc/rootset.c index 4dce00d98..1eabc8154 100644 --- a/src/mm/cacao-gc/rootset.c +++ b/src/mm/cacao-gc/rootset.c @@ -79,6 +79,9 @@ rootset_t *rootset_resize(rootset_t *rs) Searches global variables to compile the global root set out of references contained in them. + REMEMBER: All threads are stopped, so we can use unsynced access + in this function. + SEARCHES IN: - thread objects (threads.c) - classloader objects (loader.c) @@ -110,30 +113,28 @@ static rootset_t *rootset_from_globals(rootset_t *rs) refcount = rs->refcount; - /* walk through all registered references */ - /* REMEMBER: all threads are stopped, so we can use unsynced access here */ - re = list_first_unsynced(gc_reflist); - while (re) { - + /* walk through all registered strong references */ + for (re = list_first_unsynced(gc_reflist_strong); re != NULL; re = list_next_unsynced(gc_reflist_strong, re)) { GC_LOG2( printf("Found Registered Reference: %p at %p of type %d\n", *(re->ref), re->ref, ref->reftype); ); /* add this registered reference to the root set */ ROOTSET_ADD(re->ref, true, re->reftype) + } + + /* walk through all registered weak references */ + for (re = list_first_unsynced(gc_reflist_weak); re != NULL; re = list_next_unsynced(gc_reflist_weak, re)) { + GC_LOG2( printf("Found Registered Weak Reference: %p at %p of type %d\n", *(re->ref), re->ref, ref->reftype); ); - re = list_next_unsynced(gc_reflist, re); + /* add this registered reference to the root set */ + ROOTSET_ADD(re->ref, false, re->reftype) } /* walk through all finalizer entries */ - /* REMEMBER: all threads are stopped, so we can use unsynced access here */ - fe = list_first_unsynced(final_list); - while (fe) { - + for (fe = list_first_unsynced(final_list); fe != NULL; fe = list_next_unsynced(final_list, fe)) { GC_LOG2( printf("Found Finalizer Entry: %p\n", (void *) fe->o); ); /* add this object with finalizer to the root set */ ROOTSET_ADD(&( fe->o ), false, GC_REFTYPE_FINALIZER) - - fe = list_next_unsynced(final_list, fe); } /* remeber how many references there are inside this root set */ @@ -391,9 +392,9 @@ void rootset_writeback(rootset_t *rs) #if !defined(NDEBUG) static const char* reftype_names[] = { - "XXXXXXXXXXXX", "THREADOBJECT", "CLASSLOADER ", - "GLOBAL-REF ", "FINALIZER ", "LOCAL-REF ", - "ON-STACK-ADR", "STATIC FIELD" + "THREADOBJECT", "CLASSLOADER ", "GLOBAL-REF ", + "FINALIZER ", "LOCAL-REF ", "ON-STACK-ADR", + "STATIC FIELD", "LOCKRECORD " }; void rootset_print(rootset_t *rs) @@ -426,9 +427,9 @@ void rootset_print(rootset_t *rs) printf("\t\t"); printf("%s ", reftype_names[rs->refs[i].reftype]); if (rs->refs[i].marks) - printf("MARK+UPDATE"); + printf("STRONG"); else - printf(" UPDATE"); + printf(" WEAK"); printf(" "); heap_print_object(o); printf("\n");