PatchSet 5089 Date: 2004/08/22 13:31:24 Author: guilhem Branch: HEAD Tag: (none) Log: Fixed double/float to int conversion on sparc/jit.
* config/sparc/jit-icode.h, config/i386/jit-icode.h, config/alpha/jit-icode.h, config/arm/jit-icode.h, config/m68k/jit-icode.h (HAVE_cvt_double_int_ieee, HAVE_cvt_float_int_ieee): New define symbols. * kaffe/kaffevm/jit/icode.c (cvt_double_int): New JIT codelet to use non Java-compatible floating point to integer converting instruction. (cvt_float_int): New JIT codelet to use non Java-compatible floating point to integer converting instruction. * test/internal/TypeConversion.java: Check for NaN (float or double) to int conversion. * test/internal/jitBasic.c: Fixed a memory overreading. Members: ChangeLog:1.2647->1.2648 config/alpha/jit-icode.h:1.3->1.4 config/arm/jit-icode.h:1.2->1.3 config/i386/jit-icode.h:1.5->1.6 config/sparc/jit-icode.h:1.3->1.4 kaffe/kaffevm/jit/icode.c:1.28->1.29 test/internal/TypeConversion.java:1.1->1.2 test/internal/jitBasic.c:1.3->1.4 Index: kaffe/ChangeLog diff -u kaffe/ChangeLog:1.2647 kaffe/ChangeLog:1.2648 --- kaffe/ChangeLog:1.2647 Sat Aug 21 16:32:42 2004 +++ kaffe/ChangeLog Sun Aug 22 13:31:24 2004 @@ -1,3 +1,22 @@ +2004-08-22 Guilhem Lavaux <[EMAIL PROTECTED]> + + * config/sparc/jit-icode.h, config/i386/jit-icode.h, + config/alpha/jit-icode.h, config/arm/jit-icode.h, + config/m68k/jit-icode.h + (HAVE_cvt_double_int_ieee, HAVE_cvt_float_int_ieee): New define + symbols. + + * kaffe/kaffevm/jit/icode.c + (cvt_double_int): New JIT codelet to use non Java-compatible + floating point to integer converting instruction. + (cvt_float_int): New JIT codelet to use non Java-compatible + floating point to integer converting instruction. + + * test/internal/TypeConversion.java: Check for NaN (float or + double) to int conversion. + + * test/internal/jitBasic.c: Fixed a memory overreading. + 2004-08-21 Dalibor Topic <[EMAIL PROTECTED]> * config/powerpc/sysdepCallMethod.h: @@ -20,7 +39,7 @@ * config/alpha/sysdepCallMethod.h: Include missing file. - * kaffe/kaffevm/jit/methodcalls.c, + h * kaffe/kaffevm/jit/methodcalls.c, kaffe/kaffevm/jit/methodcalls.h: Export soft_fixup_trampoline. Index: kaffe/config/alpha/jit-icode.h diff -u kaffe/config/alpha/jit-icode.h:1.3 kaffe/config/alpha/jit-icode.h:1.4 --- kaffe/config/alpha/jit-icode.h:1.3 Sun Jun 17 16:39:09 2001 +++ kaffe/config/alpha/jit-icode.h Sun Aug 22 13:31:27 2004 @@ -277,7 +277,9 @@ #else #undef HAVE_cvt_float_int +#undef HAVE_cvt_float_int_ieee #undef HAVE_cvt_double_int +#undef HAVE_cvt_double_int_ieee #undef HAVE_cvt_float_long #undef HAVE_cvt_double_long Index: kaffe/config/arm/jit-icode.h diff -u kaffe/config/arm/jit-icode.h:1.2 kaffe/config/arm/jit-icode.h:1.3 --- kaffe/config/arm/jit-icode.h:1.2 Sun Jun 17 16:39:10 2001 +++ kaffe/config/arm/jit-icode.h Sun Aug 22 13:31:27 2004 @@ -157,7 +157,9 @@ #define HAVE_cvt_int_double cvtid_RxR #define HAVE_cvt_float_int cvtfi_RxR +#undef HAVE_cvt_float_int_ieee #define HAVE_cvt_double_int cvtdi_RxR +#undef HAVE_cvt_double_int_ieee #undef HAVE_cvt_long_double #undef HAVE_cvt_long_float Index: kaffe/config/i386/jit-icode.h diff -u kaffe/config/i386/jit-icode.h:1.5 kaffe/config/i386/jit-icode.h:1.6 --- kaffe/config/i386/jit-icode.h:1.5 Sun Jun 17 16:39:10 2001 +++ kaffe/config/i386/jit-icode.h Sun Aug 22 13:31:28 2004 @@ -124,7 +124,9 @@ #define HAVE_cvt_float_double cvtfd_RxR #define HAVE_cvt_double_float cvtdf_RxR #undef HAVE_cvt_float_int +#undef HAVE_cvt_float_int_ieee #undef HAVE_cvt_double_int +#undef HAVE_cvt_double_int_ieee #undef HAVE_cvt_float_long #undef HAVE_cvt_double_long Index: kaffe/config/sparc/jit-icode.h diff -u kaffe/config/sparc/jit-icode.h:1.3 kaffe/config/sparc/jit-icode.h:1.4 --- kaffe/config/sparc/jit-icode.h:1.3 Sun Jun 17 16:39:11 2001 +++ kaffe/config/sparc/jit-icode.h Sun Aug 22 13:31:29 2004 @@ -110,8 +110,10 @@ #define HAVE_build_code_ref set_wordpc_xxC #define HAVE_cvt_int_double cvtid_RxR -#define HAVE_cvt_float_int cvtfi_RxR -#define HAVE_cvt_double_int cvtdi_RxR +#define HAVE_cvt_float_int_ieee cvtfi_RxR +#undef HAVE_cvt_float_int +#define HAVE_cvt_double_int_ieee cvtdi_RxR +#undef HAVE_cvt_double_int #define HAVE_cvt_int_float cvtif_RxR #define HAVE_cvt_float_double cvtfd_RxR #define HAVE_cvt_double_float cvtdf_RxR Index: kaffe/kaffe/kaffevm/jit/icode.c diff -u kaffe/kaffe/kaffevm/jit/icode.c:1.28 kaffe/kaffe/kaffevm/jit/icode.c:1.29 --- kaffe/kaffe/kaffevm/jit/icode.c:1.28 Thu Aug 19 19:29:03 2004 +++ kaffe/kaffe/kaffevm/jit/icode.c Sun Aug 22 13:31:30 2004 @@ -33,6 +33,7 @@ #include "locks.h" #include "machine.h" #include "codeproto.h" +#include "fp.h" #if defined(WORDS_BIGENDIAN) #define LSLOT(_s) ((_s)+1) @@ -468,6 +469,26 @@ } void +move_float_const_bits(SlotInfo* dst, int val) +{ + constpool *c; + label* l; + SlotInfo* tmp; + + c = newConstant(CPint, val); + l = newLabel(); + l->type = Lconstant; + l->at = 0; + l->to = (uintp)c; + l->from = 0; + + slot_alloctmp(tmp); + move_label_const(tmp, l); + load_float(dst, tmp); + slot_freetmp(tmp); +} + +void move_float_const(SlotInfo* dst, float val) { #if defined(HAVE_move_float_const) @@ -1157,14 +1178,15 @@ #endif } -#if defined(HAVE_and_long_const) void and_long_const(SlotInfo* dst, SlotInfo* src, jlong val) { +#if defined(HAVE_and_long_const) if (HAVE_and_long_const_rangecheck(val)) { lslot_lslot_lconst(dst, src, val, HAVE_and_long_const, Tcomplex); } else +#endif { SlotInfo* tmp; slot_alloctmp(tmp); @@ -1173,7 +1195,6 @@ slot_freetmp(tmp); } } -#endif void or_int_const(SlotInfo* dst, SlotInfo* src, jint val) @@ -2791,7 +2812,7 @@ } else { assert(labtab[n]->type == Lnull); - labtab[n]->type = Linternal; + labtab[n]->type = Linternal | (labtab[n]->type & ~Ltomask); slot_slot_const(0, 0, (jword)labtab[n], HAVE_set_label, Tnull); labtab[n] = 0; } @@ -3049,6 +3070,36 @@ used_ieee_rounding = true; #if defined(HAVE_cvt_float_int) slot_slot_slot(dst, 0, src, HAVE_cvt_float_int, Tcomplex); +#elif defined(HAVE_cvt_float_int_ieee) + { + SlotInfo *tmp; + + slot_alloctmp(tmp); + + end_sub_block(); + and_int_const(tmp, src, FEXPMASK); + cbranch_int_const_ne(tmp, FEXPMASK, reference_label(1, 1)); + + and_int_const(tmp, src, FMANMASK); + cbranch_int_const_eq(tmp, 0, reference_label(1, 2)); + + start_sub_block(); + move_int_const(dst, 0); + end_sub_block(); + branch_a(reference_label(1, 3)); + + set_label(1, 1); + set_label(1, 2); + start_sub_block(); + slot_slot_lslot(dst, 0, src, HAVE_cvt_float_int_ieee, Tcomplex); + end_sub_block(); + + set_label(1, 3); + + start_sub_block(); + + slot_freetmp(tmp); + } #else end_sub_block(); pusharg_float(src, 0); @@ -3096,6 +3147,39 @@ used_ieee_rounding = true; #if defined(HAVE_cvt_double_int) slot_slot_lslot(dst, 0, src, HAVE_cvt_double_int, Tcomplex); +#elif defined(HAVE_cvt_double_int_ieee) + { + SlotInfo *tmp; + int i; + + end_sub_block(); + slot_alloc2tmp(tmp); + + and_long_const(tmp, src, DEXPMASK); + cbranch_int_const_ne(LSLOT(tmp), (jint)(DEXPMASK & 0xffffffff), reference_label(1, 1)); + cbranch_int_const_ne(HSLOT(tmp), (jint)((DEXPMASK >> 32) & 0xffffffff), reference_label(1, 2)); + + and_long_const(tmp, src, DMANMASK); + cbranch_int_const_ne(LSLOT(tmp), 0, reference_label(1, 3)); + cbranch_int_const_eq(HSLOT(tmp), 0, reference_label(1, 4)); + + set_label(1, 3); + start_sub_block(); + move_int_const(dst, 0); + end_sub_block(); + branch_a(reference_label(1, 5)); + + set_label(1, 4); + set_label(1, 1); + set_label(1, 2); + start_sub_block(); + slot_slot_lslot(dst, 0, src, HAVE_cvt_double_int_ieee, Tcomplex); + end_sub_block(); + + set_label(1, 5); + slot_free2tmp(tmp); + start_sub_block(); + } #else end_sub_block(); pusharg_double(src, 0); Index: kaffe/test/internal/TypeConversion.java diff -u kaffe/test/internal/TypeConversion.java:1.1 kaffe/test/internal/TypeConversion.java:1.2 --- kaffe/test/internal/TypeConversion.java:1.1 Fri Apr 25 21:35:34 2003 +++ kaffe/test/internal/TypeConversion.java Sun Aug 22 13:31:29 2004 @@ -14,6 +14,22 @@ { return (int)a; } + + public static final int test__float_nan_to_int = 0; + public static float mynanf = Float.NaN; + + public static int float_nan_to_int() + { + return (int)mynanf; + } + + public static final int test__double_nan_to_int = 0; + public static double mynand = Double.NaN; + + public static int double_nan_to_int() + { + return (int)mynand; + } public static final float test_1__int_to_float = 1.0F; public static final float test_255__int_to_float = 255.0F; Index: kaffe/test/internal/jitBasic.c diff -u kaffe/test/internal/jitBasic.c:1.3 kaffe/test/internal/jitBasic.c:1.4 --- kaffe/test/internal/jitBasic.c:1.3 Mon Jul 19 13:19:07 2004 +++ kaffe/test/internal/jitBasic.c Sun Aug 22 13:31:29 2004 @@ -222,11 +222,26 @@ for( lpc = 0; (lpc < CLASS_NSFIELDS(cl)) && retval; lpc++ ) { Field *field; + uint32 expected_value; field = &CLASS_SFIELDS(cl)[lpc]; - kaffe_dprintf(" field: %s = 0x%08x\n", - field->name->data, - ((int *)field->info.addr)[0]); + + switch (field->bsize) { + case 1: + expected_value = ((uint8 *)field->info.addr)[0]; + break; + case 2: + expected_value = ((uint16 *)field->info.addr)[0]; + break; + case 4: + expected_value = ((uint32 *)field->info.addr)[0]; + break; + default: + expected_value = 0; + } + kaffe_dprintf(" field: %s = 0x%08x\n", + field->name->data, + expected_value); if( !strncmp("test_", field->name->data, 5) ) { retval = testMethod(cl, field); _______________________________________________ kaffe mailing list [EMAIL PROTECTED] http://kaffe.org/cgi-bin/mailman/listinfo/kaffe