static method in m68k jit compiler

Kiyo Inaba inaba at src.ricoh.co.jp
Thu Aug 13 09:46:25 PDT 1998


I'm now trying to make jit compiler for m68k back on the earth.

One problem I have right now is the mismatch of argument positions
between non static methods and static methods.

By using following calling sequence, let me try to describe.

	java/io/PrintWriter.<clinit>()V:
	+->java/lang/System.getProperty(Ljava/lang/String;)Ljava/lang/String;:
	   +->java/lang/System.getProperty(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;:
	      +->java/util/Properties.getProperty(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;:
		 +->java/util/Properties.getProperty(Ljava/lang/String;)Ljava/lang/String;:

The head of "java/io/PrintWriter.<clinit>()V:" is,
	0 ldc #30 <String "line.separator">
	2 invokestatic #31 <Method java.lang.String getProperty(java.lang.String)>
and, compiled one is
	0x3607d8:       linkw %fp,#-64
	0x3607dc:       moveal #3736280,%a0     jlString(3736280) = "line.separator"
	0x3607e2:       movel %a0,%sp at -
	0x3607e4:       moveal #698592,%a1      *698592 = 0x2e2ce0
	0x3607ea:       moveal %a1@,%a1
	0x3607ec:       jsr %a1@
	0x3607ee:       addql #4,%sp

Fine, it pushes string on the stack and jumps to the subroutine.

And, the head of "java/lang/System.getProperty(Ljava/lang/String;)Ljava/lang/String;:" is,
	0 aload_0
	1 aconst_null
	2 invokestatic #8 <Method java.lang.String getProperty(java.lang.String, java.lang.String)>
and, compiled one is
	0x2e2ce0:       linkw %fp,#-68
	0x2e2ce4:       moveal %fp@(12),%a0
	0x2e2ce8:       moveal %a0,%a1
	0x2e2cea:       moveal #0,%a2
	0x2e2cf0:       movel %a2,%sp at -
	0x2e2cf2:       movel %a1,%sp at -
	0x2e2cf4:       moveal #698638,%a3
	0x2e2cfa:       moveal %a3@,%a3
	0x2e2cfc:       jsr %a3@
	0x2e2cfe:       addql #8,%sp

Again, it looks fine...

But, actually, the "%fp@(12)" is incorrect. It should be "%fp@(8)" for
the first argument in the stack.

The head of "java/util/Properties.getProperty(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;:"
	0 aload_0
	1 aload_1
	2 invokevirtual #16 <Method java.lang.Object get(java.lang.Object)>
and its counterpart
	0x394130:       linkw %fp,#-72
	0x394134:       moveal %fp@(8),%a0
	0x394138:       moveal %a0,%a1
	0x39413a:       moveal %fp@(12),%a2
	0x39413e:       moveal %a2,%a3
	0x394140:       moveal %a1@,%a4
	0x394142:       moveal %a4@(108),%a5
	0x394146:       movel %a3,%sp at -
	0x394148:       movel %a1,%sp at -
	0x39414a:       movel %a4,%fp@(-56)
	0x39414e:       jsr %a5@
	0x394150:       addql #8,%sp
shows you such argument mismatch does not happen for non static method.

So, there should be two possibilities to fix this problem.
	1) fix caller side to add 1 word extra to be pushed.
		or
	2) fix callee side to adjust offset.

But before digging into this problem, I'd like to get some suggestions.

Kiyo


More information about the kaffe mailing list