This is the mail archive of the
kawa@sourceware.cygnus.com
mailing list for the Kawa project.
Bug for invoking interfaces in CodeAttr
- To: "Kawa" <kawa at sourceware dot cygnus dot com>
- Subject: Bug for invoking interfaces in CodeAttr
- From: "Daniel Bonniot" <bonniot at cma dot ensmp dot fr>
- Date: Mon, 21 Feb 2000 16:12:42 +0100
- Organization: d.bonniot@mail.dotcom.fr
For a change, this patch does not seems too controversial to me... ;)
When doing an invokeinterface, one has to give has a parameter the number of
words taken in the stack by the arguments. CodeAttr used to put the number
of arguments (counting this), which was not valid for, say, 'long'
arguments.
I also corrected two error messages that use the old, deprecated "compile_*"
form instead of the new "emit*".
Here is the patch:
RCS file: /cvs/kawa/kawa/gnu/bytecode/CodeAttr.java,v
retrieving revision 1.37
diff -u -r1.37 CodeAttr.java
--- CodeAttr.java 2000/02/02 06:23:00 1.37
+++ CodeAttr.java 2000/02/21 15:03:59
@@ -919,6 +919,18 @@
emitFieldop(field, 181); // putfield
}
+ /** Comptes the number of stack words taken by a list of types. */
+ private int words(Type[] types)
+ {
+ int res = 0;
+ for (int i=types.length; --i >= 0; )
+ if (types[i].size > 4)
+ res+=2;
+ else
+ res++;
+ return res;
+ }
+
public void emitInvokeMethod (Method method, int opcode)
{
reserve(opcode == 185 ? 5 : 3);
@@ -933,7 +945,7 @@
putIndex2(getConstants().addMethodRef(method));
if (opcode == 185) // invokeinterface
{
{
- put1(arg_count);
+ put1(words(method.arg_types)+1); // 1 word for 'this'
put1(0);
}
while (--arg_count >= 0)
@@ -1052,7 +1064,7 @@
&& (sig2 == 'L' || sig2 == '['))
opcode = 165; // if_acmpeq (inverted: if_acmpne)
else
- throw new Error ("non-matching types to compile_goto_ifeq");
+ throw new Error ("non-matching types to emitGotoIfEq");
if (invert)
opcode++;
emitTransfer (label, opcode);
@@ -1400,7 +1412,7 @@
}
}
if (op < 0)
- throw new Error ("unsupported Method.compile_convert");
+ throw new Error ("unsupported CodeAttr.emitConvert");
reserve(1);
popType();
put1(op);