Ticket #968: active_to_custom.patch

File active_to_custom.patch, 20.7 KB (added by jrtayloriv, 5 years ago)

replace "active_destroy" with "custom_destroy" -- updated to leave and deprecate original macros

  • src/oo.c

     
    286286 
    287287    /* Set custom GC mark and destroy on the object. */ 
    288288    PObj_custom_mark_SET(cloned); 
    289     PObj_active_destroy_SET(cloned); 
     289    PObj_custom_destroy_SET(cloned); 
    290290 
    291291    /* Flag that it is an object */ 
    292292    PObj_is_object_SET(cloned); 
  • src/ops/set.ops

     
    507507        memmove($1, clone, sizeof (PMC)); 
    508508 
    509509        /* don't let the clone's destruction destroy the destination's data */ 
    510         PObj_active_destroy_CLEAR(clone); 
     510        PObj_custom_destroy_CLEAR(clone); 
    511511        PMC_data(clone) = NULL; 
    512512        PMC_metadata(clone) = NULL; 
    513513        PMC_next_for_GC(clone) = NULL; 
  • src/gc/generational_ms.c

     
    606606=item C<static void gc_gms_chain_objects(PARROT_INTERP, Small_Object_Pool *pool, 
    607607Small_Object_Arena *new_arena, size_t real_size)> 
    608608 
    609 TODO: interfere active_destroy and put these items into a 
     609TODO: interfere custom_destroy and put these items into a 
    610610separate white area, so that a sweep has just to run through these 
    611611objects 
    612612 
     
    16911691        PMC * const obj = (PMC*)GMSH_to_PObj(h); 
    16921692        if (PObj_needs_early_gc_TEST(obj)) 
    16931693            --arena_base->num_early_gc_PMCs; 
    1694         if (PObj_active_destroy_TEST(obj)) 
     1694        if (PObj_custom_destroy_TEST(obj)) 
    16951695            VTABLE_destroy(interp, (PMC *)obj); 
    16961696    } 
    16971697    pool->free_list = pool->white; 
  • src/pmc.c

     
    109109{ 
    110110    ASSERT_ARGS(Parrot_pmc_destroy) 
    111111 
    112     if (PObj_active_destroy_TEST(pmc)) { 
     112    if (PObj_custom_destroy_TEST(pmc)) { 
    113113        VTABLE_destroy(interp, pmc); 
    114114        /* Prevent repeated calls. */ 
    115         PObj_active_destroy_CLEAR(pmc); 
     115        PObj_custom_destroy_CLEAR(pmc); 
    116116    } 
    117117 
    118118    PObj_custom_mark_CLEAR(pmc); 
  • src/pmc/lexinfo.pmc

     
    7171            (hash_hash_key_fn)Parrot_str_to_hashval); /*        hash    */ 
    7272 
    7373        SELF.set_pointer(hash); 
    74         PObj_active_destroy_SET(SELF); 
     74        PObj_custom_destroy_SET(SELF); 
    7575    } 
    7676 
    7777/* 
  • src/pmc/class.pmc

     
    12221222 
    12231223        /* Set custom GC mark and destroy on the object. */ 
    12241224        PObj_custom_mark_SET(object); 
    1225         PObj_active_destroy_SET(object); 
     1225        PObj_custom_destroy_SET(object); 
    12261226 
    12271227        /* Flag that it is an object */ 
    12281228        PObj_is_object_SET(object); 
  • src/pmc/object.pmc

     
    714714    VTABLE void thawfinish(visit_info *info) { 
    715715        /* Set custom GC mark and destroy on the object. */ 
    716716        PObj_custom_mark_SET(SELF); 
    717         PObj_active_destroy_SET(SELF); 
     717        PObj_custom_destroy_SET(SELF); 
    718718 
    719719        /* Flag that it is an object */ 
    720720        PObj_is_object_SET(SELF); 
  • src/pmc/eventhandler.pmc

     
    3939 
    4040    VTABLE void init() { 
    4141        PObj_custom_mark_SET(SELF); 
    42         PObj_active_destroy_SET(SELF); 
     42        PObj_custom_destroy_SET(SELF); 
    4343    } 
    4444 
    4545/* 
     
    101101                    INTERP->iglobals, IGLOBALS_INTERPRETER); 
    102102 
    103103        PObj_custom_mark_SET(SELF); 
    104         PObj_active_destroy_SET(SELF); 
     104        PObj_custom_destroy_SET(SELF); 
    105105 
    106106        e->type        = type; 
    107107        e->code        = code; 
  • src/pmc/fixedfloatarray.pmc

     
    7373        dest_float_array  = (FLOATVAL*)mem_sys_allocate(mem_size); 
    7474        mem_sys_memcopy(dest_float_array, self_float_array, mem_size); 
    7575        SET_ATTR_float_array(INTERP, dest, dest_float_array); 
    76         PObj_active_destroy_SET(dest); 
     76        PObj_custom_destroy_SET(dest); 
    7777 
    7878        return dest; 
    7979    } 
     
    290290        SET_ATTR_size(INTERP, SELF, new_size); 
    291291        SET_ATTR_float_array(INTERP, SELF, 
    292292                mem_allocate_n_typed(new_size, FLOATVAL)); 
    293         PObj_active_destroy_SET(SELF); 
     293        PObj_custom_destroy_SET(SELF); 
    294294    } 
    295295 
    296296/* 
  • src/pmc/parrotinterpreter.pmc

     
    242242        if (!PMC_interp(SELF)) { 
    243243            create_interp(SELF, INTERP); 
    244244        } 
    245         PObj_active_destroy_SET(SELF); 
     245        PObj_custom_destroy_SET(SELF); 
    246246    } 
    247247 
    248248/* 
     
    268268        if (!PMC_interp(SELF)) { 
    269269            create_interp(SELF, p); 
    270270        } 
    271         PObj_active_destroy_SET(SELF); 
     271        PObj_custom_destroy_SET(SELF); 
    272272    } 
    273273 
    274274 
     
    309309            Parrot_ParrotInterpreter_attributes *attrs = 
    310310                mem_allocate_zeroed_typed(Parrot_ParrotInterpreter_attributes); 
    311311            PMC_data(SELF) = attrs; 
    312             PObj_active_destroy_SET(SELF); 
     312            PObj_custom_destroy_SET(SELF); 
    313313        } 
    314314        PMC_interp(SELF) = (struct parrot_interp_t *)value; 
    315315    } 
     
    722722                Parrot_ParrotInterpreter_attributes *attrs = 
    723723                    mem_allocate_zeroed_typed(Parrot_ParrotInterpreter_attributes); 
    724724                PMC_data(SELF) = attrs; 
    725                 PObj_active_destroy_SET(SELF); 
     725                PObj_custom_destroy_SET(SELF); 
    726726            } 
    727727 
    728728            PMC_interp(SELF) = INTERP; 
  • src/pmc/filehandle.pmc

     
    8484        data_struct->os_handle     = (PIOHANDLE) PIO_INVALID_HANDLE; 
    8585 
    8686        PObj_custom_mark_SET(SELF); 
    87         PObj_active_destroy_SET(SELF); 
     87        PObj_custom_destroy_SET(SELF); 
    8888    } 
    8989 
    9090/* 
  • src/pmc/exception.pmc

     
    8484 
    8585    VTABLE void init() { 
    8686        /* Set flags for custom GC mark and destroy. */ 
    87         PObj_active_destroy_SET(SELF); 
     87        PObj_custom_destroy_SET(SELF); 
    8888        PObj_custom_mark_SET(SELF); 
    8989 
    9090        SET_ATTR_severity(INTERP, SELF, EXCEPT_error); 
     
    124124        } 
    125125 
    126126        /* Set flags for custom GC mark. */ 
    127         PObj_active_destroy_SET(SELF); 
     127        PObj_custom_destroy_SET(SELF); 
    128128        PObj_custom_mark_SET(SELF); 
    129129 
    130130        /* Set up the core struct and default values for the exception object. */ 
  • src/pmc/bigint.pmc

     
    627627 
    628628    VTABLE void init() { 
    629629        bigint_init(INTERP, SELF); 
    630         PObj_active_destroy_SET(SELF); 
     630        PObj_custom_destroy_SET(SELF); 
    631631    } 
    632632 
    633633    VTABLE PMC *clone() { 
  • src/pmc/timer.pmc

     
    7979 
    8080        /* Set flags for custom GC mark and destroy. */ 
    8181        PObj_custom_mark_SET(SELF); 
    82         PObj_active_destroy_SET(SELF); 
     82        PObj_custom_destroy_SET(SELF); 
    8383 
    8484        /* Set up the core struct. */ 
    8585        core_struct->id          = 0; 
  • src/pmc/sockaddr.pmc

     
    4747            (Parrot_Sockaddr_attributes *) PMC_data(SELF); 
    4848 
    4949        pdata_struct->pointer = mem_allocate_zeroed_typed(struct sockaddr_in); 
    50         PObj_active_destroy_SET(SELF); 
     50        PObj_custom_destroy_SET(SELF); 
    5151    } 
    5252 
    5353/* 
  • src/pmc/parrotrunningthread.pmc

     
    5050            mem_allocate_zeroed_typed(Parrot_ParrotRunningThread_attributes); 
    5151        attrs->tid = -1; 
    5252        PMC_data(SELF) = attrs; 
    53         PObj_active_destroy_SET(SELF); 
     53        PObj_custom_destroy_SET(SELF); 
    5454    } 
    5555 
    5656/* 
  • src/pmc/fixedintegerarray.pmc

     
    4040*/ 
    4141 
    4242    VTABLE void init() { 
    43         PObj_active_destroy_SET(SELF); 
     43        PObj_custom_destroy_SET(SELF); 
    4444    } 
    4545 
    4646/* 
     
    190190            SET_ATTR_int_array(INTERP, dest, dest_int_array); 
    191191 
    192192            mem_sys_memcopy(dest_int_array, int_array, size * sizeof (INTVAL)); 
    193             PObj_active_destroy_SET(dest); 
     193            PObj_custom_destroy_SET(dest); 
    194194        } 
    195195 
    196196        return dest; 
     
    432432        GET_ATTR_int_array(INTERP, SELF, int_array); 
    433433        SET_ATTR_int_array(INTERP, SELF, 
    434434                mem_realloc_n_typed(int_array, size, INTVAL)); 
    435         PObj_active_destroy_SET(SELF); 
     435        PObj_custom_destroy_SET(SELF); 
    436436    } 
    437437 
    438438/* 
     
    640640        Parrot_FixedIntegerArray_attributes *attrs = 
    641641            mem_allocate_zeroed_typed(Parrot_FixedIntegerArray_attributes); 
    642642        PMC_data(SELF) = attrs; 
    643         PObj_active_destroy_SET(SELF); 
     643        PObj_custom_destroy_SET(SELF); 
    644644 
    645645        if (info->extra_flags == EXTRA_IS_NULL) { 
    646646            IMAGE_IO * const io = info->image_io; 
  • src/pmc/scheduler.pmc

     
    5252 
    5353        /* Set flags for custom GC mark and destroy. */ 
    5454        PObj_custom_mark_SET(SELF); 
    55         PObj_active_destroy_SET(SELF); 
     55        PObj_custom_destroy_SET(SELF); 
    5656 
    5757        /* Set up the core struct. */ 
    5858        core_struct->id          = 0; 
  • src/pmc/resizablebooleanarray.pmc

     
    392392 
    393393        SET_ATTR_bit_array(INTERP, dest, dest_bit_array); 
    394394 
    395         PObj_active_destroy_SET(dest); 
     395        PObj_custom_destroy_SET(dest); 
    396396        return dest; 
    397397    } 
    398398 
  • src/pmc/bignum.pmc

     
    841841 
    842842    VTABLE void init() { 
    843843        bignum_init(INTERP, SELF); 
    844         PObj_active_destroy_SET(SELF); 
     844        PObj_custom_destroy_SET(SELF); 
    845845    } 
    846846 
    847847    VTABLE PMC *clone() { 
  • src/pmc/exceptionhandler.pmc

     
    5656         * context - the stacks can only be deeper in the interpreter - so no 
    5757         * mark of context is needed */ 
    5858        PObj_custom_mark_SET(SELF); 
    59         PObj_active_destroy_SET(SELF); 
     59        PObj_custom_destroy_SET(SELF); 
    6060    } 
    6161/* 
    6262 
  • src/pmc/parrotlibrary.pmc

     
    4646*/ 
    4747 
    4848    VTABLE void init() { 
    49         PObj_active_destroy_SET(SELF); 
     49        PObj_custom_destroy_SET(SELF); 
    5050    } 
    5151 
    5252/* 
  • src/pmc/managedstruct.pmc

     
    4646*/ 
    4747 
    4848    VTABLE void init() { 
    49         PObj_active_destroy_SET(SELF); 
     49        PObj_custom_destroy_SET(SELF); 
    5050    } 
    5151 
    5252/* 
  • src/pmc/packfileannotation.pmc

     
    4242        Parrot_PackfileAnnotation_attributes * attrs = 
    4343                mem_allocate_zeroed_typed(Parrot_PackfileAnnotation_attributes); 
    4444 
    45         PObj_active_destroy_SET(SELF); 
     45        PObj_custom_destroy_SET(SELF); 
    4646        PMC_data(SELF) = attrs; 
    4747    } 
    4848 
  • src/pmc/fixedbooleanarray.pmc

     
    4545*/ 
    4646 
    4747    VTABLE void init() { 
    48         PObj_active_destroy_SET(SELF); 
     48        PObj_custom_destroy_SET(SELF); 
    4949    } 
    5050 
    5151/* 
     
    9797            SET_ATTR_bit_array(INTERP, dest, clone_bit_array); 
    9898        } 
    9999 
    100         PObj_active_destroy_SET(dest); 
     100        PObj_custom_destroy_SET(dest); 
    101101        return dest; 
    102102    } 
    103103 
  • src/packdump.c

     
    111111    "on_free_list", 
    112112    "custom_mark", 
    113113    "custom_GC", 
    114     "active_destroy", 
     114    "custom_destroy", 
    115115    "report", 
    116116    "data_is_PMC_array", 
    117117    "need_finalize", 
  • src/jit/i386/jit_defs.c

     
    24102410    emitm_ret(pc); 
    24112411    PARROT_ASSERT(pc - jit_info.arena.start <= JIT_ALLOC_SIZE); 
    24122412    /* could shrink arena.start here to used size */ 
    2413     PObj_active_destroy_SET(pmc_nci); 
     2413    PObj_custom_destroy_SET(pmc_nci); 
    24142414    if (sizeptr) 
    24152415        *sizeptr = JIT_ALLOC_SIZE; 
    24162416    return (void *)D2FPTR(jit_info.arena.start); 
  • src/dynpmc/rational.pmc

     
    269269        PMC_data(SELF)     = attrs; 
    270270        PMC_rational(SELF) = (RATIONAL *)malloc(sizeof (RATIONAL)); 
    271271        mpq_init(RT(SELF)); 
    272         PObj_active_destroy_SET(SELF); 
     272        PObj_custom_destroy_SET(SELF); 
    273273      #endif 
    274274    } 
    275275 
  • src/dynpmc/gdbmhash.pmc

     
    105105 
    106106        attrs->db_handle = mem_allocate_zeroed_typed(GDBM_FH); 
    107107        PMC_data(SELF)   = attrs; 
    108         PObj_active_destroy_SET(SELF); 
     108        PObj_custom_destroy_SET(SELF); 
    109109    } 
    110110 
    111111    VTABLE void destroy() { 
  • docs/embed.pod

     
    18531853 
    18541854=item C<pmc_type> 
    18551855 
    1856 =item C<PObj_active_destroy_SET> 
     1856=item C<PObj_custom_destroy_SET> 
    18571857 
    18581858=item C<PObj_custom_mark_SET> 
    18591859 
  • docs/vtables.pod

     
    211211=item C<destroy> 
    212212 
    213213Do any data shut-down and finalization you need to do. To have this method 
    214 called, you must set the C<Pobj_active_destroy_FLAG>. 
     214called, you must set the C<Pobj_custom_destroy_FLAG>. 
    215215 
    216216=item C<get_integer> 
    217217 
  • docs/pdds/pdd09_gc.pod

     
    560560 
    561561=over 4 
    562562 
    563 =item PObj_active_destroy_FLAG 
     563=item PObj_custom_destroy_FLAG 
    564564 
    565565The PMC has some sort of active destructor, and will have that destructor 
    566566called when the PMC is destroyed. The destructor is typically called from 
  • docs/pmc.pod

     
    4242C<PMC_data> in the PMC's C<init()> and C<init_pmc()> VTABLE functions (if used) 
    4343and it must be destroyed in the C<destroy()> VTABLE function.  PMCs with ATTRs 
    4444also need to indicate that they need active destruction by calling 
    45 C<PObj_active_destroy_SET()> or C<PObj_custom_mark_destroy_SETALL()>. 
     45C<PObj_custom_destroy_SET()> or C<PObj_custom_mark_destroy_SETALL()>. 
    4646 
    4747If your PMC only needs to store a single pointer, it can use C<PMC_data> directly. 
    4848Note that this may make maintaining your PMC difficult, should more data ever 
     
    8080VTABLE function must call B<Parrot_gc_mark_PObj_alive()> on all B<PObj>s which your PMC 
    8181contains. 
    8282 
    83 =item PObj_active_destroy_FLAG 
     83=item PObj_custom_destroy_FLAG 
    8484 
    8585If your PMC allocates any memory or opens any resources during its lifetime, it 
    86 must set B<PObj_active_destroy> and implement the B<destroy()> VTABLE function to 
     86must set B<PObj_custom_destroy> and implement the B<destroy()> VTABLE function to 
    8787free those resources. 
    8888 
    8989=item PObj_needs_early_gc_FLAG 
  • include/parrot/pobj.h

     
    192192    /* Mark the buffer as needing GC */ 
    193193    PObj_custom_GC_FLAG         = POBJ_FLAG(21), 
    194194    /* Set if the PObj has a destroy method that must be called */ 
    195     PObj_active_destroy_FLAG    = POBJ_FLAG(22), 
     195    PObj_custom_destroy_FLAG    = POBJ_FLAG(22), 
    196196    /* For debugging, report when this buffer gets moved around */ 
    197197    PObj_report_FLAG            = POBJ_FLAG(23), 
    198198 
     
    290290#define PObj_special_CLEAR(flag, o) do { \ 
    291291    PObj_flag_CLEAR(flag, o); \ 
    292292    if ((PObj_get_FLAGS(o) & \ 
    293                 (PObj_active_destroy_FLAG | \ 
     293                (PObj_custom_destroy_FLAG | \ 
    294294                 PObj_custom_mark_FLAG | \ 
    295295                 PObj_needs_early_gc_FLAG))) \ 
    296296        gc_flag_SET(is_special_PMC, o); \ 
     
    313313#define PObj_custom_mark_CLEAR(o)   PObj_special_CLEAR(custom_mark, o) 
    314314#define PObj_custom_mark_TEST(o)   PObj_flag_TEST(custom_mark, o) 
    315315 
    316 #define PObj_active_destroy_SET(o) PObj_flag_SET(active_destroy, o) 
    317 #define PObj_active_destroy_TEST(o) PObj_flag_TEST(active_destroy, o) 
    318 #define PObj_active_destroy_CLEAR(o) PObj_flag_CLEAR(active_destroy, o) 
     316#define PObj_custom_destroy_SET(o) PObj_flag_SET(custom_destroy, o) 
     317#define PObj_custom_destroy_TEST(o) PObj_flag_TEST(custom_destroy, o) 
     318#define PObj_custom_destroy_CLEAR(o) PObj_flag_CLEAR(custom_destroy, o) 
    319319 
     320/***************************************************** 
     321 * DEPRECATED -- use PObj_custom_destroy_FOO() instead  
     322 ******************************************************/ 
     323#define PObj_active_destroy_SET(o) PObj_flag_SET(custom_destroy, o) 
     324#define PObj_active_destroy_TEST(o) PObj_flag_TEST(custom_destroy, o) 
     325#define PObj_active_destroy_CLEAR(o) PObj_flag_CLEAR(custom_destroy, o) 
     326 
    320327#define PObj_is_class_SET(o) PObj_flag_SET(is_class, o) 
    321328#define PObj_is_class_TEST(o) PObj_flag_TEST(is_class, o) 
    322329#define PObj_is_class_CLEAR(o) PObj_flag_CLEAR(is_class, o) 
     
    357364 
    358365#define PObj_custom_mark_destroy_SETALL(o) do { \ 
    359366        PObj_custom_mark_SET(o); \ 
    360         PObj_active_destroy_SET(o); \ 
     367        PObj_custom_destroy_SET(o); \ 
    361368} while (0) 
    362369 
    363370#endif /* PARROT_POBJ_H_GUARD */ 
  • config/gen/crypto/digest_pmc.in

     
    3636@TEMP_md_guard@ 
    3737        @TEMP_md_ctx@ *c    = mem_allocate_zeroed_typed(@TEMP_md_ctx@); 
    3838        PMC_data(SELF) = c; 
    39         PObj_active_destroy_SET(SELF); 
     39        PObj_custom_destroy_SET(SELF); 
    4040#else 
    4141        Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_ILL_INHERIT, 
    4242            "@TEMP_md_name@ is disabled"); 
     
    7575        memcpy(c, PMC_data(SELF), sizeof (@TEMP_md_ctx@)); 
    7676        PMC_data(retval) = c; 
    7777 
    78         PObj_active_destroy_SET(retval); 
     78        PObj_custom_destroy_SET(retval); 
    7979        return retval; 
    8080#else 
    8181        return NULL;