Index: include/Arrays.h =================================================================== RCS file: /home/cvspublic/kaffe/include/Arrays.h,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 Arrays.h --- Arrays.h 1998/03/31 19:10:53 1.1.1.1 +++ Arrays.h 1999/01/18 17:02:43 @@ -12,28 +12,30 @@ #ifndef __array_h #define __array_h -#define ARRAY_FIELDS \ - unsigned int length; \ - double align[0] - -struct Array { - Hjava_lang_Object base; - ARRAY_FIELDS; -}; - /* * Define various array types */ -typedef struct { Hjava_lang_Object base; ARRAY_FIELDS; struct { jbyte body[1]; } data[1]; } HArrayOfBoolean; -typedef struct { Hjava_lang_Object base; ARRAY_FIELDS; struct { jbyte body[1]; } data[1]; } HArrayOfByte; -typedef struct { Hjava_lang_Object base; ARRAY_FIELDS; struct { jchar body[1]; } data[1]; } HArrayOfChar; -typedef struct { Hjava_lang_Object base; ARRAY_FIELDS; struct { jdouble body[1]; } data[1]; } HArrayOfDouble; -typedef struct { Hjava_lang_Object base; ARRAY_FIELDS; struct { jfloat body[1]; } data[1]; } HArrayOfFloat; -typedef struct { Hjava_lang_Object base; ARRAY_FIELDS; struct { jint body[1]; } data[1]; } HArrayOfInt; -typedef struct { Hjava_lang_Object base; ARRAY_FIELDS; struct { jshort body[1]; } data[1]; } HArrayOfShort; -typedef struct { Hjava_lang_Object base; ARRAY_FIELDS; struct { jlong body[1]; } data[1]; } HArrayOfLong; -typedef struct { Hjava_lang_Object base; ARRAY_FIELDS; struct { Hjava_lang_Object* body[1]; } data[1]; } HArrayOfArray; -typedef struct { Hjava_lang_Object base; ARRAY_FIELDS; struct { Hjava_lang_Object* body[1]; } data[1]; } HArrayOfObject; +#define DEFINE_ARRAY_OF(TYPE, NAME) \ +typedef struct { \ + Hjava_lang_Object base; \ + unsigned int length; \ + union { \ + double align; \ + TYPE body[1]; \ + } data[1]; \ +} NAME + +DEFINE_ARRAY_OF(jbyte, HArrayOfBoolean); +DEFINE_ARRAY_OF(jbyte, HArrayOfByte); +DEFINE_ARRAY_OF(jchar, HArrayOfChar); +DEFINE_ARRAY_OF(jdouble, HArrayOfDouble); +DEFINE_ARRAY_OF(jfloat, HArrayOfFloat); +DEFINE_ARRAY_OF(jint, HArrayOfInt); +DEFINE_ARRAY_OF(jshort, HArrayOfShort); +DEFINE_ARRAY_OF(jlong, HArrayOfLong); +DEFINE_ARRAY_OF(Hjava_lang_Object*, HArrayOfArray); +DEFINE_ARRAY_OF(Hjava_lang_Object*, HArrayOfObject); +#undef DEFINE_ARRAY_OF /* Get length of arrays */ #define obj_length(_obj) ((_obj)->length) Index: kaffe/kaffevm/gtypes.h =================================================================== RCS file: /home/cvspublic/kaffe/kaffe/kaffevm/gtypes.h,v retrieving revision 1.5 diff -u -r1.5 gtypes.h --- gtypes.h 1998/12/27 00:10:08 1.5 +++ gtypes.h 1999/01/18 17:02:43 @@ -77,7 +77,6 @@ typedef u2 accessFlags; typedef u2 constIndex; -typedef struct Array Array; typedef struct _fields Field; #if !defined(__DEFINED_METHOD) Index: kaffe/kaffevm/object.h =================================================================== RCS file: /home/cvspublic/kaffe/kaffe/kaffevm/object.h,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 object.h --- object.h 1998/03/31 19:10:54 1.1.1.1 +++ object.h 1999/01/18 17:02:43 @@ -22,16 +22,16 @@ #define OBJECT_DATA(OBJ) ((void*)((Hjava_lang_Object*)(OBJ)+1)) /* Number of elements. */ -#define ARRAY_SIZE(ARRAY) (((Array*)(ARRAY))->length) -#define ARRAY_DATA(ARRAY) ((void*)((Array*)(ARRAY)+1)) -#define OBJARRAY_DATA(ARRAY) ((Hjava_lang_Object**)((Array*)(ARRAY)+1)) +#define ARRAY_SIZE(ARRAY) (((HArrayOfObject*)(ARRAY))->length) +#define ARRAY_DATA(ARRAY) ((void*)&(((HArrayOfObject*)(ARRAY))->data)) +#define OBJARRAY_DATA(ARRAY) ((Hjava_lang_Object**)&(((HArrayOfObject*)(ARRAY))->data)) /* * These bizzare casts provide various offset into the object structure. */ #define OBJECT_DTABLE_OFFSET ((int)&(*(Hjava_lang_Object*)0).dtable) #define ARRAY_SIZE_OFFSET ((int)&ARRAY_SIZE(0)) -#define ARRAY_DATA_OFFSET ((int)(((Array*)0)+1)) +#define ARRAY_DATA_OFFSET ((int)ARRAY_DATA(0)) struct Hjava_lang_Class; Index: kaffe/kaffevm/object.c =================================================================== RCS file: /home/cvspublic/kaffe/kaffe/kaffevm/object.c,v retrieving revision 1.7 diff -u -r1.7 object.c --- object.c 1999/01/06 07:53:03 1.7 +++ object.c 1999/01/18 17:02:43 @@ -106,10 +106,10 @@ Hjava_lang_Object* obj; if (CLASS_IS_PRIMITIVE(elclass)) { - obj = gc_malloc((TYPE_SIZE(elclass) * count) + sizeof(Array), GC_ALLOC_PRIMARRAY); + obj = gc_malloc((TYPE_SIZE(elclass) * count) + ARRAY_DATA_OFFSET, GC_ALLOC_PRIMARRAY); } else { - obj = gc_malloc((PTR_TYPE_SIZE * count) + sizeof(Array), GC_ALLOC_REFARRAY); + obj = gc_malloc((PTR_TYPE_SIZE * count) + ARRAY_DATA_OFFSET, GC_ALLOC_REFARRAY); } class = lookupArray(elclass); obj->dtable = class->dtable; Index: kaffe/kaffevm/intrp/icode.h =================================================================== RCS file: /home/cvspublic/kaffe/kaffe/kaffevm/intrp/icode.h,v retrieving revision 1.6 diff -u -r1.6 icode.h --- icode.h 1998/12/19 20:30:06 1.6 +++ icode.h 1999/01/18 17:02:44 @@ -291,7 +291,7 @@ #define adjustpc(a) /* Not needed for interpreter */ -#define check_array_index(O, I) if ((I)[0].v.tint >= ((struct Array*)((O)[0].v.taddr))->length) { \ +#define check_array_index(O, I) if ((I)[0].v.tint >= ARRAY_SIZE((O)[0].v.taddr)) { \ soft_badarrayindex(); \ } #define build_call_frame(SIG, OBJ, NRARGS) /* Not needed for interpreter */