* src/mm/cacao-gc/gc.h (list_gcref_entry_t): Renamed type to reftype.
authormichi <none@none>
Tue, 21 Aug 2007 10:20:33 +0000 (10:20 +0000)
committermichi <none@none>
Tue, 21 Aug 2007 10:20:33 +0000 (10:20 +0000)
[!ENABLE_HANDLES]: Added development break.

* src/mm/cacao-gc/gc.c (gc_reference_register): Added reftype to arguments.

* src/mm/gc-common.h: Added reftype defines.
* src/mm/cacao-gc/rootset.h: Removed reftype defines.

* src/mm/cacao-gc/rootset.c: Adapted to changes.

* src/vmcore/loader.c (loader_hashtable_classloader_add): Pass reftype to GC.
* src/native/jni.c (_Jv_JNI_NewGlobalRef): Likewise.
* src/threads/native/threads.c (threads_init): Likewise.
* src/threads/threads-common.c (threads_thread_new): Likewise.
(threads_thread_print_info) [WITH_CLASSPATH_GNU]: Fixed thread name printing.

* src/cacaoh/dummy.c (gc_reference_register): Adapted dummy function to new sig.

--HG--
branch : exact-gc

src/cacaoh/dummy.c
src/mm/cacao-gc/gc.c
src/mm/cacao-gc/gc.h
src/mm/cacao-gc/rootset.c
src/mm/cacao-gc/rootset.h
src/mm/gc-common.h
src/native/jni.c
src/threads/native/threads.c
src/threads/threads-common.c
src/vmcore/loader.c

index 323141df0203c89be2358163959d95d7c9ba510c..aa9365b6ebed7959d1040431a30333f9333251b7 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: dummy.c 8368 2007-08-20 21:36:53Z michi $
+   $Id: dummy.c 8374 2007-08-21 10:20:33Z michi $
 
 */
 
@@ -365,7 +365,7 @@ void finalizer_run(void *o, void *p)
 
 /* gc *************************************************************************/
 
-void gc_reference_register(java_object_t **ref)
+void gc_reference_register(java_object_t **ref, int32_t reftype)
 {
        vm_abort("gc_reference_register");
 }
index 754eb36658096c1c8a1d25e2e9ba1683f84ec6ad..31cf9c4e35f7f659a9b74b3fea44dbff305c5145 100644 (file)
@@ -127,7 +127,7 @@ void gc_init(u4 heapmaxsize, u4 heapstartsize)
 
 *******************************************************************************/
 
-void gc_reference_register(java_object_t **ref)
+void gc_reference_register(java_object_t **ref, int32_t reftype)
 {
        list_gcref_entry_t *re;
 
@@ -147,7 +147,10 @@ void gc_reference_register(java_object_t **ref)
 
        re = NEW(list_gcref_entry_t);
 
-       re->ref = ref;
+       re->ref     = ref;
+#if !defined(NDEBUG)
+       re->reftype = reftype;
+#endif
 
        list_add_last(gc_reflist, re);
 }
index ee8ac829f614ceddf143cabbe9fc997c525d2236..752c627ee2691885426eae4d2f01ba366a6e7cf8 100644 (file)
 # error "GC does only work with replacement enabled!"
 #endif
 
+#if 1 && !defined(ENABLE_HANDLES)
+# error "GC does only work with handles (indirection cells) enabled!"
+#endif
+
 #if 1 && !defined(__ALPHA__) && !defined(__ARM__) && !defined(__I386__) && !defined(__POWERPC__) && !defined(__X86_64__) && !defined(__M68K__) && !defined(__SPARC_64__)
 # error "GC was only ported to some architectures so far!"
 #endif
@@ -126,6 +130,9 @@ typedef struct list_gcref_entry_t list_gcref_entry_t;
 struct list_gcref_entry_t {
        listnode_t      linkage;
        java_object_t **ref;
+#if !defined(NDEBUG)
+       s4              reftype;
+#endif
 };
 
 
index 58cfbbee2a6440f881a9d0ae5a26dc565909803a..8b9ffd0aed581cce35bac7bcf31c147f156ddde8 100644 (file)
@@ -92,9 +92,9 @@ rootset_t *rootset_resize(rootset_t *rs)
 #define ROOTSET_ADD(adr,mrk,tp) \
        if (refcount >= rs->capacity) \
                rs = rootset_resize(rs); \
-       rs->refs[refcount].ref   = (adr); \
-       rs->refs[refcount].marks = (mrk); \
-       rs->refs[refcount].type  = (tp); \
+       rs->refs[refcount].ref     = (adr); \
+       rs->refs[refcount].marks   = (mrk); \
+       rs->refs[refcount].reftype = (tp); \
        refcount++;
 
 static rootset_t *rootset_from_globals(rootset_t *rs)
@@ -117,10 +117,10 @@ static rootset_t *rootset_from_globals(rootset_t *rs)
        re = list_first_unsynced(gc_reflist);
        while (re) {
 
-               GC_LOG2( printf("Found Registered Reference: %p at %p\n", *(re->ref), re->ref); );
+               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, REFTYPE_REGISTERED)
+               ROOTSET_ADD(re->ref, true, re->reftype)
 
                re = list_next_unsynced(gc_reflist, re);
        }
