Ticket #980: gc-refactor.patch
File gc-refactor.patch, 33.0 KB (added by jrtayloriv, 12 years ago) |
---|
-
include/parrot/interpreter.h
212 212 int n_free_slots; /* amount of allocated */ 213 213 } context_mem; 214 214 215 216 215 struct _handler_node_t; /* forward def - exit.h */ 217 216 218 217 /* The actual interpreter structure */ … … 222 221 struct Arenas *arena_base; /* Pointer to this interpreter's 223 222 * arena */ 224 223 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 225 229 PMC *class_hash; /* Hash of classes */ 226 230 VTABLE **vtables; /* array of vtable ptrs */ 227 231 int n_vtable_max; /* highest used type */ … … 293 297 /* 8: PMC *PBC_Libs Hash of load_bytecode cde */ 294 298 /* 9: PMC *Executable String PMC with name from argv[0]. */ 295 299 296 PMC *gc_registry; /* root set of registered PMCs */297 300 298 301 PMC *HLL_info; /* HLL names and types */ 299 302 PMC *HLL_namespace; /* cache of HLL toplevel ns */ … … 324 327 325 328 UINTVAL recursion_limit; /* Sub call resursion limit */ 326 329 327 UINTVAL gc_generation; /* GC generation number */328 330 329 331 opcode_t *current_args; /* ptr into code w/ set_args op */ 330 332 opcode_t *current_params; /* ... w/ get_params op */ -
src/gc/api.c
198 198 /* TODO: Have each core register a ->pobject_lives function pointer in the 199 199 Arenas struct, and call that pointer directly instead of having a messy 200 200 set of #if preparser conditions. */ 201 #if PARROT_GC_GMS202 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 */208 201 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 213 218 # if ! DISABLE_GC_DEBUG 214 219 # 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 219 224 # endif 220 225 # 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 PMC225 * 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 } 235 240 # 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)); 240 245 # endif 241 #endif /* PARROT_GC_GMS */ 246 } 242 247 } 243 248 244 249 /* … … 268 273 269 274 interp->lo_var_ptr = stacktop; 270 275 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); 283 277 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 284 309 initialize_memory_pools(interp); 285 310 initialize_header_pools(interp); 286 311 } … … 525 550 Buffer_bufstart(buffer) = NULL; 526 551 Buffer_buflen(buffer) = 0; 527 552 528 if (pool->object_size - GC_HEADER_SIZE> sizeof (Buffer))553 if (pool->object_size - interp->gc_sys->header_size > sizeof (Buffer)) 529 554 memset(buffer + 1, 0, 530 pool->object_size - sizeof (Buffer) - GC_HEADER_SIZE);555 pool->object_size - sizeof (Buffer) - interp->gc_sys->header_size); 531 556 532 557 return buffer; 533 558 } … … 954 979 const UINTVAL object_size = pool->object_size; 955 980 956 981 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); 958 983 size_t i; 959 984 960 985 for (i = 0; i < cur_arena->used; i++) { … … 1185 1210 Parrot_gc_ptr_is_pmc(PARROT_INTERP, ARGIN(void *ptr)) 1186 1211 { 1187 1212 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); 1190 1215 } 1191 1216 1192 1217 /* … … 1208 1233 Small_Object_Arena *arena; 1209 1234 Small_Object_Pool *pool; 1210 1235 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 } 1212 1239 pool = interp->arena_base->pmc_pool; 1213 1240 for (arena = pool->last_Arena; arena; arena = arena->prev) { 1214 1241 const ptrdiff_t ptr_diff = (ptrdiff_t)pmc - (ptrdiff_t)arena->start_objects; … … 1585 1612 } 1586 1613 1587 1614 /* 1615 =item C<void Parrot_gc_write_barrier(PARROT_INTERP, PMC *agg, PMC *old, PMC 1616 *new)> 1588 1617 1618 Wrapper around write_barrier hook for currently active GC system ... 1619 1620 =cut 1621 1622 */ 1623 1624 void 1625 Parrot_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 1633 Wrapper around write_barrier_key hook for currently active GC system ... 1634 1635 =cut 1636 1637 */ 1638 1639 void 1640 Parrot_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 1589 1647 =item C<void * Parrot_gc_allocate_pmc_attributes(PARROT_INTERP, PMC *pmc, size_t 1590 1648 size)> 1591 1649 -
include/parrot/gc_api.h
89 89 typedef void (*alloc_objects_fn_type)(PARROT_INTERP, struct Small_Object_Pool *); 90 90 typedef void (*gc_object_fn_type)(PARROT_INTERP, struct Small_Object_Pool *, PObj *); 91 91 92 /*93 * macros used in arena scan code to convert from object pointers94 * to arena pointers ...95 */96 92 97 #if PARROT_GC_GMS98 # 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 #else102 # define GC_HEADER_SIZE 0103 # define PObj_to_ARENA(o) (o)104 # define ARENA_to_PObj(p) (p)105 #endif106 107 93 /* &gen_from_enum(interpinfo.pasm) prefix(INTERPINFO_) */ 108 94 109 95 typedef enum { … … 357 343 int Parrot_gc_total_sized_buffers(PARROT_INTERP) 358 344 __attribute__nonnull__(1); 359 345 346 void Parrot_gc_write_barrier(PARROT_INTERP, PMC *agg, PMC *old, PMC *new) 347 __attribute__nonnull__(1); 348 349 void 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 360 357 #define ASSERT_ARGS_Parrot_block_GC_mark __attribute__unused__ int _ASSERT_ARGS_CHECK = \ 361 358 PARROT_ASSERT_ARG(interp) 362 359 #define ASSERT_ARGS_Parrot_block_GC_sweep __attribute__unused__ int _ASSERT_ARGS_CHECK = \ … … 489 486 PARROT_ASSERT_ARG(interp) 490 487 #define ASSERT_ARGS_Parrot_gc_total_sized_buffers __attribute__unused__ int _ASSERT_ARGS_CHECK = \ 491 488 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) 492 493 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */ 493 494 /* HEADERIZER END: src/gc/api.c */ 494 495 495 496 void Parrot_gc_inf_init(PARROT_INTERP); 496 497 497 /* write barrier */498 #if PARROT_GC_MS499 # 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 #endif502 503 #if PARROT_GC_GMS504 # 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 #endif526 527 #if PARROT_GC_INF528 # 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 #endif531 532 498 #endif /* PARROT_GC_API_H_GUARD */ 533 499 534 500 /* -
src/gc/alloc_resources.c
417 417 for (cur_buffer_arena = header_pool->last_Arena; 418 418 cur_buffer_arena; 419 419 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; 421 432 UINTVAL i; 422 433 const size_t objects_end = cur_buffer_arena->used; 423 434 -
src/gc/gc_private.h
17 17 #define PARROT_GC_PRIVATE_H_GUARD 18 18 19 19 #include "parrot/settings.h" 20 #include "generational_ms.h" 20 21 22 21 23 #if ! DISABLE_GC_DEBUG 22 24 /* Set when walking the system stack. Defined in src/gc/system.c */ 23 25 extern int CONSERVATIVE_POINTER_CHASING; … … 82 84 struct GC_MS_PObj_Wrapper * next_ptr; 83 85 } GC_MS_PObj_Wrapper; 84 86 87 88 typedef 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 95 typedef 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 85 117 typedef struct Small_Object_Arena { 86 118 size_t used; 87 119 size_t total_objects; … … 99 131 struct PMC_Attribute_Arena * prev; 100 132 } PMC_Attribute_Arena; 101 133 102 #if PARROT_GC_GMS103 /*104 * all objects have this header in front of the actual105 * object pointer. The prev/next pointers chain all existing106 * objects for one pool (sizeclass) together.107 *108 * XXX this could lead to unaligned FLOATVALs in the adjacent PMC109 * if that's true either insert a dummy or reorder PMC members110 * ??? 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 generation139 */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 157 134 typedef struct PMC_Attribute_Pool { 158 135 size_t attr_size; 159 136 size_t total_objects; … … 181 158 int skip; 182 159 size_t replenish_level; 183 160 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 */ 188 169 alloc_objects_fn_type more_objects; 189 170 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 192 174 struct Memory_Pool *mem_pool; 193 175 size_t start_arena_memory; 194 176 size_t end_arena_memory; 195 177 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 196 184 #if GC_USE_LAZY_ALLOCATOR 197 185 void *newfree; 198 186 void *newlast; 199 187 #endif 200 #if PARROT_GC_GMS201 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 */207 188 208 struct _gc_gms_gen *first_gen; /* linked list of generations */209 struct _gc_gms_gen *last_gen;210 211 #endif212 189 } Small_Object_Pool; 213 190 214 191 typedef struct Arenas { … … 368 345 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */ 369 346 370 347 PARROT_WARN_UNUSED_RESULT 371 INTVAL contained_in_pool( 348 INTVAL contained_in_pool(PARROT_INTERP, 372 349 ARGIN(const Small_Object_Pool *pool), 373 350 ARGIN(const void *ptr)) 374 351 __attribute__nonnull__(1) 375 __attribute__nonnull__(2); 352 __attribute__nonnull__(2) 353 __attribute__nonnull__(3); 376 354 377 355 PARROT_WARN_UNUSED_RESULT 378 356 PARROT_CANNOT_RETURN_NULL … … 461 439 __attribute__nonnull__(1); 462 440 463 441 #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) \ 465 444 || PARROT_ASSERT_ARG(ptr) 466 445 #define ASSERT_ARGS_get_bufferlike_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \ 467 446 PARROT_ASSERT_ARG(interp) -
src/gc/system.c
489 489 490 490 for (i = 0; i < arena_base->num_sized; i++) { 491 491 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)) 493 493 return 1; 494 494 } 495 495 … … 512 512 is_pmc_ptr(PARROT_INTERP, ARGIN(const void *ptr)) 513 513 { 514 514 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); 516 516 } 517 517 518 518 -
include/parrot/settings.h
44 44 * Please note that only 0 and 3 currently work (and INF doesn't really 45 45 * "work"). 46 46 */ 47 47 #define PARROT_GC_DEFAULT_TYPE MS 48 48 #define PARROT_GC_SUBSYSTEM 0 49 49 50 50 #if PARROT_GC_SUBSYSTEM == 0 -
src/hash.c
1304 1304 1305 1305 if (bucket) { 1306 1306 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); 1309 1316 } 1310 1317 */ 1318 } 1311 1319 bucket->value = value; 1312 1320 } 1313 1321 else { 1314 1322 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); 1317 1332 } 1318 1333 */ 1334 } 1319 1335 bucket = hash->free_list; 1320 1336 1321 1337 if (!bucket) { … … 1422 1438 "hash corruption: type = %d\n", hash->entry_type); 1423 1439 }; 1424 1440 1425 if (key) 1441 if (key){ 1426 1442 parrot_hash_put(interp, dest, key, valtmp); 1443 } 1427 1444 } 1428 1445 } 1429 1446 -
src/gc/gc_ms.c
128 128 arena_base->do_gc_mark = gc_ms_mark_and_sweep; 129 129 arena_base->finalize_gc_system = NULL; 130 130 arena_base->init_pool = gc_ms_pool_init; 131 131 132 } 132 133 133 134 /* -
src/gc/mark_sweep.c
352 352 353 353 /* 354 354 355 =item C<INTVAL contained_in_pool( const Small_Object_Pool *pool, const void356 *ptr)>355 =item C<INTVAL contained_in_pool(PARROT_INTERP, const Small_Object_Pool *pool, 356 const void *ptr)> 357 357 358 358 Returns whether the given C<*ptr> points to a location in C<pool>. 359 359 … … 363 363 364 364 PARROT_WARN_UNUSED_RESULT 365 365 INTVAL 366 contained_in_pool( ARGIN(const Small_Object_Pool *pool), ARGIN(const void *ptr))366 contained_in_pool(PARROT_INTERP, ARGIN(const Small_Object_Pool *pool), ARGIN(const void *ptr)) 367 367 { 368 368 ASSERT_ARGS(contained_in_pool) 369 369 const Small_Object_Arena *arena; 370 370 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 } 373 374 for (arena = pool->last_Arena; arena; arena = arena->prev) { 374 375 const ptrdiff_t ptr_diff = 375 376 (ptrdiff_t)ptr - (ptrdiff_t)arena->start_objects; -
src/list.c
384 384 memset(Buffer_bufstart((Buffer*)chunk), 0, size); 385 385 386 386 /* 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 } 390 394 Parrot_unblock_GC_mark(interp); 391 395 392 396 /* Parrot_unblock_GC_sweep(interp); */ … … 395 399 396 400 397 401 /* 398 402 399 403 =item C<static void rebuild_chunk_ptrs(List *list, int cut)> 400 404 401 405 Rebuilds C<list> and updates/optimizes chunk usage. Deletes empty chunks, … … 516 520 MAX_ITEMS * list->item_size); 517 521 518 522 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 */ 520 528 } 521 529 522 530 mem_sys_memmove( … … 537 545 Parrot_gc_reallocate_buffer_storage(interp, (Buffer *)prev, 538 546 (prev->items + chunk->items) * list->item_size); 539 547 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 */ 541 553 } 542 554 mem_sys_memmove( 543 555 (char *) Buffer_bufstart(&prev->data) + … … 637 649 len * sizeof (List_chunk *)); 638 650 639 651 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 */ 641 657 } 642 658 643 659 list->collect_runs = Parrot_gc_count_collect_runs(interp); … … 1136 1152 chunk->items * list->item_size); 1137 1153 1138 1154 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 */ 1140 1160 } 1141 1161 1142 1162 chunk->flags |= no_power_2; … … 1156 1176 chunk->items * list->item_size); 1157 1177 1158 1178 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 */ 1160 1184 } 1161 1185 1162 1186 chunk->flags &= ~sparse; … … 1247 1271 break; 1248 1272 case enum_type_PMC: 1249 1273 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 */ 1253 1282 } 1254 1283 ((PMC **) Buffer_bufstart(&chunk->data))[idx] = (PMC *)item; 1255 1284 break; … … 1333 1362 { 1334 1363 ASSERT_ARGS(list_append) 1335 1364 /* initially, list may be empty, also used by assign */ 1336 while (idx >= list->cap) 1365 while (idx >= list->cap){ 1337 1366 add_chunk_at_end(interp, list, idx); 1338 1367 } 1339 1368 list_set(interp, list, item, type, idx); 1340 1369 1341 1370 /* invariant: prepare for next push */ -
src/pmc/resizablepmcarray.pmc
266 266 SELF.set_integer_native(key+1); 267 267 268 268 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 270 275 data[key] = src; 271 276 } 272 277 -
src/pmc/resizablestringarray.pmc
86 86 SELF.set_integer_native(key+1); 87 87 88 88 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 */ 90 94 str_array[key] = value; 91 95 } 92 96 -
src/pmc/fixedpmcarray.pmc
543 543 _("FixedPMCArray: index out of bounds!")); 544 544 545 545 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 */ 547 551 data[key] = src; 548 552 } 549 553 -
src/pmc/default.pmc
231 231 PMC *prop; 232 232 233 233 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 */ 235 239 propagate_std_props(interp, self, prop); 236 240 return prop; 237 241 } -
src/pmc/fixedstringarray.pmc
436 436 "FixedStringArray: index out of bounds!"); 437 437 438 438 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 */ 440 444 str_array[key] = value; 441 445 } 442 446 -
src/pmc_freeze.c
1337 1337 #endif 1338 1338 /* 1339 1339 * 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 } 1342 1345 */ 1343 1346 *info->thaw_ptr = pmc; 1344 1347 return; … … 1357 1360 info->thaw_result = pmc; 1358 1361 else { 1359 1362 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 */ 1361 1368 } 1362 1369 *info->thaw_ptr = pmc; 1363 1370 } 1364 1371 list_assign(interp, (List *)PMC_data(info->id_list), id, pmc, enum_type_PMC); 1372 1365 1373 /* remember nested aggregates depth first */ 1366 1374 list_unshift(interp, (List *)PMC_data(info->todo), pmc, enum_type_PMC); 1367 1375 } 1368 1376 1369 1370 1377 /* 1371 1378 1372 1379 =item C<static UINTVAL id_from_pmc(PARROT_INTERP, PMC* pmc)> -
include/parrot/oo.h
32 32 #define get_attrib_num(x, y) ((PMC **)(x))[(y)] 33 33 #define set_attrib_num(o, x, y, z) \ 34 34 do { \ 35 GC_WRITE_BARRIER(interp, (o), ((PMC **)(x))[y], (z)); \35 Parrot_gc_write_barrier(interp, (o), ((PMC **)(x))[y], (z)); \ 36 36 ((PMC **)(x))[(y)] = (z); \ 37 37 } while (0)