Author: heimdall
Date: Sat Aug 13 17:21:09 2005
New Revision: 8948

Modified:
   branches/gmc/classes/default.pmc
   branches/gmc/classes/unmanagedstruct.pmc
   branches/gmc/include/parrot/pobj.h
   branches/gmc/include/parrot/smallobject.h
   branches/gmc/src/dod.c
   branches/gmc/src/gc_gmc.c
   branches/gmc/src/hash.c
   branches/gmc/src/headers.c
   branches/gmc/src/jit_debug.c
   branches/gmc/src/key.c
   branches/gmc/src/memory.c
   branches/gmc/src/pmc.c
   branches/gmc/src/pmc_freeze.c
Log:
pmc_ext now in pmc_body.


Modified: branches/gmc/classes/default.pmc
==============================================================================
--- branches/gmc/classes/default.pmc    (original)
+++ branches/gmc/classes/default.pmc    Sat Aug 13 17:21:09 2005
@@ -186,8 +186,13 @@ C<initializer> if it is supplied, otherw
 */
 
     void init_pmc_props (PMC* initializer, PMC* properties) {
+    #if PARROT_GC_GMC
+       if (!Gmc_has_PMC_EXT_TEST(SELF))
+           Gmc_PMC_flag_SET(has_ext,SELF);
+    #else
         if (!SELF->pmc_ext)
             add_pmc_ext(INTERP, SELF);
+    #endif
         DOD_WRITE_BARRIER(INTERP, SELF, NULL, properties);
         PMC_metadata(SELF) = properties;
         if (initializer)
@@ -240,7 +245,12 @@ Returns the property for C<*key>. If no 
 */
 
     PMC* getprop(STRING* key) {
-        if (SELF->pmc_ext && PMC_metadata(SELF)) {
+    #if PARROT_GC_GMC
+       if (Gmc_has_PMC_EXT_TEST(SELF) && PMC_metadata(SELF))
+    #else
+        if (SELF->pmc_ext && PMC_metadata(SELF))
+    #endif
+       {
           return VTABLE_get_pmc_keyed_str(INTERP, PMC_metadata(SELF), key);
         }
         else {
@@ -261,13 +271,23 @@ Sets the property for C<*key> to C<*valu
 
     void setprop(STRING* key, PMC* value) {
         check_set_std_props(INTERP, SELF, key, value);
-        if (SELF->pmc_ext && PMC_metadata(SELF)) {
+    #if PARROT_GC_GMC
+       if (Gmc_has_PMC_EXT_TEST(SELF) && PMC_metadata(SELF))
+    #else
+        if (SELF->pmc_ext && PMC_metadata(SELF))
+    #endif
+       {
             VTABLE_set_pmc_keyed_str(INTERP,
                 PMC_metadata(SELF), key, value);
         } else {
             PMC *prop;
+    #if PARROT_GC_GMC
+           if (!Gmc_has_PMC_EXT_TEST(SELF))
+               Gmc_PMC_flag_SET(has_ext,SELF);
+    #else
             if (!SELF->pmc_ext)
                 add_pmc_ext(INTERP, SELF);
+    #endif
             /* first make new hash */
             PMC_metadata(SELF) = prop =
                 pmc_new_noinit(INTERP, enum_class_PerlHash);
@@ -293,7 +313,12 @@ Deletes the property for C<*key>.
 */
 
     void delprop(STRING* key) {
-        if (SELF->pmc_ext && PMC_metadata(SELF)) {
+    #if PARROT_GC_GMC
+       if (Gmc_has_PMC_EXT_TEST(SELF) && PMC_metadata(SELF))
+    #else
+        if (SELF->pmc_ext && PMC_metadata(SELF))
+    #endif
+       {
             VTABLE_delete_keyed_str(INTERP, PMC_metadata(SELF), key);
         }
         return;
@@ -310,8 +335,13 @@ Returns the PMC's properties.
 */
 
     PMC* getprops() {
+    #if PARROT_GC_GMC
+       if (!Gmc_has_PMC_EXT_TEST(SELF))
+           Gmc_PMC_flag_SET(has_ext,SELF);
+    #else
         if (!SELF->pmc_ext)
             add_pmc_ext(INTERP, SELF);
+    #endif
         if (!PMC_metadata(SELF)) {
             PMC *prop;
             PMC_metadata(SELF) = prop =
@@ -821,7 +851,12 @@ Look for NCI methods and properties.
         /* lets look for props first
          * XXX do we need that in the default object system?
          */
-        if (SELF->pmc_ext && PMC_metadata(SELF)) {
+    #if PARROT_GC_GMC
+       if (Gmc_has_PMC_EXT_TEST(SELF) && PMC_metadata(SELF))
+    #else
+        if (SELF->pmc_ext && PMC_metadata(SELF))
+    #endif
+       {
              b = hash_get_bucket(INTERP, (Hash*) PMC_metadata(SELF), name);
              if (b)
                  p = b->value;
@@ -876,7 +911,11 @@ Used by DOD to mark the PMC.
 
     void visit(visit_info *info) {
         /* default - mark prop hash */
+    #if PARROT_GC_GMC
+       if (Gmc_has_PMC_EXT_TEST(SELF) && PMC_metadata(SELF) &&
+    #else
         if (SELF->pmc_ext && PMC_metadata(SELF) &&
+    #endif
             info->extra_flags != EXTRA_IS_PROP_HASH) {
             info->extra_flags = EXTRA_IS_PROP_HASH;
             info->extra = PMC_metadata(SELF);
@@ -914,8 +953,13 @@ Initializes the PMC during unarchiving.
     void thaw(visit_info *info) {
         /* default - initialize the PMC */
         if (info->extra_flags == EXTRA_IS_PROP_HASH) {
+    #if PARROT_GC_GMC
+           if (!Gmc_has_PMC_EXT_TEST(SELF))
+               Gmc_PMC_flag_SET(has_ext,SELF);
+    #else
             if (!SELF->pmc_ext)
                 add_pmc_ext(INTERP, SELF);
+    #endif
             info->thaw_ptr = &PMC_metadata(SELF);
             info->container = SELF;
             (info->visit_pmc_now)(INTERP, PMC_metadata(SELF), info);

Modified: branches/gmc/classes/unmanagedstruct.pmc
==============================================================================
--- branches/gmc/classes/unmanagedstruct.pmc    (original)
+++ branches/gmc/classes/unmanagedstruct.pmc    Sat Aug 13 17:21:09 2005
@@ -334,7 +334,12 @@ ret_pmc(Interp* interpreter, PMC* pmc, c
             /* now check if initializer has a signature attached */
             init = PMC_pmc_val(pmc);
             ptr = VTABLE_get_pmc_keyed_int(interpreter, init, idx*3);
-            if (ptr->pmc_ext && PMC_metadata(ptr)) {
+    #if PARROT_GC_GMC
+           if (Gmc_has_PMC_EXT_TEST(ptr) && PMC_metadata(ptr))
+    #else
+            if (ptr->pmc_ext && PMC_metadata(ptr))
+    #endif
+           {    
                 PMC *sig = VTABLE_getprop(interpreter, ptr,
                         string_from_cstring(interpreter, "_signature", 0));
                 if (VTABLE_defined(interpreter, sig)) {
@@ -352,7 +357,11 @@ ret_pmc(Interp* interpreter, PMC* pmc, c
             ptr  = VTABLE_get_pmc_keyed_int(interpreter, init, idx * 3);
 
             /* grab the struct from the metadata */
+    #if PARROT_GC_GMC
+           if (Gmc_has_PMC_EXT_TEST(ptr) && PMC_metadata(ptr))
+    #else
             if (ptr->pmc_ext && PMC_metadata(ptr))
+    #endif
             {
                 ret = VTABLE_getprop(interpreter, ptr,
                         const_string(interpreter, "_struct"));

Modified: branches/gmc/include/parrot/pobj.h
==============================================================================
--- branches/gmc/include/parrot/pobj.h  (original)
+++ branches/gmc/include/parrot/pobj.h  Sat Aug 13 17:21:09 2005
@@ -91,8 +91,15 @@ typedef struct pobj_t {
 
 
 /* TODO: Change to a real pmc_body type. */
-#define DEFAULT_BODY UnionVal
-#define PMC_BODY DEFAULT_BODY
+typedef struct default_body {
+    UnionVal u;
+    PMC *_metadata;
+    struct _Sync *_synchronize;
+    PMC *_next_for_GC;
+    DPOINTER *data;
+} default_body;
+
+#define PMC_BODY default_body
 
 
 /* Hack for the get_FLAGS macro to be happy. */
@@ -122,14 +129,14 @@ typedef Buffer PObj;
 #if PARROT_GC_GMC
 
 #define PMC_body(pmc)         (pmc)->body
-#define PObj_bufstart(pmc)    PMC_body(pmc)->_b._bufstart
-#define PObj_buflen(pmc)      PMC_body(pmc)->_b._buflen
-#define PMC_struct_val(pmc)   PMC_body(pmc)->_ptrs._struct_val
-#define PMC_pmc_val(pmc)      PMC_body(pmc)->_ptrs._pmc_val
-#define PMC_int_val(pmc)      PMC_body(pmc)->_i._int_val
-#define PMC_int_val2(pmc)     PMC_body(pmc)->_i._int_val2
-#define PMC_num_val(pmc)      PMC_body(pmc)->_num_val
-#define PMC_str_val(pmc)      PMC_body(pmc)->_string_val
+#define PObj_bufstart(pmc)    PMC_body(pmc)->u._b._bufstart
+#define PObj_buflen(pmc)      PMC_body(pmc)->u._b._buflen
+#define PMC_struct_val(pmc)   PMC_body(pmc)->u._ptrs._struct_val
+#define PMC_pmc_val(pmc)      PMC_body(pmc)->u._ptrs._pmc_val
+#define PMC_int_val(pmc)      PMC_body(pmc)->u._i._int_val
+#define PMC_int_val2(pmc)     PMC_body(pmc)->u._i._int_val2
+#define PMC_num_val(pmc)      PMC_body(pmc)->u._num_val
+#define PMC_str_val(pmc)      PMC_body(pmc)->u._string_val
 
 #else
 
@@ -191,11 +198,6 @@ struct parrot_string_t {
 /* put data into the PMC_EXT structure */
 #define PMC_DATA_IN_EXT 1
 
-
-
-#if PARROT_GC_GMC
-#endif
-
 struct PMC {
 #if PARROT_GC_GMC
     PMC_BODY *body;
@@ -204,10 +206,12 @@ struct PMC {
     pobj_t obj;
 #endif
     VTABLE *vtable;
+#if ! PARROT_GC_GMC
 #if ! PMC_DATA_IN_EXT
     DPOINTER *data;
 #endif /* ! PMC_DATA_IN_EXT */
     struct PMC_EXT *pmc_ext;
+#endif /* ! PARROT_GC_GMC */
 };
 
 struct _Sync;   /* forward decl */
@@ -244,6 +248,17 @@ struct PMC_EXT {
 
 typedef struct PMC_EXT PMC_EXT;
 
+#if PARROT_GC_GMC
+
+#define PMC_data(pmc)         PMC_body(pmc)->data
+#define PMC_data0(pmc)        PMC_data(pmc)
+#define PMC_metadata(pmc)     PMC_body(pmc)->_metadata
+#define PMC_next_for_GC(pmc)  PMC_body(pmc)->_next_for_GC
+#define PMC_sync(pmc)         PMC_body(pmc)->_synchronize
+#define PMC_union(pmc)       PMC_body(pmc)->u
+
+#else
+
 #ifdef NDEBUG
 #  define PMC_ext_checked(pmc)             (pmc)->pmc_ext
 #else
@@ -260,11 +275,9 @@ typedef struct PMC_EXT PMC_EXT;
 #define PMC_metadata(pmc)     PMC_ext_checked(pmc)->_metadata
 #define PMC_next_for_GC(pmc)  PMC_ext_checked(pmc)->_next_for_GC
 #define PMC_sync(pmc)         PMC_ext_checked(pmc)->_synchronize
-#if PARROT_GC_GMC
-#define PMC_union(pmc)        (pmc)->body
-#else
 #define PMC_union(pmc)       (pmc)->obj.u
-#endif
+
+#endif /* PARROT_GC_GMC */
 
 /* macro for accessing union data */
 #define next_for_GC pmc_ext->_next_for_GC

Modified: branches/gmc/include/parrot/smallobject.h
==============================================================================
--- branches/gmc/include/parrot/smallobject.h   (original)
+++ branches/gmc/include/parrot/smallobject.h   Sat Aug 13 17:21:09 2005
@@ -133,7 +133,7 @@ typedef enum gmc_flags {
     Gmc_private_4_FLAG = 1 << 4,
     Gmc_private_5_FLAG = 1 << 5,
     Gmc_private_6_FLAG = 1 << 6,
-    Gmc_private_7_FLAG = 1 << 7,
+    Gmc_has_ext_FLAG = 1 << 7, /*  flag */
 
     /* Type flags for most common PMCs */
     Gmc_PMC_is_int_FLAG      = 1 << 8,
@@ -173,6 +173,8 @@ typedef enum gmc_flags {
 #define Gmc_PMC_flag_SET(flag, pmc)                Gmc_PMC_hdr_flag_SET(flag, 
Gmc_PMC_get_HDR(pmc))
 #define Gmc_PMC_flag_CLEAR(flag, pmc)              
Gmc_PMC_hdr_flag_CLEAR(flag, Gmc_PMC_get_HDR(pmc))
 
+#define Gmc_has_PMC_EXT_TEST(pmc)                  Gmc_PMC_flag_TEST(has_ext, 
pmc)
+
 
 /* Same structure than in GMS for header lists. */
 #define GC_GMC_STORE_SIZE (64-2)

Modified: branches/gmc/src/dod.c
==============================================================================
--- branches/gmc/src/dod.c      (original)
+++ branches/gmc/src/dod.c      Sat Aug 13 17:21:09 2005
@@ -91,7 +91,12 @@ mark_special(Parrot_Interp interpreter, 
     else
         hi_prio = 0;
 
-    if (obj->pmc_ext) {
+#if PARROT_GC_GMC
+    if (PMC_data(obj))
+#else
+    if (obj->pmc_ext)
+#endif
+    {
         PMC* tptr = arena_base->dod_trace_ptr;
 
         ++arena_base->num_extended_PMCs;
@@ -219,7 +224,12 @@ void pobject_lives(Interp *interpreter, 
     else {
         if (PObj_is_PMC_TEST(obj)) {
             PMC *p = (PMC*)obj;
-            if (p->pmc_ext && PMC_metadata(p)) {
+#if PARROT_GC_GMC
+           if (PMC_metadata(p))
+#else
+            if (p->pmc_ext && PMC_metadata(p))
+#endif
+           {
                 fprintf(stderr, "GC: error obj %p (%s) has properties\n",
                         p, (char*)p->vtable->whoami->strstart);
             }
@@ -822,6 +832,11 @@ Parrot_dod_sweep(Interp *interpreter,
                     if (PObj_active_destroy_TEST(p))
                         VTABLE_destroy(interpreter, p);
 
+#if PARROT_GC_GMC
+                    if (PObj_is_PMC_EXT_TEST(p) && PMC_data(p) != NULL) {
+                       mem_sys_free(PMC_data(p));
+                   }
+#else
                     if (PObj_is_PMC_EXT_TEST(p) && p->pmc_ext != NULL) {
                         /* if the PMC has a PMC_EXT structure,
                          * return it to the pool/arena
@@ -831,13 +846,18 @@ Parrot_dod_sweep(Interp *interpreter,
                         ext_pool->add_free_object(interpreter, ext_pool,
                                 p->pmc_ext);
                     }
+#endif
 #ifndef NDEBUG
                     /*
                      * invalidate the PMC
                      */
                     PMC_struct_val(p) = (void*)0xdeadbeef;
                     PMC_pmc_val(p) = (void*)0xdeadbeef;
+#if PARROT_GC_GMC
+                   PMC_data(p) = (void*)0xdeadbeef;
+#else
                     p->pmc_ext = (void*)0xdeadbeef;
+#endif /* PARROT_GC_GMC */
 #endif
                 }
                 /* else object is a buffer(like) */

Modified: branches/gmc/src/gc_gmc.c
==============================================================================
--- branches/gmc/src/gc_gmc.c   (original)
+++ branches/gmc/src/gc_gmc.c   Sat Aug 13 17:21:09 2005
@@ -347,11 +347,8 @@ gc_gmc_copy_gen (Gc_gmc_gen *from, Gc_gm
 static void
 gc_gmc_gen_free(Gc_gmc_gen *gen)
 {
-    fprintf (stderr, "Freeing gen %p\n", gen);
-    fprintf (stderr, "Freeing gen->data %p\n", gen->first);
     mem_sys_free(gen->first);
     mem_sys_free(gen);
-    fprintf (stderr, "Done freeing\n");
 }
 
 
@@ -382,7 +379,6 @@ gc_gmc_more_pmc_bodies (Interp *interpre
        gen = gc_gmc_gen_init (interpreter);
        gc_gmc_insert_gen (interpreter, dummy_gc, gen);
     }
-    fprintf(stderr, "Done with insertion\n");
 
     for (gen = dummy_gc->yng_fst, ogen = gc->yng_fst; ogen->next; gen = 
gen->next)
     {
@@ -392,13 +388,11 @@ gc_gmc_more_pmc_bodies (Interp *interpre
        ogen = ogen_nxt;
     }
     dummy_gc->yng_lst = gen;
-    fprintf(stderr, "Done with young copy\n");
 
     for (gen = dummy_gc->yng_fst, i = 0; i < (nb_gen/2); i++, gen = gen->next);
     dummy_gc->old_fst = gen->next;
     gen->next->prev = NULL;
     gen->next = NULL;
-    fprintf(stderr, "Done with cutting in a half, old_fst: %p\n", gc->old_fst);
 
     for (gen = dummy_gc->old_fst, ogen = gc->old_fst; ogen; gen = gen->next)
     {
@@ -407,7 +401,6 @@ gc_gmc_more_pmc_bodies (Interp *interpre
        gc_gmc_gen_free(ogen);
        ogen = ogen_nxt;
     }
-    fprintf(stderr,"Done with old copy\n");
     dummy_gc->old_lst = gen;
 
     gc->yng_fst = dummy_gc->yng_fst;
@@ -415,11 +408,10 @@ gc_gmc_more_pmc_bodies (Interp *interpre
     gc->old_fst = dummy_gc->old_fst;
     gc->old_lst = dummy_gc->old_lst;
 
-    fprintf(stderr, "gc->old_fst: %p\n", gc->old_fst);
 
     mem_sys_free(dummy_gc);
     
-#ifndef GMC_DEBUG
+#ifdef GMC_DEBUG
     fprintf(stderr, "Done with allocation\n");
 #endif
 }

Modified: branches/gmc/src/hash.c
==============================================================================
--- branches/gmc/src/hash.c     (original)
+++ branches/gmc/src/hash.c     Sat Aug 13 17:21:09 2005
@@ -374,6 +374,8 @@ expand_hash(Interp *interpreter, Hash *h
     void *new_mem;
     size_t offset, i, new_loc;
 
+    fprintf(stderr, "Trying to expand hash at %p\n", hash);
+
     /*
        allocate some less buckets
        e.g. 3 buckets, 4 pointers:

Modified: branches/gmc/src/headers.c
==============================================================================
--- branches/gmc/src/headers.c  (original)
+++ branches/gmc/src/headers.c  Sat Aug 13 17:21:09 2005
@@ -243,6 +243,9 @@ Get a header.
 
 
 static PMC_EXT * new_pmc_ext(Parrot_Interp);
+#if PARROT_GC_GMC
+void gc_gmc_tmp_ext_init(Parrot_Interp *, PMC *);
+#endif
 
 PMC *
 new_pmc_header(Interp *interpreter, UINTVAL flags)
@@ -265,7 +268,9 @@ new_pmc_header(Interp *interpreter, UINT
 #else
         flags |= PObj_is_special_PMC_FLAG;
 #endif
+#if ! PARROT_GC_GMC
         pmc->pmc_ext = new_pmc_ext(interpreter);
+#endif /* PARROT_GC_GMC */
         if (flags & PObj_is_PMC_shared_FLAG) {
             PMC_sync(pmc) = mem_internal_allocate(sizeof(*PMC_sync(pmc)));
             PMC_sync(pmc)->owner = interpreter;
@@ -273,15 +278,16 @@ new_pmc_header(Interp *interpreter, UINT
         }
     }
     else
+#if PARROT_GC_GMC
+       PMC_data(pmc) = NULL;
+#else
         pmc->pmc_ext = NULL;
+#endif
     PObj_get_FLAGS(pmc) |= PObj_is_PMC_FLAG|flags;
     pmc->vtable = NULL;
 #if ! PMC_DATA_IN_EXT
     PMC_data(pmc) = NULL;
 #endif
-/*#if PARROT_GC_GMC
-    pmc->body = new_pmc_body(interpreter);
-#endif*/
     return pmc;
 }
 
@@ -321,7 +327,9 @@ new_pmc_typed_header(Interp *interpreter
 #else
         flags |= PObj_is_special_PMC_FLAG;
 #endif
+#if ! PARROT_GC_GMC
         pmc->pmc_ext = new_pmc_ext(interpreter);
+#endif
         if (flags & PObj_is_PMC_shared_FLAG) {
             PMC_sync(pmc) = mem_internal_allocate(sizeof(*PMC_sync(pmc)));
             PMC_sync(pmc)->owner = interpreter;
@@ -329,7 +337,11 @@ new_pmc_typed_header(Interp *interpreter
         }
     }
     else
+#if PARROT_GC_GMC
+       PMC_data(pmc) = NULL;
+#else
         pmc->pmc_ext = NULL;
+#endif
     PObj_get_FLAGS(pmc) |= PObj_is_PMC_FLAG|flags;
     pmc->vtable = NULL;
 #if ! PMC_DATA_IN_EXT
@@ -370,6 +382,8 @@ new_pmc_ext(Interp *interpreter)
     return ptr;
 }
 
+# if ! PARROT_GC_GMC
+
 /*
 
 =item C<void
@@ -397,6 +411,8 @@ add_pmc_ext(Interp *interpreter, PMC *pm
 #endif
 }
 
+#endif /* ! PARROT_GC_GMC */
+
 /*
 
 =item C<STRING *

Modified: branches/gmc/src/jit_debug.c
==============================================================================
--- branches/gmc/src/jit_debug.c        (original)
+++ branches/gmc/src/jit_debug.c        Sat Aug 13 17:21:09 2005
@@ -156,8 +156,8 @@ write_types(FILE *stabs)
                 ";\""
                 "," N_LSYM ",0,0,0\n", i++, BYTE_SIZE(STRING),
 #if PARROT_GC_GMC
-                BIT_OFFSET(STRING, body->_b._bufstart), BIT_SIZE(void*),
-                BIT_OFFSET(STRING, body->_b._buflen), BIT_SIZE(size_t),
+                BIT_OFFSET(STRING, body->u._b._bufstart), BIT_SIZE(void*),
+                BIT_OFFSET(STRING, body->u._b._buflen), BIT_SIZE(size_t),
 #else
                 BIT_OFFSET(STRING, obj.u._b._bufstart), BIT_SIZE(void*),
                 BIT_OFFSET(STRING, obj.u._b._buflen), BIT_SIZE(size_t),
@@ -187,8 +187,10 @@ write_types(FILE *stabs)
     fprintf(stabs, "data:(0,14),%d,%d;",
             BIT_OFFSET(PMC, data), BIT_SIZE(void*));
 #endif
+#if ! PARROT_GC_GMC
     fprintf(stabs, "pmc_ext:*(0,%d),%d,%d;",
             i, BIT_OFFSET(PMC, pmc_ext), BIT_SIZE(void*));
+#endif 
     fprintf(stabs, ";\"");
     fprintf(stabs, "," N_LSYM ",0,0,0\n");
 

Modified: branches/gmc/src/key.c
==============================================================================
--- branches/gmc/src/key.c      (original)
+++ branches/gmc/src/key.c      Sat Aug 13 17:21:09 2005
@@ -405,7 +405,11 @@ Returns the next key if C<key> is in a s
 PMC *
 key_next(Interp *interpreter, PMC *key)
 {
+#if PARROT_GC_GMC
+    if (!PMC_data(key))
+#else
     if (!key->pmc_ext)
+#endif
         return NULL;
     return PMC_data(key);
 }

Modified: branches/gmc/src/memory.c
==============================================================================
--- branches/gmc/src/memory.c   (original)
+++ branches/gmc/src/memory.c   Sat Aug 13 17:21:09 2005
@@ -114,6 +114,13 @@ mem__sys_realloc(void *from, size_t size
 #ifdef DETAIL_MEMORY_DEBUG
     printf("Freed %p (realloc -- %i bytes)\n", from, size);
 #endif
+    /* XXX: DON'T LOOK !!! */
+    if (from == 0x0832b8c8)
+    {
+       fprintf (stderr, "PROUT!\n");
+       from = NULL;
+       *(int*)from = 54;
+    }
     ptr = realloc(from, size);
     if (!ptr)
          PANIC("Out of mem");

Modified: branches/gmc/src/pmc.c
==============================================================================
--- branches/gmc/src/pmc.c      (original)
+++ branches/gmc/src/pmc.c      Sat Aug 13 17:21:09 2005
@@ -103,7 +103,12 @@ pmc_reuse(Interp *interpreter, PMC *pmc,
     }
 
     /* Do we have an extension area? */
-    if (PObj_is_PMC_EXT_TEST(pmc) && pmc->pmc_ext) {
+#if ! PARROT_GC_GMC
+    if (PObj_is_PMC_EXT_TEST(pmc) && pmc->pmc_ext)
+#else
+    if (PObj_is_PMC_EXT_TEST(pmc) && Gmc_has_PMC_EXT_TEST(pmc))
+#endif
+    {
         has_ext = 1;
     }
 
@@ -112,20 +117,36 @@ pmc_reuse(Interp *interpreter, PMC *pmc,
 
         if (!has_ext) {
             /* If we need an ext area, go allocate one */
+#if PARROT_GC_GMC
+           Gmc_PMC_flag_SET(has_ext,pmc);
+#else
             add_pmc_ext(interpreter, pmc);
+#endif
         }
         new_flags = PObj_is_PMC_EXT_FLAG;
     }
     else {
         if (has_ext) {
+#if PARROT_GC_GMC
+           mem_sys_free(PMC_data(pmc));
+#else
             /* if the PMC has a PMC_EXT structure,
              * return it to the pool/arena
              */
             struct Small_Object_Pool *ext_pool =
                 interpreter->arena_base->pmc_ext_pool;
             ext_pool->add_free_object(interpreter, ext_pool, pmc->pmc_ext);
+#endif
         }
+#if PARROT_GC_GMC
+       Gmc_PMC_flag_CLEAR(has_ext,pmc);
+       PMC_metadata(pmc) = NULL;
+       PMC_sync(pmc) = NULL;
+       PMC_next_for_GC(pmc) = NULL;
+       PMC_data(pmc) = NULL;
+#else
         pmc->pmc_ext = NULL;
+#endif
 #if ! PMC_DATA_IN_EXT
         PMC_data(pmc) = NULL;
 #endif
@@ -437,6 +458,10 @@ create_class_pmc(Interp *interpreter, IN
      */
     class = get_new_pmc_header(interpreter, type, PObj_constant_FLAG);
     if (PObj_is_PMC_EXT_TEST(class)) {
+#if PARROT_GC_GMC
+       if (Gmc_has_PMC_EXT_TEST(class))
+           mem_sys_free(PMC_data(class));
+#else
         /* if the PMC has a PMC_EXT structure,
          * return it to the pool/arena
          * we don't need it - basically only the vtable is important
@@ -445,8 +470,18 @@ create_class_pmc(Interp *interpreter, IN
             interpreter->arena_base->pmc_ext_pool;
         ext_pool->add_free_object(interpreter, ext_pool,
                 class->pmc_ext);
+#endif
     }
+#if PARROT_GC_GMC
+    Gmc_PMC_flag_CLEAR(has_ext,class);
+    PMC_metadata(class) = NULL;
+    PMC_sync(class) = NULL;
+    PMC_next_for_GC(class) = NULL;
+    PMC_data(class) = NULL;
+#else
     class->pmc_ext = NULL;
+#endif
+    
     DOD_flag_CLEAR(is_special_PMC, class);
     PMC_pmc_val(class)   = (void*)0xdeadbeef;
     PMC_struct_val(class)= (void*)0xdeadbeef;

Modified: branches/gmc/src/pmc_freeze.c
==============================================================================
--- branches/gmc/src/pmc_freeze.c       (original)
+++ branches/gmc/src/pmc_freeze.c       Sat Aug 13 17:21:09 2005
@@ -570,7 +570,11 @@ static void
 pmc_add_ext(Parrot_Interp interpreter, PMC *pmc)
 {
     if (pmc->vtable->flags & VTABLE_PMC_NEEDS_EXT)
+#if PARROT_GC_GMC
+       Gmc_PMC_flag_SET(has_ext,pmc);
+#else
         add_pmc_ext(interpreter, pmc);
+#endif
 }
 
 /*
@@ -613,11 +617,19 @@ cleanup_next_for_GC_pool(Parrot_Interp i
             else
                 nm += 4;
             if (!(*dod_flags & (PObj_on_free_list_FLAG << nm)))
+#if PARROT_GC_GMC
+               if (Gmc_has_PMC_EXT_TEST(p))
+#else
                 if (p->pmc_ext)
+#endif
                     PMC_next_for_GC(p) = NULL;
 #else
             if (!PObj_on_free_list_TEST(p)) {
+#if PARROT_GC_GMC
+               if (Gmc_has_PMC_EXT_TEST(p))
+#else
                 if (p->pmc_ext)
+#endif
                     PMC_next_for_GC(p) = NULL;
             }
 #endif
@@ -1007,7 +1019,11 @@ do_thaw(Parrot_Interp interpreter, PMC* 
     }
     list_assign(interpreter, PMC_data(info->id_list), id, pmc, enum_type_PMC);
     /* remember nested aggregates depth first */
+#if PARROT_GC_GMC
+    if (Gmc_has_PMC_EXT_TEST(pmc))
+#else
     if (pmc->pmc_ext)
+#endif
         list_unshift(interpreter, PMC_data(info->todo), pmc, enum_type_PMC);
 }
 
@@ -1109,7 +1125,12 @@ Remembers the PMC for later processing.
 static void
 add_pmc_next_for_GC(Parrot_Interp interpreter, PMC *pmc, visit_info *info)
 {
-    if (pmc->pmc_ext) {
+#if PARROT_GC_GMC
+    if (Gmc_has_PMC_EXT_TEST(pmc))
+#else
+    if (pmc->pmc_ext)
+#endif
+    {
         PMC_next_for_GC(info->mark_ptr) = pmc;
         info->mark_ptr = PMC_next_for_GC(pmc) = pmc;
     }
@@ -1144,7 +1165,12 @@ next_for_GC_seen(Parrot_Interp interpret
      * we can only remember PMCs with a next_for_GC pointer
      * which is located in pmc_ext
      */
-    if (pmc->pmc_ext) {
+#if PARROT_GC_GMC
+    if (Gmc_has_PMC_EXT_TEST(pmc))
+#else
+    if (pmc->pmc_ext)
+#endif
+    {
         /* already seen? */
         if (PMC_next_for_GC(pmc)) {
             seen = 1;
@@ -1207,7 +1233,11 @@ todo_list_seen(Parrot_Interp interpreter
     *id = info->id;
     hash_put(interpreter, PMC_struct_val(info->seen), pmc, (void*)*id);
     /* remember containers */
+#if PARROT_GC_GMC
+    if (Gmc_has_PMC_EXT_TEST(pmc))
+#else
     if (pmc->pmc_ext)
+#endif
         list_unshift(interpreter, PMC_data(info->todo), pmc, enum_type_PMC);
     return 0;
 }
@@ -1310,7 +1340,12 @@ visit_loop_next_for_GC(Parrot_Interp int
     PMC *prev = NULL;
 
     visit_next_for_GC(interpreter, current, info);
-    if (current->pmc_ext) {
+#if PARROT_GC_GMC
+    if (Gmc_has_PMC_EXT_TEST(current))
+#else
+    if (current->pmc_ext)
+#endif
+    {
         for ( ; current != prev; current = PMC_next_for_GC(current)) {
             VTABLE_visit(interpreter, current, info);
             prev = current;

Reply via email to