@@ -133,7 +133,7 @@ static rootset_t *rootset_from_globals(rootset_t *rs)
                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, REFTYPE_FINALIZER)
+               ROOTSET_ADD(&( fe->o ), false, GC_REFTYPE_FINALIZER)
 
                fe = list_next_unsynced(final_list, fe);
        }
@@ -184,7 +184,7 @@ static rootset_t *rootset_from_classes(rootset_t *rs)
                                        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);
+                       ROOTSET_ADD(f->value, true, GC_REFTYPE_CLASSREF);
 
                }
 
@@ -268,7 +268,7 @@ static rootset_t *rootset_from_thread(threadobject *thread, rootset_t *rs)
                        GC_LOG2( printf("Found Reference (Java Local): %p\n", (void *) sf->javalocals[i].a); );
 
                        /* add this reference to the root set */
-                       ROOTSET_ADD((java_object_t **) &( sf->javalocals[i] ), true, REFTYPE_STACK);
+                       ROOTSET_ADD((java_object_t **) &( sf->javalocals[i] ), true, GC_REFTYPE_STACK);
 
                }
 
@@ -281,7 +281,7 @@ static rootset_t *rootset_from_thread(threadobject *thread, rootset_t *rs)
                        GC_LOG2( printf("Found Reference (Java Stack): %p\n", (void *) sf->javastack[i].a); );
 
                        /* add this reference to the root set */
-                       ROOTSET_ADD((java_object_t **) &( sf->javastack[i] ), true, REFTYPE_STACK);
+                       ROOTSET_ADD((java_object_t **) &( sf->javastack[i] ), true, GC_REFTYPE_STACK);
 
                }
 
@@ -290,7 +290,7 @@ static rootset_t *rootset_from_thread(threadobject *thread, rootset_t *rs)
                        GC_LOG( printf("Found Reference (Sync Slot): %p\n", (void *) sf->syncslots[i].a); );
 
                        /* add this reference to the root set */
-                       ROOTSET_ADD((java_object_t **) &( sf->syncslots[i] ), true, REFTYPE_STACK);
+                       ROOTSET_ADD((java_object_t **) &( sf->syncslots[i] ), true, GC_REFTYPE_STACK);
 
                }
        }
@@ -308,10 +308,10 @@ static rootset_t *rootset_from_thread(threadobject *thread, rootset_t *rs)
                        /* there should be no null pointers in here */
                        GC_ASSERT(lrt->refs[i] != NULL);
 
-                       GC_LOG( printf("Found LocalRef: %p\n", (void *) lrt->refs[i]); );
+                       GC_LOG2( printf("Found LocalRef: %p\n", (void *) lrt->refs[i]); );
 
                        /* add this reference to the root set */
-                       ROOTSET_ADD(&( lrt->refs[i] ), true, REFTYPE_LOCALREF);
+                       ROOTSET_ADD(&( lrt->refs[i] ), true, GC_REFTYPE_LOCALREF);
 
                }
 
@@ -391,10 +391,10 @@ void rootset_writeback(rootset_t *rs)
 /* Debugging ******************************************************************/
 
 #if !defined(NDEBUG)
