Thread: [Sablevm-developer] problem with divisions, float, double
Brought to you by:
egagnon
From: Fabien R. <re...@ne...> - 2004-05-13 07:27:01
|
Hello, With Arith.java I have some problem with numbers : [verbose class: loading "Arith"] iadd [verbose class: loading "java/lang/Integer"] [verbose class: loading "java/lang/Number"] = 4 isub = 2 imul = 3 idiv = 3 irem = 0 ineg = -3 ladd [verbose class: loading "java/lang/Long"] = 4 lsub = 2 lmul = 3 ldiv = 3 lrem = 0 lneg = -3 fadd [verbose class: loading "java/lang/Float"] [verbose class: loading "java/lang/Double"] = 3.0 fsub = 3.0 fmul = 0.0 fdiv [verbose gc: previously allocated 16777180 bytes, surviving 56040 bytes, new heap is 16777216 bytes, gc time = 0 sec 9971 usec] [verbose gc: previously allocated 16777208 bytes, surviving 55972 bytes, new heap is 16777216 bytes, gc time = 0 sec 8790 usec] [verbose gc: previously allocated 16777192 bytes, surviving 55980 bytes, new heap is 16777216 bytes, gc time = 0 sec 9381 usec] Kaffe too has problems (crashs when there is a double) This is the source : public class Arith { static int add(int a, int b) { return a + b; } static int sub(int a, int b) { return a - b; } static int mul(int a, int b) { return a * b; } static int div(int a, int b) { return a / b; } static int rem(int a, int b) { return a % b; } static int neg(int a) { return -a; } static long add(long a, long b) { return a + b; } static long sub(long a, long b) { return a - b; } static long mul(long a, long b) { return a * b; } static long div(long a, long b) { return a / b; } static long rem(long a, long b) { return a % b; } static long neg(long a) { return -a; } static float add(float a, float b) { return a + b; } static float sub(float a, float b) { return a - b; } static float mul(float a, float b) { return a * b; } static float div(float a, float b) { return a / b; } static float rem(float a, float b) { return a % b; } static float neg(float a) { return -a; } static double add(double a, double b) { return a + b; } static double sub(double a, double b) { return a - b; } static double mul(double a, double b) { return a * b; } static double div(double a, double b) { return a / b; } static double rem(double a, double b) { return a % b; } static double neg(double a) { return -a; } public static void main (String[] args) { test_int (3, 1); test_long (3, 1); test_float (3, 0); test_double (3, 0); System.out.println("Done!"); } static void test_int(int a, int b) { char prefix = 'i'; System.out.println(prefix + "add"); System.out.println("\t= " + add(a,b)); System.out.println(prefix + "sub"); System.out.println("\t= " + sub(a,b)); System.out.println(prefix + "mul"); System.out.println("\t= " + mul(a,b)); System.out.println(prefix + "div"); System.out.println("\t= " + div(a,b)); System.out.println(prefix + "rem"); System.out.println("\t= " + rem(a,b)); System.out.println(prefix + "neg"); System.out.println("\t= " + neg(a)); } static void test_long(long a, long b) { char prefix = 'l'; System.out.println(prefix + "add"); System.out.println("\t= " + add(a,b)); System.out.println(prefix + "sub"); System.out.println("\t= " + sub(a,b)); System.out.println(prefix + "mul"); System.out.println("\t= " + mul(a,b)); System.out.println(prefix + "div"); System.out.println("\t= " + div(a,b)); System.out.println(prefix + "rem"); System.out.println("\t= " + rem(a,b)); System.out.println(prefix + "neg"); System.out.println("\t= " + neg(a)); } static void test_float(float a, float b) { char prefix = 'f'; System.out.println(prefix + "add"); System.out.println("\t= " + add(a,b)); System.out.println(prefix + "sub"); System.out.println("\t= " + sub(a,b)); System.out.println(prefix + "mul"); System.out.println("\t= " + mul(a,b)); System.out.println(prefix + "div"); System.out.println("\t= " + div(a,b)); System.out.println(prefix + "rem"); System.out.println("\t= " + rem(a,b)); System.out.println(prefix + "neg"); System.out.println("\t= " + neg(a)); } static void test_double(double a, double b) { char prefix = 'd'; System.out.println(prefix + "add"); System.out.println("\t= " + add(a,b)); System.out.println(prefix + "sub"); System.out.println("\t= " + sub(a,b)); System.out.println(prefix + "mul"); System.out.println("\t= " + mul(a,b)); System.out.println(prefix + "div"); System.out.println("\t= " + div(a,b)); System.out.println(prefix + "rem"); System.out.println("\t= " + rem(a,b)); System.out.println(prefix + "neg"); System.out.println("\t= " + neg(a)); } } If someone has an idea ... Cheers, Fabien |
From: Chris P. <chr...@ma...> - 2004-05-13 11:24:20
Attachments:
Arith.java
|
Hi Fabien, We're able to help you much better if you include any details that might possibly be relevant. It's also helpful if you provide minimal test cases (i.e. remove all the working stuff from a test case). I take it that divide-by-zero is meant to print out "Infinity" for floating point numbers, but that sablevm hangs. Did you try it with the --with-threading=switch and --enable-debugging-features options passed to configure? Or just the default (which would be the inlined-engine with signalling for exceptions)? What architectures did you try it on? Does it work with Sun's java? The attached Arith.java works for me on x86 with inlined and switch-debug engines. Cheers, Chris |
From: Fabien R. <re...@ne...> - 2004-05-13 11:42:44
|
I use --with-thread=direct on ARM and that doesn´t wotk. On my x86, that works with default options. I´ll try with --enable-debugging-features. Cheers, Fabien Chris Pickett wrote: > Hi Fabien, > > We're able to help you much better if you include any details that > might possibly be relevant. It's also helpful if you provide minimal > test cases (i.e. remove all the working stuff from a test case). I > take it that divide-by-zero is meant to print out "Infinity" for > floating point numbers, but that sablevm hangs. > > Did you try it with the --with-threading=switch and > --enable-debugging-features options passed to configure? Or just the > default (which would be the inlined-engine with signalling for > exceptions)? > > What architectures did you try it on? > > Does it work with Sun's java? > > The attached Arith.java works for me on x86 with inlined and > switch-debug engines. > > Cheers, > Chris > >------------------------------------------------------------------------ > >public class Arith >{ > public static void main(String[] args) > { > float a = 3; > float b = 0; > System.out.println(a / b); > } >} > > |
From: Grzegorz B. P. <ga...@de...> - 2004-05-13 18:19:34
|
On (13/05/04 13:42), Fabien Renaud wrote: > I use --with-thread=direct on ARM and that doesn?t wotk. On my x86, that > works with default options. > I?ll try with --enable-debugging-features. This will not help. ARM is the last architecture that needs ironing out of these arithmetic CPU-specific quirks. Basically ARM doesn't catch any special cases, so you have to check for them yourself, by hand. The practical problem here is that all Debian ARM machines are unaccessible since some weeks, so I don't have access to a system where I could finish the port. I tried iPAQ cluster at handhelds.org, but software there is much too old and installing newer versions of a dozen of tools in home directory would be a lot of work. So, if you knew of an up-to-date ARM system where I could get an account - let me know. You could also try to fix it yourself. Compile SableVM in testing mode by passing --enable-inlinability-testing [*] to ./configure and run BTF tests ex. from http://devel.sablevm.org/arm/btf.tgz ('sablevm -Y BytecodeVerificationTest') and then look into instructions.m4.c to fix the instructions that give us problems on ARM. It's not terribly complicated but it practically impossible to do it w/o access to hardware (unless you want to spend time reading StrongARM specs to find out which cases you have to catch yourself). I wish I could help you more, Grzegorz B. Prokopski [*] This is not ideal, as this testing mode was designed to help porting *inlined engine* and not to track portability issues like arithmetic problems. It is a side effect, but this will help, becaue it'll catch pretty much all unexpected signals and will try to recover from them - thus allowing the tests to run further. The only problem would be that you'd have mixed "inlining failures" with "bytecode implementation failures". PS: Regardless of the impression you can get from the above description, finishing ARM port is *not* a problem per se. Given proper access to hardware, this should be an hour or a few hours at most of not very challenging work. -- Grzegorz B. Prokopski <ga...@de...> Debian GNU/Linux http://www.debian.org SableVM - LGPLed JVM http://www.sablevm.org Why SableVM ?!? http://devel.sablevm.org/wiki/WhySableVM |
From: Grzegorz B. P. <ga...@de...> - 2004-05-13 19:59:26
Attachments:
arm-btf-results.txt
|
Hi again, Small update. With help from our Debian Project Leader, Martin Michlmayr I got the output of running BTF on an ARM machine (attached). It looks like all DADD, DDIV, DMUL, DREM, operations involving NaN or Infinity return wrong results. At the end we also see that an integer operation causes CPU to generate signal which should not be there... I did some tests running "equivalent" C code on ARM machnes from handhelds.org's iPAQ cluster, but everything seems to work just fine, so I have no clue yet as to what exactly is the problem. You might want to look at instructions.m4.c and instrucions*.c files generated for it for the engine you're using (switch/direct/inlined). After all it's just a plain C code so it shouldn't be anything magical to just get it to work. Ex. you can easily take gdb/ddd and put a breakpoint on DADD and see what exactly it exectues. You want to configure --enable-debugging-features to change optimiation level from -O2 to -O0, which will make debugging much easier. Let me know if you have questions, HTH Grzegorz B. Prokopski -- Grzegorz B. Prokopski <ga...@de...> Debian GNU/Linux http://www.debian.org SableVM - LGPLed JVM http://www.sablevm.org Why SableVM ?!? http://devel.sablevm.org/wiki/WhySableVM |