### Eclipse Workspace Patch 1.0 #P parrot Index: include/parrot/call.h =================================================================== --- include/parrot/call.h (revision 40324) +++ include/parrot/call.h (working copy) @@ -70,10 +70,30 @@ INTVAL slurp_n; /* number of :flat/:slurpy args/params to match */ } call_state_item; +typedef union UnionCallStateVal { + struct _ptrs { //or two pointers, both are defines + DPOINTER * _struct_val; + PMC * _pmc_val; + } _ptrs; + struct _i { + INTVAL _int_val; // or 2 intvals + INTVAL _int_val2; + } _i; + FLOATVAL _num_val; // or one float + struct parrot_string_t * _string_val; // or a pointer to a string +} UnionCallStateVal; + +#define UVal_ptr(u) (u)._ptrs._struct_val +#define UVal_pmc(u) (u)._ptrs._pmc_val +#define UVal_int(u) (u)._i._int_val +#define UVal_int2(u) (u)._i._int_val2 +#define UVal_num(u) (u)._num_val +#define UVal_str(u) (u)._string_val + typedef struct call_state { call_state_item src; call_state_item dest; - UnionVal val; + UnionCallStateVal val; int n_actual_args; /* arguments incl. flatten */ int optionals; /* sum of optionals */ int params; /* sum of params */ Index: src/call/pcc.c =================================================================== --- src/call/pcc.c (revision 40324) +++ src/call/pcc.c (working copy) @@ -1665,7 +1665,7 @@ * RT #54860 and others * Save current value while setting the optional */ - const UnionVal old_value = st->val; + const UnionCallStateVal old_value = st->val; while (dest->sig & PARROT_ARG_OPTIONAL) { null_val(st->dest.sig, st); Index: include/parrot/pobj.h =================================================================== --- include/parrot/pobj.h (revision 40324) +++ include/parrot/pobj.h (working copy) @@ -15,46 +15,18 @@ #include "parrot/config.h" -typedef union UnionVal { - struct _b { /* One Buffer structure */ - void * _bufstart; - size_t _buflen; - } _b; - struct _ptrs { /* or two pointers, both are defines */ - DPOINTER * _struct_val; - PMC * _pmc_val; - } _ptrs; - struct _i { - INTVAL _int_val; /* or 2 intvals */ - INTVAL _int_val2; - } _i; - FLOATVAL _num_val; /* or one float */ - struct parrot_string_t * _string_val; /* or a pointer to a string */ -} UnionVal; - -#define UVal_ptr(u) (u)._ptrs._struct_val -#define UVal_pmc(u) (u)._ptrs._pmc_val -#define UVal_int(u) (u)._i._int_val -#define UVal_int2(u) (u)._i._int_val2 -#define UVal_num(u) (u)._num_val -#define UVal_str(u) (u)._string_val - /* Parrot Object - base class for all others */ typedef struct pobj_t { - UnionVal u; + void * _bufstart; + size_t _buflen; Parrot_UInt flags; } pobj_t; -/* plain Buffer is the smallest Parrot Obj */ -typedef struct Buffer { - UnionVal cache; - Parrot_UInt flags; -} Buffer; - -typedef Buffer PObj; +typedef pobj_t PObj; +typedef pobj_t Buffer; -#define PObj_bufstart(pmc) (pmc)->cache._b._bufstart -#define PObj_buflen(pmc) (pmc)->cache._b._buflen +#define PObj_bufstart(pmc) (pmc)->_bufstart +#define PObj_buflen(pmc) (pmc)->_buflen /* See src/gc/alloc_resources.c. the basic idea is that buffer memory is set up as follows: @@ -84,10 +56,6 @@ v v v v */ -typedef struct Buffer_alloc_unit { - INTVAL ref_count; - UnionVal buffer[1]; /* Guarantee it's suitably aligned */ -} Buffer_alloc_unit; /* Given a pointer to the buffer, find the ref_count and the actual start of the allocated space. Setting ref_count is clunky because we avoid lvalue @@ -112,7 +80,8 @@ } parrot_string_representation_t; struct parrot_string_t { - UnionVal cache; + void * _bufstart; + size_t _buflen; Parrot_UInt flags; char *strstart; UINTVAL bufused; @@ -126,7 +95,8 @@ /* note that cache and flags are isomorphic with Buffer and PObj */ struct PMC { - UnionVal cache; + void * _bufstart; + size_t _buflen; Parrot_UInt flags; VTABLE *vtable; DPOINTER *data; Index: src/jit_debug_xcoff.c =================================================================== --- src/jit_debug_xcoff.c (revision 40324) +++ src/jit_debug_xcoff.c (working copy) @@ -118,63 +118,69 @@ fprintf(stabs, ".stabx \"STRING:t%d=*%d\"" ",0," C_DECL ",0\n", i, i+1); ++i; - fprintf(stabs, ".stabx \"Parrot_String:T%d=s%d" - "bufstart:14,%d,%d;" - "buflen:6,%d,%d;" /* XXX type */ - "flags:12,%d,%d;" - "bufused:12,%d,%d;" - "strstart:15,%d,%d;" /* fake a char* */ + fprintf(stabs, ".stabs \"Parrot_String:T(0,%d)=s%d" + "bufstart:(0,14),%d,%d;" + "buflen:(0,6),%d,%d;" + "flags:(0,12),%d,%d;" + "bufused:(0,12),%d,%d;" + "strstart:(0,15),%d,%d;" ";\"" - ",0," C_DECL ",0\n", i++, BYTE_SIZE(STRING), - BIT_OFFSET(STRING, cache._b._bufstart), BIT_SIZE(void*), - BIT_OFFSET(STRING, cache._b._buflen), BIT_SIZE(size_t), + "," N_LSYM ",0,0,0\n", i++, BYTE_SIZE(STRING), + BIT_OFFSET(STRING, _bufstart), BIT_SIZE(void*), + BIT_OFFSET(STRING, _buflen), BIT_SIZE(size_t), BIT_OFFSET(STRING, flags), BIT_SIZE(UINTVAL), BIT_OFFSET(STRING, bufused), BIT_SIZE(UINTVAL), BIT_OFFSET(STRING, strstart), BIT_SIZE(void*)); - fprintf(stabs, ".stabx \"PMCType:T%d=e", i++); + fprintf(stabs, ".stabs \"PMCType:T(0,%d)=e", i++); for (j = 0; j < interp->n_vtable_max; ++j) { if (interp->vtables[j] && interp->vtables[j]->whoami) { - STRING* name = interp->vtables[j]->whoami; - fwrite(name->strstart, name->strlen, 1, stabs); + STRING *name = interp->vtables[j]->whoami; + size_t items = fwrite(name->strstart, name->strlen, 1, stabs); + if (!items) + fprintf(stderr, "Error writing stabs!\n"); fprintf(stabs, ":%d,", j); } } - fprintf(stabs, ";\",0," C_DECL ",0\n"); - /* PMC type */ - fprintf(stabs, ".stabx \"PMC:T%d=s%d", i, BYTE_SIZE(PMC)); - fprintf(stabs, "cache:%d,%d,%d;", - i + 1, BIT_OFFSET(PMC, cache), BIT_SIZE(UnionVal)); - fprintf(stabs, "flags:%d,%d,%d;", - i + 1, BIT_OFFSET(PMC, flags), BIT_SIZE(Parrot_UInt)); - fprintf(stabs, "vtable:*%d,%d,%d;", - i + 3, BIT_OFFSET(PMC, vtable), BIT_SIZE(void*)); - fprintf(stabs, "data:14,%d,%d;", - BIT_OFFSET(PMC, data), BIT_SIZE(void*)); - fprintf(stabs, "pmc_ext:*%d,%d,%d;", - i, BIT_OFFSET(PMC, pmc_ext), BIT_SIZE(void*)); - fprintf(stabs, ";\""); - fprintf(stabs, ",0," C_DECL ",0\n"); + fprintf(stabs, ";\"," N_LSYM ",0,0,0\n"); - fprintf(stabs, ".stabx \"cache:%d,%d,%d;" - "flags:12,%d,%d;" - ";\"" - ",0," C_DECL ",0\n", - i + 2, BIT_SIZE(UnionVal), BIT_SIZE(Parrot_UInt)); - fprintf(stabs, ".stabx \"UnionVal:T%d=u%d" - "int_val:12,%d,%d;" - "pmc_val:*%d,%d,%d;" - ";\"" - ",0," C_DECL ",0\n", i + 2, BYTE_SIZE(UnionVal), - BIT_OFFSET(UnionVal, int_val), BIT_SIZE(INTVAL), - i, BIT_OFFSET(UnionVal, pmc_val), BIT_SIZE(void*)); - fprintf(stabs, ".stabx \"VTABLE:T%d=s%d" - "base_type:%d,%d,%d;" - ";\"" - ",0," C_DECL ",0\n", i + 3, BYTE_SIZE(UnionVal), - i - 1, BIT_OFFSET(VTABLE, base_type), BIT_SIZE(INTVAL)); - i += 4; + fprintf(stabs, ".stabs \"PMC:T(0,%d)=s%d" + "bufstart:(0,14),%d,%d;" + "buflen:(0,6),%d,%d;" + "flags:(0,12),%d,%d;" + "vtable:*(0,%d),%d,%d;" + "data:(0,14),%d,%d;" + "pmc_ext:*(0,%d),%d,%d;" + ";\"" + "," N_LSYM ",0,0,0\n", i, BYTE_SIZE(PMC), + BIT_OFFSET(PMC, _bufstart), BIT_SIZE(void*), + BIT_OFFSET(PMC, _buflen), BIT_SIZE(size_t), + BIT_OFFSET(PMC, flags), BIT_SIZE(UINTVAL), + i + 1, BIT_OFFSET(PMC, vtable), BIT_SIZE(void*), + BIT_OFFSET(PMC, data), BIT_SIZE(void*), + i + 2, BIT_OFFSET(PMC, pmc_ext), BIT_SIZE(void*)); + + i++; + + //some one can add some field to this one + fprintf(stabs, ".stabs \"VTABLE:T(0,%d)=s%d" + "base_type:(0,12),%d,%d;" + ";\"" + "," N_LSYM ",0,0,0\n", i, BYTE_SIZE(_vtable), + BIT_OFFSET(VTABLE, base_type), BIT_SIZE(INTVAL)); + + i++; + + fprintf(stabs, ".stabs \"PMC:T(0,%d)=s%d" + "_metadata:*(0,%d),%d,%d;" + "_next_for_GC:*(0,%d),%d,%d;" + ";\"" + "," N_LSYM ",0,0,0\n", i, BYTE_SIZE(PMC), + i - 2, BIT_OFFSET(PMC_EXT, _metadata), BIT_SIZE(void*), + i - 2, BIT_OFFSET(PMC_EXT, _next_for_GC), BIT_SIZE(void*)); + + i++; } Index: include/parrot/hash.h =================================================================== --- include/parrot/hash.h (revision 40324) +++ include/parrot/hash.h (working copy) @@ -28,11 +28,12 @@ /* * hash_entry is currently unused in the hash structure - */ + typedef struct _hash_entry { HashEntryType type; UnionVal val; } HashEntry; +*/ /* A BucketIndex is an index into the pool of available buckets. */ typedef UINTVAL BucketIndex; Index: src/jit_debug.c =================================================================== --- src/jit_debug.c (revision 40324) +++ src/jit_debug.c (working copy) @@ -106,6 +106,7 @@ static void write_types(FILE *stabs, PARROT_INTERP) { + //It would be create if this function would be auto generated :) int i, j; /* borrowed from mono */ static BaseTypes base_types[] = { @@ -152,14 +153,14 @@ ++i; fprintf(stabs, ".stabs \"Parrot_String:T(0,%d)=s%d" "bufstart:(0,14),%d,%d;" - "buflen:(0,6),%d,%d;" /* XXX type */ + "buflen:(0,6),%d,%d;" "flags:(0,12),%d,%d;" "bufused:(0,12),%d,%d;" - "strstart:(0,15),%d,%d;" /* fake a char* */ + "strstart:(0,15),%d,%d;" ";\"" "," N_LSYM ",0,0,0\n", i++, BYTE_SIZE(STRING), - BIT_OFFSET(STRING, cache._b._bufstart), BIT_SIZE(void*), - BIT_OFFSET(STRING, cache._b._buflen), BIT_SIZE(size_t), + BIT_OFFSET(STRING, _bufstart), BIT_SIZE(void*), + BIT_OFFSET(STRING, _buflen), BIT_SIZE(size_t), BIT_OFFSET(STRING, flags), BIT_SIZE(UINTVAL), BIT_OFFSET(STRING, bufused), BIT_SIZE(UINTVAL), BIT_OFFSET(STRING, strstart), BIT_SIZE(void*)); @@ -177,35 +178,42 @@ fprintf(stabs, ";\"," N_LSYM ",0,0,0\n"); - /* PMC type */ - fprintf(stabs, ".stabs \"PMC:T(0,%d)=s%d", i, BYTE_SIZE(PMC)); - fprintf(stabs, "cache:(0,%d),%d,%d;", - i + 1, BIT_OFFSET(PMC, cache), BIT_SIZE(UnionVal)); - fprintf(stabs, "flags:(0,%d),%d,%d;", - i + 1, BIT_OFFSET(PMC, flags), BIT_SIZE(Parrot_UInt)); - fprintf(stabs, "vtable:*(0,%d),%d,%d;", - i + 3, BIT_OFFSET(PMC, vtable), BIT_SIZE(void*)); - fprintf(stabs, "data:(0,14),%d,%d;", - BIT_OFFSET(PMC, data), BIT_SIZE(void*)); - fprintf(stabs, "pmc_ext:*(0,%d),%d,%d;", - i, BIT_OFFSET(PMC, pmc_ext), BIT_SIZE(void*)); - fprintf(stabs, ";\""); - fprintf(stabs, "," N_LSYM ",0,0,0\n"); - - fprintf(stabs, ".stabs \"UnionVal:T(0,%d)=u%d" - "int_val:(0,12),%d,%d;" - "pmc_val:*(0,%d),%d,%d;" + fprintf(stabs, ".stabs \"PMC:T(0,%d)=s%d" + "bufstart:(0,14),%d,%d;" + "buflen:(0,6),%d,%d;" + "flags:(0,12),%d,%d;" + "vtable:*(0,%d),%d,%d;" + "data:(0,14),%d,%d;" + "pmc_ext:*(0,%d),%d,%d;" ";\"" - "," N_LSYM ",0,0,0\n", i + 2, BYTE_SIZE(UnionVal), - BIT_OFFSET(UnionVal, _i._int_val), BIT_SIZE(INTVAL), - i, BIT_OFFSET(UnionVal, _ptrs._pmc_val), BIT_SIZE(void*)); + "," N_LSYM ",0,0,0\n", i, BYTE_SIZE(PMC), + BIT_OFFSET(PMC, _bufstart), BIT_SIZE(void*), + BIT_OFFSET(PMC, _buflen), BIT_SIZE(size_t), + BIT_OFFSET(PMC, flags), BIT_SIZE(UINTVAL), + i + 1, BIT_OFFSET(PMC, vtable), BIT_SIZE(void*), + BIT_OFFSET(PMC, data), BIT_SIZE(void*), + i + 2, BIT_OFFSET(PMC, pmc_ext), BIT_SIZE(void*)); + + i++; + + //some one can add some field to this one fprintf(stabs, ".stabs \"VTABLE:T(0,%d)=s%d" - "base_type:(0,%d),%d,%d;" + "base_type:(0,12),%d,%d;" + ";\"" + "," N_LSYM ",0,0,0\n", i, BYTE_SIZE(_vtable), + BIT_OFFSET(VTABLE, base_type), BIT_SIZE(INTVAL)); + + i++; + + fprintf(stabs, ".stabs \"PMC:T(0,%d)=s%d" + "_metadata:*(0,%d),%d,%d;" + "_next_for_GC:*(0,%d),%d,%d;" ";\"" - "," N_LSYM ",0,0,0\n", i + 3, BYTE_SIZE(UnionVal), - i - 1, BIT_OFFSET(VTABLE, base_type), BIT_SIZE(INTVAL)); - i += 4; + "," N_LSYM ",0,0,0\n", i, BYTE_SIZE(PMC), + i - 2, BIT_OFFSET(PMC_EXT, _metadata), BIT_SIZE(void*), + i - 2, BIT_OFFSET(PMC_EXT, _next_for_GC), BIT_SIZE(void*)); + i++; } /*