Ticket #549: unionvalrem.patch

File unionvalrem.patch, 14.0 KB (added by jessevdam, 12 years ago)

patch removing the unionval struct from the pobj.h

  • include/parrot/call.h

    ### Eclipse Workspace Patch 1.0
    #P parrot
     
    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/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); 
  • 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; 
     20    void *     _bufstart; 
     21    size_t     _buflen; 
    4522    Parrot_UInt flags; 
    4623} pobj_t; 
    4724 
    48 /* plain Buffer is the smallest Parrot Obj */ 
    49 typedef struct Buffer { 
    50     UnionVal    cache; 
    51     Parrot_UInt flags; 
    52 } Buffer; 
    53  
    54 typedef Buffer PObj; 
     25typedef pobj_t PObj; 
     26typedef pobj_t Buffer; 
    5527 
    56 #define PObj_bufstart(pmc)    (pmc)->cache._b._bufstart 
    57 #define PObj_buflen(pmc)      (pmc)->cache._b._buflen 
     28#define PObj_bufstart(pmc)    (pmc)->_bufstart 
     29#define PObj_buflen(pmc)      (pmc)->_buflen 
    5830 
    5931/* See src/gc/alloc_resources.c. the basic idea is that buffer memory is 
    6032   set up as follows: 
     
    8456                    v                  v      v                  v 
    8557 
    8658*/ 
    87 typedef struct Buffer_alloc_unit { 
    88     INTVAL ref_count; 
    89     UnionVal buffer[1]; /* Guarantee it's suitably aligned */ 
    90 } Buffer_alloc_unit; 
    9159 
    9260/* Given a pointer to the buffer, find the ref_count and the actual start of 
    9361   the allocated space. Setting ref_count is clunky because we avoid lvalue 
     
    11280} parrot_string_representation_t; 
    11381 
    11482struct parrot_string_t { 
    115     UnionVal    cache; 
     83    void *     _bufstart; 
     84    size_t     _buflen; 
    11685    Parrot_UInt flags; 
    11786    char       *strstart; 
    11887    UINTVAL     bufused; 
     
    12695 
    12796/* note that cache and flags are isomorphic with Buffer and PObj */ 
    12897struct PMC { 
    129     UnionVal        cache; 
     98    void *         _bufstart; 
     99    size_t         _buflen; 
    130100    Parrot_UInt     flags; 
    131101    VTABLE         *vtable; 
    132102    DPOINTER       *data; 
  • 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;" 
    168                 ";\"" 
    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;" 
    174                 ";\"" 
    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; 
     148    fprintf(stabs, ".stabs \"PMC:T(0,%d)=s%d" 
     149                 "bufstart:(0,14),%d,%d;" 
     150                 "buflen:(0,6),%d,%d;" 
     151                 "flags:(0,12),%d,%d;" 
     152                    "vtable:*(0,%d),%d,%d;" 
     153                 "data:(0,14),%d,%d;" 
     154                 "pmc_ext:*(0,%d),%d,%d;" 
     155                 ";\"" 
     156                 "," N_LSYM ",0,0,0\n", i, BYTE_SIZE(PMC), 
     157                 BIT_OFFSET(PMC, _bufstart), BIT_SIZE(void*), 
     158                 BIT_OFFSET(PMC, _buflen), BIT_SIZE(size_t), 
     159                 BIT_OFFSET(PMC, flags), BIT_SIZE(UINTVAL), 
     160                 i + 1, BIT_OFFSET(PMC, vtable), BIT_SIZE(void*), 
     161                 BIT_OFFSET(PMC, data), BIT_SIZE(void*), 
     162                 i + 2, BIT_OFFSET(PMC, pmc_ext), BIT_SIZE(void*)); 
     163 
     164     i++; 
     165 
     166     //some one can add some field to this one 
     167     fprintf(stabs, ".stabs \"VTABLE:T(0,%d)=s%d" 
     168                 "base_type:(0,12),%d,%d;" 
     169                 ";\"" 
     170                 "," N_LSYM ",0,0,0\n", i, BYTE_SIZE(_vtable), 
     171                 BIT_OFFSET(VTABLE, base_type), BIT_SIZE(INTVAL)); 
     172 
     173     i++; 
     174 
     175     fprintf(stabs, ".stabs \"PMC:T(0,%d)=s%d" 
     176                            "_metadata:*(0,%d),%d,%d;" 
     177                    "_next_for_GC:*(0,%d),%d,%d;" 
     178                 ";\"" 
     179                 "," N_LSYM ",0,0,0\n", i, BYTE_SIZE(PMC), 
     180                 i - 2, BIT_OFFSET(PMC_EXT, _metadata), BIT_SIZE(void*), 
     181                 i - 2, BIT_OFFSET(PMC_EXT, _next_for_GC), BIT_SIZE(void*)); 
     182 
     183     i++; 
    178184 
    179185} 
    180186 
  • 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                "bufstart:(0,14),%d,%d;" 
     183                "buflen:(0,6),%d,%d;" 
     184                "flags:(0,12),%d,%d;" 
     185                    "vtable:*(0,%d),%d,%d;" 
     186                "data:(0,14),%d,%d;" 
     187                "pmc_ext:*(0,%d),%d,%d;" 
    198188                ";\"" 
    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*)); 
     189                "," N_LSYM ",0,0,0\n", i, BYTE_SIZE(PMC), 
     190                BIT_OFFSET(PMC, _bufstart), BIT_SIZE(void*), 
     191                BIT_OFFSET(PMC, _buflen), BIT_SIZE(size_t), 
     192                BIT_OFFSET(PMC, flags), BIT_SIZE(UINTVAL), 
     193                i + 1, BIT_OFFSET(PMC, vtable), BIT_SIZE(void*), 
     194                BIT_OFFSET(PMC, data), BIT_SIZE(void*), 
     195                i + 2, BIT_OFFSET(PMC, pmc_ext), BIT_SIZE(void*)); 
     196 
     197    i++; 
     198 
     199    //some one can add some field to this one 
    202200    fprintf(stabs, ".stabs \"VTABLE:T(0,%d)=s%d" 
    203                 "base_type:(0,%d),%d,%d;" 
     201                "base_type:(0,12),%d,%d;" 
     202                ";\"" 
     203                "," N_LSYM ",0,0,0\n", i, BYTE_SIZE(_vtable), 
     204                BIT_OFFSET(VTABLE, base_type), BIT_SIZE(INTVAL)); 
     205 
     206    i++; 
     207 
     208    fprintf(stabs, ".stabs \"PMC:T(0,%d)=s%d" 
     209                    "_metadata:*(0,%d),%d,%d;" 
     210                    "_next_for_GC:*(0,%d),%d,%d;" 
    204211                ";\"" 
    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; 
     212                "," N_LSYM ",0,0,0\n", i, BYTE_SIZE(PMC), 
     213                i - 2, BIT_OFFSET(PMC_EXT, _metadata), BIT_SIZE(void*), 
     214                i - 2, BIT_OFFSET(PMC_EXT, _next_for_GC), BIT_SIZE(void*)); 
    208215 
     216    i++; 
    209217} 
    210218 
    211219/*