* src/vm/vm.c (vm/vm.h): Added.
(vm_call_method_intern): New function.
(vm_call_method_intern_int): Likewise.
(vm_call_method): Likewise.
(vm_call_method_int): Likewise.
(vm_call_method_long): Likewise.
(vm_call_method_float): Likewise.
(vm_call_method_double): Likewise.
* src/vm/vm.h (vm_arg): Structure added.
(vm_call_method_intern): New function.
(vm_call_method_intern_int): Likewise.
(vm_call_method): Likewise.
(vm_call_method_int): Likewise.
(vm_call_method_long): Likewise.
(vm_call_method_float): Likewise.
(vm_call_method_double): Likewise.
* src/vm/jit/tools/genoffsets.c (vm/vm.h): Added.
(sizejniblock): Renamed to sizevmarg.
(offjniitemtype): Renamed to offvmargtype.
(offjniitem): Renamed to offvmargdata.
* src/vm/jit/x86_64/asmpart.S (asm_calljavafunction2): Pointer to
vm_arg block is now in a2. Use new defines.
* src/vm/jit/stacktrace.c (vm/vm.h): Added.
(ASM_CALLJAVAFUNCTION): Replaced with vm_call_method_intern.
* src/vm/exceptions.c: Likewise.
* src/vm/properties.c: Likewise.
* src/vm/loader.c: Likewise.
* src/vm/finalizer.c: Likewise.
* src/vm/initialize.c: Likewise.
* src/cacao/cacao.c: Likewise.
* src/native/vm/VMClassLoader.c: Likewise.
* src/threads/native/threads.c: Likewise.
* src/cacaoh/headers.c (asm_calljavafunction): Removed.
(intrp_asm_calljavafunction): Likewise.
(vm_call_method_intern): New function.
* src/native/jni.c (fill_callblock_from_vargs): Renamed to
_Jv_jni_vmargs_from_vargs.
(fill_callblock_from_objectarray): Renamed to
_Jv_jni_vmargs_from_objectarray.
(_Jv_jni_vmargs_from_objectarray): New function.
(_Jv_jni_CallVoidMethodA): Likewise.
(ASM_CALLJAVAFUNCTION2): Replaced with appropriate vm_call_method
function.
(NewObjectA): Implemented.
(CallVoidMethodA): Likewise.
(CallNonvirtualVoidMethodA): Likewise.
(CallStaticVoidMethodA): Likewise.
Philipp Tomsich
Christian Thalinger
- $Id: cacao.c 4542 2006-02-21 13:39:51Z twisti $
+ $Id: cacao.c 4552 2006-03-04 17:15:44Z twisti $
*/
if (!m)
throw_main_exception_exit();
- ASM_CALLJAVAFUNCTION(m, o, NULL, NULL, NULL);
+ (void) vm_call_method_intern(m, o, NULL, NULL, NULL);
/* configure(transport,NULL) */
m = class_resolveclassmethod(
s = javastring_new_char(transport);
- ASM_CALLJAVAFUNCTION(m, o, s, NULL, NULL);
+ (void) vm_call_method_intern(m, o, s, NULL, NULL);
if (!m)
throw_main_exception_exit();
if (!m)
throw_main_exception_exit();
- ASM_CALLJAVAFUNCTION(m, o, NULL, NULL, NULL);
+ (void) vm_call_method_intern(m, o, NULL, NULL, NULL);
}
#endif
s = javastring_new_char(mainstring);
- ASM_CALLJAVAFUNCTION(m, o, s, NULL, NULL);
+ (void) vm_call_method_intern(m, o, s, NULL, NULL);
if (*exceptionptr)
throw_main_exception_exit();
if (!m)
throw_main_exception_exit();
- ASM_CALLJAVAFUNCTION_ADR(o, m, o, NULL, NULL, NULL);
+ o = vm_call_method_intern(m, o, NULL, NULL, NULL);
if (o == NULL) {
fprintf(stderr, "Could not get manifest from %s (invalid or corrupt jarfile?)\n", mainstring);
if (!m)
throw_main_exception_exit();
- ASM_CALLJAVAFUNCTION_ADR(o, m, o, NULL, NULL, NULL);
+ o = vm_call_method_intern(m, o, NULL, NULL, NULL);
if (o == NULL) {
fprintf(stderr, "Could not get main attributes from %s (invalid or corrupt jarfile?)\n", mainstring);
s = javastring_new_char("Main-Class");
- ASM_CALLJAVAFUNCTION_ADR(o, m, o, s, NULL, NULL);
+ o = vm_call_method_intern(m, o, s, NULL, NULL);
if (!o)
throw_main_exception_exit();
&jvmti_jdwp_EventCallbacks,
sizeof(jvmti_jdwp_EventCallbacks))){
log_text("unable to setup event callbacks");
- cacao_exit(1);
+ vm_exit(1);
}
/* setup listening process (JDWP) */
#endif
/* here we go... */
- ASM_CALLJAVAFUNCTION(m, oa, NULL, NULL, NULL);
+ (void) vm_call_method_intern(m, oa, NULL, NULL, NULL);
/* exception occurred? */
Philipp Tomsich
Christian Thalinger
- $Id: headers.c 4433 2006-02-04 20:15:23Z twisti $
+ $Id: headers.c 4552 2006-03-04 17:15:44Z twisti $
*/
java_objectheader *native_new_and_init_throwable(classinfo *c, java_lang_Throwable *t) { return NULL; }
-#if defined(ENABLE_JIT)
-java_objectheader *asm_calljavafunction(methodinfo *m,
- void *arg1, void *arg2,
- void *arg3, void *arg4)
-{ return NULL; }
-#endif
-
-#if defined(ENABLE_INTRP)
-java_objectheader *intrp_asm_calljavafunction(methodinfo *m,
- void *arg1, void *arg2,
- void *arg3, void *arg4)
+java_objectheader *vm_call_method_intern(methodinfo *m, void *a0, void *a1,
+ void *a2, void *a3)
{ return NULL; }
-#endif
/* code patching functions */
Christian Thalinger
Edwin Steiner
- $Id: jni.c 4530 2006-02-21 09:11:53Z twisti $
+ $Id: jni.c 4552 2006-03-04 17:15:44Z twisti $
*/
void *ptr_env = (void*) &JNI_JNIEnvTable;
-#define PTR_TO_ITEM(ptr) ((u8)(size_t)(ptr))
-
/* global variables ***********************************************************/
/* global reference table *****************************************************/
}
-static void fill_callblock_from_vargs(void *obj, methoddesc *descr,
- jni_callblock blk[], va_list data,
- s4 rettype)
+/* _Jv_jni_fill_vmargs_from_vargs **********************************************
+
+ XXX
+
+*******************************************************************************/
+
+static void _Jv_jni_vmargs_from_vargs(java_objectheader *o, methoddesc *descr,
+ vm_arg *vmargs, va_list ap)
{
typedesc *paramtypes;
s4 i;
i = 0;
- if (obj != NULL) {
+ if (o != NULL) {
/* the `this' pointer */
- blk[0].itemtype = TYPE_ADR;
- blk[0].item = PTR_TO_ITEM(obj);
+ vmargs[0].type = TYPE_ADR;
+ vmargs[0].data = (u8) (ptrint) o;
paramtypes++;
i++;
case PRIMITIVETYPE_CHAR:
case PRIMITIVETYPE_SHORT:
case PRIMITIVETYPE_BOOLEAN:
- blk[i].itemtype = TYPE_INT;
- blk[i].item = (s8) va_arg(data, s4);
- break;
-
case PRIMITIVETYPE_INT:
- blk[i].itemtype = TYPE_INT;
- blk[i].item = (s8) va_arg(data, s4);
+ vmargs[i].type = TYPE_INT;
+ vmargs[i].data = (s8) va_arg(ap, s4);
break;
case PRIMITIVETYPE_LONG:
- blk[i].itemtype = TYPE_LNG;
- blk[i].item = (s8) va_arg(data, s8);
+ vmargs[i].type = TYPE_LNG;
+ vmargs[i].data = (s8) va_arg(ap, s8);
break;
case PRIMITIVETYPE_FLOAT:
- blk[i].itemtype = TYPE_FLT;
+ vmargs[i].type = TYPE_FLT;
#if defined(__ALPHA__)
/* this keeps the assembler function much simpler */
- *((jdouble *) (&blk[i].item)) = (jdouble) va_arg(data, jdouble);
+ *((jdouble *) (&vmargs[i].data)) = (jdouble) va_arg(ap, jdouble);
#else
- *((jfloat *) (&blk[i].item)) = (jfloat) va_arg(data, jdouble);
+ *((jfloat *) (&vmargs[i].data)) = (jfloat) va_arg(ap, jdouble);
#endif
break;
case PRIMITIVETYPE_DOUBLE:
- blk[i].itemtype = TYPE_DBL;
- *((jdouble *) (&blk[i].item)) = (jdouble) va_arg(data, jdouble);
+ vmargs[i].type = TYPE_DBL;
+ *((jdouble *) (&vmargs[i].data)) = (jdouble) va_arg(ap, jdouble);
break;
case TYPE_ADR:
- blk[i].itemtype = TYPE_ADR;
- blk[i].item = PTR_TO_ITEM(va_arg(data, void*));
+ vmargs[i].type = TYPE_ADR;
+ vmargs[i].data = (u8) (ptrint) va_arg(ap, void*);
break;
}
}
+}
- /* The standard doesn't say anything about return value checking,
- but it appears to be useful. */
- if (rettype != descr->returntype.decltype)
- log_text("\n====\nWarning call*Method called for function with wrong return type\n====");
-}
+/* _Jv_jni_vmargs_from_objectarray *********************************************
+ XXX
-/* XXX it could be considered if we should do typechecking here in the future */
+*******************************************************************************/
-static bool fill_callblock_from_objectarray(void *obj, methoddesc *descr,
- jni_callblock blk[],
+static bool _Jv_jni_vmargs_from_objectarray(java_objectheader *o,
+ methoddesc *descr,
+ vm_arg *vmargs,
java_objectarray *params)
{
java_objectheader *param;
i = 0;
- if (obj) {
+ if (o != NULL) {
/* this pointer */
- blk[0].itemtype = TYPE_ADR;
- blk[0].item = PTR_TO_ITEM(obj);
+ vmargs[0].type = TYPE_ADR;
+ vmargs[0].data = (u8) (ptrint) o;
paramtypes++;
paramcount--;
case TYPE_FLOAT:
case TYPE_DOUBLE:
param = params->data[j];
- if (!param)
+
+ if (param == NULL)
goto illegal_arg;
/* internally used data type */
- blk[i].itemtype = paramtypes->type;
+ vmargs[i].type = paramtypes->type;
/* convert the value according to its declared type */
switch (paramtypes->decltype) {
case PRIMITIVETYPE_BOOLEAN:
if (c == primitivetype_table[paramtypes->decltype].class_wrap)
- blk[i].item = (s8) ((java_lang_Boolean *) param)->value;
+ vmargs[i].data = (s8) ((java_lang_Boolean *) param)->value;
else
goto illegal_arg;
break;
case PRIMITIVETYPE_BYTE:
if (c == primitivetype_table[paramtypes->decltype].class_wrap)
- blk[i].item = (s8) ((java_lang_Byte *) param)->value;
+ vmargs[i].data = (s8) ((java_lang_Byte *) param)->value;
else
goto illegal_arg;
break;
case PRIMITIVETYPE_CHAR:
if (c == primitivetype_table[paramtypes->decltype].class_wrap)
- blk[i].item = (s8) ((java_lang_Character *) param)->value;
+ vmargs[i].data = (s8) ((java_lang_Character *) param)->value;
else
goto illegal_arg;
break;
case PRIMITIVETYPE_SHORT:
if (c == primitivetype_table[paramtypes->decltype].class_wrap)
- blk[i].item = (s8) ((java_lang_Short *) param)->value;
+ vmargs[i].data = (s8) ((java_lang_Short *) param)->value;
else if (c == primitivetype_table[PRIMITIVETYPE_BYTE].class_wrap)
- blk[i].item = (s8) ((java_lang_Byte *) param)->value;
+ vmargs[i].data = (s8) ((java_lang_Byte *) param)->value;
else
goto illegal_arg;
break;
case PRIMITIVETYPE_INT:
if (c == primitivetype_table[paramtypes->decltype].class_wrap)
- blk[i].item = (s8) ((java_lang_Integer *) param)->value;
+ vmargs[i].data = (s8) ((java_lang_Integer *) param)->value;
else if (c == primitivetype_table[PRIMITIVETYPE_SHORT].class_wrap)
- blk[i].item = (s8) ((java_lang_Short *) param)->value;
+ vmargs[i].data = (s8) ((java_lang_Short *) param)->value;
else if (c == primitivetype_table[PRIMITIVETYPE_BYTE].class_wrap)
- blk[i].item = (s8) ((java_lang_Byte *) param)->value;
+ vmargs[i].data = (s8) ((java_lang_Byte *) param)->value;
else
goto illegal_arg;
break;
case PRIMITIVETYPE_LONG:
if (c == primitivetype_table[paramtypes->decltype].class_wrap)
- blk[i].item = (s8) ((java_lang_Long *) param)->value;
+ vmargs[i].data = (s8) ((java_lang_Long *) param)->value;
else if (c == primitivetype_table[PRIMITIVETYPE_INT].class_wrap)
- blk[i].item = (s8) ((java_lang_Integer *) param)->value;
+ vmargs[i].data = (s8) ((java_lang_Integer *) param)->value;
else if (c == primitivetype_table[PRIMITIVETYPE_SHORT].class_wrap)
- blk[i].item = (s8) ((java_lang_Short *) param)->value;
+ vmargs[i].data = (s8) ((java_lang_Short *) param)->value;
else if (c == primitivetype_table[PRIMITIVETYPE_BYTE].class_wrap)
- blk[i].item = (s8) ((java_lang_Byte *) param)->value;
+ vmargs[i].data = (s8) ((java_lang_Byte *) param)->value;
else
goto illegal_arg;
break;
case PRIMITIVETYPE_FLOAT:
if (c == primitivetype_table[paramtypes->decltype].class_wrap)
- *((jfloat *) (&blk[i].item)) = (jfloat) ((java_lang_Float *) param)->value;
+ *((jfloat *) (&vmargs[i].data)) = (jfloat) ((java_lang_Float *) param)->value;
else
goto illegal_arg;
break;
case PRIMITIVETYPE_DOUBLE:
if (c == primitivetype_table[paramtypes->decltype].class_wrap)
- *((jdouble *) (&blk[i].item)) = (jdouble) ((java_lang_Double *) param)->value;
+ *((jdouble *) (&vmargs[i].data)) = (jdouble) ((java_lang_Double *) param)->value;
else if (c == primitivetype_table[PRIMITIVETYPE_FLOAT].class_wrap)
- *((jfloat *) (&blk[i].item)) = (jfloat) ((java_lang_Float *) param)->value;
+ *((jfloat *) (&vmargs[i].data)) = (jfloat) ((java_lang_Float *) param)->value;
else
goto illegal_arg;
break;
default:
goto illegal_arg;
- } /* end declared type switch */
+ }
break;
case TYPE_ADDRESS:
goto illegal_arg;
}
}
- blk[i].itemtype = TYPE_ADR;
- blk[i].item = PTR_TO_ITEM(params->data[j]);
- break;
+ vmargs[i].type = TYPE_ADR;
+ vmargs[i].data = (u8) (ptrint) params->data[j];
+ break;
default:
goto illegal_arg;
- } /* end param type switch */
-
- } /* end param loop */
+ }
+ }
/* if (rettype) */
/* *rettype = descr->returntype.decltype; */
}
+/* _Jv_jni_vmargs_from_objectarray *********************************************
+
+ XXX
+
+*******************************************************************************/
+
+static void _Jv_jni_vmargs_from_args(java_objectheader *o, methoddesc *descr,
+ vm_arg *vmargs, jvalue *args)
+{
+ typedesc *paramtypes;
+ s4 i;
+ s4 j;
+
+ paramtypes = descr->paramtypes;
+
+ /* if method is non-static fill first block and skip `this' pointer */
+
+ i = 0;
+
+ if (o != NULL) {
+ /* the `this' pointer */
+ vmargs[0].type = TYPE_ADR;
+ vmargs[0].data = (u8) (ptrint) o;
+
+ paramtypes++;
+ i++;
+ }
+
+ for (j = 0; i < descr->paramcount; i++, j++, paramtypes++) {
+ switch (paramtypes->decltype) {
+ /* primitive types */
+ case PRIMITIVETYPE_BOOLEAN:
+ case PRIMITIVETYPE_BYTE:
+ case PRIMITIVETYPE_CHAR:
+ case PRIMITIVETYPE_SHORT:
+ case PRIMITIVETYPE_INT:
+ vmargs[i].type = TYPE_INT;
+ vmargs[i].data = (s8) args[j].i;
+ break;
+
+ case PRIMITIVETYPE_LONG:
+ vmargs[i].type = TYPE_LNG;
+ vmargs[i].data = (s8) args[j].j;
+ break;
+
+ case PRIMITIVETYPE_FLOAT:
+ vmargs[i].type = TYPE_FLT;
+#if defined(__ALPHA__)
+ /* this keeps the assembler function much simpler */
+
+ *((jdouble *) (&vmargs[i].data)) = (jdouble) args[j].f;
+#else
+ *((jfloat *) (&vmargs[i].data)) = args[j].f;
+#endif
+ break;
+
+ case PRIMITIVETYPE_DOUBLE:
+ vmargs[i].type = TYPE_DBL;
+ *((jdouble *) (&vmargs[i].data)) = args[j].d;
+ break;
+
+ case TYPE_ADR:
+ vmargs[i].type = TYPE_ADR;
+ vmargs[i].data = (u8) (ptrint) args[j].l;
+ break;
+ }
+ }
+}
+
+
/* _Jv_jni_CallObjectMethod ****************************************************
Internal function to call Java Object methods.
{
methodinfo *resm;
s4 paramcount;
- jni_callblock *blk;
+ vm_arg *vmargs;
java_objectheader *ret;
s4 dumpsize;
paramcount = resm->parseddesc->paramcount;
- blk = DMNEW(jni_callblock, paramcount);
+ vmargs = DMNEW(vm_arg, paramcount);
- fill_callblock_from_vargs(o, resm->parseddesc, blk, ap, TYPE_ADR);
+ _Jv_jni_vmargs_from_vargs(o, resm->parseddesc, vmargs, ap);
STATISTICS(jnicallXmethodnvokation());
- ASM_CALLJAVAFUNCTION2_ADR(ret, resm, paramcount,
- paramcount * sizeof(jni_callblock),
- blk);
+ ret = vm_call_method(resm, paramcount, vmargs);
/* release dump area */
static jint _Jv_jni_CallIntMethod(java_objectheader *o, vftbl_t *vftbl,
methodinfo *m, va_list ap, s4 type)
{
- methodinfo *resm;
- s4 paramcount;
- jni_callblock *blk;
- jint ret;
- s4 dumpsize;
+ methodinfo *resm;
+ s4 paramcount;
+ vm_arg *vmargs;
+ jint ret;
+ s4 dumpsize;
STATISTICS(jniinvokation());
paramcount = resm->parseddesc->paramcount;
- blk = DMNEW(jni_callblock, paramcount);
+ vmargs = DMNEW(vm_arg, paramcount);
- fill_callblock_from_vargs(o, resm->parseddesc, blk, ap, type);
+ _Jv_jni_vmargs_from_vargs(o, resm->parseddesc, vmargs, ap);
STATISTICS(jnicallXmethodnvokation());
- ASM_CALLJAVAFUNCTION2_INT(ret, resm, paramcount,
- paramcount * sizeof(jni_callblock),
- blk);
+ ret = vm_call_method_int(resm, paramcount, vmargs);
/* release dump area */
static jlong _Jv_jni_CallLongMethod(java_objectheader *o, vftbl_t *vftbl,
methodinfo *m, va_list ap)
{
- methodinfo *resm;
- s4 paramcount;
- jni_callblock *blk;
- jlong ret;
- s4 dumpsize;
+ methodinfo *resm;
+ s4 paramcount;
+ vm_arg *vmargs;
+ jlong ret;
+ s4 dumpsize;
STATISTICS(jniinvokation());
paramcount = resm->parseddesc->paramcount;
- blk = DMNEW(jni_callblock, paramcount);
+ vmargs = DMNEW(vm_arg, paramcount);
- fill_callblock_from_vargs(o, resm->parseddesc, blk, ap, PRIMITIVETYPE_LONG);
+ _Jv_jni_vmargs_from_vargs(o, resm->parseddesc, vmargs, ap);
STATISTICS(jnicallXmethodnvokation());
- ASM_CALLJAVAFUNCTION2_LONG(ret, resm, paramcount,
- paramcount * sizeof(jni_callblock),
- blk);
+ ret = vm_call_method_long(resm, paramcount, vmargs);
/* release dump area */
static jfloat _Jv_jni_CallFloatMethod(java_objectheader *o, vftbl_t *vftbl,
methodinfo *m, va_list ap)
{
- methodinfo *resm;
- s4 paramcount;
- jni_callblock *blk;
- jdouble ret;
- s4 dumpsize;
+ methodinfo *resm;
+ s4 paramcount;
+ vm_arg *vmargs;
+ jdouble ret;
+ s4 dumpsize;
/* Class initialization is done by the JIT compiler. This is ok
since a static method always belongs to the declaring class. */
paramcount = resm->parseddesc->paramcount;
- blk = DMNEW(jni_callblock, paramcount);
+ vmargs = DMNEW(vm_arg, paramcount);
- fill_callblock_from_vargs(o, resm->parseddesc, blk, ap,
- PRIMITIVETYPE_FLOAT);
+ _Jv_jni_vmargs_from_vargs(o, resm->parseddesc, vmargs, ap);
STATISTICS(jnicallXmethodnvokation());
- ASM_CALLJAVAFUNCTION2_FLOAT(ret, resm, paramcount,
- paramcount * sizeof(jni_callblock),
- blk);
+ ret = vm_call_method_float(resm, paramcount, vmargs);
/* release dump area */
static jdouble _Jv_jni_CallDoubleMethod(java_objectheader *o, vftbl_t *vftbl,
methodinfo *m, va_list ap)
{
- methodinfo *resm;
- s4 paramcount;
- jni_callblock *blk;
- jfloat ret;
- s4 dumpsize;
+ methodinfo *resm;
+ s4 paramcount;
+ vm_arg *vmargs;
+ jfloat ret;
+ s4 dumpsize;
/* Class initialization is done by the JIT compiler. This is ok
since a static method always belongs to the declaring class. */
paramcount = resm->parseddesc->paramcount;
- blk = DMNEW(jni_callblock, paramcount);
+ vmargs = DMNEW(vm_arg, paramcount);
- fill_callblock_from_vargs(o, resm->parseddesc, blk, ap,
- PRIMITIVETYPE_DOUBLE);
+ _Jv_jni_vmargs_from_vargs(o, resm->parseddesc, vmargs, ap);
STATISTICS(jnicallXmethodnvokation());
- ASM_CALLJAVAFUNCTION2_DOUBLE(ret, resm, paramcount,
- paramcount * sizeof(jni_callblock),
- blk);
+ ret = vm_call_method_double(resm, paramcount, vmargs);
/* release dump area */
static void _Jv_jni_CallVoidMethod(java_objectheader *o, vftbl_t *vftbl,
methodinfo *m, va_list ap)
{
- methodinfo *resm;
- s4 paramcount;
- jni_callblock *blk;
- s4 dumpsize;
+ methodinfo *resm;
+ s4 paramcount;
+ vm_arg *vmargs;
+ s4 dumpsize;
if (m == NULL) {
exceptions_throw_nullpointerexception();
paramcount = resm->parseddesc->paramcount;
- blk = DMNEW(jni_callblock, paramcount);
+ vmargs = DMNEW(vm_arg, paramcount);
- fill_callblock_from_vargs(o, resm->parseddesc, blk, ap, TYPE_VOID);
+ _Jv_jni_vmargs_from_vargs(o, resm->parseddesc, vmargs, ap);
STATISTICS(jnicallXmethodnvokation());
- ASM_CALLJAVAFUNCTION2(resm, paramcount,
- paramcount * sizeof(jni_callblock),
- blk);
+ (void) vm_call_method(resm, paramcount, vmargs);
+
+ /* release dump area */
+
+ dump_release(dumpsize);
+}
+
+
+/* _Jv_jni_CallVoidMethodA *****************************************************
+
+ Internal function to call Java void methods.
+
+*******************************************************************************/
+
+static void _Jv_jni_CallVoidMethodA(java_objectheader *o, vftbl_t *vftbl,
+ methodinfo *m, jvalue *args)
+{
+ methodinfo *resm;
+ s4 paramcount;
+ vm_arg *vmargs;
+ s4 dumpsize;
+
+ if (m == NULL) {
+ exceptions_throw_nullpointerexception();
+ return;
+ }
+
+ /* Class initialization is done by the JIT compiler. This is ok
+ since a static method always belongs to the declaring class. */
+
+ if (m->flags & ACC_STATIC) {
+ /* For static methods we reset the object. */
+
+ if (o != NULL)
+ o = NULL;
+
+ /* for convenience */
+
+ resm = m;
+
+ } else {
+ /* For instance methods we make a virtual function table lookup. */
+
+ resm = method_vftbl_lookup(vftbl, m);
+ }
+
+ /* mark start of dump memory area */
+
+ dumpsize = dump_size();
+
+ paramcount = resm->parseddesc->paramcount;
+
+ vmargs = DMNEW(vm_arg, paramcount);
+
+ _Jv_jni_vmargs_from_args(o, resm->parseddesc, vmargs, args);
+
+ STATISTICS(jnicallXmethodnvokation());
+
+ (void) vm_call_method(resm, paramcount, vmargs);
/* release dump area */
java_objectarray *params)
{
methodinfo *resm;
- jni_callblock *blk;
+ vm_arg *vmargs;
java_objectheader *ro;
s4 argcount;
s4 paramcount;
class the method belongs to. For static methods the obj
parameter is ignored. */
- if (!(m->flags & ACC_STATIC) && o &&
- (!builtin_instanceof(o, m->class)))
- {
+ if (!(m->flags & ACC_STATIC) && o && (!builtin_instanceof(o, m->class))) {
*exceptionptr =
new_exception_message(string_java_lang_IllegalArgumentException,
"Object parameter of wrong type in Java_java_lang_reflect_Method_invokeNative");
resm = m;
}
- blk = MNEW(jni_callblock, argcount);
+ vmargs = MNEW(vm_arg, argcount);
- if (!fill_callblock_from_objectarray(o, resm->parseddesc, blk, params))
+ if (!_Jv_jni_vmargs_from_objectarray(o, resm->parseddesc, vmargs, params))
return NULL;
switch (resm->parseddesc->returntype.decltype) {
case TYPE_VOID:
- ASM_CALLJAVAFUNCTION2(resm, argcount,
- argcount * sizeof(jni_callblock),
- blk);
+ (void) vm_call_method(resm, argcount, vmargs);
ro = NULL;
break;
s4 i;
java_lang_Boolean *bo;
- ASM_CALLJAVAFUNCTION2_INT(i, resm, argcount,
- argcount * sizeof(jni_callblock),
- blk);
+ i = vm_call_method_int(resm, argcount, vmargs);
ro = builtin_new(class_java_lang_Boolean);
s4 i;
java_lang_Byte *bo;
- ASM_CALLJAVAFUNCTION2_INT(i, resm, argcount,
- argcount * sizeof(jni_callblock),
- blk);
+ i = vm_call_method_int(resm, argcount, vmargs);
ro = builtin_new(class_java_lang_Byte);
s4 i;
java_lang_Character *co;
- ASM_CALLJAVAFUNCTION2_INT(i, resm, argcount,
- argcount * sizeof(jni_callblock),
- blk);
+ i = vm_call_method_int(resm, argcount, vmargs);
ro = builtin_new(class_java_lang_Character);
s4 i;
java_lang_Short *so;
- ASM_CALLJAVAFUNCTION2_INT(i, resm, argcount,
- argcount * sizeof(jni_callblock),
- blk);
+ i = vm_call_method_int(resm, argcount, vmargs);
ro = builtin_new(class_java_lang_Short);
s4 i;
java_lang_Integer *io;
- ASM_CALLJAVAFUNCTION2_INT(i, resm, argcount,
- argcount * sizeof(jni_callblock),
- blk);
+ i = vm_call_method_int(resm, argcount, vmargs);
ro = builtin_new(class_java_lang_Integer);
s8 l;
java_lang_Long *lo;
- ASM_CALLJAVAFUNCTION2_LONG(l, resm, argcount,
- argcount * sizeof(jni_callblock),
- blk);
+ l = vm_call_method_long(resm, argcount, vmargs);
ro = builtin_new(class_java_lang_Long);
float f;
java_lang_Float *fo;
- ASM_CALLJAVAFUNCTION2_FLOAT(f, resm, argcount,
- argcount * sizeof(jni_callblock),
- blk);
+ f = vm_call_method_float(resm, argcount, vmargs);
ro = builtin_new(class_java_lang_Float);
double d;
java_lang_Double *_do;
- ASM_CALLJAVAFUNCTION2_DOUBLE(d, resm, argcount,
- argcount * sizeof(jni_callblock),
- blk);
+ d = vm_call_method_double(resm, argcount, vmargs);
ro = builtin_new(class_java_lang_Double);
break;
case TYPE_ADR:
- ASM_CALLJAVAFUNCTION2_ADR(ro, resm, argcount,
- argcount * sizeof(jni_callblock),
- blk);
+ ro = vm_call_method(resm, argcount, vmargs);
break;
default:
/* if this happens the exception has already been set by
fill_callblock_from_objectarray */
- MFREE(blk, jni_callblock, argcount);
+ MFREE(vmargs, vm_arg, argcount);
return NULL;
}
- MFREE(blk, jni_callblock, argcount);
+ MFREE(vmargs, vm_arg, argcount);
if (*exceptionptr) {
java_objectheader *cause;
/* print the stacktrace */
- ASM_CALLJAVAFUNCTION(m, e, NULL, NULL, NULL);
+ (void) vm_call_method_intern(m, e, NULL, NULL, NULL);
}
}
o = builtin_new(clazz);
- if (!o)
+ if (o == NULL)
return NULL;
/* call constructor */
o = builtin_new(clazz);
- if (!o)
+ if (o == NULL)
return NULL;
/* call constructor */
}
-/***********************************************************************************
+/* NewObjectA *****************************************************************
- Constructs a new Java object
- arguments that are to be passed to the constructor are placed in
- args array of jvalues
+ Programmers place all arguments that are to be passed to the
+ constructor in an args array of jvalues that immediately follows
+ the methodID argument. NewObjectA() accepts the arguments in this
+ array, and, in turn, passes them to the Java method that the
+ programmer wishes to invoke.
-***********************************************************************************/
+*******************************************************************************/
jobject NewObjectA(JNIEnv* env, jclass clazz, jmethodID methodID, jvalue *args)
{
+ java_objectheader *o;
+ methodinfo *m;
+
STATISTICS(jniinvokation());
- log_text("JNI-Call: NewObjectA: IMPLEMENT ME!");
+ m = (methodinfo *) methodID;
- return NewLocalRef(env, NULL);
+ /* create object */
+
+ o = builtin_new(clazz);
+
+ if (o == NULL)
+ return NULL;
+
+ /* call constructor */
+
+ _Jv_jni_CallVoidMethodA(o, o->vftbl, m, args);
+
+ return NewLocalRef(env, o);
}
void CallVoidMethodA(JNIEnv *env, jobject obj, jmethodID methodID, jvalue *args)
{
- log_text("JNI-Call: CallVoidMethodA: IMPLEMENT ME!");
+ java_objectheader *o;
+ methodinfo *m;
+
+ o = (java_objectheader *) obj;
+ m = (methodinfo *) methodID;
+
+ _Jv_jni_CallVoidMethodA(o, o->vftbl, m, args);
}
void CallNonvirtualVoidMethodA(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, jvalue * args)
-{
- log_text("JNI-Call: CallNonvirtualVoidMethodA: IMPLEMENT ME!");
+{
+ java_objectheader *o;
+ classinfo *c;
+ methodinfo *m;
+
+ o = (java_objectheader *) obj;
+ c = (classinfo *) clazz;
+ m = (methodinfo *) methodID;
+
+ _Jv_jni_CallVoidMethodA(o, c->vftbl, m, args);
}
void CallStaticVoidMethodA(JNIEnv *env, jclass clazz, jmethodID methodID, jvalue * args)
{
- log_text("JNI-Call: CallStaticVoidMethodA: IMPLEMENT ME!");
+ methodinfo *m;
+
+ m = (methodinfo *) methodID;
+
+ _Jv_jni_CallVoidMethodA(NULL, NULL, m, args);
}
builtin_monitorenter(*global_ref_table);
#endif
- ASM_CALLJAVAFUNCTION_ADR(o, getmid, *global_ref_table, lobj, NULL, NULL);
+ o = vm_call_method_intern(getmid, *global_ref_table, lobj, NULL, NULL);
refcount = (java_lang_Integer *) o;
return NULL;
}
- ASM_CALLJAVAFUNCTION(putmid, *global_ref_table, lobj, newval, NULL);
+ (void) vm_call_method_intern(putmid, *global_ref_table, lobj, newval,
+ NULL);
} else {
/* we can access the object itself, as we are in a
builtin_monitorenter(*global_ref_table);
#endif
- ASM_CALLJAVAFUNCTION_ADR(o, getmid, *global_ref_table, globalRef, NULL,
- NULL);
+ o = vm_call_method_intern(getmid, *global_ref_table, globalRef, NULL, NULL);
refcount = (java_lang_Integer *) o;
val = refcount->value - 1;
if (val == 0) {
- ASM_CALLJAVAFUNCTION(removemid, *global_ref_table, refcount, NULL,
- NULL);
+ (void) vm_call_method_intern(removemid, *global_ref_table, refcount,
+ NULL, NULL);
} else {
/* we do not create a new object, but set the new value into
Changes: Christian Thalinger
- $Id: native.c 4541 2006-02-21 13:37:48Z twisti $
+ $Id: native.c 4552 2006-03-04 17:15:44Z twisti $
*/
#include "vm/options.h"
#include "vm/resolve.h"
#include "vm/stringlocal.h"
+#include "vm/vm.h"
#include "vm/jit/asmpart.h"
#include "vm/jit/jit.h"
/* call initializer */
- ASM_CALLJAVAFUNCTION(m, o, NULL, NULL, NULL);
+ (void) vm_call_method_intern(m, o, NULL, NULL, NULL);
return o;
}
/* call initializer */
- ASM_CALLJAVAFUNCTION(m, o, s, NULL, NULL);
+ (void) vm_call_method_intern(m, o, s, NULL, NULL);
return o;
}
/* call initializer */
- ASM_CALLJAVAFUNCTION(m, o, (void *) (ptrint) i, NULL, NULL);
+ (void) vm_call_method_intern(m, o, (void *) (ptrint) i, NULL, NULL);
return o;
}
/* call initializer */
- ASM_CALLJAVAFUNCTION(m, o, t, NULL, NULL);
+ (void) vm_call_method_intern(m, o, t, NULL, NULL);
return o;
}
Christian Thalinger
Edwin Steiner
- $Id: VMClassLoader.c 4487 2006-02-12 02:18:20Z edwin $
+ $Id: VMClassLoader.c 4552 2006-03-04 17:15:44Z twisti $
*/
+#include "config.h"
+
#include <sys/stat.h>
-#include "config.h"
#include "vm/types.h"
#include "mm/memory.h"
#include "vm/statistics.h"
#include "vm/stringlocal.h"
#include "vm/suck.h"
+#include "vm/vm.h"
#include "vm/zip.h"
#include "vm/jit/asmpart.h"
/* if a resource was found, add it to the vector */
if (path) {
- ASM_CALLJAVAFUNCTION_INT(ret, m, o, path, NULL, NULL);
+ ret = vm_call_method_intern_int(m, o, path, NULL, NULL);
- if (!ret)
+ if (ret == 0)
return NULL;
}
}
Changes: Christian Thalinger
Edwin Steiner
- $Id: threads.c 4534 2006-02-21 09:31:25Z twisti $
+ $Id: threads.c 4552 2006-03-04 17:15:44Z twisti $
*/
if (!method)
return false;
- ASM_CALLJAVAFUNCTION(method, mainthread, mainthreadobj, threadname,
- (void *) 5);
+ (void) vm_call_method_intern(method, mainthread, mainthreadobj, threadname,
+ (void *) 5);
if (*exceptionptr)
return false;
if (!method)
return false;
- ASM_CALLJAVAFUNCTION(method, threadgroup, mainthread, NULL, NULL);
+ (void) vm_call_method_intern(method, threadgroup, mainthread, NULL, NULL);
if (*exceptionptr)
return false;
if (!method)
throw_exception();
- ASM_CALLJAVAFUNCTION(method, thread, NULL, NULL, NULL);
+ (void) vm_call_method_intern(method, thread, NULL, NULL, NULL);
}
else {
Changes: Edwin Steiner
- $Id: exceptions.c 4550 2006-03-01 17:00:33Z twisti $
+ $Id: exceptions.c 4552 2006-03-04 17:15:44Z twisti $
*/
#include "vm/loader.h"
#include "vm/options.h"
#include "vm/stringlocal.h"
+#include "vm/vm.h"
#include "vm/jit/asmpart.h"
#include "vm/jit/jit.h"
#include "vm/jit/methodheader.h"
/* print the stacktrace */
if (pss) {
- ASM_CALLJAVAFUNCTION(pss, xptr, NULL, NULL, NULL);
+ (void) vm_call_method_intern(pss, xptr, NULL, NULL, NULL);
/* This normally means, we are EXTREMLY out of memory or have a */
/* serious problem while printStackTrace. But may be another */
class_java_lang_Object,
true);
- if (!m)
+ if (m == NULL)
return *exceptionptr;
- ASM_CALLJAVAFUNCTION_ADR(o, m, (void *) (ptrint) index, NULL, NULL, NULL);
+ o = vm_call_method_intern(m, (void *) (ptrint) index, NULL, NULL, NULL);
s = (java_lang_String *) o;
- if (!s)
+ if (s == NULL)
return *exceptionptr;
e = new_exception_javastring(string_java_lang_ArrayIndexOutOfBoundsException,
s);
- if (!e)
+ if (e == NULL)
return *exceptionptr;
return e;
Changes:
- $Id: finalizer.c 4357 2006-01-22 23:33:38Z twisti $
+ $Id: finalizer.c 4552 2006-03-04 17:15:44Z twisti $
*/
#include "vm/global.h"
#include "vm/options.h"
#include "vm/stringlocal.h"
+#include "vm/vm.h"
#include "vm/jit/asmpart.h"
/* call the finalizer function */
- ASM_CALLJAVAFUNCTION(ob->vftbl->class->finalizer, ob, NULL, NULL, NULL);
+ vm_call_method_intern(ob->vftbl->class->finalizer, ob, NULL, NULL, NULL);
/* if we had an exception in the finalizer, ignore it */
Joseph Wenninger
Christian Thalinger
- $Id: global.h 4551 2006-03-03 00:00:39Z twisti $
+ $Id: global.h 4552 2006-03-04 17:15:44Z twisti $
*/
#define ACC_MIRANDA 0x8000
-/* data structure for calls from c code to java methods */
-
-struct jni_callblock {
- u8 itemtype;
- u8 item;
-};
-
-typedef struct jni_callblock jni_callblock;
-
-
/* data structures of the runtime system **************************************/
/* java_objectheader ***********************************************************
Andreas Krall
Christian Thalinger
- $Id: initialize.c 4357 2006-01-22 23:33:38Z twisti $
+ $Id: initialize.c 4552 2006-03-04 17:15:44Z twisti $
*/
#include "vm/options.h"
#include "vm/statistics.h"
#include "vm/stringlocal.h"
+#include "vm/vm.h"
#include "vm/jit/asmpart.h"
/* now call the initializer */
- ASM_CALLJAVAFUNCTION(m, NULL, NULL, NULL, NULL);
+ (void) vm_call_method_intern(m, NULL, NULL, NULL, NULL);
#if defined(USE_THREADS) && !defined(NATIVE_THREADS)
assert(blockInts == 0);
Changes: Christian Thalinger
Edwin Steiner
- $Id: stacktrace.c 4533 2006-02-21 09:25:16Z twisti $
+ $Id: stacktrace.c 4552 2006-03-04 17:15:44Z twisti $
*/
#include "vm/loader.h"
#include "vm/options.h"
#include "vm/stringlocal.h"
+#include "vm/vm.h"
#include "vm/jit/asmpart.h"
#include "vm/jit/codegen-common.h"
#include "vm/jit/methodheader.h"
/* call function */
- ASM_CALLJAVAFUNCTION(m, o, NULL, NULL, NULL);
+ (void) vm_call_method_intern(m, o, NULL, NULL, NULL);
/* remove stackframeinfo */
Changes:
- $Id: genoffsets.c 4357 2006-01-22 23:33:38Z twisti $
+ $Id: genoffsets.c 4552 2006-03-04 17:15:44Z twisti $
*/
+#include "config.h"
+
#include <stdio.h>
#include "vm/types.h"
-#include "vm/global.h"
#include "mm/memory.h"
+#include "vm/class.h"
+#include "vm/global.h"
#include "vm/linker.h"
#include "vm/method.h"
-#include "vm/class.h"
+#include "vm/vm.h"
#include "vm/jit/asmpart.h"
#include "vm/jit/stacktrace.h"
printf("/* define some sizeof()'s */\n\n");
- printf("#define sizejniblock %3d\n", (s4) sizeof(jni_callblock));
+ printf("#define sizevmarg %3d\n", (s4) sizeof(vm_arg));
printf("#define sizestackframeinfo %3d\n", (s4) sizeof(stackframeinfo));
printf("\n\n/* define some offsets */\n\n");
printf("#define offclassvftbl %3d\n", (s4) OFFSET(classinfo, vftbl));
printf("\n\n");
- printf("#define offjniitemtype %3d\n", (s4) OFFSET(jni_callblock, itemtype));
- printf("#define offjniitem %3d\n", (s4) OFFSET(jni_callblock, item));
+ printf("#define offvmargtype %3d\n", (s4) OFFSET(vm_arg, type));
+ printf("#define offvmargdata %3d\n", (s4) OFFSET(vm_arg, data));
printf("\n\n");
printf("#define offcast_super_baseval %3d\n", (s4) OFFSET(castinfo, super_baseval));
Changes:
- $Id: asmpart.S 4530 2006-02-21 09:11:53Z twisti $
+ $Id: asmpart.S 4552 2006-03-04 17:15:44Z twisti $
*/
jle L_copy_done
mov a1,itmp3 /* arg count */
- mov a3,itmp2 /* pointer to arg block */
+ mov a2,itmp2 /* pointer to arg block */
mov itmp2,%r14 /* save argument block pointer */
mov itmp3,%r15 /* save argument count */
- sub $sizejniblock,itmp2 /* initialize pointer (smaller code) */
+ sub $sizevmarg,itmp2 /* initialize pointer (smaller code) */
add $1,itmp3 /* initialize argument count */
xor %r12,%r12 /* initialize integer argument counter*/
xor %r13,%r13 /* initialize float argument counter */
L_register_copy:
- add $sizejniblock,itmp2 /* goto next argument block */
- dec itmp3 /* argument count - 1 */
+ add $sizevmarg,itmp2 /* goto next argument block */
+ dec itmp3 /* argument count - 1 */
jz L_register_copy_done
- andb $0x02,offjniitemtype(itmp2) /* is this a float/double type? */
- jnz L_register_handle_float /* yes, handle it */
+ andb $0x02,offvmargtype(itmp2) /* is this a float/double type? */
+ jnz L_register_handle_float /* yes, handle it */
- cmp $INT_ARG_CNT,%r12 /* are we out of integer argument */
- je L_register_copy /* register? yes, next loop */
+ cmp $INT_ARG_CNT,%r12 /* are we out of integer argument */
+ je L_register_copy /* register? yes, next loop */
lea jumptable_integer(%rip),%rbp
mov 0(%rbp,%r12,8),%rbx
and $0xfffffffffffffffe,%rbp /* keep stack 16-byte aligned */
shl $3,%rbp /* calculate stack size */
- sub %rbp,sp /* stack frame for arguments */
- mov sp,%rbx /* use %rbx as temp sp */
+ sub %rbp,sp /* stack frame for arguments */
+ mov sp,%rbx /* use %rbx as temp sp */
- sub $sizejniblock,%r14 /* initialize pointer (smaller code) */
+ sub $sizevmarg,%r14 /* initialize pointer (smaller code) */
add $1,%r15 /* initialize argument count */
L_stack_copy_loop:
- add $sizejniblock,%r14 /* goto next argument block */
+ add $sizevmarg,%r14 /* goto next argument block */
dec %r15 /* are there any arguments left? */
jz L_copy_done /* no test needed after dec */
- andb $0x02,offjniitemtype(%r14) /* is this a float/double type? */
+ andb $0x02,offvmargtype(%r14) /* is this a float/double type? */
jnz L_stack_handle_float
- dec %r12 /* arguments assigned to registers */
+ dec %r12 /* arguments assigned to registers */
jge L_stack_copy_loop
jmp L_stack_copy
L_stack_handle_float:
- dec %r13 /* arguments assigned to registers */
+ dec %r13 /* arguments assigned to registers */
jge L_stack_copy_loop
L_stack_copy:
- mov offjniitem(%r14),itmp3 /* copy s8 argument onto stack */
- mov itmp3,0(%rbx)
- add $8,%rbx /* increase sp to next argument */
+ mov offvmargdata(%r14),itmp3 /* copy s8 argument onto stack */
+ mov itmp3,0(%rbx)
+ add $8,%rbx /* increase sp to next argument */
jmp L_stack_copy_loop
L_copy_done:
.quad handle_a5
handle_a0:
- mov offjniitem(itmp2),a0
+ mov offvmargdata(itmp2),a0
jmp L_register_copy
handle_a1:
- mov offjniitem(itmp2),a1
+ mov offvmargdata(itmp2),a1
jmp L_register_copy
handle_a2:
- mov offjniitem(itmp2),a2
+ mov offvmargdata(itmp2),a2
jmp L_register_copy
handle_a3:
- mov offjniitem(itmp2),a3
+ mov offvmargdata(itmp2),a3
jmp L_register_copy
handle_a4:
- mov offjniitem(itmp2),a4
+ mov offvmargdata(itmp2),a4
jmp L_register_copy
handle_a5:
- mov offjniitem(itmp2),a5
+ mov offvmargdata(itmp2),a5
jmp L_register_copy
.quad handle_fa7
handle_fa0:
- movq offjniitem(itmp2),fa0
+ movq offvmargdata(itmp2),fa0
jmp L_register_copy
handle_fa1:
- movq offjniitem(itmp2),fa1
+ movq offvmargdata(itmp2),fa1
jmp L_register_copy
handle_fa2:
- movq offjniitem(itmp2),fa2
+ movq offvmargdata(itmp2),fa2
jmp L_register_copy
handle_fa3:
- movq offjniitem(itmp2),fa3
+ movq offvmargdata(itmp2),fa3
jmp L_register_copy
handle_fa4:
- movq offjniitem(itmp2),fa4
+ movq offvmargdata(itmp2),fa4
jmp L_register_copy
handle_fa5:
- movq offjniitem(itmp2),fa5
+ movq offvmargdata(itmp2),fa5
jmp L_register_copy
handle_fa6:
- movq offjniitem(itmp2),fa6
+ movq offvmargdata(itmp2),fa6
jmp L_register_copy
handle_fa7:
- movq offjniitem(itmp2),fa7
+ movq offvmargdata(itmp2),fa7
jmp L_register_copy
call builtin_asm_get_exceptionptrptr@PLT
mov v0,itmp2 /* v0 == xptr */
#else
- lea _no_threads_exceptionptr,itmp2
+ lea _no_threads_exceptionptr(%rip),itmp2
#endif
mov (itmp2),xptr /* get the exception pointer */
movl $0,(itmp2) /* clear exception pointer */
call builtin_asm_get_exceptionptrptr@PLT
mov v0,itmp2 /* v0 == xptr */
#else
- lea _no_threads_exceptionptr,itmp2
+ mov _no_threads_exceptionptr,itmp2
#endif
mov (itmp2),xptr /* get the exception pointer */
movl $0,(itmp2) /* clear exception pointer */
Edwin Steiner
Christian Thalinger
- $Id: loader.c 4540 2006-02-21 13:35:53Z twisti $
+ $Id: loader.c 4552 2006-03-04 17:15:44Z twisti $
*/
#include "vm/statistics.h"
#include "vm/stringlocal.h"
#include "vm/suck.h"
+#include "vm/vm.h"
#if defined(ENABLE_ZLIB)
# include "vm/zip.h"
if (!m)
return false;
- ASM_CALLJAVAFUNCTION_ADR(cl, m, NULL, NULL, NULL, NULL);
+ cl = vm_call_method_intern(m, NULL, NULL, NULL, NULL);
if (!cl)
return false;
s = javastring_new_slash_to_dot(name);
- ASM_CALLJAVAFUNCTION_ADR(o, lc, cl, s, NULL, NULL);
+ o = vm_call_method_intern(lc, cl, s, NULL, NULL);
c = (classinfo *) o;
Changes:
- $Id: properties.c 4435 2006-02-04 23:59:54Z twisti $
+ $Id: properties.c 4552 2006-03-04 17:15:44Z twisti $
*/
#include "vm/method.h"
#include "vm/options.h"
#include "vm/stringlocal.h"
+#include "vm/vm.h"
#include "vm/jit/asmpart.h"
k = javastring_new_char(key);
v = javastring_new_char(value);
- ASM_CALLJAVAFUNCTION(mput, psystem, k, v, NULL);
+ (void) vm_call_method_intern(mput, psystem, k, v, NULL);
}
#include "vm/signallocal.h"
#include "vm/stringlocal.h"
#include "vm/suck.h"
+#include "vm/vm.h"
#include "vm/jit/asmpart.h"
#include "vm/jit/profile/profile.h"
/* call the exit function with passed exit status */
- ASM_CALLJAVAFUNCTION(m, (void *) (ptrint) status, NULL, NULL, NULL);
+ (void) vm_call_method_intern(m, (void *) (ptrint) status, NULL, NULL, NULL);
/* this should never happen */
}
+/* vm_call_method_intern *******************************************************
+
+ Calls a Java method with a fixed number of arguments (namely 4) and
+ returns an address.
+
+*******************************************************************************/
+
+java_objectheader *vm_call_method_intern(methodinfo *m, void *a0, void *a1,
+ void *a2, void *a3)
+{
+ java_objectheader *o;
+
+#if defined(ENABLE_JIT)
+# if defined(ENABLE_INTRP)
+ if (opt_intrp)
+ o = intrp_asm_calljavafunction(m, a0, a1, a2, a3);
+ else
+# endif
+ o = asm_calljavafunction(m, a0, a1, a2, a3);
+#else
+ o = intrp_asm_calljavafunction(m, a0, a1, a2, a3);
+#endif
+
+ return o;
+}
+
+
+/* vm_call_method_intern_int ***************************************************
+
+ Calls a Java method with a fixed number of arguments (namely 4) and
+ returns an integer (s4).
+
+*******************************************************************************/
+
+s4 vm_call_method_intern_int(methodinfo *m, void *a0, void *a1, void *a2,
+ void *a3)
+{
+ s4 i;
+
+#if defined(ENABLE_JIT)
+# if defined(ENABLE_INTRP)
+ if (opt_intrp)
+ i = intrp_asm_calljavafunction_int(m, a0, a1, a2, a3);
+ else
+# endif
+ i = asm_calljavafunction_int(m, a0, a1, a2, a3);
+#else
+ i = intrp_asm_calljavafunction_int(m, a0, a1, a2, a3);
+#endif
+
+ return i;
+}
+
+
+/* vm_call_method **************************************************************
+
+ Calls a Java method with a variable number of arguments and returns
+ an address.
+
+*******************************************************************************/
+
+java_objectheader *vm_call_method(methodinfo *m, u4 count, vm_arg *vmargs)
+{
+ java_objectheader *o;
+
+#if defined(ENABLE_JIT)
+# if defined(ENABLE_INTRP)
+ if (opt_intrp)
+ o = intrp_asm_calljavafunction2(m, count, vmargs);
+ else
+# endif
+ o = asm_calljavafunction2(m, count, vmargs);
+#else
+ o = intrp_asm_calljavafunction(m, count, vmargs);
+#endif
+
+ return o;
+}
+
+
+/* vm_call_method_int **********************************************************
+
+ Calls a Java method with a variable number of arguments and returns
+ an integer (s4).
+
+*******************************************************************************/
+
+s4 vm_call_method_int(methodinfo *m, u4 count, vm_arg *vmargs)
+{
+ s4 i;
+
+#if defined(ENABLE_JIT)
+# if defined(ENABLE_INTRP)
+ if (opt_intrp)
+ i = intrp_asm_calljavafunction2int(m, count, vmargs);
+ else
+# endif
+ i = asm_calljavafunction2int(m, count, vmargs);
+#else
+ i = intrp_asm_calljavafunction2int(m, count, vmargs);
+#endif
+
+ return i;
+}
+
+
+/* vm_call_method_long *********************************************************
+
+ Calls a Java method with a variable number of arguments and returns
+ a long (s8).
+
+*******************************************************************************/
+
+s8 vm_call_method_long(methodinfo *m, u4 count, vm_arg *vmargs)
+{
+ s8 l;
+
+#if defined(ENABLE_JIT)
+# if defined(ENABLE_INTRP)
+ if (opt_intrp)
+ l = intrp_asm_calljavafunction2long(m, count, vmargs);
+ else
+# endif
+ l = asm_calljavafunction2long(m, count, vmargs);
+#else
+ l = intrp_asm_calljavafunction2long(m, count, vmargs);
+#endif
+
+ return l;
+}
+
+
+/* vm_call_method_float ********************************************************
+
+ Calls a Java method with a variable number of arguments and returns
+ an float.
+
+*******************************************************************************/
+
+float vm_call_method_float(methodinfo *m, u4 count, vm_arg *vmargs)
+{
+ float f;
+
+#if defined(ENABLE_JIT)
+# if defined(ENABLE_INTRP)
+ if (opt_intrp)
+ f = intrp_asm_calljavafunction2float(m, count, vmargs);
+ else
+# endif
+ f = asm_calljavafunction2float(m, count, vmargs);
+#else
+ f = intrp_asm_calljavafunction2float(m, count, vmargs);
+#endif
+
+ return f;
+}
+
+
+/* vm_call_method_double *******************************************************
+
+ Calls a Java method with a variable number of arguments and returns
+ a double.
+
+*******************************************************************************/
+
+double vm_call_method_double(methodinfo *m, u4 count, vm_arg *vmargs)
+{
+ double d;
+
+#if defined(ENABLE_JIT)
+# if defined(ENABLE_INTRP)
+ if (opt_intrp)
+ d = intrp_asm_calljavafunction2double(m, count, vmargs);
+ else
+# endif
+ d = asm_calljavafunction2double(m, count, vmargs);
+#else
+ d = intrp_asm_calljavafunction2double(m, count, vmargs);
+#endif
+
+ return d;
+}
+
+
/*
* These are local overrides for various environment variables in Emacs.
* Please do not remove this and leave it at the end of the file, where
extern classinfo *mainclass;
+/* vm_arg **********************************************************************
+
+ Datastructure for arguments to call Java methods via vm_call_method
+ functions.
+
+*******************************************************************************/
+
+typedef struct vm_arg vm_arg;
+
+struct vm_arg {
+ u8 type;
+ u8 data;
+};
+
+
/* function prototypes ********************************************************/
void usage(void);
void vm_exit_handler(void);
+/* Java method calling functions */
+java_objectheader *vm_call_method_intern(methodinfo *m, void *a0, void *a1,
+ void *a2, void *a3);
+
+s4 vm_call_method_intern_int(methodinfo *m, void *a0, void *a1, void *a2,
+ void *a3);
+
+java_objectheader *vm_call_method(methodinfo *m, u4 count, vm_arg *vmargs);
+s4 vm_call_method_int(methodinfo *m, u4 count, vm_arg *vmargs);
+s8 vm_call_method_long(methodinfo *m, u4 count, vm_arg *vmargs);
+float vm_call_method_float(methodinfo *m, u4 count, vm_arg *vmargs);
+double vm_call_method_double(methodinfo *m, u4 count, vm_arg *vmargs);
+
#endif /* _VM_H */
/*