Ticket #980: gc-refactor.patch

File gc-refactor.patch, 33.0 KB (added by jrtayloriv, 12 years ago)

remove weird gc.t thing, and move important stuff to top for readability

  • include/parrot/interpreter.h

     
    212212    int n_free_slots;               /* amount of allocated */ 
    213213} context_mem; 
    214214 
    215  
    216215struct _handler_node_t; /* forward def - exit.h */ 
    217216 
    218217/* The actual interpreter structure */ 
     
    222221    struct Arenas *arena_base;                /* Pointer to this interpreter's 
    223222                                               * arena */ 
    224223 
     224    struct GC_Subsystem *gc_sys;              /*functions and data specific  
     225                                                  to current GC subsystem*/ 
     226 
     227    PMC *gc_registry;                         /* root set of registered PMCs */ 
     228 
    225229    PMC     *class_hash;                      /* Hash of classes */ 
    226230    VTABLE **vtables;                         /* array of vtable ptrs */ 
    227231    int      n_vtable_max;                    /* highest used type */ 
     
    293297    /* 8:   PMC *PBC_Libs                Hash of load_bytecode cde */ 
    294298    /* 9:   PMC *Executable              String PMC with name from argv[0]. */ 
    295299 
    296     PMC *gc_registry;                         /* root set of registered PMCs */ 
    297300 
    298301    PMC *HLL_info;                            /* HLL names and types */ 
    299302    PMC *HLL_namespace;                       /* cache of HLL toplevel ns */ 
     
    324327 
    325328    UINTVAL recursion_limit;                  /* Sub call resursion limit */ 
    326329 
    327     UINTVAL gc_generation;                    /* GC generation number */ 
    328330 
    329331    opcode_t *current_args;                   /* ptr into code w/ set_args op */ 
    330332    opcode_t *current_params;                 /* ... w/ get_params op */ 
  • src/gc/api.c

     
    198198    /* TODO: Have each core register a ->pobject_lives function pointer in the 
    199199       Arenas struct, and call that pointer directly instead of having a messy 
    200200       set of #if preparser conditions. */ 
    201 #if PARROT_GC_GMS 
    202     do { 
    203         if (!PObj_live_TEST(obj) && \ 
    204                 PObj_to_GMSH(obj)->gen->gen_no >= interp->gc_generation) \ 
    205             parrot_gc_gms_Parrot_gc_mark_PObj_alive(interp, obj); \ 
    206     } while (0); 
    207 #else /* not PARROT_GC_GMS */ 
    208201 
    209     /* if object is live or on free list return */ 
    210     if (PObj_is_live_or_free_TESTALL(obj)) 
    211         return; 
    212  
     202    if (interp->gc_sys->sys_type == GMS) { 
     203        /* 
     204        do { 
     205            if (!PObj_live_TEST(obj) &&   
     206                 PObj_to_GMSH(obj)->gen->gen_no >= 
     207                 interp->gc_sys->gc_sys_data.gms_data->gc_generation)  
     208                parrot_gc_gms_Parrot_gc_mark_PObj_alive(interp, obj); 
     209        } while (0); 
     210        break; 
     211        */ 
     212    } 
     213    else { 
     214        /* if object is live or on free list return */ 
     215        if (PObj_is_live_or_free_TESTALL(obj)) 
     216            return; 
     217         
    213218#  if ! DISABLE_GC_DEBUG 
    214219#    if GC_VERBOSE 
    215     if (CONSERVATIVE_POINTER_CHASING) 
    216         fprintf(stderr, "GC Warning! Unanchored %s %p found in system areas \n", 
    217                 PObj_is_PMC_TEST(obj) ? "PMC" : "Buffer", obj); 
    218  
     220        if (CONSERVATIVE_POINTER_CHASING) 
     221            fprintf(stderr, "GC Warning! Unanchored %s %p found in system areas \n", 
     222                    PObj_is_PMC_TEST(obj) ? "PMC" : "Buffer", obj); 
     223         
    219224#    endif 
    220225#  endif 
    221     /* mark it live */ 
    222     PObj_live_SET(obj); 
    223  
    224     /* if object is a PMC and contains buffers or PMCs, then attach the PMC 
    225      * to the chained mark list. */ 
    226     if (PObj_is_PMC_TEST(obj)) { 
    227         PMC * const p = (PMC *)obj; 
    228  
    229         if (PObj_is_special_PMC_TEST(obj)) 
    230             mark_special(interp, p); 
    231  
    232         else if (PMC_metadata(p)) 
    233             Parrot_gc_mark_PObj_alive(interp, (PObj*)PMC_metadata(p)); 
    234     } 
     226        /* mark it live */ 
     227        PObj_live_SET(obj); 
     228         
     229        /* if object is a PMC and contains buffers or PMCs, then attach the PMC 
     230         * to the chained mark list. */ 
     231        if (PObj_is_PMC_TEST(obj)) { 
     232            PMC * const p = (PMC *)obj; 
     233             
     234            if (PObj_is_special_PMC_TEST(obj)) 
     235                mark_special(interp, p); 
     236             
     237            else if (PMC_metadata(p)) 
     238                Parrot_gc_mark_PObj_alive(interp, (PObj*)PMC_metadata(p)); 
     239        } 
    235240#  if GC_VERBOSE 
    236     /* buffer GC_DEBUG stuff */ 
    237     if (GC_DEBUG(interp) && PObj_report_TEST(obj)) 
    238         fprintf(stderr, "GC: buffer %p pointing to %p marked live\n", 
    239                 obj, Buffer_bufstart((Buffer *)obj)); 
     241        /* buffer GC_DEBUG stuff */ 
     242        if (GC_DEBUG(interp) && PObj_report_TEST(obj)) 
     243            fprintf(stderr, "GC: buffer %p pointing to %p marked live\n", 
     244                    obj, Buffer_bufstart((Buffer *)obj)); 
    240245#  endif 
    241 #endif  /* PARROT_GC_GMS */ 
     246    } 
    242247} 
    243248 
    244249/* 
     
    268273 
    269274    interp->lo_var_ptr = stacktop; 
    270275 
    271 #if PARROT_GC_MS 
    272     Parrot_gc_ms_init(interp); 
    273 #endif 
    274 #if PARROT_GC_IMS 
    275     Parrot_gc_ims_init(interp); 
    276 #endif 
    277 #if PARROT_GC_GMS 
    278     Parrot_gc_gms_init(interp); 
    279 #endif 
    280 #if PARROT_GC_INF 
    281     Parrot_gc_inf_init(interp); 
    282 #endif 
     276    interp->gc_sys = mem_allocate_zeroed_typed(GC_Subsystem); 
    283277 
     278    /*JT: This is set at compile time ... what we need to do next is  
     279     *    add a command-line switch --gc that will enable us to choose 
     280     *    a different one ... if --gc is set, we use it, otherwise use 
     281     *    the default  */   
     282    interp->gc_sys->sys_type = PARROT_GC_DEFAULT_TYPE; 
     283 
     284    /* Set the sys_type here if we got a --gc command line switch 
     285     * ... we need some sort of set_gc_sys_type_from_command_line_switch()  
     286     * function ... 
     287     */ 
     288 
     289    /*Call appropriate initialization function for GC subsystem*/ 
     290    switch(interp->gc_sys->sys_type) { 
     291      case MS: 
     292        Parrot_gc_ms_init(interp); 
     293        break; 
     294      /* These currently don't work 
     295      case IMS: 
     296        Parrot_gc_ims_init(interp); 
     297        break; 
     298      case GMS: 
     299        Parrot_gc_gms_init(interp); 
     300        break; 
     301      case INF: 
     302        Parrot_gc_inf_init(interp); 
     303        break;   
     304       */ 
     305      default: 
     306        break;  /*What SHOULD we be doing if we get here?*/ 
     307    } 
     308 
    284309    initialize_memory_pools(interp); 
    285310    initialize_header_pools(interp); 
    286311} 
     
    525550    Buffer_bufstart(buffer) = NULL; 
    526551    Buffer_buflen(buffer)   = 0; 
    527552 
    528     if (pool->object_size - GC_HEADER_SIZE > sizeof (Buffer)) 
     553    if (pool->object_size - interp->gc_sys->header_size > sizeof (Buffer)) 
    529554        memset(buffer + 1, 0, 
    530                 pool->object_size - sizeof (Buffer) - GC_HEADER_SIZE); 
     555                pool->object_size - sizeof (Buffer) - interp->gc_sys->header_size); 
    531556 
    532557    return buffer; 
    533558} 
     
    954979    const UINTVAL       object_size = pool->object_size; 
    955980 
    956981    for (cur_arena = pool->last_Arena; cur_arena; cur_arena = cur_arena->prev) { 
    957         PMC   *p = (PMC *)((char*)cur_arena->start_objects + GC_HEADER_SIZE); 
     982        PMC   *p = (PMC *)((char*)cur_arena->start_objects + dest_interp->gc_sys->header_size); 
    958983        size_t i; 
    959984 
    960985        for (i = 0; i < cur_arena->used; i++) { 
     
    11851210Parrot_gc_ptr_is_pmc(PARROT_INTERP, ARGIN(void *ptr)) 
    11861211{ 
    11871212    ASSERT_ARGS(Parrot_gc_ptr_is_pmc) 
    1188     return contained_in_pool(interp->arena_base->pmc_pool, ptr) || 
    1189            contained_in_pool(interp->arena_base->constant_pmc_pool, ptr); 
     1213        return contained_in_pool(interp, interp->arena_base->pmc_pool, ptr) || 
     1214        contained_in_pool(interp, interp->arena_base->constant_pmc_pool, ptr); 
    11901215} 
    11911216 
    11921217/* 
     
    12081233    Small_Object_Arena *arena; 
    12091234    Small_Object_Pool *pool; 
    12101235 
    1211     pmc = (PMC*)PObj_to_ARENA(pmc); 
     1236    if (interp->gc_sys->PObj_to_Arena){ 
     1237        pmc = (PMC*) interp->gc_sys->PObj_to_Arena(pmc); 
     1238    } 
    12121239    pool = interp->arena_base->pmc_pool; 
    12131240    for (arena = pool->last_Arena; arena; arena = arena->prev) { 
    12141241        const ptrdiff_t ptr_diff = (ptrdiff_t)pmc - (ptrdiff_t)arena->start_objects; 
     
    15851612} 
    15861613 
    15871614/* 
     1615=item C<void Parrot_gc_write_barrier(PARROT_INTERP, PMC *agg, PMC *old, PMC 
     1616*new)> 
    15881617 
     1618Wrapper around write_barrier hook for currently active GC system ... 
     1619 
     1620=cut 
     1621 
     1622*/ 
     1623 
     1624void  
     1625Parrot_gc_write_barrier(PARROT_INTERP, PMC *agg, PMC *old, PMC *new){ 
     1626    interp->gc_sys->write_barrier(interp, agg, old, new); 
     1627} 
     1628 
     1629/* 
     1630=item C<void Parrot_gc_write_barrier_key(PARROT_INTERP, PMC *agg, PMC *old, PObj 
     1631*old_key, PMC *_new, PObj *new_key)> 
     1632 
     1633Wrapper around write_barrier_key hook for currently active GC system ... 
     1634 
     1635=cut 
     1636 
     1637*/ 
     1638 
     1639void  
     1640Parrot_gc_write_barrier_key(PARROT_INTERP, PMC *agg, PMC *old, PObj *old_key, PMC *_new, PObj *new_key){ 
     1641    interp->gc_sys->write_barrier_key(interp, agg, old, old_key, _new, new_key); 
     1642} 
     1643 
     1644 
     1645/* 
     1646 
    15891647=item C<void * Parrot_gc_allocate_pmc_attributes(PARROT_INTERP, PMC *pmc, size_t 
    15901648size)> 
    15911649 
  • include/parrot/gc_api.h

     
    8989typedef void (*alloc_objects_fn_type)(PARROT_INTERP, struct Small_Object_Pool *); 
    9090typedef void (*gc_object_fn_type)(PARROT_INTERP, struct Small_Object_Pool *, PObj *); 
    9191 
    92 /* 
    93  * macros used in arena scan code to convert from object pointers 
    94  * to arena pointers ... 
    95  */ 
    9692 
    97 #if PARROT_GC_GMS 
    98 #  define GC_HEADER_SIZE (sizeof (Gc_gms_hdr)) 
    99 #  define PObj_to_ARENA(o) PObj_to_GMSH(o) 
    100 #  define ARENA_to_PObj(p) GMSH_to_PObj((Gc_gms_hdr*)(p)) 
    101 #else 
    102 #  define GC_HEADER_SIZE 0 
    103 #  define PObj_to_ARENA(o) (o) 
    104 #  define ARENA_to_PObj(p) (p) 
    105 #endif 
    106  
    10793/* &gen_from_enum(interpinfo.pasm) prefix(INTERPINFO_) */ 
    10894 
    10995typedef enum { 
     
    357343int Parrot_gc_total_sized_buffers(PARROT_INTERP) 
    358344        __attribute__nonnull__(1); 
    359345 
     346void  Parrot_gc_write_barrier(PARROT_INTERP, PMC *agg, PMC *old, PMC *new) 
     347        __attribute__nonnull__(1); 
     348 
     349void  Parrot_gc_write_barrier_key(PARROT_INTERP, 
     350    PMC *agg, 
     351    PMC *old, 
     352    PObj *old_key, 
     353    PMC *_new, 
     354    PObj *new_key) 
     355        __attribute__nonnull__(1); 
     356 
    360357#define ASSERT_ARGS_Parrot_block_GC_mark __attribute__unused__ int _ASSERT_ARGS_CHECK = \ 
    361358       PARROT_ASSERT_ARG(interp) 
    362359#define ASSERT_ARGS_Parrot_block_GC_sweep __attribute__unused__ int _ASSERT_ARGS_CHECK = \ 
     
    489486       PARROT_ASSERT_ARG(interp) 
    490487#define ASSERT_ARGS_Parrot_gc_total_sized_buffers __attribute__unused__ int _ASSERT_ARGS_CHECK = \ 
    491488       PARROT_ASSERT_ARG(interp) 
     489#define ASSERT_ARGS_Parrot_gc_write_barrier __attribute__unused__ int _ASSERT_ARGS_CHECK = \ 
     490       PARROT_ASSERT_ARG(interp) 
     491#define ASSERT_ARGS_Parrot_gc_write_barrier_key __attribute__unused__ int _ASSERT_ARGS_CHECK = \ 
     492       PARROT_ASSERT_ARG(interp) 
    492493/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */ 
    493494/* HEADERIZER END: src/gc/api.c */ 
    494495 
    495496void Parrot_gc_inf_init(PARROT_INTERP); 
    496497 
    497 /* write barrier */ 
    498 #if PARROT_GC_MS 
    499 #  define GC_WRITE_BARRIER(interp, agg, old, _new) do { } while (0) 
    500 #  define GC_WRITE_BARRIER_KEY(interp, agg, old, old_key, _new, new_key) do { } while (0) 
    501 #endif 
    502  
    503 #if PARROT_GC_GMS 
    504 #  define GC_WRITE_BARRIER(interp, agg, old, _new) do { \ 
    505     UINTVAL gen_agg, gen_new; \ 
    506     if (!(_new) || PMC_IS_NULL(_new)) \ 
    507         break; \ 
    508     gen_agg = PObj_to_GMSH(agg)->gen->gen_no; \ 
    509     gen_new = PObj_to_GMSH(_new)->gen->gen_no; \ 
    510     if (gen_agg < gen_new) \ 
    511         parrot_gc_gms_wb((interp), (agg), (old), (_new)); \ 
    512 } while (0) 
    513  
    514 #  define GC_WRITE_BARRIER_KEY(interp, agg, old, old_key, _new, new_key) do { \ 
    515     UINTVAL gen_agg, gen_new, gen_key; \ 
    516     if (!(_new) || PMC_IS_NULL(_new)) \ 
    517         break; \ 
    518     gen_agg = PObj_to_GMSH(agg)->gen->gen_no; \ 
    519     gen_new = PObj_to_GMSH(_new)->gen->gen_no; \ 
    520     gen_key = PObj_to_GMSH(new_key)->gen->gen_no; \ 
    521     if (gen_agg < gen_new || gen_agg < gen_key) \ 
    522         parrot_gc_gms_wb_key((interp), (agg), (old), (old_key), (_new), (new_key)); \ 
    523 } while (0) 
    524  
    525 #endif 
    526  
    527 #if PARROT_GC_INF 
    528 #  define GC_WRITE_BARRIER(interp, agg, old, _new) do { } while (0) 
    529 #  define GC_WRITE_BARRIER_KEY(interp, agg, old, old_key, _new, new_key) do { } while (0) 
    530 #endif 
    531  
    532498#endif /* PARROT_GC_API_H_GUARD */ 
    533499 
    534500/* 
  • src/gc/alloc_resources.c

     
    417417        for (cur_buffer_arena = header_pool->last_Arena; 
    418418                cur_buffer_arena; 
    419419                cur_buffer_arena = cur_buffer_arena->prev) { 
    420             Buffer *b = (Buffer *)ARENA_to_PObj(cur_buffer_arena->start_objects); 
     420            /*JT: Something like this is what we really want ...  
     421             *JT: if only I knew how to program C ... 
     422            if (interp->gc_sys->Arena_to_PObj){ 
     423                Buffer *b =  
     424                    (Buffer *)  
     425                    interp->gc_sys->Arena_to_PObj(cur_buffer_arena->start_objects); 
     426            } 
     427            */ 
     428 
     429            /*JT: but for now, we'll just cheat, since it's only GMS  
     430                  that needs that stuff anyway*/ 
     431            Buffer *b = (Buffer *) cur_buffer_arena->start_objects; 
    421432            UINTVAL i; 
    422433            const size_t objects_end = cur_buffer_arena->used; 
    423434 
  • src/gc/gc_private.h

     
    1717#define PARROT_GC_PRIVATE_H_GUARD 
    1818 
    1919#include "parrot/settings.h" 
     20#include "generational_ms.h" 
    2021 
     22 
    2123#if ! DISABLE_GC_DEBUG 
    2224/* Set when walking the system stack. Defined in src/gc/system.c */ 
    2325extern int CONSERVATIVE_POINTER_CHASING; 
     
    8284    struct GC_MS_PObj_Wrapper * next_ptr; 
    8385} GC_MS_PObj_Wrapper; 
    8486 
     87 
     88typedef enum _gc_sys_type_enum { 
     89    MS,  /*mark and sweep*/ 
     90    IMS, /*incremental mark and sweep*/ 
     91    GMS, /*generational mark and sweep*/ 
     92    INF /*infinite memory core*/ 
     93} gc_sys_type_enum; 
     94 
     95typedef struct GC_Subsystem { 
     96    gc_sys_type_enum sys_type;  /* Which GC subsystem are we using? */ 
     97 
     98    union {                     /* Holds system-specific data structures*/ 
     99        struct gc_gms_sys_data gms_data; 
     100    } gc_sys_data; 
     101 
     102    /*Function hooks that GC systems can choose if they want 
     103     *These will be called from the GC API function  */ 
     104    void (*write_barrier)(PARROT_INTERP, PMC *, PMC *, PMC *); 
     105    void (*write_barrier_key)(PARROT_INTERP, PMC *, PMC *, PObj *, PMC *, PObj *); 
     106 
     107    /* functions used in arena scan code to convert from object pointers 
     108     * to arena pointers ... GMS only I think ...*/ 
     109 
     110    void * (*PObj_to_Arena)(const void *); 
     111    PObj * (*Arena_to_PObj)(void *); 
     112 
     113    /*JT: this is only used by GMS afaict, but we'll keep it here for now ...*/ 
     114    size_t header_size; 
     115} GC_Subsystem; 
     116 
    85117typedef struct Small_Object_Arena { 
    86118    size_t                     used; 
    87119    size_t                     total_objects; 
     
    99131    struct PMC_Attribute_Arena * prev; 
    100132} PMC_Attribute_Arena; 
    101133 
    102 #if PARROT_GC_GMS 
    103 /* 
    104  * all objects have this header in front of the actual 
    105  * object pointer. The prev/next pointers chain all existing 
    106  * objects for one pool (sizeclass) together. 
    107  * 
    108  * XXX this could lead to unaligned FLOATVALs in the adjacent PMC 
    109  *     if that's true either insert a dummy or reorder PMC members 
    110  *     ??? How is that possible? 
    111  */ 
    112 typedef struct _gc_gms_hdr { 
    113     struct _gc_gms_hdr *prev; 
    114     struct _gc_gms_hdr *next; 
    115     struct _gc_gms_gen *gen; 
    116     void *gc_dummy_align;       /* see above */ 
    117 } Gc_gms_hdr; 
    118  
    119 #  define PObj_to_GMSH(o) (((Gc_gms_hdr*)(o))-1) 
    120 #  define GMSH_to_PObj(p) ((PObj*) ((p)+1)) 
    121  
    122 /* the structure uses 2 ptrs itself */ 
    123 #  define GC_GMS_STORE_SIZE (64-2) 
    124  
    125 typedef struct _gc_gms_hdr_store { 
    126     struct _gc_gms_hdr_store *next; 
    127     Gc_gms_hdr **ptr;                           /* insert location */ 
    128     Gc_gms_hdr * (store[GC_GMS_STORE_SIZE]);    /* array of hdr pointers */ 
    129 } Gc_gms_hdr_store; 
    130  
    131 typedef struct _gc_gms_hdr_list { 
    132     Gc_gms_hdr_store *first; 
    133     Gc_gms_hdr_store *last; 
    134 } Gc_gms_hdr_list; 
    135  
    136  
    137 /* 
    138  * all objects belong to one generation 
    139  */ 
    140 typedef struct _gc_gms_gen { 
    141     UINTVAL gen_no;                     /* generation number */ 
    142     UINTVAL timely_destruct_obj_sofar;  /* sum up to this generation */ 
    143     UINTVAL black_color;                /* live color of this generation */ 
    144     struct _gc_gms_hdr *first;          /* first header in this generation */ 
    145     struct _gc_gms_hdr *last;           /* last header in this generation */ 
    146     struct _gc_gms_hdr *fin;            /* need destruction/finalization */ 
    147     struct Small_Object_Pool *pool;     /* where this generation belongs to */ 
    148     Gc_gms_hdr_list igp;                /* IGPs for this generation */ 
    149     UINTVAL n_possibly_dead;            /* overwritten count */ 
    150     UINTVAL n_objects;                  /* live objects count */ 
    151     struct _gc_gms_gen *prev; 
    152     struct _gc_gms_gen *next; 
    153 } Gc_gms_gen; 
    154  
    155 #endif /* PARROT_GC_GMS */ 
    156  
    157134typedef struct PMC_Attribute_Pool { 
    158135    size_t attr_size; 
    159136    size_t total_objects; 
     
    181158    int skip; 
    182159    size_t replenish_level; 
    183160    GC_MS_PObj_Wrapper * free_list; 
    184     /* adds a free object to the pool's free list  */ 
    185     add_free_object_fn_type     add_free_object; 
    186     get_free_object_fn_type     get_free_object; 
    187     alloc_objects_fn_type       alloc_objects; 
     161 
     162     
     163    add_free_object_fn_type     add_free_object; /* adds a free object to  
     164                                                    the pool's free list  */ 
     165    get_free_object_fn_type     get_free_object; /* gets and removes a free  
     166                                                    object from the pool's  
     167                                                    free list */ 
     168    alloc_objects_fn_type       alloc_objects;  /* allocates more objects */ 
    188169    alloc_objects_fn_type       more_objects; 
    189170    gc_object_fn_type           gc_object; 
    190     /* gets and removes a free object from the pool's free list */ 
    191     /* allocates more objects */ 
     171 
     172 
     173     
    192174    struct Memory_Pool *mem_pool; 
    193175    size_t start_arena_memory; 
    194176    size_t end_arena_memory; 
    195177    PARROT_OBSERVER const char *name; 
     178 
     179    /*Contains GC system-specific data structures*/ 
     180    union { 
     181        struct gc_gms_smallobjpool_data *gms; /*generational mark and sweep*/ 
     182    } gc_sys_priv_data; 
     183 
    196184#if GC_USE_LAZY_ALLOCATOR 
    197185    void *newfree; 
    198186    void *newlast; 
    199187#endif 
    200 #if PARROT_GC_GMS 
    201     struct _gc_gms_hdr marker;          /* limit of list */ 
    202     struct _gc_gms_hdr *black;          /* alive */ 
    203     struct _gc_gms_hdr *black_fin;      /* alive, needs destruction */ 
    204     struct _gc_gms_hdr *gray;           /* to be scanned */ 
    205     struct _gc_gms_hdr *white;          /* unprocessed */ 
    206     struct _gc_gms_hdr *white_fin;      /* unprocesse, needs destruction */ 
    207188 
    208     struct _gc_gms_gen *first_gen;      /* linked list of generations */ 
    209     struct _gc_gms_gen *last_gen; 
    210  
    211 #endif 
    212189} Small_Object_Pool; 
    213190 
    214191typedef struct Arenas { 
     
    368345/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */ 
    369346 
    370347PARROT_WARN_UNUSED_RESULT 
    371 INTVAL contained_in_pool( 
     348INTVAL contained_in_pool(PARROT_INTERP, 
    372349    ARGIN(const Small_Object_Pool *pool), 
    373350    ARGIN(const void *ptr)) 
    374351        __attribute__nonnull__(1) 
    375         __attribute__nonnull__(2); 
     352        __attribute__nonnull__(2) 
     353        __attribute__nonnull__(3); 
    376354 
    377355PARROT_WARN_UNUSED_RESULT 
    378356PARROT_CANNOT_RETURN_NULL 
     
    461439        __attribute__nonnull__(1); 
    462440 
    463441#define ASSERT_ARGS_contained_in_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \ 
    464        PARROT_ASSERT_ARG(pool) \ 
     442       PARROT_ASSERT_ARG(interp) \ 
     443    || PARROT_ASSERT_ARG(pool) \ 
    465444    || PARROT_ASSERT_ARG(ptr) 
    466445#define ASSERT_ARGS_get_bufferlike_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \ 
    467446       PARROT_ASSERT_ARG(interp) 
  • src/gc/system.c

     
    489489 
    490490    for (i = 0; i < arena_base->num_sized; i++) { 
    491491        if (arena_base->sized_header_pools[i] 
    492         &&  contained_in_pool(arena_base->sized_header_pools[i], ptr)) 
     492            &&  contained_in_pool(interp, arena_base->sized_header_pools[i], ptr)) 
    493493            return 1; 
    494494    } 
    495495 
     
    512512is_pmc_ptr(PARROT_INTERP, ARGIN(const void *ptr)) 
    513513{ 
    514514    ASSERT_ARGS(is_pmc_ptr) 
    515     return contained_in_pool(interp->arena_base->pmc_pool, ptr); 
     515        return contained_in_pool(interp, interp->arena_base->pmc_pool, ptr); 
    516516} 
    517517 
    518518 
  • include/parrot/settings.h

     
    4444 * Please note that only 0 and 3 currently work (and INF doesn't really 
    4545 * "work"). 
    4646 */ 
    47  
     47#define PARROT_GC_DEFAULT_TYPE MS 
    4848#define PARROT_GC_SUBSYSTEM 0 
    4949 
    5050#if PARROT_GC_SUBSYSTEM == 0 
  • src/hash.c

     
    13041304 
    13051305    if (bucket) { 
    13061306        if (hash->entry_type == enum_type_PMC && hash->container) { 
    1307             GC_WRITE_BARRIER_KEY(interp, hash->container, 
    1308                     (PMC *)bucket->value, bucket->key, (PMC *)value, key); 
     1307         
     1308        /*JT: can't get this to work right now ... 
     1309        if (interp->gc_sys->write_barrier_key) { 
     1310            Parrot_gc_write_barrier_key(interp, 
     1311                                              hash->container, 
     1312                                              (PMC *)bucket->value,  
     1313                                              bucket->key,  
     1314                                              (PMC *)value,  
     1315                                              key); 
    13091316        } 
    1310  
     1317        */ 
     1318        } 
    13111319        bucket->value = value; 
    13121320    } 
    13131321    else { 
    13141322        if (hash->entry_type == enum_type_PMC && hash->container) { 
    1315             GC_WRITE_BARRIER_KEY(interp, hash->container, 
    1316                     NULL, NULL, (PMC *)value, key); 
     1323 
     1324        /*JT: can't get this to work right now ... 
     1325        if (interp->gc_sys->write_barrier_key){ 
     1326            Parrot_gc_write_barrier_key(interp,  
     1327                                              hash->container, 
     1328                                              NULL,  
     1329                                              NULL,  
     1330                                              (PMC *)value,  
     1331                                              key); 
    13171332        } 
    1318  
     1333        */ 
     1334        } 
    13191335        bucket = hash->free_list; 
    13201336 
    13211337        if (!bucket) { 
     
    14221438                    "hash corruption: type = %d\n", hash->entry_type); 
    14231439        }; 
    14241440 
    1425         if (key) 
     1441        if (key){ 
    14261442            parrot_hash_put(interp, dest, key, valtmp); 
     1443        } 
    14271444    } 
    14281445} 
    14291446 
  • src/gc/gc_ms.c

     
    128128    arena_base->do_gc_mark         = gc_ms_mark_and_sweep; 
    129129    arena_base->finalize_gc_system = NULL; 
    130130    arena_base->init_pool          = gc_ms_pool_init; 
     131 
    131132} 
    132133 
    133134/* 
  • src/gc/mark_sweep.c

     
    352352 
    353353/* 
    354354 
    355 =item C<INTVAL contained_in_pool(const Small_Object_Pool *pool, const void 
    356 *ptr)> 
     355=item C<INTVAL contained_in_pool(PARROT_INTERP, const Small_Object_Pool *pool, 
     356const void *ptr)> 
    357357 
    358358Returns whether the given C<*ptr> points to a location in C<pool>. 
    359359 
     
    363363 
    364364PARROT_WARN_UNUSED_RESULT 
    365365INTVAL 
    366 contained_in_pool(ARGIN(const Small_Object_Pool *pool), ARGIN(const void *ptr)) 
     366contained_in_pool(PARROT_INTERP, ARGIN(const Small_Object_Pool *pool), ARGIN(const void *ptr)) 
    367367{ 
    368368    ASSERT_ARGS(contained_in_pool) 
    369369    const Small_Object_Arena *arena; 
    370370 
    371     ptr = PObj_to_ARENA(ptr); 
    372  
     371    if (interp->gc_sys->PObj_to_Arena){ 
     372        ptr = interp->gc_sys->PObj_to_Arena(ptr); 
     373    } 
    373374    for (arena = pool->last_Arena; arena; arena = arena->prev) { 
    374375        const ptrdiff_t ptr_diff = 
    375376            (ptrdiff_t)ptr - (ptrdiff_t)arena->start_objects; 
  • src/list.c

     
    384384    memset(Buffer_bufstart((Buffer*)chunk), 0, size); 
    385385 
    386386    /* see also src/hash.c */ 
    387     if (list->container) 
    388         GC_WRITE_BARRIER(interp, list->container, 0, chunk); 
    389  
     387    if (list->container) { 
     388        /*JT: not working now ... GMS only anyway 
     389        if (interp->gc_sys->write_barrier){ 
     390            Parrot_gc_write_barrier(interp, list->container, 0, chunk); 
     391        } 
     392        */ 
     393    } 
    390394    Parrot_unblock_GC_mark(interp); 
    391395 
    392396    /* Parrot_unblock_GC_sweep(interp); */ 
     
    395399 
    396400 
    397401/* 
    398  
     402   
    399403=item C<static void rebuild_chunk_ptrs(List *list, int cut)> 
    400404 
    401405Rebuilds C<list> and updates/optimizes chunk usage. Deletes empty chunks, 
     
    516520                        MAX_ITEMS * list->item_size); 
    517521 
    518522                if (list->container) { 
    519                     GC_WRITE_BARRIER(interp, list->container, 0, prev); 
     523                    /*JT: not working now ... GMS only anyway 
     524                    if (interp->gc_sys->write_barrier){ 
     525                        Parrot_gc_write_barrier(interp, list->container, 0, prev); 
     526                    } 
     527                    */ 
    520528                } 
    521529 
    522530                mem_sys_memmove( 
     
    537545                Parrot_gc_reallocate_buffer_storage(interp, (Buffer *)prev, 
    538546                        (prev->items + chunk->items) * list->item_size); 
    539547                if (list->container) { 
    540                     GC_WRITE_BARRIER(interp, list->container, 0, prev); 
     548                    /*JT: not working now ... GMS only anyway 
     549                    if (interp->gc_sys->write_barrier){ 
     550                        Parrot_gc_write_barrier(interp, list->container, 0, prev); 
     551                    } 
     552                    */ 
    541553                } 
    542554                mem_sys_memmove( 
    543555                        (char *) Buffer_bufstart(&prev->data) + 
     
    637649                len * sizeof (List_chunk *)); 
    638650 
    639651        if (list->container) { 
    640             GC_WRITE_BARRIER(interp, list->container, 0, list); 
     652            /*JT: not working now ... GMS only anyway 
     653            if (interp->gc_sys->write_barrier){ 
     654                Parrot_gc_write_barrier(interp, list->container, 0, list); 
     655            } 
     656            */ 
    641657        } 
    642658 
    643659        list->collect_runs = Parrot_gc_count_collect_runs(interp); 
     
    11361152                chunk->items * list->item_size); 
    11371153 
    11381154        if (list->container) { 
    1139             GC_WRITE_BARRIER(interp, list->container, 0, chunk); 
     1155            /*JT: not working now ... GMS only anyway 
     1156            if (interp->gc_sys->write_barrier){ 
     1157                Parrot_gc_write_barrier(interp, list->container, 0, chunk); 
     1158            } 
     1159            */ 
    11401160        } 
    11411161 
    11421162        chunk->flags |= no_power_2; 
     
    11561176                chunk->items * list->item_size); 
    11571177 
    11581178        if (list->container) { 
    1159             GC_WRITE_BARRIER(interp, list->container, 0, chunk); 
     1179            /*JT: not working now ... GMS only anyway 
     1180            if (interp->gc_sys->write_barrier){ 
     1181                Parrot_gc_write_barrier(interp, list->container, 0, chunk); 
     1182            } 
     1183            */ 
    11601184        } 
    11611185 
    11621186        chunk->flags &= ~sparse; 
     
    12471271        break; 
    12481272    case enum_type_PMC: 
    12491273        if (list->container) { 
    1250             GC_WRITE_BARRIER(interp, list->container, 
    1251                     ((PMC **) Buffer_bufstart(&chunk->data))[idx], 
    1252                     (PMC *)item); 
     1274            /*JT: not working now ... GMS only anyway 
     1275            if (interp->gc_sys->write_barrier){ 
     1276                Parrot_gc_write_barrier(interp,  
     1277                                              list->container,  
     1278                                              ((PMC **) Buffer_bufstart(&chunk->data))[idx], 
     1279                                              (PMC *)item); 
     1280            } 
     1281            */ 
    12531282        } 
    12541283        ((PMC **) Buffer_bufstart(&chunk->data))[idx] = (PMC *)item; 
    12551284        break; 
     
    13331362{ 
    13341363    ASSERT_ARGS(list_append) 
    13351364    /* initially, list may be empty, also used by assign */ 
    1336     while (idx >= list->cap) 
     1365    while (idx >= list->cap){ 
    13371366        add_chunk_at_end(interp, list, idx); 
    1338  
     1367    } 
    13391368    list_set(interp, list, item, type, idx); 
    13401369 
    13411370    /* invariant: prepare for next push */ 
  • src/pmc/resizablepmcarray.pmc

     
    266266            SELF.set_integer_native(key+1); 
    267267 
    268268        data      = PMC_array(SELF); 
    269         GC_WRITE_BARRIER(INTERP, SELF, data[key], src); 
     269        /*JT: not working now ... GMS only anyway 
     270        if (interp->gc_sys->write_barrier){ 
     271            Parrot_gc_write_barrier(INTERP, SELF, data[key], src); 
     272        } 
     273        */ 
     274 
    270275        data[key] = src; 
    271276    } 
    272277 
  • src/pmc/resizablestringarray.pmc

     
    8686            SELF.set_integer_native(key+1); 
    8787 
    8888        GET_ATTR_str_array(INTERP, SELF, str_array); 
    89         GC_WRITE_BARRIER(INTERP, SELF, str_array[key], value); 
     89        /*JT: not working now ... GMS only anyway 
     90        if (interp->gc_sys->write_barrier){ 
     91            Parrot_gc_write_barrier(INTERP, SELF, str_array[key], value); 
     92        } 
     93        */ 
    9094        str_array[key] = value; 
    9195    } 
    9296 
  • src/pmc/fixedpmcarray.pmc

     
    543543                _("FixedPMCArray: index out of bounds!")); 
    544544 
    545545        data      = PMC_array(SELF); 
    546         GC_WRITE_BARRIER(INTERP, SELF, data[key], src); 
     546        /*JT: not working now ... GMS only anyway 
     547        if (interp->gc_sys->write_barrier){ 
     548            Parrot_gc_write_barrier(INTERP, SELF, data[key], src); 
     549        } 
     550        */ 
    547551        data[key] = src; 
    548552    } 
    549553 
  • src/pmc/default.pmc

     
    231231    PMC *prop; 
    232232 
    233233    PMC_metadata(self) = prop = pmc_new(interp, enum_class_Hash); 
    234     GC_WRITE_BARRIER(interp, self, NULL, prop); 
     234    /*JT: not working now ... GMS only anyway 
     235    if (interp->gc_sys->write_barrier){ 
     236        Parrot_gc_write_barrier(interp, self, NULL, prop); 
     237    } 
     238    */ 
    235239    propagate_std_props(interp, self, prop); 
    236240    return prop; 
    237241} 
  • src/pmc/fixedstringarray.pmc

     
    436436                "FixedStringArray: index out of bounds!"); 
    437437 
    438438        GET_ATTR_str_array(INTERP, SELF, str_array); 
    439         GC_WRITE_BARRIER(INTERP, SELF, str_array[key], value); 
     439        /*JT: not working now ... GMS only anyway 
     440        if (interp->gc_sys->write_barrier){ 
     441            Parrot_gc_write_barrier(INTERP, SELF, str_array[key], value); 
     442        } 
     443        */ 
    440444        str_array[key] = value; 
    441445    } 
    442446 
  • src/pmc_freeze.c

     
    13371337#endif 
    13381338        /* 
    13391339         * that's a duplicate 
    1340          if (info->container) 
    1341          GC_WRITE_BARRIER(interp, info->container, NULL, pmc); 
     1340         if (info->container){ 
     1341           if (interp->gc_sys->write_barrier){ 
     1342             Parrot_gc_write_barrier(interp, info->container, NULL, pmc); 
     1343           } 
     1344         } 
    13421345         */ 
    13431346        *info->thaw_ptr = pmc; 
    13441347        return; 
     
    13571360        info->thaw_result = pmc; 
    13581361    else { 
    13591362        if (info->container) { 
    1360             GC_WRITE_BARRIER(interp, info->container, NULL, pmc); 
     1363            /*JT: not working now ... GMS only anyway             
     1364            if (interp->gc_sys->write_barrier){ 
     1365                Parrot_gc_write_barrier(interp, info->container, NULL, pmc); 
     1366            } 
     1367            */ 
    13611368        } 
    13621369        *info->thaw_ptr = pmc; 
    13631370    } 
    13641371    list_assign(interp, (List *)PMC_data(info->id_list), id, pmc, enum_type_PMC); 
     1372 
    13651373    /* remember nested aggregates depth first */ 
    13661374    list_unshift(interp, (List *)PMC_data(info->todo), pmc, enum_type_PMC); 
    13671375} 
    13681376 
    1369  
    13701377/* 
    13711378 
    13721379=item C<static UINTVAL id_from_pmc(PARROT_INTERP, PMC* pmc)> 
  • include/parrot/oo.h

     
    3232#define get_attrib_num(x, y)    ((PMC **)(x))[(y)] 
    3333#define set_attrib_num(o, x, y, z) \ 
    3434    do { \ 
    35         GC_WRITE_BARRIER(interp, (o), ((PMC **)(x))[y], (z)); \ 
     35        Parrot_gc_write_barrier(interp, (o), ((PMC **)(x))[y], (z)); \ 
    3636        ((PMC **)(x))[(y)] = (z); \ 
    3737    } while (0)