? pinaki_patch Index: machine.c =================================================================== RCS file: /cvs/kaffe/kaffe/kaffe/kaffevm/intrp/machine.c,v retrieving revision 1.42 diff -u -r1.42 machine.c --- machine.c 5 Apr 2004 17:43:39 -0000 1.42 +++ machine.c 24 Aug 2004 15:14:44 -0000 @@ -132,13 +132,22 @@ /* If this is native, then call the real function */ methaccflags = meth->accflags; if (methaccflags & ACC_NATIVE) { + int nargs = (methaccflags & ACC_STATIC) ? METHOD_NARGS(meth) : (METHOD_NARGS(meth)+1); + jvalue *arguments = (jvalue *)alloca(sizeof(jvalue)*nargs); + int i; + jvalue ret; + + for (i = 0; i < nargs; i++) + memcpy(&arguments[i], &arg[i].v, sizeof(jvalue)); + NDBG( dprintf("Call to native %s.%s%s.\n", meth->class->name->data, meth->name->data, METHOD_SIGD(meth)); ) if (methaccflags & ACC_STATIC) { - callMethodA(meth, meth, 0, (jvalue*)arg, (jvalue*)retval, 1); + callMethodA(meth, meth, 0, arguments, &ret, 1); } else { - callMethodA(meth, meth, ((jvalue*)arg)[0].l, &((jvalue*)arg)[1], (jvalue*)retval, 1); + callMethodA(meth, meth, arguments[0].l, &(arguments)[1], &ret, 1); } + memcpy(&retval->v, &ret, sizeof(jvalue)); return; } Index: methodcalls.c =================================================================== RCS file: /cvs/kaffe/kaffe/kaffe/kaffevm/intrp/methodcalls.c,v retrieving revision 1.1 diff -u -r1.1 methodcalls.c --- methodcalls.c 19 Aug 2004 19:29:03 -0000 1.1 +++ methodcalls.c 24 Aug 2004 15:14:45 -0000 @@ -31,7 +31,17 @@ Method *meth = (Method *)call->function; if ((meth->accflags & ACC_NATIVE) == 0) { - virtualMachine(meth, (slots*)(call->args+2), (slots*)call->ret, THREAD_DATA()); + slots *sl = (slots *) alloca(sizeof(slots)*(call->nrargs-2)); + slots ret; + int i; + + for (i = 0; i < call->nrargs-2; i++) + memcpy(&sl[i].v, &call->args[2+i], sizeof(jvalue)); + + virtualMachine(meth, sl, &ret, THREAD_DATA()); + + if (call->retsize > 0) + memcpy(call->ret, &ret.v, sizeof(jvalue)); } else { Hjava_lang_Object* syncobj = 0; Index: slots.h =================================================================== RCS file: /cvs/kaffe/kaffe/kaffe/kaffevm/intrp/slots.h,v retrieving revision 1.3 diff -u -r1.3 slots.h --- slots.h 30 May 2002 22:47:33 -0000 1.3 +++ slots.h 24 Aug 2004 15:14:45 -0000 @@ -44,6 +44,7 @@ /* NB. This should match jvalue and eventually be replaced by it */ typedef struct _slots { + int size[2]; union { jint tint; jword tword;