From: michi Date: Tue, 6 Mar 2007 10:28:12 +0000 (+0000) Subject: Static class references are now explicitly added to the rootset. X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=936c0bb3feac878cc7ad724baf348a8eb48bb1f9;p=cacao.git Static class references are now explicitly added to the rootset. * src/mm/cacao-gc/rootset.c (rootset_from_classes): Added. * src/mm/cacao-gc/rootset.h (REFTYPE_CLASSREF): Added. --HG-- branch : exact-gc --- diff --git a/configure.ac b/configure.ac index 05284e909..c2ca770c0 100644 --- a/configure.ac +++ b/configure.ac @@ -22,7 +22,7 @@ dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA dnl 02110-1301, USA. dnl -dnl $Id: configure.ac 7441 2007-03-02 23:13:10Z michi $ +dnl $Id: configure.ac 7434 2007-03-02 19:44:53Z edwin $ dnl Process this file with autoconf to produce a configure script. diff --git a/src/mm/cacao-gc/rootset.c b/src/mm/cacao-gc/rootset.c index 1cd9b826d..4ae074fd4 100644 --- a/src/mm/cacao-gc/rootset.c +++ b/src/mm/cacao-gc/rootset.c @@ -168,6 +168,56 @@ void rootset_from_globals(rootset_t *rs) } +void rootset_from_classes(rootset_t *rs) +{ + classinfo *c; + fieldinfo *f; + void *sys_start, *sys_end; + int refcount; + int i; + + GC_LOG( dolog("GC: Acquiring Root-Set from classes ..."); ); + + /* TODO: cleanup!!! */ + sys_start = heap_region_sys->base; + sys_end = heap_region_sys->ptr; + + refcount = rs->refcount; + + /* walk through all classinfo blocks */ + for (c = sys_start; c < (classinfo *) sys_end; c++) { + + GC_LOG2( printf("Searching in class "); class_print(c); printf("\n"); ); + + /* walk through all fields */ + f = c->fields; + for (i = 0; i < c->fieldscount; i++, f++) { + + /* check if this is a static reference */ + if (!IS_ADR_TYPE(f->type) || !(f->flags & ACC_STATIC)) + continue; + + /* check for outside or null pointers */ + if (f->value.a == NULL) + continue; + + GC_LOG2( printf("Found Static Field Reference: %p\n", (void *) f->value.a); + printf("\tfrom field: "); field_print(f); printf("\n"); + printf("\tto object : "); heap_print_object(f->value.a); printf("\n"); ); + + /* add this static field reference to the root set */ + ROOTSET_ADD(&( f->value ), true, REFTYPE_CLASSREF); + + } + + } + + /* remeber how many references there are inside this root set */ + rs->refcount = refcount; + +} + + /* rootset_from_thread ********************************************************* Searches the stack of the passed thread for references and compiles a @@ -276,6 +326,7 @@ rootset_t *rootset_readout() /* find the global rootset ... */ rs_top = rootset_create(); rootset_from_globals(rs_top); + rootset_from_classes(rs_top); /* ... and the rootsets for the threads */ rs = rs_top; @@ -343,7 +394,9 @@ void rootset_writeback(rootset_t *rs) #if !defined(NDEBUG) const char* ref_type_names[] = { - "XXXXXX", "THREAD", "CLASSL", "GLOBAL", "FINAL ", "LOCAL ", "STACK " + "XXXXXX", "THREAD", "CLASSL", + "GLOBAL", "FINAL ", "LOCAL ", + "STACK ", "STATIC" }; void rootset_print(rootset_t *rs) diff --git a/src/mm/cacao-gc/rootset.h b/src/mm/cacao-gc/rootset.h index af70efb88..758467ac7 100644 --- a/src/mm/cacao-gc/rootset.h +++ b/src/mm/cacao-gc/rootset.h @@ -52,7 +52,7 @@ typedef struct rootset_t rootset_t; /* Structures *****************************************************************/ #define ROOTSET_DUMMY_THREAD ((threadobject *) (ptrint) -1) -#define RS_REFS 32 +#define RS_REFS 512 /* TODO: you see why we need to rethink this!!! */ #define REFTYPE_THREADOBJECT 1 #define REFTYPE_CLASSLOADER 2 @@ -60,6 +60,7 @@ typedef struct rootset_t rootset_t; #define REFTYPE_FINALIZER 4 #define REFTYPE_LOCALREF 5 #define REFTYPE_STACK 6 +#define REFTYPE_CLASSREF 7 /* rootset is passed as array of pointers, which point to the location of the reference */ diff --git a/src/vm/builtin.h b/src/vm/builtin.h index 3fa01fefb..a1e9b9839 100644 --- a/src/vm/builtin.h +++ b/src/vm/builtin.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: builtin.h 7356 2007-02-14 11:00:28Z twisti $ + $Id: builtin.h 7316 2007-02-10 19:06:54Z twisti $ */ diff --git a/src/vm/jit/codegen-common.c b/src/vm/jit/codegen-common.c index 7496334bf..f46d0d9ca 100644 --- a/src/vm/jit/codegen-common.c +++ b/src/vm/jit/codegen-common.c @@ -39,7 +39,7 @@ memory. All functions writing values into the data area return the offset relative the begin of the code area (start of procedure). - $Id: codegen-common.c 7407 2007-02-26 19:12:03Z michi $ + $Id: codegen-common.c 7403 2007-02-25 21:31:58Z pm $ */ diff --git a/src/vm/jit/i386/asmpart.S b/src/vm/jit/i386/asmpart.S index 05d1d0199..92f75974e 100644 --- a/src/vm/jit/i386/asmpart.S +++ b/src/vm/jit/i386/asmpart.S @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: asmpart.S 7355 2007-02-14 10:57:32Z twisti $ + $Id: asmpart.S 7310 2007-02-09 13:00:04Z twisti $ */ diff --git a/src/vm/jit/i386/emit.c b/src/vm/jit/i386/emit.c index e41b296a1..215b53643 100644 --- a/src/vm/jit/i386/emit.c +++ b/src/vm/jit/i386/emit.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: emit.c 7356 2007-02-14 11:00:28Z twisti $ + $Id: emit.c 7316 2007-02-10 19:06:54Z twisti $ */ diff --git a/src/vm/jit/x86_64/emit.c b/src/vm/jit/x86_64/emit.c index b7d792f7f..6406a1bbd 100644 --- a/src/vm/jit/x86_64/emit.c +++ b/src/vm/jit/x86_64/emit.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: emit.c 7356 2007-02-14 11:00:28Z twisti $ + $Id: emit.c 7317 2007-02-11 00:02:54Z twisti $ */ diff --git a/src/vmcore/classcache.c b/src/vmcore/classcache.c index 11a666907..1a9c7d869 100644 --- a/src/vmcore/classcache.c +++ b/src/vmcore/classcache.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: classcache.c 7441 2007-03-02 23:13:10Z michi $ + $Id: classcache.c 7435 2007-03-02 19:45:42Z edwin $ */ diff --git a/tests/regression/Makefile.am b/tests/regression/Makefile.am index 6a32c19c7..c02f75e31 100644 --- a/tests/regression/Makefile.am +++ b/tests/regression/Makefile.am @@ -26,7 +26,7 @@ ## ## Authors: Christian Thalinger ## -## $Id: Makefile.am 7441 2007-03-02 23:13:10Z michi $ +## $Id: Makefile.am 7433 2007-03-02 19:42:13Z edwin $ ## Process this file with automake to produce Makefile.in