[kaffe] Simple program shows strange results

Timothy Stack stack at cs.utah.edu
Fri Mar 14 08:42:01 PST 2003


hi,

> In message "Re: [kaffe] Simple program shows strange results"
>     on 03/03/05, Ito Kazumitsu <kaz at maczuka.gcd.org> writes:
> 
> > I have made a simpler test program:
> 
> This strange problem occurs with float and double, but not
> with int or byte.
> 
> $ cat Test.java.m4
> public class Test {
>   public static void main(String[] args) {
>       T x = C1;
>       if (x < C2) {
>         System.err.println("x<C2: " + x);
>         x = C2;
>       }
>       System.err.println(x);
>   }
> }

CVS update and try this again.  (Thanks for the test case!)

If you're interested, the causes were:

	I modified move_float() in icode.c to look like 
	move_int/move_ref/etc since it was generating inefficient code on 
	the PowerPC.

	Unfortunately, the x86 jitter depended on the way the old
	move_float() worked, so it was not working properly when a slot
	was aliased.  For example, in the following bytecode:

		ldc 10.0
		fstore_1
		fload_1

	Kaffe optimizes away the store and subsequent load since it is 
	potentially redundant.  Unfortunately, because of the bizarro way 
	the x86 FPU works, this does not work and the 10.0 value never 
	gets written to the proper place on the stack.  Therefore, the 
	floating point number that gets printed is just whatever garbage 
	is on the stack at the time.

Solution:

	Modify slotAlias() in machine.c to aggressively spill Rreadonce 
	registers (the x86 float register).  This method works and seems 
	to generate the same code  as before on x86 (as far as I know), 
	without screwing over CPUs with more sensible FPUs.

thanks,

tim stack




More information about the kaffe mailing list