Index: src/gc/api.c =================================================================== --- src/gc/api.c (revision 40397) +++ src/gc/api.c (working copy) @@ -373,6 +373,16 @@ if (PObj_active_destroy_TEST(pmc)) VTABLE_destroy(interp, pmc); + if (PMC_data(pmc) && pmc->vtable->attr_size) { +#if 0 + mem_sys_free(PMC_data(pmc)); + PMC_data(pmc) = NULL; +#else + Parrot_gc_free_pmc_attributes(interp, pmc, pmc->vtable->attr_size); +#endif + } + PARROT_ASSERT(NULL == PMC_data(pmc)); + if (PObj_is_PMC_EXT_TEST(pmc)) Parrot_gc_free_pmc_ext(interp, pmc); Index: src/pmc.c =================================================================== --- src/pmc.c (revision 40397) +++ src/pmc.c (working copy) @@ -241,6 +241,24 @@ /* Set the right vtable */ pmc->vtable = new_vtable; + if (PMC_data(pmc) && pmc->vtable->attr_size) { +#if 0 + mem_sys_free(PMC_data(pmc)); +#else + Parrot_gc_free_pmc_attributes(interp, pmc, pmc->vtable->attr_size); +#endif + } + + if (new_vtable->attr_size) { +#if 0 + PMC_data(pmc) = mem_sys_allocate_zeroed(new_vtable->attr_size); +#else + Parrot_gc_allocate_pmc_attributes(interp, pmc, pmc->vtable->attr_size); +#endif +} + else + PMC_data(pmc) = NULL; + return pmc; } @@ -361,6 +379,14 @@ /* Do we have an extension area? */ INTVAL const has_ext = (PObj_is_PMC_EXT_TEST(pmc) && pmc->pmc_ext); + if (PMC_data(pmc) && pmc->vtable->attr_size) { +#if 0 + mem_sys_free(PMC_data(pmc)); +#else + Parrot_gc_free_pmc_attributes(interp, pmc, pmc->vtable->attr_size); +#endif + } + /* Do we need one? */ if (flags & VTABLE_PMC_NEEDS_EXT) { /* If we need an ext area, go allocate one */ @@ -465,6 +491,14 @@ pmc = Parrot_gc_new_pmc_header(interp, flags); pmc->vtable = vtable; + if (vtable->attr_size) { +#if 0 + PMC_data(pmc) = mem_sys_allocate_zeroed(vtable->attr_size); +#else + Parrot_gc_allocate_pmc_attributes(interp, pmc, pmc->vtable->attr_size); +#endif + } + #if GC_VERBOSE if (Interp_flags_TEST(interp, PARROT_TRACE_FLAG)) { /* XXX make a more verbose trace flag */ Index: src/pmc/class.pmc =================================================================== --- src/pmc/class.pmc (revision 40397) +++ src/pmc/class.pmc (working copy) @@ -443,7 +443,7 @@ */ pmclass Class - need_ext { + need_ext auto_attrs { ATTR INTVAL id; /* The type number of the PMC. [deprecated: See RT #48024] */ ATTR STRING *name; /* The name of the class. */ @@ -479,14 +479,13 @@ */ VTABLE void init() { - Parrot_Class_attributes * const _class = mem_allocate_zeroed_typed(Parrot_Class_attributes); + Parrot_Class_attributes * const _class = + (Parrot_Class_attributes *) PMC_data(SELF); - /* Set flags for custom GC mark and destroy. */ + /* Set flag for custom GC mark. */ PObj_custom_mark_SET(SELF); - PObj_active_destroy_SET(SELF); /* Set up the object. */ - PMC_data(SELF) = _class; _class->name = CONST_STRING(interp, ""); _class->_namespace = PMCNULL; _class->parents = pmc_new(interp, enum_class_ResizablePMCArray); @@ -559,21 +558,6 @@ /* -=item C - -Frees the memory associated with the class's underlying struct. - -=cut - -*/ - - VTABLE void destroy() { - mem_sys_free(PMC_data(SELF)); - PMC_data(SELF) = NULL; - } - -/* - =item C Returns the name of the class (without the HLL namespace). Index: src/pmc/complex.pmc =================================================================== --- src/pmc/complex.pmc (revision 40397) +++ src/pmc/complex.pmc (working copy) @@ -217,7 +217,7 @@ } -pmclass Complex need_ext { +pmclass Complex need_ext auto_attrs { ATTR FLOATVAL re; /* real part */ ATTR FLOATVAL im; /* imaginary part */ @@ -327,10 +327,6 @@ Initializes the complex number with the specified initializer. The initializer can be a string PMC or a numeric array with (real, imag) -=item C - -Cleans up. - =item C Creates an identical copy of the complex number. @@ -340,12 +336,8 @@ */ VTABLE void init() { - /* XXX should check if mem_sys_allocate failed */ - PMC_data(SELF) = mem_allocate_typed(Parrot_Complex_attributes); SET_ATTR_re(INTERP, SELF, 0.0); SET_ATTR_im(INTERP, SELF, 0.0); - - PObj_active_destroy_SET(SELF); } VTABLE void init_pmc(PMC *initializer) { @@ -380,11 +372,6 @@ } } - VTABLE void destroy() { - mem_sys_free(PMC_data(SELF)); - PMC_data(SELF) = NULL; - } - VTABLE PMC *clone() { PMC * const dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF)); FLOATVAL re, im; Index: src/pmc/cpointer.pmc =================================================================== --- src/pmc/cpointer.pmc (revision 40397) +++ src/pmc/cpointer.pmc (working copy) @@ -46,7 +46,7 @@ */ -pmclass CPointer need_ext { +pmclass CPointer need_ext auto_attrs { ATTR void *pointer; /* The stored pointer. */ ATTR STRING *sig; /* A string signature for the pointer. */ @@ -61,13 +61,9 @@ */ VTABLE void init() { - Parrot_CPointer_attributes * const pdata_struct = - mem_allocate_typed(Parrot_CPointer_attributes); + SET_ATTR_pointer(INTERP, SELF, NULL); + SET_ATTR_sig(INTERP, SELF, NULL); - PMC_data(SELF) = pdata_struct; - pdata_struct->pointer = NULL; - pdata_struct->sig = NULL; - PObj_custom_mark_destroy_SETALL(SELF); } @@ -83,19 +79,21 @@ */ VTABLE void mark() { - Parrot_CPointer_attributes * const data = PARROT_CPOINTER(SELF); + STRING *sig; + GET_ATTR_sig(INTERP, SELF, sig); + if (sig) { + void *pointer; + GET_ATTR_pointer(INTERP, SELF, pointer); + Parrot_gc_mark_PObj_alive(interp, (PObj *)sig); - if (data->sig) { - Parrot_gc_mark_PObj_alive(interp, (PObj *)data->sig); - - if (data->pointer) { - if (Parrot_str_equal(interp, data->sig, CONST_STRING(interp, "P"))) { - PMC ** const pmc_pointer = (PMC **) data->pointer; + if (pointer) { + if (Parrot_str_equal(interp, sig, CONST_STRING(interp, "P"))) { + PMC ** const pmc_pointer = (PMC **) pointer; PARROT_ASSERT(*pmc_pointer); Parrot_gc_mark_PObj_alive(interp, (PObj *) *pmc_pointer); } - else if (Parrot_str_equal(interp, data->sig, CONST_STRING(interp, "S"))) { - STRING ** const str_pointer = (STRING **) data->pointer; + else if (Parrot_str_equal(interp, sig, CONST_STRING(interp, "S"))) { + STRING ** const str_pointer = (STRING **) pointer; PARROT_ASSERT(*str_pointer); Parrot_gc_mark_PObj_alive(interp, (PObj *) *str_pointer); } @@ -114,12 +112,6 @@ */ VTABLE void destroy() { - Parrot_CPointer_attributes * const data = PARROT_CPOINTER(SELF); - - if (data) { - mem_sys_free(data); - PMC_data(SELF) = NULL; - } } /* Index: src/pmc/fixedfloatarray.pmc =================================================================== --- src/pmc/fixedfloatarray.pmc (revision 40397) +++ src/pmc/fixedfloatarray.pmc (working copy) @@ -19,7 +19,7 @@ */ -pmclass FixedFloatArray need_ext provides array { +pmclass FixedFloatArray need_ext auto_attrs provides array { ATTR INTVAL size; ATTR FLOATVAL *float_array; @@ -40,9 +40,6 @@ */ VTABLE void init() { - Parrot_FixedFloatArray_attributes* attrs = - mem_allocate_zeroed_typed(Parrot_FixedFloatArray_attributes); - PMC_data(SELF) = attrs; } /* @@ -60,9 +57,6 @@ GET_ATTR_float_array(INTERP, SELF, float_array); if (float_array) mem_sys_free(float_array); - - mem_sys_free(PMC_data(SELF)); - PMC_data(SELF) = NULL; } /* Index: src/pmc/retcontinuation.pmc =================================================================== --- src/pmc/retcontinuation.pmc (revision 40397) +++ src/pmc/retcontinuation.pmc (working copy) @@ -23,7 +23,7 @@ #include "parrot/oplib/ops.h" -pmclass RetContinuation extends Continuation need_ext { +pmclass RetContinuation extends Continuation need_ext auto_attrs { /* @@ -37,9 +37,7 @@ VTABLE void init() { Parrot_RetContinuation_attributes * const attrs = - mem_allocate_typed(Parrot_RetContinuation_attributes); - - PMC_data(SELF) = attrs; + (Parrot_RetContinuation_attributes *) PMC_data(SELF); PMC_cont(SELF) = new_ret_continuation(INTERP); PObj_custom_mark_destroy_SETALL(SELF); @@ -55,9 +53,6 @@ if (cc) mem_sys_free(cc); - - mem_sys_free(PMC_data(SELF)); - PMC_data(SELF) = NULL; } /* Index: src/pmc/parrotinterpreter.pmc =================================================================== --- src/pmc/parrotinterpreter.pmc (revision 40397) +++ src/pmc/parrotinterpreter.pmc (working copy) @@ -240,8 +240,9 @@ Parrot_ParrotInterpreter_attributes *attrs = mem_allocate_zeroed_typed(Parrot_ParrotInterpreter_attributes); PMC_data(SELF) = attrs; + } + if (!PMC_interp(SELF)) { create_interp(SELF, INTERP); - PARROT_ASSERT(attrs->interp); } PObj_active_destroy_SET(SELF); } @@ -261,8 +262,15 @@ VTABLE void init_pmc(PMC *parent) { Parrot_Interp p = PMC_interp(parent); - if (!PMC_interp(SELF)) + if (!PMC_data(SELF)) { + Parrot_ParrotInterpreter_attributes *attrs = + mem_allocate_zeroed_typed(Parrot_ParrotInterpreter_attributes); + PMC_data(SELF) = attrs; + } + if (!PMC_interp(SELF)) { create_interp(SELF, p); + } + PObj_active_destroy_SET(SELF); } Index: src/pmc/resizableintegerarray.pmc =================================================================== --- src/pmc/resizableintegerarray.pmc (revision 40397) +++ src/pmc/resizableintegerarray.pmc (working copy) @@ -20,7 +20,7 @@ */ -pmclass ResizableIntegerArray extends FixedIntegerArray need_ext provides array { +pmclass ResizableIntegerArray extends FixedIntegerArray need_ext auto_attrs provides array { ATTR INTVAL resize_threshold; /* max size before array needs to be resized */ /* @@ -33,10 +33,7 @@ */ VTABLE void init() { - Parrot_ResizableIntegerArray_attributes* attrs = - mem_allocate_zeroed_typed(Parrot_ResizableIntegerArray_attributes); - PMC_data(SELF) = attrs; - PObj_active_destroy_SET(SELF); + SUPER(); } /* Index: src/pmc/exception.pmc =================================================================== --- src/pmc/exception.pmc (revision 40397) +++ src/pmc/exception.pmc (working copy) @@ -52,7 +52,7 @@ #include "parrot/exceptions.h" #include "pmc_sub.h" -pmclass Exception { +pmclass Exception auto_attrs { ATTR INTVAL id; /* The task ID in the scheduler. */ ATTR FLOATVAL birthtime; /* The creation time stamp of the exception. */ @@ -83,15 +83,8 @@ */ VTABLE void init() { - Parrot_Exception_attributes * const core_struct = - mem_allocate_zeroed_typed(Parrot_Exception_attributes); - - /* Set up the core struct and default values for the exception object. */ - PMC_data(SELF) = core_struct; - - /* Set flags for custom GC mark and destroy. */ + /* Set flags for custom GC mark. */ PObj_custom_mark_SET(SELF); - PObj_active_destroy_SET(SELF); SET_ATTR_severity(INTERP, SELF, EXCEPT_error); SET_ATTR_handled(INTERP, SELF, 0); @@ -116,9 +109,6 @@ INTVAL severity_val; STRING *message_val; - Parrot_Exception_attributes * const core_struct = - mem_allocate_zeroed_typed(Parrot_Exception_attributes); - INTVAL ishash = VTABLE_isa(interp, values, CONST_STRING(interp, 'Hash')); if (ishash) { @@ -132,10 +122,8 @@ message_val = VTABLE_get_string(interp, values); } - PMC_data(SELF) = core_struct; - /* Set flags for custom GC mark and destroy. */ + /* Set flags for custom GC mark. */ PObj_custom_mark_SET(SELF); - PObj_active_destroy_SET(SELF); /* Set up the core struct and default values for the exception object. */ @@ -175,25 +163,6 @@ /* -=item C - -Destroys the exception. - -=cut - -*/ - - VTABLE void destroy() { - Parrot_Exception_attributes * const core_struct = PARROT_EXCEPTION(SELF); - if (core_struct) { - if (core_struct->thrower) - Parrot_free_context(interp, core_struct->thrower, 1); - mem_sys_free(core_struct); - } - } - -/* - =item C Return true. Index: src/pmc/multisub.pmc =================================================================== --- src/pmc/multisub.pmc (revision 40397) +++ src/pmc/multisub.pmc (working copy) @@ -19,7 +19,7 @@ */ -pmclass MultiSub extends ResizablePMCArray need_ext provides array { +pmclass MultiSub extends ResizablePMCArray need_ext auto_attrs provides array { VTABLE void push_pmc(PMC *value) { STRING * const _sub = CONST_STRING(interp, "Sub"); Index: src/pmc/resizablefloatarray.pmc =================================================================== --- src/pmc/resizablefloatarray.pmc (revision 40397) +++ src/pmc/resizablefloatarray.pmc (working copy) @@ -20,7 +20,7 @@ */ -pmclass ResizableFloatArray extends FixedFloatArray need_ext provides array { +pmclass ResizableFloatArray extends FixedFloatArray need_ext auto_attrs provides array { ATTR INTVAL resize_threshold; /* max size before array needs resizing */ @@ -35,9 +35,7 @@ */ VTABLE void init() { - Parrot_ResizableFloatArray_attributes* attrs = - mem_allocate_zeroed_typed(Parrot_ResizableFloatArray_attributes); - PMC_data(SELF) = attrs; + SUPER(); } /* Index: src/pmc/resizablestringarray.pmc =================================================================== --- src/pmc/resizablestringarray.pmc (revision 40397) +++ src/pmc/resizablestringarray.pmc (working copy) @@ -18,7 +18,7 @@ */ -pmclass ResizableStringArray extends FixedStringArray need_ext provides array { +pmclass ResizableStringArray extends FixedStringArray need_ext auto_attrs provides array { ATTR UINTVAL resize_threshold; /*max capacity before resizing */ /* @@ -36,12 +36,7 @@ */ VTABLE void init() { - Parrot_ResizableStringArray_attributes *attrs = - mem_allocate_zeroed_typed(Parrot_ResizableStringArray_attributes); - - PMC_data(SELF) = attrs; - - PObj_custom_mark_destroy_SETALL(SELF); + SUPER(); } /* Index: src/pmc/continuation.pmc =================================================================== --- src/pmc/continuation.pmc (revision 40397) +++ src/pmc/continuation.pmc (working copy) @@ -45,7 +45,7 @@ * need the next_for_GC pointer in the pmc_ext area. */ -pmclass Continuation need_ext { +pmclass Continuation need_ext auto_attrs { ATTR struct Parrot_cont *cont; /* the continuation struct */ /* @@ -60,8 +60,7 @@ VTABLE void init() { Parrot_Continuation_attributes *attrs = - mem_allocate_zeroed_typed(Parrot_Continuation_attributes); - PMC_data(SELF) = attrs; + (Parrot_Continuation_attributes *) PMC_data(SELF); PMC_cont(SELF) = new_continuation(INTERP, NULL); PObj_custom_mark_destroy_SETALL(SELF); @@ -120,8 +119,6 @@ mem_sys_free(cc); } - mem_sys_free(PMC_data(SELF)); - PMC_data(SELF) = NULL; } /* Index: src/pmc/stringiterator.pmc =================================================================== --- src/pmc/stringiterator.pmc (revision 40397) +++ src/pmc/stringiterator.pmc (working copy) @@ -22,7 +22,7 @@ */ -pmclass StringIterator extends Iterator { +pmclass StringIterator auto_attrs extends Iterator { ATTR PMC *string; /* String to iterate over */ ATTR INTVAL pos; /* Current position of iterator for forward iterator */ /* Previous position of iterator for reverse iterator */ @@ -39,35 +39,15 @@ */ VTABLE void init_pmc(PMC *string) { - Parrot_StringIterator_attributes * const attrs = - mem_allocate_zeroed_typed(Parrot_StringIterator_attributes); + SET_ATTR_string(INTERP, SELF, string); - attrs->string = string; - PMC_data(SELF) = attrs; - - PObj_custom_mark_destroy_SETALL(SELF); - /* by default, iterate from start */ SELF.set_integer_native(ITERATE_FROM_START); + PObj_custom_mark_SET(SELF); } /* -=item C - -destroys this PMC - -=cut - -*/ - - VTABLE void destroy() { - mem_sys_free(PMC_data(SELF)); - PMC_data(SELF) = NULL; - } - -/* - =item C Marks the current idx/key and the aggregate as live. Index: src/pmc/undef.pmc =================================================================== --- src/pmc/undef.pmc (revision 40397) +++ src/pmc/undef.pmc (working copy) @@ -57,7 +57,6 @@ VTABLE_destroy(interp, clone); PObj_is_object_SET(SELF); - PObj_active_destroy_SET(SELF); } } Index: src/pmc/fixedintegerarray.pmc =================================================================== --- src/pmc/fixedintegerarray.pmc (revision 40397) +++ src/pmc/fixedintegerarray.pmc (working copy) @@ -19,7 +19,7 @@ */ -pmclass FixedIntegerArray need_ext provides array { +pmclass FixedIntegerArray need_ext auto_attrs provides array { ATTR INTVAL size; /* number of INTVALs stored in this array */ ATTR INTVAL * int_array; /* INTVALs are stored here */ @@ -40,9 +40,6 @@ */ VTABLE void init() { - Parrot_FixedIntegerArray_attributes* attrs = - mem_allocate_zeroed_typed(Parrot_FixedIntegerArray_attributes); - PMC_data(SELF) = attrs; PObj_active_destroy_SET(SELF); } @@ -154,8 +151,6 @@ GET_ATTR_int_array(INTERP, SELF, int_array); if (int_array) mem_sys_free(int_array); - mem_sys_free(PMC_data(SELF)); - PMC_data(SELF) = NULL; } /* Index: src/pmc/resizablebooleanarray.pmc =================================================================== --- src/pmc/resizablebooleanarray.pmc (revision 40397) +++ src/pmc/resizablebooleanarray.pmc (working copy) @@ -30,7 +30,7 @@ /* Convert a size in bits to a size in bytes */ #define BITS_TO_BYTES(size) ((size) / BITS_PER_CHAR) -pmclass ResizableBooleanArray extends FixedBooleanArray need_ext provides array { +pmclass ResizableBooleanArray extends FixedBooleanArray need_ext auto_attrs provides array { /* RBA uses the same attributes as FBA, but in RBA they're used as follows: size: position of the last element (a.k.a tail_pos) resize_threshold: position of the first element (a.k.a. head_pos) */ Index: src/pmc/parrotlibrary.pmc =================================================================== --- src/pmc/parrotlibrary.pmc (revision 40397) +++ src/pmc/parrotlibrary.pmc (working copy) @@ -31,7 +31,7 @@ #define PMC_dlhandle(x) ((Parrot_ParrotLibrary_attributes*)PMC_data(x))->dl_handle #define PMC_oplib_init(x) ((Parrot_ParrotLibrary_attributes*)PMC_data(x))->oplib_init -pmclass ParrotLibrary need_ext provides library { +pmclass ParrotLibrary need_ext auto_attrs provides library { ATTR void * dl_handle; /* DLL handle */ ATTR void * oplib_init; /* oplib init function */ @@ -46,9 +46,6 @@ */ VTABLE void init() { - Parrot_ParrotLibrary_attributes * const attrs = - mem_allocate_zeroed_typed(Parrot_ParrotLibrary_attributes); - PMC_data(SELF) = attrs; PObj_active_destroy_SET(SELF); } @@ -66,8 +63,6 @@ void *dl_handle = PMC_dlhandle(SELF); if (dl_handle) Parrot_dlclose(dl_handle); - mem_sys_free(PMC_data(SELF)); - PMC_data(SELF) = NULL; } Index: src/pmc/exceptionhandler.pmc =================================================================== --- src/pmc/exceptionhandler.pmc (revision 40397) +++ src/pmc/exceptionhandler.pmc (working copy) @@ -22,7 +22,7 @@ #include "parrot/oplib/ops.h" -pmclass ExceptionHandler extends Continuation need_ext { +pmclass ExceptionHandler extends Continuation need_ext auto_attrs { ATTR PMC *handled_types; ATTR PMC *handled_types_except; @@ -41,11 +41,10 @@ VTABLE void init() { Parrot_ExceptionHandler_attributes * const core_struct = - mem_allocate_zeroed_typed(Parrot_ExceptionHandler_attributes); + (Parrot_ExceptionHandler_attributes *)PMC_data(SELF); Parrot_cont * const cc = new_continuation(INTERP, NULL); cc->invoked = 0; - PMC_data(SELF) = core_struct; PMC_cont(SELF) = cc; core_struct->min_severity = 0; core_struct->max_severity = 0; Index: src/pmc/pmcproxy.pmc =================================================================== --- src/pmc/pmcproxy.pmc (revision 40397) +++ src/pmc/pmcproxy.pmc (working copy) @@ -64,7 +64,7 @@ */ -pmclass PMCProxy extends Class need_ext { +pmclass PMCProxy extends Class need_ext auto_attrs { /* @@ -77,14 +77,13 @@ */ VTABLE void init() { - Parrot_Class_attributes * const _pmc = mem_allocate_zeroed_typed(Parrot_Class_attributes); + Parrot_Class_attributes * const _pmc = + (Parrot_Class_attributes *) PMC_data(SELF); PMC * const new_attribute = pmc_new(interp, enum_class_Hash); STRING * const name = CONST_STRING(interp, "proxy"); - PMC_data(SELF) = _pmc; - /* Set flags for custom GC mark and destroy. */ + /* Set flag for custom GC mark. */ PObj_custom_mark_SET(SELF); - PObj_active_destroy_SET(SELF); /* Set up the object. */ _pmc->id = 0; Index: src/pmc/default.pmc =================================================================== --- src/pmc/default.pmc (revision 40397) +++ src/pmc/default.pmc (working copy) @@ -327,6 +327,19 @@ /* +=item C + +Does nothing. + +=cut + +*/ + + VTABLE void destroy() { + } + +/* + =item C Default fallback. Creates a new PMC of the type of the class SELF and Index: src/pmc/fixedstringarray.pmc =================================================================== --- src/pmc/fixedstringarray.pmc (revision 40397) +++ src/pmc/fixedstringarray.pmc (working copy) @@ -19,7 +19,7 @@ */ -pmclass FixedStringArray need_ext provides array { +pmclass FixedStringArray need_ext auto_attrs provides array { ATTR STRING **str_array; /* where the STRINGs are stored */ ATTR UINTVAL size; /* element count */ @@ -40,12 +40,6 @@ */ VTABLE void init() { - - Parrot_FixedStringArray_attributes *attrs = - mem_allocate_zeroed_typed(Parrot_FixedStringArray_attributes); - - PMC_data(SELF) = attrs; - PObj_custom_mark_destroy_SETALL(SELF); } @@ -67,9 +61,6 @@ if (str_array) mem_sys_free(str_array); - - mem_sys_free(PMC_data(SELF)); - PMC_data(SELF) = NULL; } /* Index: src/pmc/fixedbooleanarray.pmc =================================================================== --- src/pmc/fixedbooleanarray.pmc (revision 40397) +++ src/pmc/fixedbooleanarray.pmc (working copy) @@ -23,7 +23,7 @@ #define BITS_PER_CHAR 8 -pmclass FixedBooleanArray need_ext provides array { +pmclass FixedBooleanArray need_ext auto_attrs provides array { ATTR UINTVAL size; /* # of bits this fba holds */ ATTR UINTVAL resize_threshold; /* max capacity before resizing */ ATTR unsigned char * bit_array; /* where the bits go */ @@ -45,10 +45,6 @@ */ VTABLE void init() { - Parrot_FixedBooleanArray_attributes* attrs = - mem_allocate_zeroed_typed(Parrot_FixedBooleanArray_attributes); - - PMC_data(SELF) = attrs; PObj_active_destroy_SET(SELF); } @@ -67,8 +63,6 @@ GET_ATTR_bit_array(INTERP, SELF, bit_array); if (bit_array) mem_sys_free(bit_array); - mem_sys_free(PMC_data(SELF)); - PMC_data(SELF) = NULL; } /* Index: lib/Parrot/Vtable.pm =================================================================== --- lib/Parrot/Vtable.pm (revision 40397) +++ lib/Parrot/Vtable.pm (working copy) @@ -170,6 +170,7 @@ INTVAL base_type; /* 'type' value for MMD */ STRING *whoami; /* Name of class this vtable is for */ UINTVAL flags; /* Flags. Duh */ + UINTVAL attr_size; /* Size of the attributes struct */ STRING *provides_str; /* space-separated list of interfaces */ Hash *isa_hash; /* Hash of class names */ PMC *pmc_class; /* for PMCs: a PMC of that type Index: lib/Parrot/Pmc2c/PMCEmitter.pm =================================================================== --- lib/Parrot/Pmc2c/PMCEmitter.pm (revision 40397) +++ lib/Parrot/Pmc2c/PMCEmitter.pm (working copy) @@ -458,6 +458,7 @@ $enum_name, /* base_type */ NULL, /* whoami */ $vtbl_flag, /* flags */ + 0, /* attr size */ NULL, /* provides_str */ NULL, /* isa_hash */ NULL, /* class */ @@ -601,6 +602,12 @@ EOC + if ( @{$attributes} && $self->{flags}{auto_attrs} ) { + $cout .= <<"EOC"; + vt->attr_size = sizeof(Parrot_${classname}_attributes); +EOC + } + # init vtable slot if ( $self->is_dynamic ) { $cout .= <<"EOC"; @@ -640,6 +647,14 @@ vt_${k} = Parrot_${classname}_${k}_get_vtable(interp); vt_${k}->base_type = $enum_name; vt_${k}->flags = $k_flags; +EOC + if ( @{$attributes} && $self->{flags}{auto_attrs} ) { + $cout .= <<"EOC"; + vt_${k}->attr_size = sizeof(Parrot_${classname}_attributes); +EOC + } + $cout .= <<"EOC"; + vt_${k}->attribute_defs = attr_defs; vt_${k}->base_type = entry;