FIXED: Static initializers bug in both 0.9.2 and 0.10.0 on i386

Robert Zawiasa bozo at bibl.u-szeged.hu
Mon Apr 6 02:34:22 PDT 1998


Hello,

Laurent Bossavit (morendil at micronet.fr) wrote:

> One of my classes has a static initializer that attempts to create a 
                          ^^^^^^^^^^^^^^^^^^
> BigInteger; that code is protected by a try/catch block, which 
                                          ^^^^^^^^^^^^^^^
> catches Throwable, so that if loadLibrary("math") fails with an 
> UnsatisfiedLinkError I fall back on a pure-Java implementation.
>
> The problem in Kaffe 0.9.2 is that apparently the catch block is not 
> executed; instead, the class construction appears to fail, and 
> further references to the class - in my instance, calling a static 
> method of the class - fail with a NullPointerException.
                                    ^^^^^^^^^^^^^^^^^^^^


the bug was lurking in the exception prologue (catch) code generated by the 
i386 jit (restoring the stack pointer incorrectly). Here is the quick hack
for 0.10.0 config/i386/jit-i386.def:

----------------------------------------------------------------------
--- jit-i386.def~       Mon Mar 30 20:59:50 1998
+++ jit-i386.def        Mon Apr  6 11:15:22 1998
@@ -164,16 +164,21 @@
	l->at = (uintp)CODEPC;
	LOUT = 0;

+	OUT = 0x81;
+	OUT = 0xE8|REG_esp;
+	LOUT = 3*SLOTSIZE;
+
	if (used_ieee_division == true && 0) {
		OUT = 0x81;
		OUT = 0xE8|REG_esp;
-		LOUT = SLOTSIZE;
+		LOUT = 2*SLOTSIZE;
	}

	debug(("movl ebp,esp\n"));
	debug(("subl #?,esp\n"));
+	debug(("subl #%d,esp\n", 3*SLOTSIZE));
	if (used_ieee_division == true && 0) {
-		debug(("subl #%d,esp\n", SLOTSIZE));
+		debug(("subl #%d,esp\n", 2*SLOTSIZE));
	}

	/* If this method uses IEEE, set up the mode here */
----------------------------------------------------------------------

Up for adventures!

Robert



More information about the kaffe mailing list