* src/mm/memory.h [ENABLE_GC_BOEHM]: GCNEW macros are available for boehm only.
authorMichael Starzinger <michi@complang.tuwien.ac.at>
Wed, 3 Oct 2007 11:27:28 +0000 (13:27 +0200)
committerMichael Starzinger <michi@complang.tuwien.ac.at>
Wed, 3 Oct 2007 11:27:28 +0000 (13:27 +0200)
* src/native/localref.c: Adapted ifdefs to above change.

* src/vmcore/class.c: Adapted ifdefs to above change.
(class_free): Fixed, fields array get freed properly.

* src/vmcore/field.c: Adapted ifdefs to above change.
(field_free): Implemented, field value memory gets freed.

src/mm/memory.h
src/native/localref.c
src/vmcore/class.c
src/vmcore/field.c

index 672d0e377004c0c5f933a03761d7b0b36263e58c..bab1270da5f00a94839b2032874a82efb6e20ae6 100644 (file)
@@ -180,9 +180,9 @@ Some more macros:
 #define CFREE(ptr,num)        memory_cfree((ptr),(num))
 
 
-/* GC macros ******************************************************************/
+/* GC macros (boehm only) *****************************************************/
 
-#if !defined(ENABLE_GC_CACAO)
+#if defined(ENABLE_GC_BOEHM)
 
 /* Uncollectable memory which can contain references */
 
index a7b8d07117d1d4effb1ea6b048d43419f8c315af..7893bae2f11f0babce5631c03a9918f3c10e6ff0 100644 (file)
@@ -73,7 +73,7 @@ bool localref_table_init(void)
 
        assert(LOCALREFTABLE == NULL);
 
-#if defined(ENABLE_GC_CACAO)
+#if !defined(ENABLE_GC_BOEHM)
        /* this is freed by localref_table_destroy */
        lrt = NEW(localref_table);
 #else
@@ -107,7 +107,7 @@ bool localref_table_destroy(void)
        assert(lrt);
        assert(lrt->prev == NULL);
 
-#if defined(ENABLE_GC_CACAO)
+#if !defined(ENABLE_GC_BOEHM)
        FREE(lrt, localref_table);
 #endif
 
@@ -195,7 +195,7 @@ bool localref_frame_push(int32_t capacity)
        else
                additionalrefs = 0;
 
-#if defined(ENABLE_GC_CACAO)
+#if !defined(ENABLE_GC_BOEHM)
        nlrt = (localref_table *)
                        MNEW(u1, sizeof(localref_table) + additionalrefs * SIZEOF_VOID_P);
 #else
@@ -233,7 +233,7 @@ void localref_frame_pop_all(void)
        localref_table *lrt;
        localref_table *plrt;
        int32_t         localframes;
-#if defined(ENABLE_GC_CACAO)
+#if !defined(ENABLE_GC_BOEHM)
        int32_t         additionalrefs;
 #endif
 
@@ -267,7 +267,7 @@ void localref_frame_pop_all(void)
 
                lrt->prev = NULL;
 
-#if defined(ENABLE_GC_CACAO)
+#if !defined(ENABLE_GC_BOEHM)
                /* for the exact GC local reference tables are not on the heap,
                   so we need to free them explicitly here. */
 
index 01ff3a283b98bdf15eadf868e0f656737f6f9f33..1af511f859f0294fc7a64804b65c0d19487a4c39 100644 (file)
@@ -209,14 +209,15 @@ classinfo *class_create_classinfo(utf *classname)
                log_message_utf("Creating class: ", classname);
 #endif
 
-       /* GCNEW_UNCOLLECTABLE clears the allocated memory */
-
-#if defined(ENABLE_GC_CACAO)
+#if !defined(ENABLE_GC_BOEHM)
        c = (classinfo *) heap_alloc_uncollectable(sizeof(classinfo));
+       /*c = NEW(classinfo);
+       MZERO(c, classinfo, 1);*/
 #else
        c = GCNEW_UNCOLLECTABLE(classinfo, 1);
-       /*c=NEW(classinfo);*/
+       /* GCNEW_UNCOLLECTABLE clears the allocated memory */
 #endif
+
        c->name = classname;
 
        /* Set the header.vftbl of all loaded classes to the one of
@@ -785,7 +786,7 @@ void class_free(classinfo *c)
 {
        s4 i;
        vftbl_t *v;
-               
+
        class_freecpool(c);
 
        if (c->interfaces != NULL)
@@ -794,9 +795,7 @@ void class_free(classinfo *c)
        if (c->fields) {
                for (i = 0; i < c->fieldscount; i++)
                        field_free(&(c->fields[i]));
-#if defined(ENABLE_CACAO_GC)
                MFREE(c->fields, fieldinfo, c->fieldscount);
-#endif
        }
        
        if (c->methods) {
index 74ab92e7c9c1a9b4a452afb8a6dac2e634f0ad4a..7128d1b34dc386f14ba8c58d41240a2a5ce7137d 100644 (file)
@@ -163,7 +163,7 @@ bool field_load(classbuffer *cb, fieldinfo *f, descriptor_pool *descpool)
                        break;
 
                case TYPE_ADR:
-#if defined(ENABLE_GC_CACAO)
+#if !defined(ENABLE_GC_BOEHM)
                        f->value = NEW(imm_union);
 #else
                        f->value = GCNEW_UNCOLLECTABLE(imm_union, 1);
@@ -381,7 +381,13 @@ classinfo *field_get_type(fieldinfo *f)
 
 void field_free(fieldinfo *f)
 {
-       /* empty */
+       /* free memory for fields which have a value */
+
+       if (f->value)
+#if defined(ENABLE_GC_BOEHM)
+               if (f->type != TYPE_ADR)
+#endif
+                       FREE(f->value, imm_union);
 }