-static const char* ref_type_names[] = {
-               "XXXXXX", "REGIST", "CLASSL",
-               "GLOBAL", "FINAL ", "LOCAL ",
-               "STACK ", "STATIC"
+static const char* reftype_names[] = {
+               "XXXXXXXXXXXX", "THREADOBJECT", "CLASSLOADER ",
+               "GLOBAL-REF  ", "FINALIZER   ", "LOCAL-REF   ",
+               "ON-STACK-ADR", "STATIC FIELD"
 };
 
 void rootset_print(rootset_t *rs)
@@ -425,7 +425,7 @@ void rootset_print(rootset_t *rs)
 
                        /*printf("\t\tReference at %p points to ...\n", (void *) rs->refs[i]);*/
                        printf("\t\t");
-                       printf("%s ", ref_type_names[rs->refs[i].type]);
+                       printf("%s ", reftype_names[rs->refs[i].reftype]);
                        if (rs->refs[i].marks)
                                printf("MARK+UPDATE");
                        else
index 8f3a031f7105400e967a19717b82eb82217bde4f..9cdaf067ce04187235bf38e0d761a3e74caff0c9 100644 (file)
@@ -51,15 +51,6 @@ typedef struct rootset_t rootset_t;
 
 #define ROOTSET_INITIAL_CAPACITY 16
 
-#define REFTYPE_THREADOBJECT 1
-#define REFTYPE_REGISTERED   1
-#define REFTYPE_CLASSLOADER  2
-#define REFTYPE_GLOBALREF    3
-#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 */
 
@@ -67,7 +58,7 @@ typedef struct rootset_entry_t {
        java_object_t     **ref;            /* a pointer to the actual reference */
        bool                marks;          /* indicates if a reference marks */
 #if !defined(NDEBUG)
-       s4                  type;
+       s4                  reftype;
 #endif
 } rootset_entry_t;
 
index 7909778794fda85b831cd913796c67a957fd527a..8869f5019f3c95393a5b0da955cb001351a299f2 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: gc-common.h 8302 2007-08-13 13:50:50Z michi $
+   $Id: gc-common.h 8374 2007-08-21 10:20:33Z michi $
 
 */
 
 #include "vmcore/method.h"
 
 
+/* reference types ************************************************************/
+
+#define GC_REFTYPE_THREADOBJECT  1
+#define GC_REFTYPE_CLASSLOADER   2
+#define GC_REFTYPE_JNI_GLOBALREF 3
+#define GC_REFTYPE_FINALIZER     4
+#define GC_REFTYPE_LOCALREF      5
+#define GC_REFTYPE_STACK         6
+#define GC_REFTYPE_CLASSREF      7
+
+
 /* function prototypes ********************************************************/
 
 void  gc_init(u4 heapmaxsize, u4 heapstartsize);
@@ -50,7 +61,7 @@ void  heap_free(void *p);
 void  heap_init_objectheader(java_object_t *o, u4 size);
 s4    heap_get_hashcode(java_object_t *o);
 
-void  gc_reference_register(java_object_t **ref);
+void  gc_reference_register(java_object_t **ref, int32_t reftype);
 void  gc_reference_unregister(java_object_t **ref);
 #endif
 
index a3c47564b6bea18f261bb9f9cf7db0f40472f980..dc109f8da57f6e41a17e21424af8cfeb02fd3e55 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: jni.c 8364 2007-08-20 19:52:00Z michi $
+   $Id: jni.c 8374 2007-08-21 10:20:33Z michi $
 
 */
 
@@ -3412,7 +3412,7 @@ jobject _Jv_JNI_NewGlobalRef(JNIEnv* env, jobject obj)
 #if defined(ENABLE_GC_CACAO)
        /* register global ref with the GC */
 
-       gc_reference_register(&(gre->o));
+       gc_reference_register(&(gre->o), GC_REFTYPE_JNI_GLOBALREF);
 #endif
 
        gre->o    = o;
index 043b0ff479ee1927574bee3f4202e2a725d3fef4..86558cfc56101ca2e026f083d85f697c7b568c3e 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: threads.c 8360 2007-08-20 18:02:50Z michi $
+   $Id: threads.c 8374 2007-08-21 10:20:33Z michi $
 
 */
 
@@ -908,7 +908,7 @@ bool threads_init(void)
 #if defined(ENABLE_GC_CACAO)
        /* register reference to java.lang.Thread with the GC */
 
-       gc_reference_register((java_object_t **) &(mainthread->object));
+       gc_reference_register((java_object_t **) &(mainthread->object), GC_REFTYPE_THREADOBJECT);
 #endif
 
        /* create a java.lang.Thread for the main thread */
index e02540716c6c21fb4819bda9852bdfd7fe802c36..8c467e6765436f6d8edb596ad0e3cd25b8c8f15b 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: threads-common.c 8360 2007-08-20 18:02:50Z michi $
+   $Id: threads-common.c 8374 2007-08-21 10:20:33Z michi $
 
 */
 
@@ -286,7 +286,7 @@ threadobject *threads_thread_new(void)
 #if defined(ENABLE_GC_CACAO)
                /* register reference to java.lang.Thread with the GC */
 
-               gc_reference_register((java_object_t **) &(t->object));
+               gc_reference_register((java_object_t **) &(t->object), GC_REFTYPE_THREADOBJECT);
 #endif
        }
 
@@ -529,6 +529,9 @@ void threads_thread_start(java_lang_Thread *object)
 void threads_thread_print_info(threadobject *t)
 {
        java_lang_Thread *object;
+#if defined(WITH_CLASSPATH_GNU)
+       java_lang_String *namestring;
+#endif
        utf              *name;
 
        assert(t->state != THREAD_STATE_NEW);
@@ -541,7 +544,8 @@ void threads_thread_print_info(threadobject *t)
                /* get thread name */
 
 #if defined(WITH_CLASSPATH_GNU)
-               name = javastring_toutf((java_handle_t *) LLNI_field_direct(object, name), false);
+               LLNI_field_get_ref(object, name, namestring);
+               name = javastring_toutf((java_handle_t *) namestring, false);
 #elif defined(WITH_CLASSPATH_SUN) || defined(WITH_CLASSPATH_CLDC1_1)
                /* FIXME: In cldc the name is a char[] */
 /*             name = object->name; */
index 4e2053c9cfb329340e47a62832abc793bb98cd14..5e33409541320906ab0ee0a6347b6c2bfbbbc965 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: loader.c 8369 2007-08-20 21:39:32Z michi $
+   $Id: loader.c 8374 2007-08-21 10:20:33Z michi $
 
 */
 
@@ -312,7 +312,7 @@ classloader *loader_hashtable_classloader_add(java_handle_t *cl)
 #if defined(ENABLE_GC_CACAO)
                /* register the classloader object with the GC */
 
-               gc_reference_register(&(cle->object));
+               gc_reference_register(&(cle->object), GC_REFTYPE_CLASSLOADER);
 #endif
 
                LLNI_CRITICAL_START;