Bug in Jitter

Alexandre Oliva kaffe@rufus.w3.org
08 Jul 1998 00:31:37 -0300


--Multipart_Wed_Jul__8_00:31:37_1998-1
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Godmar Back <gback@cs.utah.edu> writes:

>  I bet you wrote this off the top of your head or with a non-current
> version in mind.

Ok, I confess :-)

> Also, sync_register doesn't reset the modified flags.

I thought it did.  At least, it should; I can't find any reason for it =

not to do it.

> I think what we want is prepare_function_call() (maybe minus the part =

> where temps are spilled?).

I thought it would invalidate all registers, but now I see it doesn't.
It's good to know, now I may get some performance improvements in
Guaran=E1 <URL:http://www.dcc.unicamp.br/~oliva/guarana>

> With all that said:  I tried it, and I believe your idea works.

Cool!

> Could you elaborate some more on that patch for the x86 you're mentione=
d?

The problem is that, when a x86 float register is read from, it's
removed from the arithmetic processor stack, so any computation that
depends on it still being on the stack breaks.  When I found the
problem, I was using sync_registers(), and it would not mark the
register as clean, so it would be spilled twice.  However, even if
this were not the case, if the value of the register were read after
the first spill, an invalid value would be read, because the expected
value would have been popped from the stack already.

I'm not sure this still applies (i.e., if you mark the register as not =

modified), but the patch is attached anyway.

-- =

Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil

--Multipart_Wed_Jul__8_00:31:37_1998-1
Content-Type: application/octet-stream; type=patch
Content-Disposition: attachment; filename="i386jit.diff"
Content-Transfer-Encoding: 7bit

Index: config/i386/jit-i386.def
===================================================================
RCS file: /home/msc/oliva/src/.cvs/kaffe/config/i386/jit-i386.def,v
retrieving revision 1.1.1.8
retrieving revision 1.3
diff -u -p -r1.1.1.8 -r1.3
--- config/i386/jit-i386.def	1998/06/30 06:26:27	1.1.1.8
+++ jit-i386.def	1998/06/30 06:53:32	1.3
@@ -262,6 +262,12 @@ define_insn(spill_float, fspill_Rxx)
 	OUT = 0x98|REG_ebp;
 	LOUT = o;
 
+	if (reginfo[r].slot != NOSLOT) {
+		reginfo[r].slot->modified = 0;
+		slot_invalidate(reginfo[r].slot);
+	}
+	register_invalidate(r);
+
 	debug(("fstp %d(ebp)\n", o));
 }
 
@@ -274,6 +280,13 @@ define_insn(spill_double, fspilll_Rxx)
 	OUT = 0x98|REG_ebp;
 	LOUT = o;
 
+	if (reginfo[r].slot != NOSLOT) {
+		reginfo[r].slot->modified = 0;
+		slot_invalidate(reginfo[r].slot);
+		slot_invalidate(&reginfo[r].slot[1]);
+	}
+	register_invalidate(r);
+
 	debug(("fstpl %d(ebp)\n", o));
 }
 
@@ -846,6 +859,13 @@ define_insn(store_float, fstore_RxR)
 	OUT = 0xD9;
 	OUT = 0x18|w;
 
+	if (reginfo[r].slot != NOSLOT) {
+		reginfo[r].slot->modified = 0;
+		slot_invalidate(reginfo[r].slot);
+		slot_invalidate(&reginfo[r].slot[1]);
+	}
+	register_invalidate(r);
+
 	debug(("fstp (%s)\n", regname(w)));
 }
 
@@ -856,8 +876,14 @@ define_insn(store_double, fstorel_RxR)
 
 	OUT = 0xDD;
 	OUT = 0x18|w;
+
+	if (reginfo[r].slot != NOSLOT) {
+		reginfo[r].slot->modified = 0;
+		slot_invalidate(reginfo[r].slot);
+	}
+	register_invalidate(r);
 
-	debug(("fstlp (%s)\n", regname(w)));
+	debug(("fstpl (%s)\n", regname(w)));
 }
 
 /* --------------------------------------------------------------------- */

--Multipart_Wed_Jul__8_00:31:37_1998-1--