Ticket #549: killunionvalpatch.patch

File killunionvalpatch.patch, 105.5 KB (added by jessevdam, 5 years ago)

kill unionval patch

  • src/jit/i386/jit_defs.c

    ### Eclipse Workspace Patch 1.0
    #P parrot
     
    22652265                break; 
    22662266            case 'v': 
    22672267                break; 
    2268             case 'b':   /* buffer (void*) pass PObj_bufstart(SReg) */ 
     2268            case 'b':   /* buffer (void*) pass Buffer_bufstart(SReg) */ 
    22692269                emitm_call_cfunc(pc, get_nci_S); 
    22702270                emitm_movl_m_r(interp, pc, emit_EAX, emit_EAX, 0, 1, 
    2271                                (size_t) &PObj_bufstart((STRING *) NULL)); 
     2271                               (size_t) &Buffer_bufstart((STRING *) NULL)); 
    22722272                emitm_movl_r_m(interp, pc, emit_EAX, emit_EBP, 0, 1, args_offset); 
    22732273                break; 
    2274             case 'B':   /* buffer (void**) pass &PObj_bufstart(SReg) */ 
     2274            case 'B':   /* buffer (void**) pass &Buffer_bufstart(SReg) */ 
    22752275                emitm_call_cfunc(pc, get_nci_S); 
    22762276                emitm_lea_m_r(interp, pc, emit_EAX, emit_EAX, 0, 1, 
    2277                               (size_t) &PObj_bufstart((STRING *) NULL)); 
     2277                              (size_t) &Buffer_bufstart((STRING *) NULL)); 
    22782278                emitm_movl_r_m(interp, pc, emit_EAX, emit_EBP, 0, 1, args_offset); 
    22792279                break; 
    22802280            case 'S': 
  • src/gc/gc_private.h

     
    4747   larger then sizeof(PObj), thus creating overflow. However PObjs are never 
    4848   used by themselves, things like PMCs and STRINGs are cast to PObj in the 
    4949   GC, so we should have plenty of space. */ 
    50 typedef union GC_MS_PObj_Wrapper { 
    51     PObj obj; 
    52     PObj *next_ptr; 
     50typedef struct GC_MS_PObj_Wrapper { 
     51    size_t flags; 
     52    struct GC_MS_PObj_Wrapper * next_ptr; 
    5353} GC_MS_PObj_Wrapper; 
    5454 
    5555typedef struct Small_Object_Arena { 
     
    152152    size_t num_free_objects;    /* number of resources in the free pool */ 
    153153    int skip; 
    154154    size_t replenish_level; 
    155     void *free_list; 
     155    GC_MS_PObj_Wrapper * free_list; 
    156156    /* adds a free object to the pool's free list  */ 
    157157    add_free_object_fn_type     add_free_object; 
    158158    get_free_object_fn_type     get_free_object; 
     
    184184    Memory_Pool *constant_string_pool; 
    185185    struct Small_Object_Pool *string_header_pool; 
    186186    struct Small_Object_Pool *pmc_pool; 
    187     struct Small_Object_Pool *pmc_ext_pool; 
    188187    struct Small_Object_Pool *constant_pmc_pool; 
    189     struct Small_Object_Pool *buffer_header_pool; 
     188 //   struct Small_Object_Pool *buffer_header_pool; 
    190189    struct Small_Object_Pool *constant_string_header_pool; 
    191190    struct Small_Object_Pool **sized_header_pools; 
    192191    size_t num_sized; 
     
    225224                                     during collection */ 
    226225    UINTVAL num_early_gc_PMCs;    /* how many PMCs want immediate destruction */ 
    227226    UINTVAL num_early_PMCs_seen;  /* how many such PMCs has GC seen */ 
    228     UINTVAL num_extended_PMCs;    /* active PMCs having pmc_ext */ 
    229227    PMC* gc_mark_start;           /* first PMC marked during a GC run */ 
    230228    PMC* gc_mark_ptr;             /* last PMC marked during a GC run */ 
    231229    PMC* gc_trace_ptr;            /* last PMC trace_children was called on */ 
     
    550548        __attribute__nonnull__(2) 
    551549        FUNC_MODIFIES(*dest) 
    552550        FUNC_MODIFIES(*source); 
     551         
     552void check_memory_system(PARROT_INTERP) 
     553        __attribute__nonnull__(1);     
     554       
     555void check_memory_system(PARROT_INTERP) 
     556        __attribute__nonnull__(1);   
     557         
     558void check_small_object_pool(Small_Object_Pool * pool)                     
     559        __attribute__nonnull__(1); 
    553560 
     561void 
     562check_memory_pool(Memory_Pool *pool) 
     563        __attribute__nonnull__(1); 
     564         
     565void 
     566check_buffer_ptr(Buffer * pobj,Memory_Pool * pool) 
     567        __attribute__nonnull__(1) 
     568        __attribute__nonnull__(2); 
     569          
    554570#define ASSERT_ARGS_aligned_mem __attribute__unused__ int _ASSERT_ARGS_CHECK = \ 
    555571       PARROT_ASSERT_ARG(buffer) \ 
    556572    || PARROT_ASSERT_ARG(mem) 
     
    652668/* HEADERIZER BEGIN: src/gc/gc_ms.c */ 
    653669/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */ 
    654670 
    655 void gc_ms_pmc_ext_pool_init(ARGMOD(Small_Object_Pool *pool)) 
    656         __attribute__nonnull__(1) 
    657         FUNC_MODIFIES(*pool); 
    658  
    659671void Parrot_gc_ms_init(PARROT_INTERP) 
    660672        __attribute__nonnull__(1); 
    661673 
    662 #define ASSERT_ARGS_gc_ms_pmc_ext_pool_init __attribute__unused__ int _ASSERT_ARGS_CHECK = \ 
    663        PARROT_ASSERT_ARG(pool) 
    664674#define ASSERT_ARGS_Parrot_gc_ms_init __attribute__unused__ int _ASSERT_ARGS_CHECK = \ 
    665675       PARROT_ASSERT_ARG(interp) 
    666676/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */ 
  • include/parrot/pobj.h

     
    1515 
    1616#include "parrot/config.h" 
    1717 
    18 typedef union UnionVal { 
    19     struct _b {                                  /* One Buffer structure */ 
    20         void *     _bufstart; 
    21         size_t     _buflen; 
    22     } _b; 
    23     struct _ptrs {                                  /* or two pointers, both are defines */ 
    24         DPOINTER * _struct_val; 
    25         PMC *      _pmc_val; 
    26     } _ptrs; 
    27     struct _i { 
    28         INTVAL _int_val;                      /* or 2 intvals */ 
    29         INTVAL _int_val2; 
    30     } _i; 
    31     FLOATVAL _num_val;                       /* or one float */ 
    32     struct parrot_string_t * _string_val;    /* or a pointer to a string */ 
    33 } UnionVal; 
    34  
    35 #define UVal_ptr(u)       (u)._ptrs._struct_val 
    36 #define UVal_pmc(u)       (u)._ptrs._pmc_val 
    37 #define UVal_int(u)       (u)._i._int_val 
    38 #define UVal_int2(u)      (u)._i._int_val2 
    39 #define UVal_num(u)       (u)._num_val 
    40 #define UVal_str(u)       (u)._string_val 
    41  
    4218/* Parrot Object - base class for all others */ 
    4319typedef struct pobj_t { 
    44     UnionVal u; 
    4520    Parrot_UInt flags; 
    46 } pobj_t; 
     21} PObj; 
    4722 
    48 /* plain Buffer is the smallest Parrot Obj */ 
    49 typedef struct Buffer { 
    50     UnionVal    cache; 
     23typedef struct buffer_t { 
    5124    Parrot_UInt flags; 
     25    void *     _bufstart; 
     26    size_t     _buflen;     
    5227} Buffer; 
    5328 
    54 typedef Buffer PObj; 
    55  
    56 #define PObj_bufstart(pmc)    (pmc)->cache._b._bufstart 
    57 #define PObj_buflen(pmc)      (pmc)->cache._b._buflen 
     29#define Buffer_bufstart(buffer)    (buffer)->_bufstart 
     30#define Buffer_buflen(buffer)      (buffer)->_buflen 
    5831 
    5932/* See src/gc/alloc_resources.c. the basic idea is that buffer memory is 
    6033   set up as follows: 
     
    8457                    v                  v      v                  v 
    8558 
    8659*/ 
    87 typedef struct Buffer_alloc_unit { 
    88     INTVAL ref_count; 
    89     UnionVal buffer[1]; /* Guarantee it's suitably aligned */ 
    90 } Buffer_alloc_unit; 
    9160 
    9261/* Given a pointer to the buffer, find the ref_count and the actual start of 
    9362   the allocated space. Setting ref_count is clunky because we avoid lvalue 
    9463   casts. */ 
    9564#ifdef GC_IS_MALLOC       /* see src/gc/res_lea.c */ 
    9665#  define Buffer_alloc_offset    (offsetof(Buffer_alloc_unit, buffer)) 
    97 #  define PObj_bufallocstart(b)  ((char *)PObj_bufstart(b) - Buffer_alloc_offset) 
    98 #  define PObj_bufrefcount(b)    (((Buffer_alloc_unit *)PObj_bufallocstart(b))->ref_count) 
    99 #  define PObj_bufrefcountptr(b) (&PObj_bufrefcount(b)) 
     66#  define Buffer_bufallocstart(b)  ((char *)Buffer_bufstart(b) - Buffer_alloc_offset) 
     67#  define Buffer_bufrefcount(b)    (((Buffer_alloc_unit *)Buffer_bufallocstart(b))->ref_count) 
     68#  define Buffer_bufrefcountptr(b) (&Buffer_bufrefcount(b)) 
    10069#else                     /* see src/gc/alloc_resources.c */ 
    10170#  define Buffer_alloc_offset sizeof (INTVAL) 
    102 #  define PObj_bufallocstart(b)  ((char *)PObj_bufstart(b) - Buffer_alloc_offset) 
    103 #  define PObj_bufrefcount(b)    (*(INTVAL *)PObj_bufallocstart(b)) 
    104 #  define PObj_bufrefcountptr(b) ((INTVAL *)PObj_bufallocstart(b)) 
     71#  define Buffer_bufallocstart(b)  ((char *)Buffer_bufstart(b) - Buffer_alloc_offset) 
     72#  define Buffer_bufrefcount(b)    (*(INTVAL *)Buffer_bufallocstart(b)) 
     73#  define Buffer_bufrefcountptr(b) ((INTVAL *)Buffer_bufallocstart(b)) 
    10574#endif 
    10675 
    10776typedef enum { 
     
    11281} parrot_string_representation_t; 
    11382 
    11483struct parrot_string_t { 
    115     UnionVal    cache; 
    11684    Parrot_UInt flags; 
     85    void *     _bufstart; 
     86    size_t     _buflen; 
     87       
    11788    char       *strstart; 
    11889    UINTVAL     bufused; 
    11990    UINTVAL     strlen; 
     
    12495    const struct _charset  *charset; 
    12596}; 
    12697 
     98struct _Sync;   /* forward decl */ 
     99 
    127100/* note that cache and flags are isomorphic with Buffer and PObj */ 
    128101struct PMC { 
    129     UnionVal        cache; 
    130102    Parrot_UInt     flags; 
    131103    VTABLE         *vtable; 
    132104    DPOINTER       *data; 
    133     struct PMC_EXT *pmc_ext; 
    134 }; 
    135  
    136 struct _Sync;   /* forward decl */ 
    137105 
    138 typedef struct PMC_EXT { 
    139106    PMC *_metadata;      /* properties */ 
    140107    /* 
    141108     * PMC access synchronization for shared PMCs 
     
    160127       stuff, which'd merit an extra dereference when setting, but let 
    161128       us memset the actual GC data in a big block 
    162129    */ 
    163 } PMC_EXT; 
     130}; 
    164131 
    165 #ifdef NDEBUG 
    166 #  define PMC_ext_checked(pmc)             (pmc)->pmc_ext 
    167 #else 
    168 #  define PMC_ext_checked(pmc)             (PARROT_ASSERT((pmc)->pmc_ext), (pmc)->pmc_ext) 
    169 #endif /* NDEBUG */ 
    170132#define PMC_data(pmc)                   (pmc)->data 
    171133#define PMC_data_typed(pmc, type) (type)(pmc)->data 
    172134/* do not allow PMC_data2 as lvalue */ 
    173135#define PMC_data0(pmc)            (1 ? (pmc)->data : 0) 
    174136#define PMC_data0_typed(pmc)      (type)(1 ? (pmc)->data : 0) 
    175 #define PMC_metadata(pmc)     PMC_ext_checked(pmc)->_metadata 
    176 #define PMC_next_for_GC(pmc)  PMC_ext_checked(pmc)->_next_for_GC 
    177 #define PMC_sync(pmc)         PMC_ext_checked(pmc)->_synchronize 
     137#define PMC_metadata(pmc)     pmc->_metadata 
     138#define PMC_next_for_GC(pmc)  pmc->_next_for_GC 
     139#define PMC_sync(pmc)         pmc->_synchronize 
    178140 
    179141#define POBJ_FLAG(n) ((UINTVAL)1 << (n)) 
    180142/* PObj flags */ 
  • src/pmc_freeze.c

     
    463463str_append(PARROT_INTERP, ARGMOD(STRING *s), ARGIN(const void *b), size_t len) 
    464464{ 
    465465    ASSERT_ARGS(str_append) 
     466 
    466467    const size_t used = s->bufused; 
    467     const int need_free = (int)PObj_buflen(s) - used - len; 
     468    const int need_free = (int)Buffer_buflen(s) - used - len; 
    468469    /* 
    469470     * grow by factor 1.5 or such 
    470471     */ 
    471472    if (need_free <= 16) { 
    472         size_t new_size = (size_t) (PObj_buflen(s) * 1.5); 
    473         if (new_size < PObj_buflen(s) - need_free + 512) 
    474             new_size = PObj_buflen(s) - need_free + 512; 
     473        size_t new_size = (size_t) (Buffer_buflen(s) * 1.5); 
     474        if (new_size < Buffer_buflen(s) - need_free + 512) 
     475            new_size = Buffer_buflen(s) - need_free + 512; 
    475476        Parrot_gc_reallocate_string_storage(interp, s, new_size); 
    476         PARROT_ASSERT(PObj_buflen(s) - used - len >= 15); 
     477        PARROT_ASSERT(Buffer_buflen(s) - used - len >= 15); 
    477478    } 
    478479    mem_sys_memcopy((void *)((ptrcast_t)s->strstart + used), b, len); 
    479480    s->bufused += len; 
     
    591592shift_ascii_integer(SHIM_INTERP, ARGIN(IMAGE_IO *io)) 
    592593{ 
    593594    ASSERT_ARGS(shift_ascii_integer) 
     595 
    594596    char * const start = (char*)io->image->strstart; 
    595597    char *p = start; 
    596598    const INTVAL i = strtoul(p, &p, 10); 
     
    599601    PARROT_ASSERT(p <= start + io->image->bufused); 
    600602    io->image->strstart = p; 
    601603    io->image->bufused -= (p - start); 
     604    io->image->strlen -= (p - start); 
    602605    PARROT_ASSERT((int)io->image->bufused >= 0); 
     606 
    603607    return i; 
    604608} 
    605609 
     
    617621shift_ascii_number(SHIM_INTERP, ARGIN(IMAGE_IO *io)) 
    618622{ 
    619623    ASSERT_ARGS(shift_ascii_number) 
     624 
    620625    char * const start = (char*)io->image->strstart; 
    621626    char *p = start; 
    622627    const FLOATVAL f = (FLOATVAL) strtod(p, &p); 
     
    625630    PARROT_ASSERT(p <= start + io->image->bufused); 
    626631    io->image->strstart = p; 
    627632    io->image->bufused -= (p - start); 
     633    io->image->strlen -= (p - start); 
    628634    PARROT_ASSERT((int)io->image->bufused >= 0); 
     635 
    629636    return f; 
    630637} 
    631638 
     
    656663    PARROT_ASSERT(p <= start + io->image->bufused); 
    657664    io->image->strstart = p; 
    658665    io->image->bufused -= (p - start); 
     666    io->image->strlen -= (p - start); 
    659667    PARROT_ASSERT((int)io->image->bufused >= 0); 
    660668    s = string_make(interp, start, p - start - 1, "iso-8859-1", 0); 
    661669/*    s = string_make(interp, start, p - start - 1, "UTF-8", 0); */ 
     670 
    662671    return s; 
    663672} 
    664673 
     
    678687shift_ascii_pmc(SHIM_INTERP, ARGIN(IMAGE_IO *io)) 
    679688{ 
    680689    ASSERT_ARGS(shift_ascii_pmc) 
     690 
    681691    char * const start = (char*)io->image->strstart; 
    682692    char *p = start; 
    683693    const unsigned long i = strtoul(p, &p, 16); 
     
    685695    PARROT_ASSERT(p <= start + io->image->bufused); 
    686696    io->image->strstart = p; 
    687697    io->image->bufused -= (p - start); 
     698    io->image->strlen -= (p - start); 
    688699    PARROT_ASSERT((int)io->image->bufused >= 0); 
     700 
    689701    return (PMC*) i; 
    690702} 
    691703 
     
    712724{ 
    713725    ASSERT_ARGS(op_check_size) 
    714726    const size_t used = s->bufused; 
    715     const int need_free = (int)PObj_buflen(s) - used - len; 
     727    const int need_free = (int)Buffer_buflen(s) - used - len; 
     728 
    716729    /* 
    717730     * grow by factor 1.5 or such 
    718731     */ 
    719732    if (need_free <= 16) { 
    720         size_t new_size = (size_t) (PObj_buflen(s) * 1.5); 
    721         if (new_size < PObj_buflen(s) - need_free + 512) 
    722             new_size = PObj_buflen(s) - need_free + 512; 
     733        size_t new_size = (size_t) (Buffer_buflen(s) * 1.5); 
     734        if (new_size < Buffer_buflen(s) - need_free + 512) 
     735            new_size = Buffer_buflen(s) - need_free + 512; 
    723736        Parrot_gc_reallocate_string_storage(interp, s, new_size); 
    724         PARROT_ASSERT(PObj_buflen(s) - used - len >= 15); 
     737        PARROT_ASSERT(Buffer_buflen(s) - used - len >= 15); 
    725738    } 
    726739#ifndef DISABLE_GC_DEBUG 
    727740    Parrot_gc_compact_memory_pool(interp); 
     
    785798push_opcode_number(PARROT_INTERP, ARGIN(IMAGE_IO *io), FLOATVAL v) 
    786799{ 
    787800    ASSERT_ARGS(push_opcode_number) 
     801 
    788802    const size_t   len  = PF_size_number() * sizeof (opcode_t); 
    789803    STRING * const s    = io->image; 
    790804    const size_t   used = s->bufused; 
     
    812826push_opcode_string(PARROT_INTERP, ARGIN(IMAGE_IO *io), ARGIN(STRING *v)) 
    813827{ 
    814828    ASSERT_ARGS(push_opcode_string) 
     829 
    815830    const size_t len = PF_size_string(v) * sizeof (opcode_t); 
    816831    STRING * const s = io->image; 
    817832    const size_t used = s->bufused; 
     
    862877                                    (const opcode_t **)opcode); 
    863878 
    864879    io->image->bufused -= ((char *)io->image->strstart - start); 
     880    io->image->strlen -= ((char *)io->image->strstart - start); 
    865881    PARROT_ASSERT((int)io->image->bufused >= 0); 
    866882 
    867883    return i; 
     
    903919shift_opcode_number(SHIM_INTERP, ARGIN(IMAGE_IO *io)) 
    904920{ 
    905921    ASSERT_ARGS(shift_opcode_number) 
     922 
    906923    const char * const   start  = (const char *)io->image->strstart; 
    907924    char               **opcode = &io->image->strstart; 
    908925    const FLOATVAL       f      = PF_fetch_number(io->pf, 
    909926                                    (const opcode_t **)opcode); 
    910927 
    911928    io->image->bufused -= ((char *)io->image->strstart - start); 
     929    io->image->strlen -= ((char *)io->image->strstart - start); 
    912930    PARROT_ASSERT((int)io->image->bufused >= 0); 
    913931 
    914932    return f; 
     
    930948shift_opcode_string(PARROT_INTERP, ARGIN(IMAGE_IO *io)) 
    931949{ 
    932950    ASSERT_ARGS(shift_opcode_string) 
     951 
    933952    char * const   start  = (char*)io->image->strstart; 
    934     char         **opcode = &io->image->strstart; 
     953    char *         opcode = io->image->strstart; 
    935954    STRING * const s      = PF_fetch_string(interp, io->pf, 
    936                                 (const opcode_t **)opcode); 
     955                                (const opcode_t **)&opcode); 
    937956 
    938     io->image->bufused -= ((char *)io->image->strstart - start); 
     957    io->image->strstart = opcode; 
     958    io->image->bufused -= (opcode - start); 
     959    io->image->strlen -= (opcode - start); 
    939960    PARROT_ASSERT((int)io->image->bufused >= 0); 
    940961 
    941962    return s; 
     
    10191040         16 - PACKFILE_HEADER_BYTES % 16 : 0); 
    10201041 
    10211042    info->image_io = mem_allocate_typed(IMAGE_IO); 
     1043 
    10221044    info->image_io->image = s = info->image; 
    10231045#if FREEZE_ASCII 
    10241046    info->image_io->vtable = &ascii_funcs; 
     
    10261048    info->image_io->vtable = &opcode_funcs; 
    10271049#endif 
    10281050    pf = info->image_io->pf = PackFile_new(interp, 0); 
     1051 
    10291052    if (info->what == VISIT_FREEZE_NORMAL || 
    10301053        info->what == VISIT_FREEZE_AT_DESTRUCT) { 
    10311054 
     
    10521075        mem_sys_memcopy(pf->header, s->strstart, PACKFILE_HEADER_BYTES); 
    10531076        PackFile_assign_transforms(pf); 
    10541077        s->bufused -= header_length; 
     1078        s->strlen -= header_length; 
    10551079        LVALUE_CAST(char *, s->strstart) += header_length; 
    10561080    } 
    10571081 
     
    11711195 
    11721196    info->extra_flags = EXTRA_IS_NULL; 
    11731197    n = VTABLE_shift_pmc(interp, io); 
     1198 
    11741199    if (((UINTVAL) n & 3) == 3) { 
    11751200        /* pmc has extra data */ 
    11761201        info->extra_flags = VTABLE_shift_integer(interp, io); 
     
    11941219            *type = enum_class_Class; 
    11951220        } 
    11961221    } 
     1222 
    11971223    *id = (UINTVAL) n; 
    11981224    return seen; 
    11991225} 
     
    13561382    } 
    13571383    list_assign(interp, (List *)PMC_data(info->id_list), id, pmc, enum_type_PMC); 
    13581384    /* remember nested aggregates depth first */ 
    1359     if (pmc->pmc_ext) 
     1385    if (PObj_is_PMC_EXT_TEST(pmc)) 
    13601386        list_unshift(interp, (List *)PMC_data(info->todo), pmc, enum_type_PMC); 
    13611387} 
    13621388 
     
    13961422add_pmc_next_for_GC(SHIM_INTERP, ARGIN(PMC *pmc), ARGOUT(visit_info *info)) 
    13971423{ 
    13981424    ASSERT_ARGS(add_pmc_next_for_GC) 
    1399     if (pmc->pmc_ext) { 
     1425    if (PObj_is_PMC_EXT_TEST(pmc)) { 
    14001426        PMC_next_for_GC(info->mark_ptr) = pmc; 
    14011427        info->mark_ptr = PMC_next_for_GC(pmc) = pmc; 
    14021428    } 
     
    14331459     * we can only remember PMCs with a next_for_GC pointer 
    14341460     * which is located in pmc_ext 
    14351461     */ 
    1436     if (pmc->pmc_ext) { 
     1462    if (PObj_is_PMC_EXT_TEST(pmc)) { 
    14371463        /* already seen? */ 
    14381464        if (!PMC_IS_NULL(PMC_next_for_GC(pmc))) { 
    14391465            seen = 1; 
     
    15001526    parrot_hash_put(interp, 
    15011527            (Hash *)VTABLE_get_pointer(interp, info->seen), pmc, (void*)*id); 
    15021528    /* remember containers */ 
    1503     if (pmc->pmc_ext) 
     1529    if (PObj_is_PMC_EXT_TEST(pmc)) 
    15041530        list_unshift(interp, (List *)PMC_data(info->todo), pmc, enum_type_PMC); 
    15051531    return 0; 
    15061532} 
     
    16071633{ 
    16081634    ASSERT_ARGS(visit_loop_next_for_GC) 
    16091635    visit_next_for_GC(interp, current, info); 
    1610     if (current->pmc_ext) { 
     1636    if (PObj_is_PMC_EXT_TEST(current)) { 
    16111637        PMC *prev = NULL; 
    16121638 
    16131639        while (current != prev) { 
     
    17971823     */ 
    17981824    LVALUE_CAST(char *, image->strstart) -= bufused; 
    17991825    image->bufused = bufused; 
    1800     PARROT_ASSERT(image->strstart >= (char *)PObj_bufstart(image)); 
     1826    image->strlen += bufused; 
     1827    PARROT_ASSERT(image->strstart >= (char *)Buffer_bufstart(image)); 
    18011828 
    18021829    if (gc_block) { 
    18031830        Parrot_unblock_GC_mark(interp); 
  • src/pmc/unmanagedstruct.pmc

     
    382382            ret  = *(PMC**) p; 
    383383 
    384384            /* now check if initializer has a signature attached */ 
    385             if (ptr->pmc_ext && PMC_metadata(ptr)) { 
     385            if (PObj_is_PMC_EXT_TEST(ptr) && PMC_metadata(ptr)) { 
    386386                STRING *signature_str = CONST_STRING(interp, "_signature"); 
    387387                PMC *sig = VTABLE_getprop(interp, ptr, signature_str); 
    388388                if (VTABLE_defined(interp, sig)) { 
     
    398398            /* check the metadata for an initializer */ 
    399399 
    400400            /* grab the struct from the metadata */ 
    401             if (ptr->pmc_ext && PMC_metadata(ptr)) { 
     401            if (PObj_is_PMC_EXT_TEST(ptr) && PMC_metadata(ptr)) { 
    402402                ret = VTABLE_getprop(interp, ptr, CONST_STRING(interp, "_struct")); 
    403403            } 
    404404            else { 
  • src/pmc/key.pmc

     
    278278    VTABLE PMC *shift_pmc() { 
    279279        PMC *next_key; 
    280280 
    281         if (!SELF->pmc_ext) 
     281        if (!PObj_is_PMC_EXT_TEST(SELF)) 
    282282            return NULL; 
    283283 
    284284        GET_ATTR_next_key(INTERP, SELF, next_key); 
  • src/key.c

     
    544544    ASSERT_ARGS(key_next) 
    545545    PMC *next_key; 
    546546 
    547     if (VTABLE_isa(interp, key, CONST_STRING(interp, "Key")) && key->pmc_ext) { 
     547    if (VTABLE_isa(interp, key, CONST_STRING(interp, "Key")) && PObj_is_PMC_EXT_TEST(key)) { 
    548548        GETATTR_Key_next_key(interp, key, next_key); 
    549549        return next_key; 
    550550    } 
  • src/debug.c

     
    33713371    if (!s) 
    33723372        return; 
    33733373 
    3374     Parrot_io_eprintf(interp, "\tBuflen  =\t%12ld\n", PObj_buflen(s)); 
     3374    Parrot_io_eprintf(interp, "\tBuflen  =\t%12ld\n", Buffer_buflen(s)); 
    33753375    Parrot_io_eprintf(interp, "\tFlags   =\t%12ld\n", PObj_get_FLAGS(s)); 
    33763376    Parrot_io_eprintf(interp, "\tBufused =\t%12ld\n", s->bufused); 
    33773377    Parrot_io_eprintf(interp, "\tStrlen  =\t%12ld\n", s->strlen); 
    33783378    Parrot_io_eprintf(interp, "\tOffset  =\t%12ld\n", 
    3379                     (char*) s->strstart - (char*) PObj_bufstart(s)); 
     3379                    (char*) s->strstart - (char*) Buffer_bufstart(s)); 
    33803380    Parrot_io_eprintf(interp, "\tString  =\t%S\n", s); 
    33813381} 
    33823382 
  • src/string/api.c

     
    8989         * also be sure not to allocate from the constant pool 
    9090         */ 
    9191        PObj_flags_CLEARALL(&for_alloc); 
    92         Parrot_gc_allocate_string_storage(interp, &for_alloc, PObj_buflen(s)); 
     92        Parrot_gc_allocate_string_storage(interp, &for_alloc, Buffer_buflen(s)); 
    9393 
    9494        /* now copy memory over */ 
    9595        mem_sys_memcopy(for_alloc.strstart, s->strstart, s->bufused); 
    9696 
    9797        /* and finally use that string memory */ 
    9898 
    99         PObj_bufstart(s) = PObj_bufstart(&for_alloc); 
     99        Buffer_bufstart(s) = Buffer_bufstart(&for_alloc); 
    100100        s->strstart      = for_alloc.strstart; 
    101         PObj_buflen(s)   = PObj_buflen(&for_alloc); 
     101        Buffer_buflen(s)   = Buffer_buflen(&for_alloc); 
    102102 
    103103        /* COW_FLAG | external_FLAG */ 
    104104        PObj_is_external_CLEARALL(s); 
     
    148148        /* XXX FIXME hack to avoid cross-interpreter issue until it 
    149149         * is fixed correctly. */ 
    150150        if (n_interpreters > 1 && PObj_is_movable_TESTALL(s) && 
    151                 !Parrot_gc_ptr_in_memory_pool(interp, PObj_bufstart(s))) { 
     151                !Parrot_gc_ptr_in_memory_pool(interp, Buffer_bufstart(s))) { 
    152152            Parrot_str_write_COW(interp, d); 
    153153            Parrot_io_eprintf(interp, "cross-interpreter copy of " 
    154154                                     "relocatable string '%Ss' into tid %d\n", 
     
    215215    if (dest) { /* && dest != src */ 
    216216        /* they are different, dest is not an external string */ 
    217217#ifdef GC_IS_MALLOC 
    218         if (!PObj_is_cowed_TESTALL(dest) && PObj_bufstart(dest)) { 
    219             mem_sys_free(PObj_bufallocstart(dest)); 
     218        if (!PObj_is_cowed_TESTALL(dest) && Buffer_bufstart(dest)) { 
     219            mem_sys_free(Buffer_bufallocstart(dest)); 
    220220        } 
    221221#endif 
    222222        dest = Parrot_str_reuse_COW(interp, src, dest); 
     
    338338{ 
    339339    ASSERT_ARGS(string_capacity) 
    340340 
    341     return ((ptrcast_t)PObj_bufstart(s) + PObj_buflen(s) - 
     341    return ((ptrcast_t)Buffer_bufstart(s) + Buffer_buflen(s) - 
    342342            (ptrcast_t)s->strstart); 
    343343} 
    344344 
     
    524524        return a; 
    525525 
    526526    /* Is A real? */ 
    527     if (a == NULL || PObj_bufstart(a) == NULL) 
     527    if (a == NULL || Buffer_bufstart(a) == NULL) 
    528528        return Parrot_str_copy(interp, b); 
    529529 
    530530    saneify_string(a); 
     
    806806           it was safe by setting PObj_external_FLAG. 
    807807           (The cast is necessary to pacify TenDRA's tcc.) 
    808808           */ 
    809         PObj_bufstart(s) = s->strstart = PARROT_const_cast(char *, buffer); 
    810         PObj_buflen(s)   = s->bufused  = len; 
     809        Buffer_bufstart(s) = s->strstart = PARROT_const_cast(char *, buffer); 
     810        Buffer_buflen(s)   = s->bufused  = len; 
    811811 
    812812        if (encoding == Parrot_fixed_8_encoding_ptr) 
    813813            s->strlen = len; 
     
    855855 
    856856    /* Don't check buflen, if we are here, we already checked. */ 
    857857    Parrot_gc_reallocate_string_storage(interp, 
    858         s, PObj_buflen(s) + string_max_bytes(interp, s, addlen)); 
     858        s, Buffer_buflen(s) + string_max_bytes(interp, s, addlen)); 
    859859    return s; 
    860860} 
    861861 
     
    13281328    diff = (end_byte - start_byte) - rep->bufused; 
    13291329 
    13301330    if (diff >= 0 
    1331     || ((INTVAL)src->bufused - (INTVAL)PObj_buflen(src)) <= diff) { 
     1331    || ((INTVAL)src->bufused - (INTVAL)Buffer_buflen(src)) <= diff) { 
    13321332        Parrot_str_write_COW(interp, src); 
    13331333 
    13341334        if (diff != 0) { 
     
    24792479     */ 
    24802480    Parrot_str_write_COW(interp, s); 
    24812481 
    2482     size   = PObj_buflen(s); 
     2482    size   = Buffer_buflen(s); 
    24832483    memory = (char *)mem_sys_allocate(size); 
    24842484 
    2485     mem_sys_memcopy(memory, PObj_bufstart(s), size); 
    2486     PObj_bufstart(s) = memory; 
     2485    mem_sys_memcopy(memory, Buffer_bufstart(s), size); 
     2486    Buffer_bufstart(s) = memory; 
    24872487    s->strstart      = memory; 
    24882488 
    24892489    /* Mark the memory as both from the system and immobile */ 
     
    25162516        return; 
    25172517 
    25182518    Parrot_str_write_COW(interp, s); 
    2519     size = PObj_buflen(s); 
     2519    size = Buffer_buflen(s); 
    25202520 
    25212521    /* We need a handle on the fixed memory so we can get rid of it later */ 
    2522     memory = PObj_bufstart(s); 
     2522    memory = Buffer_bufstart(s); 
    25232523 
    25242524    /* Reallocate it the same size 
    25252525     * NOTE can't use Parrot_gc_reallocate_string_storage because of the LEA 
     
    25302530    Parrot_block_GC_sweep(interp); 
    25312531    Parrot_gc_allocate_string_storage(interp, s, size); 
    25322532    Parrot_unblock_GC_sweep(interp); 
    2533     mem_sys_memcopy(PObj_bufstart(s), memory, size); 
     2533    mem_sys_memcopy(Buffer_bufstart(s), memory, size); 
    25342534 
    25352535    /* Mark the memory as neither immobile nor system allocated */ 
    25362536    PObj_sysmem_CLEAR(s); 
     
    27222722        i += hex->strlen; 
    27232723 
    27242724        /* and usable len */ 
    2725         charlen = PObj_buflen(result); 
     2725        charlen = Buffer_buflen(result); 
    27262726        dp      = (unsigned char *)result->strstart; 
    27272727 
    27282728        PARROT_ASSERT(i <= charlen); 
  • src/string/encoding/fixed_8.c

     
    634634{ 
    635635    ASSERT_ARGS(fixed8_set_position) 
    636636    iter->bytepos = iter->charpos = pos; 
    637     PARROT_ASSERT(pos <= PObj_buflen(iter->str)); 
     637    PARROT_ASSERT(pos <= Buffer_buflen(iter->str)); 
    638638} 
    639639 
    640640 
  • src/gc/alloc_resources.c

     
    5454        __attribute__nonnull__(1) 
    5555        __attribute__nonnull__(2); 
    5656 
    57 static void debug_print_buf(PARROT_INTERP, ARGIN(const PObj *b)) 
     57static void debug_print_buf(PARROT_INTERP, ARGIN(const Buffer *b)) 
    5858        __attribute__nonnull__(1) 
    5959        __attribute__nonnull__(2); 
    6060 
     
    285285*/ 
    286286 
    287287static void 
    288 debug_print_buf(PARROT_INTERP, ARGIN(const PObj *b)) 
     288debug_print_buf(PARROT_INTERP, ARGIN(const Buffer *b)) 
    289289{ 
    290290    ASSERT_ARGS(debug_print_buf) 
    291291    fprintf(stderr, "found %p, len %d, flags 0x%08x at %s\n", 
    292             b, (int)PObj_buflen(b), (uint)PObj_get_FLAGS(b), 
     292            b, (int)Buffer_buflen(b), (uint)PObj_get_FLAGS(b), 
    293293            buffer_location(interp, b)); 
    294294} 
    295295#endif 
     
    407407                INTVAL *ref_count = NULL; 
    408408 
    409409                /* ! (on_free_list | constant | external | sysmem) */ 
    410                 if (PObj_buflen(b) && PObj_is_movable_TESTALL(b)) { 
     410                if (Buffer_buflen(b) && PObj_is_movable_TESTALL(b)) { 
    411411                    ptrdiff_t offset = 0; 
    412412#if RESOURCE_DEBUG 
    413                     if (PObj_buflen(b) >= RESOURCE_DEBUG_SIZE) 
     413                    if (Buffer_buflen(b) >= RESOURCE_DEBUG_SIZE) 
    414414                        debug_print_buf(interp, b); 
    415415#endif 
    416416 
    417417                    /* we can't perform the math all the time, because 
    418418                     * strstart might be in unallocated memory */ 
    419419                    if (PObj_is_COWable_TEST(b)) { 
    420                         ref_count = PObj_bufrefcountptr(b); 
     420                        ref_count = Buffer_bufrefcountptr(b); 
    421421 
    422422                        if (PObj_is_string_TEST(b)) { 
    423423                            offset = (ptrdiff_t)((STRING *)b)->strstart - 
    424                                 (ptrdiff_t)PObj_bufstart(b); 
     424                                (ptrdiff_t)Buffer_bufstart(b); 
    425425                        } 
    426426                    } 
    427427 
     
    429429                    if (PObj_COW_TEST(b) && 
    430430                        (ref_count && *ref_count & Buffer_moved_FLAG)) { 
    431431                        /* Find out who else references our data */ 
    432                         Buffer * const hdr = *(Buffer **)(PObj_bufstart(b)); 
     432                        Buffer * const hdr = *((Buffer **)Buffer_bufstart(b)); 
     433 
    433434 
    434435                        PARROT_ASSERT(PObj_is_COWable_TEST(b)); 
    435436 
     
    438439 
    439440                        /* TODO incr ref_count, after fixing string too 
    440441                         * Now make sure we point to where the other guy does */ 
    441                         PObj_bufstart(b) = PObj_bufstart(hdr); 
     442                        Buffer_bufstart(b) = Buffer_bufstart(hdr); 
    442443 
    443444                        /* And if we're a string, update strstart */ 
    444445                        /* Somewhat of a hack, but if we get per-pool 
    445446                         * collections, it should help ease the pain */ 
    446447                        if (PObj_is_string_TEST(b)) { 
    447                             ((STRING *)b)->strstart = (char *)PObj_bufstart(b) + 
     448                            ((STRING *)b)->strstart = (char *)Buffer_bufstart(b) + 
    448449                                    offset; 
    449450                        } 
    450451                    } 
     
    457458                        } 
    458459 
    459460                        /* Copy our memory to the new pool */ 
    460                         memcpy(cur_spot, PObj_bufstart(b), PObj_buflen(b)); 
     461                        memcpy(cur_spot, Buffer_bufstart(b), Buffer_buflen(b)); 
    461462 
    462463                        /* If we're COW */ 
    463464                        if (PObj_COW_TEST(b)) { 
    464465                            PARROT_ASSERT(PObj_is_COWable_TEST(b)); 
    465466 
    466467                            /* Let the old buffer know how to find us */ 
    467                             *(Buffer **)(PObj_bufstart(b)) = b; 
     468                            *((Buffer **)Buffer_bufstart(b)) = b; 
    468469 
    469470                            /* No guarantees that our data is still COW, so 
    470471                             * assume not, and let the above code fix-up */ 
     
    477478                                *ref_count |= Buffer_moved_FLAG; 
    478479                        } 
    479480 
    480                         PObj_bufstart(b) = cur_spot; 
     481                        Buffer_bufstart(b) = cur_spot; 
    481482 
    482483                        if (PObj_is_string_TEST(b)) { 
    483                             ((STRING *)b)->strstart = (char *)PObj_bufstart(b) + 
     484                            ((STRING *)b)->strstart = (char *)Buffer_bufstart(b) + 
    484485                                    offset; 
    485486                        } 
    486487 
    487                         cur_spot += PObj_buflen(b); 
     488                        cur_spot += Buffer_buflen(b); 
    488489                    } 
    489490                } 
    490491                b = (Buffer *)((char *)b + object_size); 
     
    676677 
    677678    /* Constant strings - not compacted */ 
    678679    arena_base->constant_string_pool = new_memory_pool(POOL_SIZE, NULL); 
    679  
    680680    alloc_new_block(interp, POOL_SIZE, arena_base->constant_string_pool, "init"); 
    681681} 
    682682 
     
    743743*/ 
    744744 
    745745/* 
     746 
     747=item C<void check_memory_system(PARROT_INTERP)> 
     748 
     749Checks the memory system of parrot on any corruptions, including 
     750the string system. 
     751 
     752=cut 
     753 
     754*/ 
     755 
     756void 
     757check_memory_system(PARROT_INTERP) 
     758{ 
     759  size_t i; 
     760  Arenas * const arena_base = interp->arena_base; 
     761 
     762  check_memory_pool(arena_base->memory_pool); 
     763  check_memory_pool(arena_base->constant_string_pool); 
     764  check_small_object_pool(arena_base->pmc_pool); 
     765  check_small_object_pool(arena_base->constant_pmc_pool); 
     766  check_small_object_pool(arena_base->string_header_pool); 
     767  check_small_object_pool(arena_base->constant_string_header_pool); 
     768 
     769  for(i = 0;i < arena_base->num_sized;i++) 
     770  { 
     771      Small_Object_Pool * pool = arena_base->sized_header_pools[i]; 
     772      if(pool != NULL && pool != arena_base->string_header_pool) 
     773        check_small_object_pool(pool); 
     774  } 
     775} 
     776 
     777/* 
     778 
     779=item C<void check_small_object_pool(Small_Object_Pool * pool)> 
     780 
     781Checks a small object pool, if it contains buffer it checks the buffers also. 
     782 
     783=cut 
     784 
     785*/ 
     786 
     787void 
     788check_small_object_pool(Small_Object_Pool * pool) 
     789{ 
     790    size_t total_objects; 
     791    size_t last_free_list_count; 
     792    Small_Object_Arena * arena_walker; 
     793    size_t free_objects; 
     794    PObj * object; 
     795    size_t i; 
     796    size_t count; 
     797    GC_MS_PObj_Wrapper * pobj_walker; 
     798 
     799    count = 10000000; /*detect unendless loop just use big enough number*/ 
     800 
     801    total_objects = pool->total_objects; 
     802    last_free_list_count = 1; 
     803    free_objects = 0; 
     804 
     805    arena_walker = pool->last_Arena; 
     806    while(arena_walker != NULL) 
     807    { 
     808            total_objects -= arena_walker->total_objects; 
     809            object = (PObj*)arena_walker->start_objects; 
     810            for(i = 0;i < arena_walker->total_objects;++i) 
     811            { 
     812                if(PObj_on_free_list_TEST(object)) 
     813                { 
     814                  ++free_objects; 
     815                  pobj_walker = (GC_MS_PObj_Wrapper*)object; 
     816                  if(pobj_walker->next_ptr == NULL) 
     817                  { 
     818                          --last_free_list_count; //should happen only ones at the end 
     819                  } 
     820                  else 
     821                  {   /*next item on free list should also be flaged as free item*/ 
     822                          pobj_walker = (GC_MS_PObj_Wrapper*)pobj_walker->next_ptr; 
     823                          PARROT_ASSERT(PObj_on_free_list_TEST((PObj*)pobj_walker)); 
     824                  } 
     825                } 
     826                else if(pool->mem_pool != NULL) /*then it means we are a buffer*/ 
     827                { 
     828                  check_buffer_ptr((Buffer*)object,pool->mem_pool); 
     829                } 
     830                object = (PObj*)((char *)object + pool->object_size); 
     831                PARROT_ASSERT(--count); 
     832            } 
     833            /*check the list*/ 
     834            if(arena_walker->prev != NULL) 
     835            { 
     836                PARROT_ASSERT(arena_walker->prev->next == arena_walker); 
     837            } 
     838        arena_walker = arena_walker->prev; 
     839        PARROT_ASSERT(--count); 
     840    } 
     841 
     842    count = 10000000; 
     843 
     844    PARROT_ASSERT(free_objects == pool->num_free_objects); 
     845 
     846    pobj_walker = (GC_MS_PObj_Wrapper*)pool->free_list; 
     847    while(pobj_walker != NULL) 
     848    { 
     849        PARROT_ASSERT(pool->start_arena_memory <= (size_t)pobj_walker); 
     850        PARROT_ASSERT(pool->end_arena_memory > (size_t)pobj_walker); 
     851        PARROT_ASSERT(PObj_on_free_list_TEST((PObj*)pobj_walker)); 
     852        --free_objects; 
     853            pobj_walker = (GC_MS_PObj_Wrapper*)pobj_walker->next_ptr; 
     854            PARROT_ASSERT(--count); 
     855    } 
     856 
     857    PARROT_ASSERT(total_objects == 0); 
     858    PARROT_ASSERT(last_free_list_count == 0 || pool->num_free_objects == 0); 
     859    PARROT_ASSERT(free_objects == 0); 
     860} 
     861 
     862/* 
     863 
     864=item C<void check_memory_pool(Memory_Pool *pool)> 
     865 
     866Checks a memory pool, containing buffer data 
     867 
     868=cut 
     869 
     870*/ 
     871 
     872void 
     873check_memory_pool(Memory_Pool *pool) 
     874{ 
     875    size_t count; 
     876    count = 10000000; /*detect unendless loop just use big enough number*/ 
     877 
     878        Memory_Block * block_walker = (Memory_Block *)pool->top_block; 
     879        while(block_walker != NULL) 
     880        { 
     881                PARROT_ASSERT(block_walker->start == (char *)block_walker + sizeof (Memory_Block)); 
     882            PARROT_ASSERT((size_t)(block_walker->top - block_walker->start) == block_walker->size - block_walker->free); 
     883 
     884        /*check the list*/ 
     885            if(block_walker->prev != NULL) 
     886            { 
     887                PARROT_ASSERT(block_walker->prev->next == block_walker); 
     888            } 
     889        block_walker = block_walker->prev; 
     890        PARROT_ASSERT(--count); 
     891        } 
     892} 
     893 
     894/* 
     895 
     896=item C<void check_buffer_ptr(Buffer * pobj,Memory_Pool * pool)> 
     897 
     898Checks wether the buffer is within the bounds of the memory pool 
     899 
     900=cut 
     901 
     902*/ 
     903 
     904void 
     905check_buffer_ptr(Buffer * pobj,Memory_Pool * pool) 
     906{ 
     907    Memory_Block * cur_block = pool->top_block; 
     908    char * bufstart; 
     909 
     910    bufstart = (char*)Buffer_bufstart(pobj); 
     911 
     912    if(bufstart == NULL && Buffer_buflen(pobj) == 0) 
     913        return; 
     914 
     915    if(PObj_external_TEST(pobj)) /*buffer does not come from the memory pool*/ 
     916    { 
     917        if (PObj_is_string_TEST(pobj)) 
     918        { 
     919            PARROT_ASSERT(((STRING *) pobj)->strstart >= (char *) Buffer_bufstart(pobj)); 
     920            PARROT_ASSERT(((STRING *) pobj)->strstart + ((STRING *) pobj)->strlen <= (char *) Buffer_bufstart(pobj) + Buffer_buflen(pobj)); 
     921        } 
     922        return; 
     923    } 
     924 
     925    if(PObj_is_COWable_TEST(pobj)) 
     926        bufstart -= sizeof (void*); 
     927 
     928    while (cur_block) 
     929    { 
     930        if ((char *)bufstart >= cur_block->start && 
     931            (char *)Buffer_bufstart(pobj) + Buffer_buflen(pobj) < cur_block->start + cur_block->size) 
     932        { 
     933            if (PObj_is_string_TEST(pobj)) 
     934            { 
     935                PARROT_ASSERT(((STRING *)pobj)->strstart >= (char *)Buffer_bufstart(pobj)); 
     936                PARROT_ASSERT(((STRING *)pobj)->strstart + ((STRING *)pobj)->strlen <= (char *)Buffer_bufstart(pobj) + Buffer_buflen(pobj)); 
     937            } 
     938            return; 
     939        } 
     940        cur_block = cur_block->prev; 
     941    } 
     942    PARROT_ASSERT(0); 
     943} 
     944 
     945/* 
    746946 * Local variables: 
    747947 *   c-file-style: "parrot" 
    748948 * End: 
  • src/call/pcc.c

     
    16651665             * RT #54860 and others 
    16661666             * Save current value while setting the optional 
    16671667             */ 
    1668             const UnionVal old_value = st->val; 
     1668            const UnionCallStateVal old_value = st->val; 
    16691669 
    16701670            while (dest->sig & PARROT_ARG_OPTIONAL) { 
    16711671                null_val(st->dest.sig, st); 
  • src/gc/mark_sweep.c

     
    3333 
    3434static void free_buffer(SHIM_INTERP, 
    3535    ARGMOD(Small_Object_Pool *pool), 
    36     ARGMOD(PObj *b)) 
     36    ARGMOD(Buffer *b)) 
    3737        __attribute__nonnull__(2) 
    3838        __attribute__nonnull__(3) 
    3939        FUNC_MODIFIES(*pool) 
     
    4141 
    4242static void free_buffer_malloc(SHIM_INTERP, 
    4343    SHIM(Small_Object_Pool *pool), 
    44     ARGMOD(PObj *b)) 
     44    ARGMOD(Buffer *b)) 
    4545        __attribute__nonnull__(3) 
    4646        FUNC_MODIFIES(*b); 
    4747 
     
    5454 
    5555PARROT_WARN_UNUSED_RESULT 
    5656PARROT_CANNOT_RETURN_NULL 
    57 static Small_Object_Pool * new_buffer_pool(PARROT_INTERP) 
    58         __attribute__nonnull__(1); 
    59  
    60 PARROT_WARN_UNUSED_RESULT 
    61 PARROT_CANNOT_RETURN_NULL 
    6257static Small_Object_Pool * new_bufferlike_pool(PARROT_INTERP, 
    6358    size_t actual_buffer_size) 
    6459        __attribute__nonnull__(1); 
     
    9893#define ASSERT_ARGS_free_pmc_in_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \ 
    9994       PARROT_ASSERT_ARG(interp) \ 
    10095    || PARROT_ASSERT_ARG(p) 
    101 #define ASSERT_ARGS_new_buffer_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \ 
    102        PARROT_ASSERT_ARG(interp) 
    10396#define ASSERT_ARGS_new_bufferlike_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \ 
    10497       PARROT_ASSERT_ARG(interp) 
    10598#define ASSERT_ARGS_new_pmc_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = \ 
     
    140133    arena_base->gc_trace_ptr        = NULL; 
    141134    arena_base->gc_mark_start       = NULL; 
    142135    arena_base->num_early_PMCs_seen = 0; 
    143     arena_base->num_extended_PMCs   = 0; 
    144136} 
    145137 
    146138/* 
     
    281273Parrot_gc_sweep_pool(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool)) 
    282274{ 
    283275    ASSERT_ARGS(Parrot_gc_sweep_pool) 
     276    PObj *b; 
     277    UINTVAL i; 
    284278    UINTVAL total_used        = 0; 
    285279    const UINTVAL object_size = pool->object_size; 
    286280 
     
    301295    } 
    302296#endif 
    303297 
    304     /* Run through all the buffer header pools and mark */ 
     298    /* Run through all the PObj header pools and mark */ 
    305299    for (cur_arena = pool->last_Arena; cur_arena; cur_arena = cur_arena->prev) { 
    306         Buffer *b = (Buffer *)cur_arena->start_objects; 
    307         UINTVAL i; 
     300        b = (PObj*)cur_arena->start_objects; 
    308301 
    309302        /* loop only while there are objects in the arena */ 
    310303        for (i = cur_arena->total_objects; i; i--) { 
     
    349342                pool->add_free_object(interp, pool, b); 
    350343            } 
    351344next: 
    352             b = (Buffer *)((char *)b + object_size); 
     345            b = (PObj *)((char *)b + object_size); 
    353346        } 
    354347    } 
    355348 
     
    443436    else 
    444437        hi_prio = 0; 
    445438 
    446     if (obj->pmc_ext) { 
     439    if (PObj_is_PMC_EXT_TEST(obj)) { 
    447440        PMC * const tptr = arena_base->gc_trace_ptr; 
    448  
    449         ++arena_base->num_extended_PMCs; 
    450441        /* 
    451442         * XXX this basically invalidates the high-priority marking 
    452443         *     of PMCs by putting all PMCs onto the front of the list. 
     
    803794 
    804795#ifndef NDEBUG 
    805796 
    806     pmc->pmc_ext     = (PMC_EXT *)0xdeadbeef; 
    807797    pmc->vtable      = (VTABLE  *)0xdeadbeef; 
    808798 
    809799#endif 
     
    835825    Small_Object_Pool * const pool = 
    836826            new_small_object_pool(buffer_size, num_headers); 
    837827 
    838     pool->gc_object = NULL; 
     828#ifdef GC_IS_MALLOC 
     829    pool->gc_object = free_buffer_malloc; 
     830#else 
     831    pool->gc_object = (gc_object_fn_type)free_buffer; 
     832#endif 
     833 
    839834    pool->mem_pool  = interp->arena_base->memory_pool; 
    840835    (interp->arena_base->init_pool)(interp, pool); 
    841836    return pool; 
     
    872867    return pool; 
    873868} 
    874869 
    875  
    876  
    877870/* 
    878871 
    879 =item C<static Small_Object_Pool * new_buffer_pool(PARROT_INTERP)> 
    880  
    881 Creates a new C<Small_Object_Pool> structure for managing buffer objects. 
     872=item C<static Small_Object_Pool * new_string_pool(PARROT_INTERP, INTVAL 
     873constant)> 
    882874 
    883 Non-constant strings and plain Buffers are stored in the sized header pools. 
     875Creates a new pool for C<STRING>s and returns it. This calls 
     876C<get_bufferlike_pool> internally, which in turn calls C<new_bufferlike_pool>. 
    884877 
    885878=cut 
    886879 
     
    889882PARROT_WARN_UNUSED_RESULT 
    890883PARROT_CANNOT_RETURN_NULL 
    891884static Small_Object_Pool * 
    892 new_buffer_pool(PARROT_INTERP) 
     885new_string_pool(PARROT_INTERP, INTVAL constant) 
    893886{ 
    894     ASSERT_ARGS(new_buffer_pool) 
    895     Small_Object_Pool * const pool = get_bufferlike_pool(interp, sizeof (Buffer)); 
     887    ASSERT_ARGS(new_string_pool) 
     888    Small_Object_Pool *pool; 
     889    if (constant) { 
     890        pool           = new_bufferlike_pool(interp, sizeof (STRING)); 
     891        pool->gc_object = NULL; 
     892        pool->mem_pool = interp->arena_base->constant_string_pool; 
     893    } 
     894    else 
     895        pool = get_bufferlike_pool(interp, sizeof (STRING)); 
    896896 
    897 #ifdef GC_IS_MALLOC 
    898     pool->gc_object = free_buffer_malloc; 
    899 #else 
    900     pool->gc_object = free_buffer; 
    901 #endif 
     897    pool->objects_per_alloc = STRING_HEADERS_PER_ALLOC; 
    902898 
    903899    return pool; 
    904900} 
     
    918914 
    919915static void 
    920916free_buffer_malloc(SHIM_INTERP, SHIM(Small_Object_Pool *pool), 
    921         ARGMOD(PObj *b)) 
     917        ARGMOD(Buffer *b)) 
    922918{ 
    923919    ASSERT_ARGS(free_buffer_malloc) 
    924920    /* free allocated space at (int *)bufstart - 1, but not if it used COW or is 
    925921     * external */ 
    926     PObj_buflen(b) = 0; 
     922    Buffer_buflen(b) = 0; 
    927923 
    928     if (!PObj_bufstart(b) || PObj_is_external_or_free_TESTALL(b)) 
     924    if (!Buffer_bufstart(b) || PObj_is_external_or_free_TESTALL(b)) 
    929925        return; 
    930926 
    931927    if (PObj_COW_TEST(b)) { 
    932         INTVAL * const refcount = PObj_bufrefcountptr(b); 
     928        INTVAL * const refcount = Buffer_bufrefcountptr(b); 
    933929 
    934930        if (--(*refcount) == 0) { 
    935931            mem_sys_free(refcount); /* the actual bufstart */ 
    936932        } 
    937933    } 
    938934    else 
    939         mem_sys_free(PObj_bufrefcountptr(b)); 
     935        mem_sys_free(Buffer_bufrefcountptr(b)); 
    940936} 
    941937 
    942938/* 
     
    952948*/ 
    953949 
    954950static void 
    955 free_buffer(SHIM_INTERP, ARGMOD(Small_Object_Pool *pool), ARGMOD(PObj *b)) 
     951free_buffer(SHIM_INTERP, ARGMOD(Small_Object_Pool *pool), ARGMOD(Buffer *b)) 
    956952{ 
    957953    ASSERT_ARGS(free_buffer) 
    958954    Memory_Pool * const mem_pool = (Memory_Pool *)pool->mem_pool; 
     
    961957     * shouldn't happen */ 
    962958    if (mem_pool) { 
    963959        if (!PObj_COW_TEST(b)) 
    964             mem_pool->guaranteed_reclaimable += PObj_buflen(b); 
     960            mem_pool->guaranteed_reclaimable += Buffer_buflen(b); 
    965961 
    966          mem_pool->possibly_reclaimable += PObj_buflen(b); 
     962         mem_pool->possibly_reclaimable += Buffer_buflen(b); 
    967963    } 
    968964 
    969     PObj_buflen(b)        = 0; 
     965    Buffer_buflen(b)        = 0; 
    970966} 
    971967 
    972968 
    973969/* 
    974970 
    975 =item C<static Small_Object_Pool * new_string_pool(PARROT_INTERP, INTVAL 
    976 constant)> 
    977  
    978 Creates a new pool for C<STRING>s and returns it. This calls 
    979 C<get_bufferlike_pool> internally, which in turn calls C<new_bufferlike_pool>. 
    980  
    981 =cut 
    982  
    983 */ 
    984  
    985 PARROT_WARN_UNUSED_RESULT 
    986 PARROT_CANNOT_RETURN_NULL 
    987 static Small_Object_Pool * 
    988 new_string_pool(PARROT_INTERP, INTVAL constant) 
    989 { 
    990     ASSERT_ARGS(new_string_pool) 
    991     Small_Object_Pool *pool; 
    992     if (constant) { 
    993         pool           = new_bufferlike_pool(interp, sizeof (STRING)); 
    994         pool->mem_pool = interp->arena_base->constant_string_pool; 
    995     } 
    996     else 
    997         pool = get_bufferlike_pool(interp, sizeof (STRING)); 
    998  
    999     pool->objects_per_alloc = STRING_HEADERS_PER_ALLOC; 
    1000  
    1001     return pool; 
    1002 } 
    1003  
    1004  
    1005 /* 
    1006  
    1007971=item C<Small_Object_Pool * get_bufferlike_pool(PARROT_INTERP, size_t 
    1008972buffer_size)> 
    1009973 
     
    10761040     * The buffer_header_pool and the string_header_pool actually live in the 
    10771041     * sized_header_pools. These pool pointers only provide faster access in 
    10781042     * new_*_header */ 
    1079     arena_base->buffer_header_pool       = new_buffer_pool(interp); 
    1080     arena_base->buffer_header_pool->name = "buffer_header"; 
     1043   // arena_base->buffer_header_pool       = new_buffer_pool(interp); 
     1044   // arena_base->buffer_header_pool->name = "buffer_header"; 
    10811045 
    10821046    /* Init the string header pool */ 
    10831047    arena_base->string_header_pool       = new_string_pool(interp, 0); 
     
    10871051    arena_base->pmc_pool                 = new_pmc_pool(interp); 
    10881052    arena_base->pmc_pool->name           = "pmc"; 
    10891053 
    1090     /* pmc extension buffer */ 
    1091     arena_base->pmc_ext_pool             = 
    1092         new_small_object_pool(sizeof (PMC_EXT), 1024); 
    1093  
    1094 #if PARROT_GC_MS 
    1095     /* 
    1096      * pmc_ext isn't a managed item. If a PMC has a pmc_ext structure 
    1097      * it is returned to the pool instantly - the structure is never 
    1098      * marked. 
    1099      * Use GS MS pool functions 
    1100      */ 
    1101     gc_ms_pmc_ext_pool_init(arena_base->pmc_ext_pool); 
    1102 #elif PARROT_GC_INF 
    1103     arena_base->init_pool(interp, arena_base->pmc_ext_pool); 
    1104 #else 
    1105     /* rational, consistant behavior (as yet unwritten) */ 
    1106 #endif 
    1107  
    1108     arena_base->pmc_ext_pool->name = "pmc_ext"; 
    1109  
    11101054    /* constant PMCs */ 
    11111055    arena_base->constant_pmc_pool                    = new_pmc_pool(interp); 
    11121056    arena_base->constant_pmc_pool->name              = "constant_pmc"; 
  • src/jit_debug_xcoff.c

     
    118118    fprintf(stabs, ".stabx \"STRING:t%d=*%d\"" 
    119119                ",0," C_DECL ",0\n", i, i+1); 
    120120    ++i; 
    121     fprintf(stabs, ".stabx \"Parrot_String:T%d=s%d" 
    122                 "bufstart:14,%d,%d;" 
    123                 "buflen:6,%d,%d;"   /* XXX type */ 
    124                 "flags:12,%d,%d;" 
    125                 "bufused:12,%d,%d;" 
    126                 "strstart:15,%d,%d;"        /* fake a char* */ 
     121    fprintf(stabs, ".stabs \"Parrot_String:T(0,%d)=s%d" 
     122                "bufstart:(0,14),%d,%d;" 
     123                "buflen:(0,6),%d,%d;" 
     124                "flags:(0,12),%d,%d;" 
     125                "bufused:(0,12),%d,%d;" 
     126                "strstart:(0,15),%d,%d;" 
    127127                ";\"" 
    128                 ",0," C_DECL ",0\n", i++, BYTE_SIZE(STRING), 
    129                 BIT_OFFSET(STRING, cache._b._bufstart), BIT_SIZE(void*), 
    130                 BIT_OFFSET(STRING, cache._b._buflen), BIT_SIZE(size_t), 
     128                "," N_LSYM ",0,0,0\n", i++, BYTE_SIZE(STRING), 
     129                BIT_OFFSET(STRING, _bufstart), BIT_SIZE(void*), 
     130                BIT_OFFSET(STRING, _buflen), BIT_SIZE(size_t), 
    131131                BIT_OFFSET(STRING, flags), BIT_SIZE(UINTVAL), 
    132132                BIT_OFFSET(STRING, bufused), BIT_SIZE(UINTVAL), 
    133133                BIT_OFFSET(STRING, strstart), BIT_SIZE(void*)); 
    134134 
    135     fprintf(stabs, ".stabx \"PMCType:T%d=e", i++); 
     135    fprintf(stabs, ".stabs \"PMCType:T(0,%d)=e", i++); 
    136136    for (j = 0; j < interp->n_vtable_max; ++j) { 
    137137        if (interp->vtables[j] && interp->vtables[j]->whoami) { 
    138             STRING* name = interp->vtables[j]->whoami; 
    139             fwrite(name->strstart, name->strlen, 1, stabs); 
     138            STRING *name  = interp->vtables[j]->whoami; 
     139            size_t  items = fwrite(name->strstart, name->strlen, 1, stabs); 
     140            if (!items) 
     141                fprintf(stderr, "Error writing stabs!\n"); 
    140142            fprintf(stabs, ":%d,", j); 
    141143        } 
    142144    } 
    143     fprintf(stabs, ";\",0," C_DECL ",0\n"); 
    144145 
    145     /* PMC type */ 
    146     fprintf(stabs, ".stabx \"PMC:T%d=s%d", i, BYTE_SIZE(PMC)); 
    147     fprintf(stabs, "cache:%d,%d,%d;", 
    148             i + 1, BIT_OFFSET(PMC, cache), BIT_SIZE(UnionVal)); 
    149     fprintf(stabs, "flags:%d,%d,%d;", 
    150             i + 1, BIT_OFFSET(PMC, flags), BIT_SIZE(Parrot_UInt)); 
    151     fprintf(stabs, "vtable:*%d,%d,%d;", 
    152             i + 3, BIT_OFFSET(PMC, vtable), BIT_SIZE(void*)); 
    153     fprintf(stabs, "data:14,%d,%d;", 
    154             BIT_OFFSET(PMC, data), BIT_SIZE(void*)); 
    155     fprintf(stabs, "pmc_ext:*%d,%d,%d;", 
    156             i, BIT_OFFSET(PMC, pmc_ext), BIT_SIZE(void*)); 
    157     fprintf(stabs, ";\""); 
    158     fprintf(stabs, ",0," C_DECL ",0\n"); 
     146    fprintf(stabs, ";\"," N_LSYM ",0,0,0\n"); 
    159147 
    160     fprintf(stabs, ".stabx \"cache:%d,%d,%d;" 
    161                 "flags:12,%d,%d;" 
    162                 ";\"" 
    163                 ",0," C_DECL ",0\n", 
    164                 i + 2, BIT_SIZE(UnionVal), BIT_SIZE(Parrot_UInt)); 
    165     fprintf(stabs, ".stabx \"UnionVal:T%d=u%d" 
    166                 "int_val:12,%d,%d;" 
    167                 "pmc_val:*%d,%d,%d;" 
     148    fprintf(stabs, ".stabs \"PMC:T(0,%d)=s%d" 
     149                "flags:(0,12),%d,%d;" 
     150                "vtable:*(0,%d),%d,%d;" 
     151                "data:(0,14),%d,%d;" 
     152                "_metadata:*(0,%d),%d,%d;" 
     153                "_next_for_GC:*(0,%d),%d,%d;" 
    168154                ";\"" 
    169                 ",0," C_DECL ",0\n", i + 2, BYTE_SIZE(UnionVal), 
    170                 BIT_OFFSET(UnionVal, int_val), BIT_SIZE(INTVAL), 
    171                 i, BIT_OFFSET(UnionVal, pmc_val), BIT_SIZE(void*)); 
    172     fprintf(stabs, ".stabx \"VTABLE:T%d=s%d" 
    173                 "base_type:%d,%d,%d;" 
     155                "," N_LSYM ",0,0,0\n", i, BYTE_SIZE(PMC), 
     156                BIT_OFFSET(PMC, flags), BIT_SIZE(UINTVAL), 
     157                i + 1, BIT_OFFSET(PMC, vtable), BIT_SIZE(void*), 
     158                BIT_OFFSET(PMC, data), BIT_SIZE(void*), 
     159                i, BIT_OFFSET(PMC, _metadata), BIT_SIZE(void*), 
     160                i, BIT_OFFSET(PMC, _next_for_GC), BIT_SIZE(void*)); 
     161 
     162    i++; 
     163 
     164    //some one can add some field to this one 
     165    fprintf(stabs, ".stabs \"VTABLE:T(0,%d)=s%d" 
     166                "base_type:(0,12),%d,%d;" 
    174167                ";\"" 
    175                 ",0," C_DECL ",0\n", i + 3, BYTE_SIZE(UnionVal), 
    176                 i - 1, BIT_OFFSET(VTABLE, base_type), BIT_SIZE(INTVAL)); 
    177     i += 4; 
     168                "," N_LSYM ",0,0,0\n", i, BYTE_SIZE(_vtable), 
     169                BIT_OFFSET(VTABLE, base_type), BIT_SIZE(INTVAL)); 
     170 
     171    i++; 
    178172 
    179173} 
    180174 
  • docs/memory_internals2.pod

     
     1=head1 NAME 
     2 
     3docs/memory_internals2.pod - Memory Internals extra documentation 
     4 
     5=head1 ABSTRACT 
     6 
     7This explanation of the memory system gives a bit more explanation of the memory/gc  
     8system used by parrot. 
     9 
     10=head2 Used memory management systems 
     11 
     12The memory system basically uses 3 types of memory management systems 
     13 
     14=over 4 
     15 
     16=item 1 The standard c allocate system 
     17 
     18=item 2 Memory pool system.  
     19 
     20This system has the following to purposes. 
     21 
     22=over 8  
     23 
     24=item * Variable sized objects are stored in a more compact way. 
     25 
     26=item * There is a compacting function to compact the data 
     27 
     28=back 
     29 
     30This compacting function is working in conjunction with the small object pool system(see next section). 
     31A C<Memory_pool> contains multiple C<Memory_bloc> objects. The more memory is needed 
     32the more C<Memory_bloc> items are added. C<Memory_bloc> items are allocated via the c allocate system. 
     33A memory pool contain variable sized buffers, such as strings. 
     34 
     35=item 3 Smalls Object pool system. 
     36 
     37This is used for efficient storage of small object with constant sizes 
     38which are allocated and released many times. 
     39 
     40=back 
     41 
     42=head2 Small object pool system 
     43 
     44All objects in the small object system are of type C<PObj> 
     45 
     46 typedef struct pobj_t { 
     47     Parrot_UInt flags; 
     48 } PObj; 
     49  
     50This struct is "sub classed" by the following 3 structs 
     51 
     52=over 4 
     53 
     54=item * GC_MS_PObj_Wrapper, this struct is used when object are on the free list 
     55 
     56 typedef struct GC_MS_PObj_Wrapper { 
     57    size_t flags; 
     58    struct GC_MS_PObj_Wrapper * next_ptr; 
     59 } GC_MS_PObj_Wrapper; 
     60  
     61=item * Buffer, this struct is used for object which hold a buffer 
     62 
     63 typedef struct buffer_t { 
     64    Parrot_UInt flags; 
     65    void *     _bufstart; 
     66    size_t     _buflen;     
     67 } Buffer; 
     68 
     69=item * PMC, the all important pmc :)  
     70 
     71 struct PMC { 
     72    Parrot_UInt     flags; 
     73    VTABLE         *vtable; 
     74    DPOINTER       *data; 
     75    PMC            *_metadata;  /* object properties */ 
     76    struct _Sync   *_synchronize; 
     77    PMC            *_next_for_GC; 
     78 }; 
     79 
     80=back 
     81 
     82The Buffer struct, is "sub classed" by the following 3 structs 
     83 
     84=over 4 
     85 
     86=item * String 
     87 
     88 struct parrot_string_t { 
     89    Parrot_UInt flags; 
     90    void *     _bufstart; 
     91    size_t     _buflen; 
     92       
     93    char       *strstart; 
     94    UINTVAL     bufused; 
     95    UINTVAL     strlen; 
     96    UINTVAL     hashval; /* cached hash value computation */ 
     97 
     98    /*    parrot_string_representation_t representation;*/ 
     99    const struct _encoding *encoding; 
     100    const struct _charset  *charset; 
     101 }; 
     102 
     103=item * List_chunk 
     104 
     105=item * List 
     106 
     107=back 
     108 
     109See pobj.h for information on the available flags, notice there is a flag indicating that 
     110the object is on the free list.  
     111 
     112The memory system is aware of 3 types of small object pools. 
     113 
     114=over 4 
     115 
     116=item 1 Those pools with a reference to a variable buffer in C<< Arenas->Memory >>. 
     117 
     118These pools must apply to the following things 
     119 
     120=over 8 
     121 
     122=item * They must be present in the sized_header_pools list 
     123 
     124=item * All object they contain must be of the type PObj  
     125 
     126    typedef struct buffer_t { 
     127       Parrot_UInt flags; 
     128       void *     _bufstart; 
     129       size_t     _buflen;     
     130    } Buffer; 
     131     
     132=item * All these field are used by the compact function of the memory pool system. 
     133 
     134=item * These objects support COW (Copy on Write) flag 
     135 
     136=back 
     137 
     138Currently used by 
     139 
     140=over 8 
     141 
     142=item * non constant Strings 
     143 
     144=item * list.c for storage of list buffer 
     145 
     146=back 
     147 
     148=item 2 The pool for the constant string.  
     149 
     150It uses the C<< Anenas->constant_string_pool >>, which is not compacted.  
     151Constant strings are not released back system during runtime.  
     152 
     153 
     154=item 3 The pool of objects without a reference to a variable buffer. 
     155 
     156Currently used by 
     157 
     158=over 8 
     159 
     160=item * PMC items. 
     161 
     162=item * constant PMC items. 
     163 
     164=back 
     165 
     166A Small_Object_Pool contains multiple Small_Object_Arena items. Arena's 
     167are added as more memory is need for the pool. These Arena's are 
     168allocated from the c allocate system. 
     169 
     170=head2 Summarization of Arenas struct 
     171 
     172A small summarize of the memory related items in the C<Arenas> struct. 
     173 
     174    typedef struct Arenas { 
     175        /*Memory for buffers used by the small object of type 1*/ 
     176        Memory_Pool *memory_pool;  
     177        /*Memory for buffers used by the small object of type 2 -> the constant strings */    
     178        Memory_Pool *constant_string_pool; 
     179        /*Pool of type 1, used for storage of the string header*/ 
     180        struct Small_Object_Pool *string_header_pool; 
     181        /*Pool of type 3, used for storage of the pmc objects*/ 
     182        struct Small_Object_Pool *pmc_pool; 
     183        /*Pool of type 3, used for storage of pmc object which have constant flag*/ 
     184        struct Small_Object_Pool *constant_pmc_pool 
     185        /*Pool of type 2, used for storage of the headers of the constant strings*/ 
     186        struct Small_Object_Pool *constant_string_header_pool; 
     187        /*Containts all the Small_Object_Pool of type 1. Which are 
     188          1. string_header_pool 
     189          2. buffer storage used by list.c (struct List_chunk) 
     190        */ 
     191        struct Small_Object_Pool **sized_header_pools; 
     192        /*Number of elements in sized_header_pools, be aware of the fact this equal to 
     193        the "buffer header" / sizeof(void*) 
     194        size_t num_sized; 
     195        ... 
     196 
     197=head2 Function summarization 
     198 
     199Here is grouped summarization of the interesting functions of the garbage collecting system 
     200to give a better overview of them. 
     201 
     202=head3 Memory pool system 
     203 
     204These function are responsible for the Memory pool system.  
     205 
     206C<alloc_new_block> This function adds a new block to a memory pool 
     207 
     208C<mem_allocate> This function allocates a buffer in a memory pool 
     209 
     210C<compact_pool> This function compacts the memory buffer system 
     211 
     212C<new_memory_pool> This function inits a new memory pool 
     213 
     214C<initialize_memory_pools> This function initializes the to memory pools 
     215 
     216C<merge_pools> This function merges to memory pools together, this is used for merging to interpreters  
     217together 
     218 
     219C<Parrot_gc_destroy_memory_pools> This function released the memory pools 
     220 
     221C<Parrot_gc_compact_memory_pool> The public api to compact the memory pools 
     222 
     223=head3 Garbage collecting 
     224 
     225The garbage collecting system exits out of the following steps. See the other  
     226memory internals documentation for more information. 
     227 
     228=over 4 
     229 
     230=item * First phase marking off all objects, follows all links except the C<< pmc->_metadata >> link 
     231 
     232=item * Second phase marking off all objects, which follows the C<< pmc->_metadata >> links 
     233 
     234=item * Sweep all the pools of dead objects 
     235 
     236=back 
     237 
     238In the first phase all object with pmc extension are put in a list which is linked via the 
     239C<< pmc->_next_for_GC >> field. Then in the second phase this list is walked down, to continue the 
     240marking. These 2 phased marking of objects is used for a prioritization system. (not  
     241documented here) 
     242 
     243These functions are responsible for the garbage collecting system.  
     244 
     245C<Parrot_gc_mark_and_sweep> The public api to run a gc 
     246 
     247C<gc_ms_mark_and_sweep> Runs the stop-the-world mark & sweep (MS) collector. 
     248 
     249C<Parrot_gc_run_init> Clears some fields before a gc run is started 
     250 
     251C<Parrot_gc_clear_live_bits> This function clears the live bit of all the objects in a pool, called before the mark phase 
     252 
     253C<gc_ms_trace_active_PMCs> Calls the 2 mark phase functions 
     254 
     255C<Parrot_gc_mark_PObj_alive> Public api to mark a given object as live 
     256 
     257C<mark_special> Does all necessary thing to mark object as alive and walks downs the links  
     258 
     259C<Parrot_gc_trace_root> This function perform the first phase of the marking of all the objects 
     260 
     261C<Parrot_gc_trace_children> This function perform the second phase of the marking of all the objects 
     262 
     263C<gc_ms_sweep_cb> This function sweeps all the pools, using the iterate util function 
     264 
     265C<Parrot_gc_sweep_pool> Sweep a pool and releases the dead objects 
     266 
     267=head4  C<< pmc->_next_for_GC >> cleanup 
     268 
     269These 2 function are used to clean of the C<< pmc->_next_for_GC >> fields in the  
     270small object pools. This is used by pmc_freeze.c 
     271 
     272C<Parrot_gc_cleanup_next_for_GC> 
     273C<cleanup_next_for_GC_pool> 
     274 
     275=head3 Small object pool objects 
     276 
     277These functions are responsible for allocation and freeing of object  
     278which make use of the small object pools 
     279 
     280C<gc_ms_add_free_object> Releases a PObj to a small object pool 
     281 
     282C<gc_ms_get_free_object> Allocates a PObj from a small object pool 
     283 
     284C<gc_ms_alloc_objects> Increases the small object pool with fresh arena so new free object becomes available 
     285 
     286C<gc_ms_more_traceable_objects> Tries to free object in the small object pool by using the gc system 
     287 
     288=head3 Small object pool Arena's 
     289 
     290These function are responsible for the arena system in a small object pool. 
     291 
     292C<Parrot_append_arena_in_pool> Allocates a new arena and add it to the pool 
     293 
     294C<Parrot_add_to_free_list> Initialized a new arena pool, by adding the free space to the free list 
     295 
     296=head3 Pmc header(ext) 
     297 
     298These function are the public api for the pmc objects (type 3). 
     299In the past there was a separate pmc_ext structure which was separately allocated, but 
     300is now integrated into the pmc header.  
     301 
     302C<Parrot_gc_new_pmc_header> Allocate/init a new pmc header 
     303 
     304C<Parrot_gc_free_pmc_header> Releases a pmc header 
     305 
     306C<Parrot_gc_add_pmc_ext> Adds pmc ext capabilities to a pmc 
     307 
     308C<Parrot_gc_free_pmc_ext> Remove pmc ext capabilities from a pmc 
     309 
     310C<Parrot_gc_add_pmc_sync> Add synchronization capability to a pmc 
     311 
     312=head3 Buffer header (including strings) 
     313 
     314These functions are the api function for object which have buffer capabilities (type 1 & 2)   
     315These function does not allocate the buffer itself.  
     316Allocation of a buffer like object, such as a string, takes place in two phases. 
     317First the header is allocated from a constant memory pool and after that 
     318a buffer is allocated form the Memory pool system. See next group of function  
     319for actual allocation of the buffer. 
     320  
     321C<Parrot_gc_new_string_header> Allocate a new String header 
     322 
     323C<Parrot_gc_free_string_header> Releases the String header 
     324 
     325C<Parrot_gc_new_bufferlike_header> Allocate a new buffer header 
     326 
     327C<Parrot_gc_free_bufferlike_header> Allocate a new buffer header  
     328 
     329C<get_free_buffer> Allocates/init a buffer like object of given size 
     330 
     331The following functions are used for alignment 
     332 
     333C<aligned_size>  
     334 
     335C<aligned_mem>  
     336 
     337C<aligned_string_size> 
     338 
     339=head4 C<get_bufferlike_pool> 
     340 
     341C<get_bufferlike_pool> Is used by the Parrot_gc_new_bufferlike_header function to get 
     342the small object pool with the right size. If does not exist it creates  
     343a new small object pool. The small object pool is stored in the C<< arenas->sized_header_pools >> 
     344list. This list only contain small object pools which hold buffer header objects, of which the 
     345buffer is stored in the C<< arena->memory pool >>.  
     346 
     347=head3 Buffer allocation 
     348 
     349These function are responsible for the allocation a the actual buffer of a  
     350buffer object. 
     351 
     352C<Parrot_gc_allocate_buffer_storage_aligned> 
     353 
     354C<Parrot_gc_reallocate_buffer_storage> 
     355 
     356C<Parrot_gc_allocate_string_storage> 
     357 
     358C<Parrot_gc_reallocate_string_storage> 
     359 
     360=head3 Initialization 
     361 
     362These functions are responsible for the initialization of the gc system  
     363 
     364 
     365C<Parrot_gc_initialize> The public api to initialize the gc system 
     366 
     367C<Parrot_gc_ms_init> The init function of the gc 
     368 
     369C<initialize_memory_pools> This function initializes the memory pools 
     370 
     371C<initialize_header_pools> This function initializes the small object pools 
     372 
     373C<new_pmc_pool> This function creates pool which contains pmc object 
     374 
     375C<new_small_object_pool> This function creates a small object pool  
     376 
     377C<gc_ms_pool_init> This function initializes a small object pool 
     378 
     379C<new_string_pool> This function creates a small object pool for string headers 
     380 
     381C<new_bufferlike_pool> This function creates a small object pool for buffer header 
     382 
     383Note that C<new_bufferlike_pool> does not register the pool in the 
     384C<< Arenas->sized_header_pools >> list, which must be done if 
     385you make use of the C<< Arenas->memory_pool >> 
     386 
     387=head3 Finalization 
     388 
     389These functions are responsible for the finalization of the gc system  
     390 
     391 
     392C<Parrot_gc_finalize> public api to finalize the gc system   
     393 
     394C<gc_ms_finalize> This function finalizes the gc system 
     395 
     396C<Parrot_gc_destroy_header_pools> This function destroys all small object pools 
     397 
     398These two function are used to free all the object in a small object pool 
     399 
     400C<sweep_cb_pmc> 
     401 
     402C<sweep_cb_buf> 
     403 
     404C<free_pool> This function released the arenas and pool back to the system 
     405 
     406=head4 PObj removal 
     407 
     408These function are called when a PObj in a small object pool get released by the gc system 
     409 
     410C<free_buffer> This function frees the associated buffer in the memory pool  
     411 
     412C<free_buffer_malloc> existing but dead at the moment  
     413 
     414C<free_pmc_in_pool> This function releases a pmc object, does finalization if needed 
     415 
     416=head3 Intrepreter merging 
     417 
     418The following functions are used for merging two interpreters together 
     419 
     420C<Parrot_gc_merge_header_pools>  
     421 
     422C<Parrot_gc_merge_buffer_pools>  
     423 
     424C<fix_pmc_syncs> 
     425 
     426=head2 Util functions 
     427 
     428These are various util functions 
     429 
     430C<header_pools_iterate_callback> This function iterates over all the small object pools 
     431 
     432C<Parrot_gc_ptr_in_memory_pool> 
     433 
     434C<Parrot_gc_ptr_is_pmc> 
     435 
     436C<Parrot_gc_get_pmc_index> 
     437 
     438C<Parrot_gc_active_sized_buffers> 
     439 
     440C<Parrot_gc_total_sized_buffers> 
     441 
     442C<Parrot_gc_active_pmcs> 
     443 
     444C<Parrot_gc_total_pmcs> 
     445 
     446C<Parrot_gc_count_mark_runs> 
     447 
     448C<Parrot_gc_count_collect_runs> 
     449 
     450C<Parrot_gc_count_lazy_mark_runs> 
     451 
     452C<Parrot_gc_total_memory_allocated> 
     453 
     454C<Parrot_gc_headers_alloc_since_last_collect> 
     455 
     456C<Parrot_gc_mem_alloc_since_last_collect> 
     457 
     458C<Parrot_gc_total_copied> 
     459 
     460C<Parrot_gc_impatient_pmcs> 
     461 
     462C<contained_in_pool> 
     463 
     464C<Parrot_gc_profile_start> 
     465 
     466C<Parrot_gc_profile_end>  
     467 
     468=head3 Blocking 
     469 
     470The following function are used the block the gc from running 
     471 
     472C<Parrot_block_GC_mark> 
     473 
     474C<Parrot_unblock_GC_mark> 
     475 
     476C<Parrot_block_GC_sweep> 
     477 
     478C<Parrot_unblock_GC_sweep> 
     479 
     480C<Parrot_is_blocked_GC_mark> 
     481 
     482C<Parrot_is_blocked_GC_sweep> 
     483 
     484C<Parrot_gc_completely_unblock> 
     485 
     486=head3 Memory Assertion check 
     487 
     488These functions can be used for debugging purpose to see whether the memory system is  
     489not corrupted. 
     490 
     491C<check_memory_system> Check the complete memory system 
     492 
     493C<check_small_object_pool> Checks a small object pool 
     494 
     495C<check_memory_pool> Check a memory pool 
     496 
     497C<check_buffer_ptr> Check buffer header to see whether the buffer is in bounds of memory pool 
     498 
     499=head1 AUTHOR 
     500 
     501Jesse van Dam C<jessevdam@hotmail.com> 
     502 
     503=head1 VERSION 
     504 
     5050.1 Augustus 2009 
     506 
     507 
  • include/parrot/gc_api.h

     
    239239        __attribute__nonnull__(1); 
    240240 
    241241void Parrot_gc_free_bufferlike_header(PARROT_INTERP, 
    242     ARGMOD(PObj *obj), 
     242    ARGMOD(Buffer *obj), 
    243243    size_t size) 
    244244        __attribute__nonnull__(1) 
    245245        __attribute__nonnull__(2) 
  • src/gc/incremental_ms.c

     
    519519{ 
    520520    ASSERT_ARGS(gc_ims_add_free_object) 
    521521    *(void **)to_add = pool->free_list; 
    522     pool->free_list  = to_add; 
     522    pool->free_list  = (GC_MS_PObj_Wrapper*)to_add; 
    523523#if DISABLE_GC_DEBUG 
    524524    UNUSED(interp); 
    525525#else 
     
    561561        (*pool->alloc_objects) (interp, pool); 
    562562 
    563563    ptr             = (PObj *)pool->free_list; 
    564     pool->free_list = *(void **)ptr; 
     564    pool->free_list = (GC_MS_PObj_Wrapper*)(*(void **)ptr); 
    565565 
    566566    /* 
    567567     * buffers are born black, PMCs not yet? 
     
    829829 
    830830    g_ims->state           = GC_IMS_COLLECT; 
    831831    g_ims->n_objects       = n_objects; 
    832     g_ims->n_extended_PMCs = arena_base->num_extended_PMCs; 
    833832} 
    834833 
    835834 
  • include/parrot/list.h

     
    1515#define PARROT_LIST_H_GUARD 
    1616 
    1717typedef struct List_chunk { 
    18     Buffer             data;        /* item store */ 
     18    Buffer             data;        /* item store, Buffer must be first element in struct*/ 
    1919    struct List_chunk *next; 
    2020    struct List_chunk *prev; 
    2121    UINTVAL            flags;       /* chunk flags */ 
  • src/string/encoding/utf8.c

     
    525525 
    526526    i->bytepos += (new_pos - pos); 
    527527    /* XXX possible buffer overrun exception? */ 
    528     PARROT_ASSERT(i->bytepos <= PObj_buflen(s)); 
     528    PARROT_ASSERT(i->bytepos <= Buffer_buflen(s)); 
    529529    i->charpos++; 
    530530} 
    531531 
  • src/gc/api.c

     
    229229            mark_special(interp, p); 
    230230 
    231231#  ifndef NDEBUG 
    232         else if (p->pmc_ext && PMC_metadata(p)) 
     232        else if (PMC_metadata(p)) 
    233233            fprintf(stderr, "GC: error obj %p (%s) has properties\n", 
    234234                    (void *)p, (char*)p->vtable->whoami->strstart); 
    235235#  endif 
     
    238238    /* buffer GC_DEBUG stuff */ 
    239239    if (GC_DEBUG(interp) && PObj_report_TEST(obj)) 
    240240        fprintf(stderr, "GC: buffer %p pointing to %p marked live\n", 
    241                 obj, PObj_bufstart((Buffer *)obj)); 
     241                obj, Buffer_bufstart((Buffer *)obj)); 
    242242#  endif 
    243243#endif  /* PARROT_GC_GMS */ 
    244244} 
     
    336336 
    337337    /* clear flags, set is_PMC_FLAG */ 
    338338    if (flags & PObj_is_PMC_EXT_FLAG) { 
    339         Small_Object_Pool * const pool = interp->arena_base->pmc_ext_pool; 
    340339        flags |= PObj_is_special_PMC_FLAG; 
    341         pmc->pmc_ext = (PMC_EXT *)pool->get_free_object(interp, pool); 
    342340 
    343341        if (flags & PObj_is_PMC_shared_FLAG) 
    344342            Parrot_gc_add_pmc_sync(interp, pmc); 
    345343    } 
    346     else 
    347         pmc->pmc_ext = NULL; 
    348344 
    349345    PObj_get_FLAGS(pmc) = PObj_is_PMC_FLAG|flags; 
    350346    pmc->vtable         = NULL; 
     
    397393Parrot_gc_add_pmc_ext(PARROT_INTERP, ARGMOD(PMC *pmc)) 
    398394{ 
    399395    ASSERT_ARGS(Parrot_gc_add_pmc_ext) 
    400     Small_Object_Pool * const pool = interp->arena_base->pmc_ext_pool; 
    401     if (!pmc->pmc_ext) 
    402         pmc->pmc_ext = (PMC_EXT *)pool->get_free_object(interp, pool); 
    403     if (!pmc->pmc_ext) 
    404         Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_ALLOCATION_ERROR, 
    405             "Parrot VM: PMC_EXT allocation failed!\n"); 
     396 
    406397    PObj_is_PMC_EXT_SET(pmc); 
    407398    PObj_is_special_PMC_SET(pmc); 
    408399 
     
    434425{ 
    435426    ASSERT_ARGS(Parrot_gc_free_pmc_ext) 
    436427    /* if the PMC has a PMC_EXT structure, return it to the pool/arena */ 
    437     Arenas            * const arena_base = interp->arena_base; 
    438     Small_Object_Pool * const ext_pool   = arena_base->pmc_ext_pool; 
    439428 
    440     if (!p->pmc_ext) 
     429    if (!PObj_is_PMC_EXT_TEST(p)) 
    441430        return; 
    442431 
    443432    if (PObj_is_PMC_shared_TEST(p) && PMC_sync(p)) { 
     
    445434        mem_internal_free(PMC_sync(p)); 
    446435        PMC_sync(p) = NULL; 
    447436    } 
    448     ext_pool->add_free_object(interp, ext_pool, p->pmc_ext); 
    449     ext_pool->num_free_objects++; 
    450     p->pmc_ext = NULL; 
    451437} 
    452438 
    453439/* 
     
    499485Parrot_gc_new_string_header(PARROT_INTERP, UINTVAL flags) 
    500486{ 
    501487    ASSERT_ARGS(Parrot_gc_new_string_header) 
     488 
    502489    STRING * const string = (STRING *)get_free_buffer(interp, 
    503490        (flags & PObj_constant_FLAG) 
    504491            ? interp->arena_base->constant_string_header_pool 
     
    553542Parrot_gc_new_bufferlike_header(PARROT_INTERP, size_t size) 
    554543{ 
    555544    ASSERT_ARGS(Parrot_gc_new_bufferlike_header) 
     545 
    556546    Small_Object_Pool * const pool = get_bufferlike_pool(interp, size); 
    557547 
    558548    return get_free_buffer(interp, pool); 
     
    576566get_free_buffer(PARROT_INTERP, ARGIN(Small_Object_Pool *pool)) 
    577567{ 
    578568    ASSERT_ARGS(get_free_buffer) 
    579     PObj * const buffer = (PObj *)pool->get_free_object(interp, pool); 
     569    Buffer * const buffer = (Buffer *)pool->get_free_object(interp, pool); 
    580570 
    581571    /* don't mess around with flags */ 
    582     PObj_bufstart(buffer) = NULL; 
    583     PObj_buflen(buffer)   = 0; 
     572    Buffer_bufstart(buffer) = NULL; 
     573    Buffer_buflen(buffer)   = 0; 
    584574 
    585     if (pool->object_size - GC_HEADER_SIZE > sizeof (PObj)) 
     575    if (pool->object_size - GC_HEADER_SIZE > sizeof (Buffer)) 
    586576        memset(buffer + 1, 0, 
    587                 pool->object_size - sizeof (PObj) - GC_HEADER_SIZE); 
     577                pool->object_size - sizeof (Buffer) - GC_HEADER_SIZE); 
    588578 
    589579    return buffer; 
    590580} 
     
    602592*/ 
    603593 
    604594void 
    605 Parrot_gc_free_bufferlike_header(PARROT_INTERP, ARGMOD(PObj *obj), 
     595Parrot_gc_free_bufferlike_header(PARROT_INTERP, ARGMOD(Buffer *obj), 
    606596    size_t size) 
    607597{ 
    608598    ASSERT_ARGS(Parrot_gc_free_bufferlike_header) 
     
    631621    size_t new_size; 
    632622    char *mem; 
    633623 
    634     PObj_buflen(buffer) = 0; 
    635     PObj_bufstart(buffer) = NULL; 
     624    Buffer_buflen(buffer) = 0; 
     625    Buffer_bufstart(buffer) = NULL; 
    636626    new_size = aligned_size(buffer, size); 
    637627    mem = (char *)mem_allocate(interp, new_size, 
    638628        interp->arena_base->memory_pool); 
    639629    mem = aligned_mem(buffer, mem); 
    640     PObj_bufstart(buffer) = mem; 
     630    Buffer_bufstart(buffer) = mem; 
    641631    if (PObj_is_COWable_TEST(buffer)) 
    642632        new_size -= sizeof (void*); 
    643     PObj_buflen(buffer) = new_size; 
     633    Buffer_buflen(buffer) = new_size; 
    644634} 
    645635 
    646636/* 
     
    671661    /* 
    672662     * we don't shrink buffers 
    673663     */ 
    674     if (newsize <= PObj_buflen(buffer)) 
     664    if (newsize <= Buffer_buflen(buffer)) 
    675665        return; 
    676666 
    677667    /* 
     
    683673     * The normal case is therefore always to allocate a new block 
    684674     */ 
    685675    new_size = aligned_size(buffer, newsize); 
    686     old_size = aligned_size(buffer, PObj_buflen(buffer)); 
     676    old_size = aligned_size(buffer, Buffer_buflen(buffer)); 
    687677    needed   = new_size - old_size; 
    688678 
    689679    if ((pool->top_block->free >= needed) 
    690     &&  (pool->top_block->top  == (char *)PObj_bufstart(buffer) + old_size)) { 
     680    &&  (pool->top_block->top  == (char *)Buffer_bufstart(buffer) + old_size)) { 
    691681        pool->top_block->free -= needed; 
    692682        pool->top_block->top  += needed; 
    693         PObj_buflen(buffer) = newsize; 
     683        Buffer_buflen(buffer) = newsize; 
    694684        return; 
    695685    } 
    696686 
    697     copysize = PObj_buflen(buffer); 
     687    copysize = Buffer_buflen(buffer); 
    698688 
    699689    if (!PObj_COW_TEST(buffer)) 
    700690        pool->guaranteed_reclaimable += copysize; 
     
    706696    /* We shouldn't ever have a 0 from size, but we do. If we can track down 
    707697     * those bugs, this can be removed which would make things cheaper */ 
    708698    if (copysize) 
    709         memcpy(mem, PObj_bufstart(buffer), copysize); 
     699        memcpy(mem, Buffer_bufstart(buffer), copysize); 
    710700 
    711     PObj_bufstart(buffer) = mem; 
     701    Buffer_bufstart(buffer) = mem; 
    712702 
    713703    if (PObj_is_COWable_TEST(buffer)) 
    714704        new_size -= sizeof (void *); 
    715705 
    716     PObj_buflen(buffer) = new_size; 
     706    Buffer_buflen(buffer) = new_size; 
    717707} 
    718708 
    719709/* 
     
    739729    Memory_Pool *pool; 
    740730    char        *mem; 
    741731 
    742     PObj_buflen(str)   = 0; 
    743     PObj_bufstart(str) = NULL; 
     732    Buffer_buflen(str)   = 0; 
     733    Buffer_bufstart(str) = NULL; 
    744734 
    745735    /* there's no sense in allocating zero memory, when the overhead of 
    746736     * allocating a string is one pointer; this can fill the pools in an 
     
    757747    mem      = (char *)mem_allocate(interp, new_size, pool); 
    758748    mem     += sizeof (void*); 
    759749 
    760     PObj_bufstart(str) = str->strstart = mem; 
    761     PObj_buflen(str)   = new_size - sizeof (void*); 
     750    Buffer_bufstart(str) = str->strstart = mem; 
     751    Buffer_buflen(str)   = new_size - sizeof (void*); 
    762752} 
    763753 
    764754/* 
     
    789779            : interp->arena_base->memory_pool; 
    790780 
    791781    /* if the requested size is smaller then buflen, we are done */ 
    792     if (newsize <= PObj_buflen(str)) 
     782    if (newsize <= Buffer_buflen(str)) 
    793783        return; 
    794784 
    795785    /* 
     
    798788     * - if there is enough size, we can just move the pool's top pointer 
    799789     */ 
    800790    new_size = aligned_string_size(newsize); 
    801     old_size = aligned_string_size(PObj_buflen(str)); 
     791    old_size = aligned_string_size(Buffer_buflen(str)); 
    802792    needed   = new_size - old_size; 
    803793 
    804794    if (pool->top_block->free >= needed 
    805     &&  pool->top_block->top  == (char *)PObj_bufstart(str) + old_size) { 
     795    &&  pool->top_block->top  == (char *)Buffer_bufstart(str) + old_size) { 
    806796        pool->top_block->free -= needed; 
    807797        pool->top_block->top  += needed; 
    808         PObj_buflen(str) = new_size - sizeof (void*); 
     798        Buffer_buflen(str) = new_size - sizeof (void*); 
    809799        return; 
    810800    } 
    811801 
     
    815805    copysize = str->bufused; 
    816806 
    817807    if (!PObj_COW_TEST(str)) 
    818         pool->guaranteed_reclaimable += PObj_buflen(str); 
     808        pool->guaranteed_reclaimable += Buffer_buflen(str); 
    819809 
    820     pool->possibly_reclaimable += PObj_buflen(str); 
     810    pool->possibly_reclaimable += Buffer_buflen(str); 
    821811 
    822812    mem = (char *)mem_allocate(interp, new_size, pool); 
    823813    mem += sizeof (void *); 
    824814 
    825815    /* copy mem from strstart, *not* bufstart */ 
    826816    oldmem             = str->strstart; 
    827     PObj_bufstart(str) = (void *)mem; 
     817    Buffer_bufstart(str) = (void *)mem; 
    828818    str->strstart      = mem; 
    829     PObj_buflen(str)   = new_size - sizeof (void*); 
     819    Buffer_buflen(str)   = new_size - sizeof (void*); 
    830820 
    831821    /* We shouldn't ever have a 0 from size, but we do. If we can track down 
    832822     * those bugs, this can be removed which would make things cheaper */ 
     
    907897            dest_arena->constant_string_header_pool, 
    908898            source_arena->constant_string_header_pool); 
    909899 
    910     Parrot_gc_merge_buffer_pools(dest_interp, 
    911             dest_arena->pmc_ext_pool, source_arena->pmc_ext_pool); 
    912  
    913900    for (i = 0; i < source_arena->num_sized; ++i) { 
    914901        if (!source_arena->sized_header_pools[i]) 
    915902            continue; 
     
    948935{ 
    949936    ASSERT_ARGS(Parrot_gc_merge_buffer_pools) 
    950937    Small_Object_Arena  *cur_arena; 
    951     void               **free_list_end; 
     938    GC_MS_PObj_Wrapper  *free_list_end; 
    952939 
    953940    PARROT_ASSERT(dest->object_size == source->object_size); 
    954941    PARROT_ASSERT((dest->name == NULL && source->name == NULL) 
     
    958945 
    959946    /* append new free_list to old */ 
    960947    /* XXX this won't work with, e.g., gc_gms */ 
    961     free_list_end  = &dest->free_list; 
     948    free_list_end = dest->free_list; 
    962949 
    963     while (*free_list_end) 
    964         free_list_end = (void **)*free_list_end; 
     950    if(free_list_end == NULL) 
     951    { 
     952        dest->free_list = source->free_list; 
     953    } 
     954    else 
     955    { 
     956        while (free_list_end->next_ptr) 
     957            free_list_end = free_list_end->next_ptr; 
    965958 
    966     *free_list_end = source->free_list; 
     959        free_list_end->next_ptr = source->free_list; 
     960    } 
    967961 
    968962    /* now append source arenas */ 
    969963    cur_arena = source->last_Arena; 
     
    10701064                (void *)pass, sweep_cb_buf); 
    10711065    } 
    10721066 
    1073     free_pool(interp->arena_base->pmc_ext_pool); 
    1074     interp->arena_base->pmc_ext_pool = NULL; 
    1075  
    10761067    mem_internal_free(interp->arena_base->sized_header_pools); 
    10771068    if (interp->arena_base->attrib_pools) 
    10781069        mem_internal_free(interp->arena_base->attrib_pools); 
     
    13371328 
    13381329        for (i = 0; i < arena->used; i++) { 
    13391330            if (!PObj_on_free_list_TEST(p)) { 
    1340                 if (p->pmc_ext) 
    1341                     PMC_next_for_GC(p) = PMCNULL; 
     1331                PMC_next_for_GC(p) = PMCNULL; 
    13421332            } 
    13431333            p++; 
    13441334        } 
     
    14651455 
    14661456Returns the number of PMCs that are marked as needing timely destruction. 
    14671457 
    1468 =item C<UINTVAL Parrot_gc_extended_pmcs(PARROT_INTERP)> 
    1469  
    1470 Returns the number of extended PMCs. 
    1471  
    1472 =cut 
    1473  
    14741458*/ 
    14751459 
    14761460size_t 
     
    15371521    return arena_base->num_early_gc_PMCs; 
    15381522} 
    15391523 
    1540 UINTVAL 
    1541 Parrot_gc_extended_pmcs(PARROT_INTERP) 
    1542 { 
    1543     ASSERT_ARGS(Parrot_gc_extended_pmcs) 
    1544     const Arenas * const arena_base = interp->arena_base; 
    1545     return arena_base->num_extended_PMCs; 
    1546 } 
    1547  
    15481524/* 
    15491525 
    15501526=item C<void Parrot_block_GC_mark(PARROT_INTERP)> 
  • src/ops/set.ops

     
    510510        /* don't let the clone's destruction destroy the destination's data */ 
    511511        PObj_active_destroy_CLEAR(clone); 
    512512        if (PObj_is_PMC_EXT_TEST(clone)) 
    513             clone->pmc_ext = NULL; 
     513        { 
     514          PMC_metadata(clone) = NULL;     
     515          PMC_next_for_GC(clone) = NULL;  
     516          PMC_sync(clone) = NULL; 
     517        } 
    514518 
    515519        /* Restore metadata. */ 
    516520        if (!PMC_IS_NULL(meta)) { 
  • src/pmc/default.pmc

     
    230230make_prop_hash(PARROT_INTERP, PMC *self) { 
    231231    PMC *prop; 
    232232 
    233     if (!self->pmc_ext) 
     233    if (!PObj_is_PMC_EXT_TEST(self)) 
    234234        Parrot_gc_add_pmc_ext(interp, self); 
    235235 
    236236    PMC_metadata(self) = prop = pmc_new(interp, enum_class_Hash); 
     
    377377*/ 
    378378 
    379379    VTABLE PMC *getprop(STRING *key) { 
    380         if (SELF->pmc_ext && PMC_metadata(SELF)) 
     380        if (PObj_is_PMC_EXT_TEST(SELF) && PMC_metadata(SELF)) 
    381381            return VTABLE_get_pmc_keyed_str(INTERP, PMC_metadata(SELF), key); 
    382382        else 
    383383            return check_get_std_props(interp, SELF, key); 
     
    397397        if (check_set_std_props(INTERP, SELF, key, value)) 
    398398            return; 
    399399 
    400         if (SELF->pmc_ext && PMC_metadata(SELF)) { 
     400        if (PObj_is_PMC_EXT_TEST(SELF) && PMC_metadata(SELF)) { 
    401401            VTABLE_set_pmc_keyed_str(INTERP, 
    402402                PMC_metadata(SELF), key, value); 
    403403        } 
     
    419419*/ 
    420420 
    421421    VTABLE void delprop(STRING *key) { 
    422         if (SELF->pmc_ext && PMC_metadata(SELF)) 
     422        if (PObj_is_PMC_EXT_TEST(SELF) && PMC_metadata(SELF)) 
    423423            VTABLE_delete_keyed_str(INTERP, PMC_metadata(SELF), key); 
    424424    } 
    425425 
     
    434434*/ 
    435435 
    436436    VTABLE PMC *getprops() { 
    437         if (!SELF->pmc_ext) 
     437        if (!PObj_is_PMC_EXT_TEST(SELF)) 
    438438            Parrot_gc_add_pmc_ext(INTERP, SELF); 
    439439 
    440440        if (!PMC_metadata(SELF)) { 
     
    10551061 
    10561062    VTABLE void visit(visit_info *info) { 
    10571063        /* default - mark prop hash */ 
    1058         if (SELF->pmc_ext && PMC_metadata(SELF) && 
     1064        if (PObj_is_PMC_EXT_TEST(SELF) && PMC_metadata(SELF) && 
    10591065            info->extra_flags != EXTRA_IS_PROP_HASH) { 
    10601066            info->extra_flags = EXTRA_IS_PROP_HASH; 
    10611067            info->extra       = PMC_metadata(SELF); 
     
    11101116    VTABLE void thaw(visit_info *info) { 
    11111117        /* default - initialize the PMC */ 
    11121118        if (info->extra_flags == EXTRA_IS_PROP_HASH) { 
    1113             if (!SELF->pmc_ext) 
     1119            if (!PObj_is_PMC_EXT_TEST(SELF)) 
    11141120                Parrot_gc_add_pmc_ext(INTERP, SELF); 
    11151121 
    11161122            info->thaw_ptr  = &PMC_metadata(SELF); 
  • src/list.c

     
    342342/* HEADERIZER END: static */ 
    343343 
    344344#define chunk_list_size(list) \ 
    345                 (PObj_buflen(&(list)->chunk_list) / sizeof (List_chunk *)) 
     345                (Buffer_buflen(&(list)->chunk_list) / sizeof (List_chunk *)) 
    346346 
    347347/* hide the ugly cast somehow: */ 
    348348#define chunk_list_ptr(list, idx) \ 
    349         ((List_chunk**) PObj_bufstart(&(list)->chunk_list))[(idx)] 
     349        ((List_chunk**) Buffer_bufstart(&(list)->chunk_list))[(idx)] 
    350350 
    351351/* 
    352352 
     
    381381    chunk->next     = NULL; 
    382382    chunk->prev     = NULL; 
    383383    Parrot_gc_allocate_buffer_storage_aligned(interp, (Buffer *)chunk, size); 
    384     memset(PObj_bufstart((Buffer*)chunk), 0, size); 
     384    memset(Buffer_bufstart((Buffer*)chunk), 0, size); 
    385385 
    386386    /* see also src/hash.c */ 
    387387    if (list->container) 
     
    520520                } 
    521521 
    522522                mem_sys_memmove( 
    523                         (char *) PObj_bufstart(&prev->data) + 
     523                        (char *) Buffer_bufstart(&prev->data) + 
    524524                        prev->items * list->item_size, 
    525                         (const char *) PObj_bufstart(&chunk->data), 
     525                        (const char *) Buffer_bufstart(&chunk->data), 
    526526                        (MAX_ITEMS - prev->items) * list->item_size); 
    527527                mem_sys_memmove( 
    528                         (char *) PObj_bufstart(&chunk->data), 
    529                         (const char *) PObj_bufstart(&chunk->data) + 
     528                        (char *) Buffer_bufstart(&chunk->data), 
     529                        (const char *) Buffer_bufstart(&chunk->data) + 
    530530                        (MAX_ITEMS - prev->items) * list->item_size, 
    531531                        (chunk->items - (MAX_ITEMS - prev->items)) 
    532532                                                        * list->item_size); 
     
    540540                    GC_WRITE_BARRIER(interp, list->container, 0, prev); 
    541541                } 
    542542                mem_sys_memmove( 
    543                         (char *) PObj_bufstart(&prev->data) + 
     543                        (char *) Buffer_bufstart(&prev->data) + 
    544544                        prev->items * list->item_size, 
    545                         (const char *) PObj_bufstart(&chunk->data), 
     545                        (const char *) Buffer_bufstart(&chunk->data), 
    546546                        chunk->items * list->item_size); 
    547547                prev->items += chunk->items; 
    548548                chunk->items = 0; 
     
    583583 
    584584        chunk->flags      = 0; 
    585585        list->grow_policy = enum_grow_unknown; 
    586         list->cap        += PObj_buflen(&chunk->data) / list->item_size - chunk->items; 
    587         chunk->items      = PObj_buflen(&chunk->data) / list->item_size; 
     586        list->cap        += Buffer_buflen(&chunk->data) / list->item_size - chunk->items; 
     587        chunk->items      = Buffer_buflen(&chunk->data) / list->item_size; 
    588588    } 
    589589 
    590590    /* XXX - still needed? - if last is empty and last->prev not full then 
     
    12271227    switch (type) { 
    12281228    case enum_type_sized: 
    12291229        /* copy data into list */ 
    1230         memcpy(&((char *) PObj_bufstart(&chunk->data))[idx * list->item_size], 
     1230        memcpy(&((char *) Buffer_bufstart(&chunk->data))[idx * list->item_size], 
    12311231                item, list->item_size); 
    12321232        break; 
    12331233    case enum_type_char: 
    1234         ((char *) PObj_bufstart(&chunk->data))[idx] = (char)PTR2INTVAL(item); 
     1234        ((char *) Buffer_bufstart(&chunk->data))[idx] = (char)PTR2INTVAL(item); 
    12351235        break; 
    12361236    case enum_type_short: 
    1237         ((short *) PObj_bufstart(&chunk->data))[idx] = (short)PTR2INTVAL(item); 
     1237        ((short *) Buffer_bufstart(&chunk->data))[idx] = (short)PTR2INTVAL(item); 
    12381238        break; 
    12391239    case enum_type_int: 
    1240         ((int *) PObj_bufstart(&chunk->data))[idx] = (int)PTR2INTVAL(item); 
     1240        ((int *) Buffer_bufstart(&chunk->data))[idx] = (int)PTR2INTVAL(item); 
    12411241        break; 
    12421242    case enum_type_INTVAL: 
    1243         ((INTVAL *) PObj_bufstart(&chunk->data))[idx] = PTR2INTVAL(item); 
     1243        ((INTVAL *) Buffer_bufstart(&chunk->data))[idx] = PTR2INTVAL(item); 
    12441244        break; 
    12451245    case enum_type_FLOATVAL: 
    1246         ((FLOATVAL *) PObj_bufstart(&chunk->data))[idx] = *(FLOATVAL *)item; 
     1246        ((FLOATVAL *) Buffer_bufstart(&chunk->data))[idx] = *(FLOATVAL *)item; 
    12471247        break; 
    12481248    case enum_type_PMC: 
    12491249        if (list->container) { 
    12501250            GC_WRITE_BARRIER(interp, list->container, 
    1251                     ((PMC **) PObj_bufstart(&chunk->data))[idx], 
     1251                    ((PMC **) Buffer_bufstart(&chunk->data))[idx], 
    12521252                    (PMC *)item); 
    12531253        } 
    1254         ((PMC **) PObj_bufstart(&chunk->data))[idx] = (PMC *)item; 
     1254        ((PMC **) Buffer_bufstart(&chunk->data))[idx] = (PMC *)item; 
    12551255        break; 
    12561256    case enum_type_STRING: 
    1257         ((STRING **) PObj_bufstart(&chunk->data))[idx] = (STRING *)item; 
     1257        ((STRING **) Buffer_bufstart(&chunk->data))[idx] = (STRING *)item; 
    12581258        break; 
    12591259    default: 
    12601260        Parrot_ex_throw_from_c_args(interp, NULL, 1, "Unknown list entry type\n"); 
     
    12961296    switch (type) { 
    12971297        case enum_type_sized: 
    12981298            return (void *)&((char *) 
    1299                 PObj_bufstart(&chunk->data))[idx * list->item_size]; 
     1299                Buffer_bufstart(&chunk->data))[idx * list->item_size]; 
    13001300        case enum_type_char: 
    1301             return (void *)&((char *) PObj_bufstart(&chunk->data))[idx]; 
     1301            return (void *)&((char *) Buffer_bufstart(&chunk->data))[idx]; 
    13021302        case enum_type_short: 
    1303             return (void *)&((short *) PObj_bufstart(&chunk->data))[idx]; 
     1303            return (void *)&((short *) Buffer_bufstart(&chunk->data))[idx]; 
    13041304        case enum_type_int: 
    1305             return (void *)&((int *) PObj_bufstart(&chunk->data))[idx]; 
     1305            return (void *)&((int *) Buffer_bufstart(&chunk->data))[idx]; 
    13061306        case enum_type_INTVAL: 
    1307             return (void *)&((INTVAL *) PObj_bufstart(&chunk->data))[idx]; 
     1307            return (void *)&((INTVAL *) Buffer_bufstart(&chunk->data))[idx]; 
    13081308        case enum_type_FLOATVAL: 
    1309             return (void *)&((FLOATVAL *) PObj_bufstart(&chunk->data))[idx]; 
     1309            return (void *)&((FLOATVAL *) Buffer_bufstart(&chunk->data))[idx]; 
    13101310        case enum_type_PMC: 
    1311             return (void *)&((PMC **) PObj_bufstart(&chunk->data))[idx]; 
     1311            return (void *)&((PMC **) Buffer_bufstart(&chunk->data))[idx]; 
    13121312        case enum_type_STRING: 
    1313             return (void *)&((STRING **) PObj_bufstart(&chunk->data))[idx]; 
     1313            return (void *)&((STRING **) Buffer_bufstart(&chunk->data))[idx]; 
    13141314        default: 
    13151315            Parrot_ex_throw_from_c_args(interp, NULL, 1, "Unknown list entry type\n"); 
    13161316    } 
     
    15691569    l = list_new(interp, other->item_type); 
    15701570 
    15711571    STRUCT_COPY(l, other); 
    1572     PObj_buflen(&l->chunk_list)   = 0; 
    1573     PObj_bufstart(&l->chunk_list) = NULL; 
     1572    Buffer_buflen(&l->chunk_list)   = 0; 
     1573    Buffer_bufstart(&l->chunk_list) = NULL; 
    15741574 
    15751575    for (chunk = other->first, prev = NULL; chunk; chunk = chunk->next) { 
    15761576        List_chunk * const new_chunk = allocate_chunk(interp, l, 
    1577                 chunk->items, PObj_buflen(&chunk->data)); 
     1577                chunk->items, Buffer_buflen(&chunk->data)); 
    15781578 
    15791579        new_chunk->flags = chunk->flags; 
    15801580 
     
    15891589            switch (l->item_type) { 
    15901590            case enum_type_PMC: 
    15911591                for (i = 0; i < chunk->items; i++) { 
    1592                     PMC * const op = ((PMC **) PObj_bufstart(&chunk->data))[i]; 
     1592                    PMC * const op = ((PMC **) Buffer_bufstart(&chunk->data))[i]; 
    15931593 
    15941594                    if (op) 
    1595                         ((PMC **) PObj_bufstart(&new_chunk->data))[i] = 
     1595                        ((PMC **) Buffer_bufstart(&new_chunk->data))[i] = 
    15961596                            VTABLE_clone(interp, op); 
    15971597                } 
    15981598                break; 
    15991599            case enum_type_STRING: 
    16001600                for (i = 0; i < chunk->items; i++) { 
    1601                     STRING *s = ((STRING **) PObj_bufstart(&chunk->data))[i]; 
     1601                    STRING *s = ((STRING **) Buffer_bufstart(&chunk->data))[i]; 
    16021602                    if (s) 
    1603                         ((STRING **) PObj_bufstart(&new_chunk->data))[i] = 
     1603                        ((STRING **) Buffer_bufstart(&new_chunk->data))[i] = 
    16041604                                Parrot_str_copy(interp, s); 
    16051605                } 
    16061606                break; 
    16071607            default: 
    1608                 mem_sys_memcopy(PObj_bufstart(&new_chunk->data), 
    1609                         PObj_bufstart(&chunk->data), PObj_buflen(&chunk->data)); 
     1608                mem_sys_memcopy(Buffer_bufstart(&new_chunk->data), 
     1609                        Buffer_bufstart(&chunk->data), Buffer_buflen(&chunk->data)); 
    16101610                break; 
    16111611            } 
    16121612        } 
     
    16431643        if (list->item_type == enum_type_PMC 
    16441644        ||  list->item_type == enum_type_STRING) { 
    16451645            if (!(chunk->flags & sparse)) { 
    1646                 PObj **p = ((PObj **) PObj_bufstart(&chunk->data)); 
     1646                PObj **p = ((PObj **) Buffer_bufstart(&chunk->data)); 
    16471647                UINTVAL i; 
    16481648 
    16491649                for (i = 0; i < chunk->items; i++, ++p) { 
     
    16881688        if (!(chunk->flags & sparse)) { 
    16891689            UINTVAL i; 
    16901690            for (i = 0; i < chunk->items && idx < n; i++, idx++) { 
    1691                 PMC ** const pos = ((PMC **) PObj_bufstart(&chunk->data)) + i; 
     1691                PMC ** const pos = ((PMC **) Buffer_bufstart(&chunk->data)) + i; 
    16921692                info->thaw_ptr   = pos; 
    16931693                (info->visit_pmc_now)(interp, *pos, info); 
    16941694            } 
     
    18301830 
    18311831            /* copy data over */ 
    18321832            mem_sys_memmove( 
    1833                     (char *)PObj_bufstart(&rest->data), 
    1834                     (char *)PObj_bufstart(&chunk->data) + idx * list->item_size, 
     1833                    (char *)Buffer_bufstart(&rest->data), 
     1834                    (char *)Buffer_bufstart(&chunk->data) + idx * list->item_size, 
    18351835                    items * list->item_size); 
    18361836        } 
    18371837        else { 
     
    18951895                            list->item_size; 
    18961896 
    18971897                    mem_sys_memmove( 
    1898                             (char *) PObj_bufstart(&chunk->data) + 
     1898                            (char *) Buffer_bufstart(&chunk->data) + 
    18991899                            idx * list->item_size, 
    1900                             (char *) PObj_bufstart(&chunk->data) + 
     1900                            (char *) Buffer_bufstart(&chunk->data) + 
    19011901                            (idx + n_items) * list->item_size, tmp_size); 
    19021902#else 
    19031903                    mem_sys_memmove( 
    1904                             (char *) PObj_bufstart(&chunk->data) + 
     1904                            (char *) Buffer_bufstart(&chunk->data) + 
    19051905                            idx * list->item_size, 
    1906                             (char *) PObj_bufstart(&chunk->data) + 
     1906                            (char *) Buffer_bufstart(&chunk->data) + 
    19071907                            (idx + n_items) * list->item_size, 
    19081908                            (chunk->items - idx - n_items) * list->item_size); 
    19091909#endif 
  • src/interp/inter_misc.c

     
    252252        case IMPATIENT_PMCS: 
    253253            ret = Parrot_gc_impatient_pmcs(interp); 
    254254            break; 
    255         case EXTENDED_PMCS: 
    256             ret = Parrot_gc_extended_pmcs(interp); 
    257             break; 
    258255        case CURRENT_RUNCORE: 
    259256            ret = interp->run_core; 
    260257            break; 
  • include/parrot/call.h

     
    7070    INTVAL slurp_n;           /* number of :flat/:slurpy args/params to match */ 
    7171} call_state_item; 
    7272 
     73typedef union UnionCallStateVal { 
     74    struct _ptrs {                                  //or two pointers, both are defines  
     75        DPOINTER * _struct_val; 
     76        PMC *      _pmc_val; 
     77    } _ptrs; 
     78    struct _i { 
     79        INTVAL _int_val;                      // or 2 intvals  
     80        INTVAL _int_val2; 
     81    } _i; 
     82    FLOATVAL _num_val;                       // or one float  
     83    struct parrot_string_t * _string_val;    // or a pointer to a string  
     84} UnionCallStateVal; 
     85 
     86#define UVal_ptr(u)       (u)._ptrs._struct_val 
     87#define UVal_pmc(u)       (u)._ptrs._pmc_val 
     88#define UVal_int(u)       (u)._i._int_val 
     89#define UVal_int2(u)      (u)._i._int_val2 
     90#define UVal_num(u)       (u)._num_val 
     91#define UVal_str(u)       (u)._string_val 
     92 
    7393typedef struct call_state { 
    7494    call_state_item src; 
    7595    call_state_item dest; 
    76     UnionVal val; 
     96    UnionCallStateVal val; 
    7797    int n_actual_args;  /* arguments incl. flatten */ 
    7898    int optionals;      /* sum of optionals */ 
    7999    int params;         /* sum of params */ 
  • src/ops/string.ops

     
    392392                $1 = PTR2UINTVAL($2->strstart); 
    393393                break; 
    394394            case STRINGINFO_BUFLEN: 
    395                 $1 = PObj_buflen($2); 
     395                $1 = Buffer_buflen($2); 
    396396                break; 
    397397            case STRINGINFO_FLAGS: 
    398398                $1 = PObj_get_FLAGS($2); 
  • src/pmc.c

     
    359359{ 
    360360    ASSERT_ARGS(pmc_reuse_check_pmc_ext) 
    361361    /* Do we have an extension area? */ 
    362     INTVAL const has_ext = (PObj_is_PMC_EXT_TEST(pmc) && pmc->pmc_ext); 
     362    INTVAL const has_ext = (PObj_is_PMC_EXT_TEST(pmc)); 
    363363 
    364364    /* Do we need one? */ 
    365365    if (flags & VTABLE_PMC_NEEDS_EXT) { 
     
    373373        PMC_data(pmc) = NULL; 
    374374        newflags &= ~PObj_is_PMC_EXT_FLAG; 
    375375        PARROT_ASSERT((newflags & PObj_is_PMC_EXT_FLAG) == 0); 
    376         PARROT_ASSERT(pmc->pmc_ext == NULL); 
    377376    } 
    378377    return newflags; 
    379378} 
  • src/string/charset/iso-8859-1.c

     
    268268        for (offs = 0; offs < src->strlen; ++offs) { 
    269269            const UINTVAL c = ENCODING_GET_BYTE(interp, src, offs); 
    270270 
    271             if (iter.bytepos >= PObj_buflen(dest) - 4) { 
     271            if (iter.bytepos >= Buffer_buflen(dest) - 4) { 
    272272                UINTVAL need = (UINTVAL)((src->strlen - offs) * 1.5); 
    273273                if (need < 16) 
    274274                    need = 16; 
    275275                Parrot_gc_reallocate_string_storage(interp, dest, 
    276                         PObj_buflen(dest) + need); 
     276                        Buffer_buflen(dest) + need); 
    277277            } 
    278278            iter.set_and_advance(interp, &iter, c); 
    279279        } 
  • src/gc/gc_ms.c

     
    2929        __attribute__nonnull__(3) 
    3030        FUNC_MODIFIES(*pool); 
    3131 
    32 static void gc_ms_add_free_pmc_ext(SHIM_INTERP, 
    33     ARGMOD(Small_Object_Pool *pool), 
    34     ARGIN(void *to_add)) 
    35         __attribute__nonnull__(2) 
    36         __attribute__nonnull__(3) 
    37         FUNC_MODIFIES(*pool); 
    38  
    3932static void gc_ms_alloc_objects(PARROT_INTERP, 
    4033    ARGMOD(Small_Object_Pool *pool)) 
    4134        __attribute__nonnull__(1) 
     
    5447        __attribute__nonnull__(2) 
    5548        FUNC_MODIFIES(*pool); 
    5649 
    57 PARROT_CANNOT_RETURN_NULL 
    58 PARROT_WARN_UNUSED_RESULT 
    59 static void * gc_ms_get_free_pmc_ext(PARROT_INTERP, 
    60     ARGMOD(Small_Object_Pool *pool)) 
    61         __attribute__nonnull__(1) 
    62         __attribute__nonnull__(2) 
    63         FUNC_MODIFIES(*pool); 
    64  
    6550static void gc_ms_mark_and_sweep(PARROT_INTERP, UINTVAL flags) 
    6651        __attribute__nonnull__(1); 
    6752 
     
    9277#define ASSERT_ARGS_gc_ms_add_free_object __attribute__unused__ int _ASSERT_ARGS_CHECK = \ 
    9378       PARROT_ASSERT_ARG(pool) \ 
    9479    || PARROT_ASSERT_ARG(to_add) 
    95 #define ASSERT_ARGS_gc_ms_add_free_pmc_ext __attribute__unused__ int _ASSERT_ARGS_CHECK = \ 
    96        PARROT_ASSERT_ARG(pool) \ 
    97     || PARROT_ASSERT_ARG(to_add) 
    9880#define ASSERT_ARGS_gc_ms_alloc_objects __attribute__unused__ int _ASSERT_ARGS_CHECK = \ 
    9981       PARROT_ASSERT_ARG(interp) \ 
    10082    || PARROT_ASSERT_ARG(pool) 
     
    10486#define ASSERT_ARGS_gc_ms_get_free_object __attribute__unused__ int _ASSERT_ARGS_CHECK = \ 
    10587       PARROT_ASSERT_ARG(interp) \ 
    10688    || PARROT_ASSERT_ARG(pool) 
    107 #define ASSERT_ARGS_gc_ms_get_free_pmc_ext __attribute__unused__ int _ASSERT_ARGS_CHECK = \ 
    108        PARROT_ASSERT_ARG(interp) \ 
    109     || PARROT_ASSERT_ARG(pool) 
    11089#define ASSERT_ARGS_gc_ms_mark_and_sweep __attribute__unused__ int _ASSERT_ARGS_CHECK = \ 
    11190       PARROT_ASSERT_ARG(interp) 
    11291#define ASSERT_ARGS_gc_ms_more_traceable_objects __attribute__unused__ int _ASSERT_ARGS_CHECK = \ 
     
    365344gc_ms_more_traceable_objects(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool)) 
    366345{ 
    367346    ASSERT_ARGS(gc_ms_more_traceable_objects) 
     347 
    368348    if (pool->skip) 
    369349        pool->skip = 0; 
    370350    else { 
     
    398378    ARGIN(void *to_add)) 
    399379{ 
    400380    ASSERT_ARGS(gc_ms_add_free_object) 
    401     PObj *object           = (PObj *)to_add; 
     381    GC_MS_PObj_Wrapper *object           = (GC_MS_PObj_Wrapper *)to_add; 
    402382 
    403383    PObj_flags_SETTO(object, PObj_on_free_list_FLAG); 
    404384 
    405     ((GC_MS_PObj_Wrapper*)object)->next_ptr = (PObj *)pool->free_list; 
    406     pool->free_list        = object; 
     385    object->next_ptr = pool->free_list; 
     386    pool->free_list  = object; 
    407387} 
    408388 
    409389/* 
     
    438418    ptr             = free_list; 
    439419    pool->free_list = ((GC_MS_PObj_Wrapper*)ptr)->next_ptr; 
    440420 
    441     PObj_flags_SETTO(ptr, 0); 
     421//    PObj_flags_SETTO(ptr, 0); 
     422    memset(ptr, 0, pool->object_size); 
    442423 
    443424    --pool->num_free_objects; 
    444425 
     
    462443{ 
    463444    ASSERT_ARGS(gc_ms_alloc_objects) 
    464445    /* Setup memory for the new objects */ 
     446 
    465447    Small_Object_Arena * const new_arena = 
    466448        mem_internal_allocate_typed(Small_Object_Arena); 
    467449 
     
    500482 
    501483=back 
    502484 
    503 =head2 MS PMC_EXT Pool functions 
    504  
    505 =over 4 
    506  
    507 =item C<void gc_ms_pmc_ext_pool_init(Small_Object_Pool *pool)> 
    508  
    509 Initialize the PMC_EXT pool functions. This is done separately from other 
    510 pools. 
    511  
    512485=cut 
    513486 
    514487*/ 
    515488 
    516 void 
    517 gc_ms_pmc_ext_pool_init(ARGMOD(Small_Object_Pool *pool)) 
    518 { 
    519     ASSERT_ARGS(gc_ms_pmc_ext_pool_init) 
    520     pool->add_free_object = gc_ms_add_free_pmc_ext; 
    521     pool->get_free_object = gc_ms_get_free_pmc_ext; 
    522     pool->alloc_objects   = gc_ms_alloc_objects; 
    523     pool->more_objects    = gc_ms_alloc_objects; 
    524 } 
    525  
    526  
    527 /* 
    528  
    529 =item C<static void gc_ms_add_free_pmc_ext(PARROT_INTERP, Small_Object_Pool 
    530 *pool, void *to_add)> 
    531  
    532 Add a freed PMC_EXT structure to the free list in the PMC_EXT pool. Objects 
    533 on the free list can be reused later. 
    534  
    535 =cut 
    536  
    537 */ 
    538  
    539 static void 
    540 gc_ms_add_free_pmc_ext(SHIM_INTERP, ARGMOD(Small_Object_Pool *pool), ARGIN(void *to_add)) 
    541 { 
    542     ASSERT_ARGS(gc_ms_add_free_pmc_ext) 
    543     PMC_EXT * const object = (PMC_EXT *)to_add; 
    544     object->_metadata      = NULL; 
    545  
    546     /* yes, this cast is a hack for now, but a pointer is a pointer */ 
    547     object->_next_for_GC   = (PMC *)pool->free_list; 
    548     pool->free_list        = object; 
    549 } 
    550  
    551 /* 
    552  
    553 =item C<static void * gc_ms_get_free_pmc_ext(PARROT_INTERP, Small_Object_Pool 
    554 *pool)> 
    555  
    556 Get a new PMC_EXT structure from the free pool and return it. 
    557  
    558 =cut 
    559  
    560 */ 
    561  
    562 PARROT_CANNOT_RETURN_NULL 
    563 PARROT_WARN_UNUSED_RESULT 
    564 static void * 
    565 gc_ms_get_free_pmc_ext(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool)) 
    566 { 
    567     ASSERT_ARGS(gc_ms_get_free_pmc_ext) 
    568     PMC_EXT *ptr; 
    569     PMC_EXT *free_list = (PMC_EXT *)pool->free_list; 
    570  
    571     /* if we don't have any objects */ 
    572     if (!free_list) { 
    573         (*pool->more_objects)(interp, pool); 
    574         free_list = (PMC_EXT *)pool->free_list; 
    575     } 
    576  
    577     ptr               = free_list; 
    578     pool->free_list   = ptr->_next_for_GC; 
    579     ptr->_next_for_GC = NULL; 
    580  
    581     --pool->num_free_objects; 
    582  
    583     return ptr; 
    584 } 
    585  
    586 /* 
    587  
    588 =back 
    589  
    590 =cut 
    591  
    592 */ 
    593  
    594489/* 
    595490 * Local variables: 
    596491 *   c-file-style: "parrot" 
  • include/parrot/hash.h

     
    2828 
    2929/* 
    3030 * hash_entry is currently unused in the hash structure 
    31  */ 
     31  
    3232typedef struct _hash_entry { 
    3333    HashEntryType type; 
    3434    UnionVal val; 
    3535} HashEntry; 
     36*/ 
    3637 
    3738/* A BucketIndex is an index into the pool of available buckets. */ 
    3839typedef UINTVAL BucketIndex; 
  • src/jit_debug.c

     
    106106static void 
    107107write_types(FILE *stabs, PARROT_INTERP) 
    108108{ 
     109        //It would be create if this function would be auto generated :) 
    109110    int i, j; 
    110111    /* borrowed from mono */ 
    111112    static BaseTypes base_types[] = { 
     
    152153    ++i; 
    153154    fprintf(stabs, ".stabs \"Parrot_String:T(0,%d)=s%d" 
    154155                "bufstart:(0,14),%d,%d;" 
    155                 "buflen:(0,6),%d,%d;"   /* XXX type */ 
     156                "buflen:(0,6),%d,%d;" 
    156157                "flags:(0,12),%d,%d;" 
    157158                "bufused:(0,12),%d,%d;" 
    158                 "strstart:(0,15),%d,%d;"        /* fake a char* */ 
     159                "strstart:(0,15),%d,%d;" 
    159160                ";\"" 
    160161                "," N_LSYM ",0,0,0\n", i++, BYTE_SIZE(STRING), 
    161                 BIT_OFFSET(STRING, cache._b._bufstart), BIT_SIZE(void*), 
    162                 BIT_OFFSET(STRING, cache._b._buflen), BIT_SIZE(size_t), 
     162                BIT_OFFSET(STRING, _bufstart), BIT_SIZE(void*), 
     163                BIT_OFFSET(STRING, _buflen), BIT_SIZE(size_t), 
    163164                BIT_OFFSET(STRING, flags), BIT_SIZE(UINTVAL), 
    164165                BIT_OFFSET(STRING, bufused), BIT_SIZE(UINTVAL), 
    165166                BIT_OFFSET(STRING, strstart), BIT_SIZE(void*)); 
     
    177178 
    178179    fprintf(stabs, ";\"," N_LSYM ",0,0,0\n"); 
    179180 
    180     /* PMC type */ 
    181     fprintf(stabs, ".stabs \"PMC:T(0,%d)=s%d", i, BYTE_SIZE(PMC)); 
    182     fprintf(stabs, "cache:(0,%d),%d,%d;", 
    183             i + 1, BIT_OFFSET(PMC, cache), BIT_SIZE(UnionVal)); 
    184     fprintf(stabs, "flags:(0,%d),%d,%d;", 
    185             i + 1, BIT_OFFSET(PMC, flags), BIT_SIZE(Parrot_UInt)); 
    186     fprintf(stabs, "vtable:*(0,%d),%d,%d;", 
    187             i + 3, BIT_OFFSET(PMC, vtable), BIT_SIZE(void*)); 
    188     fprintf(stabs, "data:(0,14),%d,%d;", 
    189             BIT_OFFSET(PMC, data), BIT_SIZE(void*)); 
    190     fprintf(stabs, "pmc_ext:*(0,%d),%d,%d;", 
    191             i, BIT_OFFSET(PMC, pmc_ext), BIT_SIZE(void*)); 
    192     fprintf(stabs, ";\""); 
    193     fprintf(stabs, "," N_LSYM ",0,0,0\n"); 
    194  
    195     fprintf(stabs, ".stabs \"UnionVal:T(0,%d)=u%d" 
    196                 "int_val:(0,12),%d,%d;" 
    197                 "pmc_val:*(0,%d),%d,%d;" 
     181    fprintf(stabs, ".stabs \"PMC:T(0,%d)=s%d" 
     182                "flags:(0,12),%d,%d;" 
     183                    "vtable:*(0,%d),%d,%d;" 
     184                "data:(0,14),%d,%d;" 
     185                "_metadata:*(0,%d),%d,%d;" 
     186                "_next_for_GC:*(0,%d),%d,%d;" 
    198187                ";\"" 
    199                 "," N_LSYM ",0,0,0\n", i + 2, BYTE_SIZE(UnionVal), 
    200                 BIT_OFFSET(UnionVal, _i._int_val), BIT_SIZE(INTVAL), 
    201                 i, BIT_OFFSET(UnionVal, _ptrs._pmc_val), BIT_SIZE(void*)); 
     188                "," N_LSYM ",0,0,0\n", i, BYTE_SIZE(PMC), 
     189                BIT_OFFSET(PMC, flags), BIT_SIZE(UINTVAL), 
     190                i + 1, BIT_OFFSET(PMC, vtable), BIT_SIZE(void*), 
     191                BIT_OFFSET(PMC, data), BIT_SIZE(void*), 
     192                i, BIT_OFFSET(PMC, _metadata), BIT_SIZE(void*), 
     193                i, BIT_OFFSET(PMC, _next_for_GC), BIT_SIZE(void*)); 
     194 
     195    i++; 
     196 
     197    //some one can add some field to this one 
    202198    fprintf(stabs, ".stabs \"VTABLE:T(0,%d)=s%d" 
    203                 "base_type:(0,%d),%d,%d;" 
     199                "base_type:(0,12),%d,%d;" 
    204200                ";\"" 
    205                 "," N_LSYM ",0,0,0\n", i + 3, BYTE_SIZE(UnionVal), 
    206                 i - 1, BIT_OFFSET(VTABLE, base_type), BIT_SIZE(INTVAL)); 
    207     i += 4; 
     201                "," N_LSYM ",0,0,0\n", i, BYTE_SIZE(_vtable), 
     202                BIT_OFFSET(VTABLE, base_type), BIT_SIZE(INTVAL)); 
    208203 
     204    i++; 
    209205} 
    210206 
    211207/*