Commit 7a1c3d48 by Bryce McKinlay Committed by Bryce McKinlay

re PR libgcj/15713 (compile interpret.cc with -fno-strict-aliasing)

2004-07-12  Bryce McKinlay  <mckinlay@redhat.com>

	PR libgcj/15713
	* include/jvm.h (_Jv_value): New union type.
	* gcj/field.h (_Jv_Field): Add new _addr union field variants
	* interperet.cc (run): Use _Jv_value union type and *_addr _Jv_Field
	union members.

From-SVN: r84596
parent 066a0344
2004-07-12 Bryce McKinlay <mckinlay@redhat.com>
PR libgcj/15713
* include/jvm.h (_Jv_value): New union type.
* gcj/field.h (_Jv_Field): Add new _addr union field variants
* interperet.cc (run): Use _Jv_value union type and *_addr _Jv_Field
union members.
2004-07-12 Scott Gilbertson <scottg@mantatest.com> 2004-07-12 Scott Gilbertson <scottg@mantatest.com>
* gnu/awt/xlib/XCanvasPeer.java (createImage): Implement. * gnu/awt/xlib/XCanvasPeer.java (createImage): Implement.
......
...@@ -39,7 +39,16 @@ struct _Jv_Field ...@@ -39,7 +39,16 @@ struct _Jv_Field
union { union {
jint boffset; /* offset in bytes for instance field */ jint boffset; /* offset in bytes for instance field */
void* addr; /* address of static field */ char* addr; /* address of static field */
jobject* object_addr; /* address of static object field... etc */
jbyte* byte_addr;
jshort* short_addr;
jchar* char_addr;
jint* int_addr;
jlong* long_addr;
jfloat* float_addr;
jdouble* double_addr;
} u; } u;
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -114,6 +114,18 @@ union _Jv_word2 ...@@ -114,6 +114,18 @@ union _Jv_word2
jdouble d; jdouble d;
}; };
union _Jv_value
{
jbyte byte_value;
jshort short_value;
jchar char_value;
jint int_value;
jlong long_value;
jfloat float_value;
jdouble double_value;
jobject object_value;
};
// An instance of this type is used to represent a single frame in a // An instance of this type is used to represent a single frame in a
// backtrace. If the interpreter has been built, we also include // backtrace. If the interpreter has been built, we also include
// information about the interpreted method. // information about the interpreted method.
......
...@@ -1156,7 +1156,7 @@ _Jv_InterpMethod::run (void *retp, ffi_raw *args) ...@@ -1156,7 +1156,7 @@ _Jv_InterpMethod::run (void *retp, ffi_raw *args)
ffi_cif *cif = &rmeth->cif; ffi_cif *cif = &rmeth->cif;
ffi_raw *raw = (ffi_raw*) sp; ffi_raw *raw = (ffi_raw*) sp;
jdouble rvalue; _Jv_value rvalue;
#if FFI_NATIVE_RAW_API #if FFI_NATIVE_RAW_API
/* We assume that this is only implemented if it's correct */ /* We assume that this is only implemented if it's correct */
...@@ -1172,11 +1172,11 @@ _Jv_InterpMethod::run (void *retp, ffi_raw *args) ...@@ -1172,11 +1172,11 @@ _Jv_InterpMethod::run (void *retp, ffi_raw *args)
* so those are checked before the switch */ * so those are checked before the switch */
if (rtype == FFI_TYPE_POINTER) if (rtype == FFI_TYPE_POINTER)
{ {
PUSHA (*(jobject*)&rvalue); PUSHA (rvalue.object_value);
} }
else if (rtype == FFI_TYPE_SINT32) else if (rtype == FFI_TYPE_SINT32)
{ {
PUSHI (*(jint*)&rvalue); PUSHI (rvalue.int_value);
} }
else if (rtype == FFI_TYPE_VOID) else if (rtype == FFI_TYPE_VOID)
{ {
...@@ -1187,36 +1187,27 @@ _Jv_InterpMethod::run (void *retp, ffi_raw *args) ...@@ -1187,36 +1187,27 @@ _Jv_InterpMethod::run (void *retp, ffi_raw *args)
switch (rtype) switch (rtype)
{ {
case FFI_TYPE_SINT8: case FFI_TYPE_SINT8:
{ PUSHI (rvalue.byte_value);
jbyte value = (*(jint*)&rvalue) & 0xff;
PUSHI (value);
}
break; break;
case FFI_TYPE_SINT16: case FFI_TYPE_SINT16:
{ PUSHI (rvalue.short_value);
jshort value = (*(jint*)&rvalue) & 0xffff;
PUSHI (value);
}
break; break;
case FFI_TYPE_UINT16: case FFI_TYPE_UINT16:
{ PUSHI (rvalue.char_value);
jint value = (*(jint*)&rvalue) & 0xffff;
PUSHI (value);
}
break; break;
case FFI_TYPE_FLOAT: case FFI_TYPE_FLOAT:
PUSHF (*(jfloat*)&rvalue); PUSHF (rvalue.float_value);
break; break;
case FFI_TYPE_DOUBLE: case FFI_TYPE_DOUBLE:
PUSHD (rvalue); PUSHD (rvalue.double_value);
break; break;
case FFI_TYPE_SINT64: case FFI_TYPE_SINT64:
PUSHL (*(jlong*)&rvalue); PUSHL (rvalue.long_value);
break; break;
default: default:
...@@ -2408,37 +2399,37 @@ _Jv_InterpMethod::run (void *retp, ffi_raw *args) ...@@ -2408,37 +2399,37 @@ _Jv_InterpMethod::run (void *retp, ffi_raw *args)
switch (type->size_in_bytes) switch (type->size_in_bytes)
{ {
case 1: case 1:
PUSHI (*(jbyte*) (field->u.addr)); PUSHI (*field->u.byte_addr);
newinsn = AMPAMP (getstatic_resolved_1); newinsn = AMPAMP (getstatic_resolved_1);
break; break;
case 2: case 2:
if (type == JvPrimClass (char)) if (type == JvPrimClass (char))
{ {
PUSHI(*(jchar*) (field->u.addr)); PUSHI (*field->u.char_addr);
newinsn = AMPAMP (getstatic_resolved_char); newinsn = AMPAMP (getstatic_resolved_char);
} }
else else
{ {
PUSHI(*(jshort*) (field->u.addr)); PUSHI (*field->u.short_addr);
newinsn = AMPAMP (getstatic_resolved_short); newinsn = AMPAMP (getstatic_resolved_short);
} }
break; break;
case 4: case 4:
PUSHI(*(jint*) (field->u.addr)); PUSHI(*field->u.int_addr);
newinsn = AMPAMP (getstatic_resolved_4); newinsn = AMPAMP (getstatic_resolved_4);
break; break;
case 8: case 8:
PUSHL(*(jlong*) (field->u.addr)); PUSHL(*field->u.long_addr);
newinsn = AMPAMP (getstatic_resolved_8); newinsn = AMPAMP (getstatic_resolved_8);
break; break;
} }
} }
else else
{ {
PUSHA(*(jobject*) (field->u.addr)); PUSHA(*field->u.object_addr);
newinsn = AMPAMP (getstatic_resolved_obj); newinsn = AMPAMP (getstatic_resolved_obj);
} }
...@@ -2494,42 +2485,43 @@ _Jv_InterpMethod::run (void *retp, ffi_raw *args) ...@@ -2494,42 +2485,43 @@ _Jv_InterpMethod::run (void *retp, ffi_raw *args)
NULLCHECK(obj); NULLCHECK(obj);
void *newinsn = NULL; void *newinsn = NULL;
_Jv_value *val = (_Jv_value *) ((char *)obj + field_offset);
if (type->isPrimitive ()) if (type->isPrimitive ())
{ {
switch (type->size_in_bytes) switch (type->size_in_bytes)
{ {
case 1: case 1:
PUSHI (*(jbyte*) ((char*)obj + field_offset)); PUSHI (val->byte_value);
newinsn = AMPAMP (getfield_resolved_1); newinsn = AMPAMP (getfield_resolved_1);
break; break;
case 2: case 2:
if (type == JvPrimClass (char)) if (type == JvPrimClass (char))
{ {
PUSHI (*(jchar*) ((char*)obj + field_offset)); PUSHI (val->char_value);
newinsn = AMPAMP (getfield_resolved_char); newinsn = AMPAMP (getfield_resolved_char);
} }
else else
{ {
PUSHI (*(jshort*) ((char*)obj + field_offset)); PUSHI (val->short_value);
newinsn = AMPAMP (getfield_resolved_short); newinsn = AMPAMP (getfield_resolved_short);
} }
break; break;
case 4: case 4:
PUSHI (*(jint*) ((char*)obj + field_offset)); PUSHI (val->int_value);
newinsn = AMPAMP (getfield_resolved_4); newinsn = AMPAMP (getfield_resolved_4);
break; break;
case 8: case 8:
PUSHL(*(jlong*) ((char*)obj + field_offset)); PUSHL (val->long_value);
newinsn = AMPAMP (getfield_resolved_8); newinsn = AMPAMP (getfield_resolved_8);
break; break;
} }
} }
else else
{ {
PUSHA(*(jobject*) ((char*)obj + field_offset)); PUSHA (val->object_value);
newinsn = AMPAMP (getfield_resolved_obj); newinsn = AMPAMP (getfield_resolved_obj);
} }
...@@ -2611,7 +2603,7 @@ _Jv_InterpMethod::run (void *retp, ffi_raw *args) ...@@ -2611,7 +2603,7 @@ _Jv_InterpMethod::run (void *retp, ffi_raw *args)
case 1: case 1:
{ {
jint value = POPI(); jint value = POPI();
*(jbyte*) (field->u.addr) = value; *field->u.byte_addr = value;
newinsn = AMPAMP (putstatic_resolved_1); newinsn = AMPAMP (putstatic_resolved_1);
break; break;
} }
...@@ -2619,7 +2611,7 @@ _Jv_InterpMethod::run (void *retp, ffi_raw *args) ...@@ -2619,7 +2611,7 @@ _Jv_InterpMethod::run (void *retp, ffi_raw *args)
case 2: case 2:
{ {
jint value = POPI(); jint value = POPI();
*(jchar*) (field->u.addr) = value; *field->u.char_addr = value;
newinsn = AMPAMP (putstatic_resolved_2); newinsn = AMPAMP (putstatic_resolved_2);
break; break;
} }
...@@ -2627,7 +2619,7 @@ _Jv_InterpMethod::run (void *retp, ffi_raw *args) ...@@ -2627,7 +2619,7 @@ _Jv_InterpMethod::run (void *retp, ffi_raw *args)
case 4: case 4:
{ {
jint value = POPI(); jint value = POPI();
*(jint*) (field->u.addr) = value; *field->u.int_addr = value;
newinsn = AMPAMP (putstatic_resolved_4); newinsn = AMPAMP (putstatic_resolved_4);
break; break;
} }
...@@ -2635,7 +2627,7 @@ _Jv_InterpMethod::run (void *retp, ffi_raw *args) ...@@ -2635,7 +2627,7 @@ _Jv_InterpMethod::run (void *retp, ffi_raw *args)
case 8: case 8:
{ {
jlong value = POPL(); jlong value = POPL();
*(jlong*) (field->u.addr) = value; *field->u.long_addr = value;
newinsn = AMPAMP (putstatic_resolved_8); newinsn = AMPAMP (putstatic_resolved_8);
break; break;
} }
...@@ -2644,7 +2636,7 @@ _Jv_InterpMethod::run (void *retp, ffi_raw *args) ...@@ -2644,7 +2636,7 @@ _Jv_InterpMethod::run (void *retp, ffi_raw *args)
else else
{ {
jobject value = POPA(); jobject value = POPA();
*(jobject*) (field->u.addr) = value; *field->u.object_addr = value;
newinsn = AMPAMP (putstatic_resolved_obj); newinsn = AMPAMP (putstatic_resolved_obj);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment