natMethod.cc (_Jv_CallAnyMethodA): Allocate a full jvalue for each argument.
* java/lang/reflect/natMethod.cc (_Jv_CallAnyMethodA): Allocate a full jvalue for each argument. Simplify. * testsuite/libjava.jni/calls.c (docall), testsuite/libjava.jni/calls.java (longpb_f): check for argument misalignment. From-SVN: r63563
This commit is contained in:
parent
b8c53e96ad
commit
a6fdf2d3bf
|
@ -1,3 +1,11 @@
|
||||||
|
2003-02-28 Hans Boehm <Hans.Boehm@hp.com>
|
||||||
|
|
||||||
|
* java/lang/reflect/natMethod.cc (_Jv_CallAnyMethodA): Allocate a full
|
||||||
|
jvalue for each argument. Simplify.
|
||||||
|
* testsuite/libjava.jni/calls.c (docall),
|
||||||
|
testsuite/libjava.jni/calls.java (longpb_f): check for argument
|
||||||
|
misalignment.
|
||||||
|
|
||||||
2003-02-28 Mark Wielaard <mark@klomp.org>
|
2003-02-28 Mark Wielaard <mark@klomp.org>
|
||||||
|
|
||||||
* Makefile.am (nat_source_files): Remove
|
* Makefile.am (nat_source_files): Remove
|
||||||
|
|
|
@ -358,46 +358,30 @@ _Jv_CallAnyMethodA (jobject obj,
|
||||||
obj = JvAllocObject (return_type);
|
obj = JvAllocObject (return_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const int size_per_arg = sizeof(jvalue);
|
||||||
|
ffi_cif cif;
|
||||||
|
|
||||||
|
char *p = (char *) __builtin_alloca (param_count * size_per_arg);
|
||||||
|
// Overallocate to get correct alignment.
|
||||||
|
void **values = (void **)
|
||||||
|
__builtin_alloca (param_count * sizeof (void *));
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int size = 0;
|
|
||||||
if (needs_this)
|
if (needs_this)
|
||||||
{
|
{
|
||||||
// The `NULL' type is `Object'.
|
// The `NULL' type is `Object'.
|
||||||
argtypes[i++] = get_ffi_type (NULL);
|
argtypes[i] = get_ffi_type (NULL);
|
||||||
size += sizeof (jobject);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int arg = 0; i < param_count; ++i, ++arg)
|
|
||||||
{
|
|
||||||
argtypes[i] = get_ffi_type (paramelts[arg]);
|
|
||||||
if (paramelts[arg]->isPrimitive())
|
|
||||||
size += paramelts[arg]->size();
|
|
||||||
else
|
|
||||||
size += sizeof (jobject);
|
|
||||||
}
|
|
||||||
|
|
||||||
ffi_cif cif;
|
|
||||||
if (ffi_prep_cif (&cif, FFI_DEFAULT_ABI, param_count,
|
|
||||||
rtype, argtypes) != FFI_OK)
|
|
||||||
{
|
|
||||||
// FIXME: throw some kind of VirtualMachineError here.
|
|
||||||
}
|
|
||||||
|
|
||||||
char *p = (char *) __builtin_alloca (size);
|
|
||||||
void **values = (void **) __builtin_alloca (param_count * sizeof (void *));
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
if (needs_this)
|
|
||||||
{
|
|
||||||
values[i] = p;
|
values[i] = p;
|
||||||
memcpy (p, &obj, sizeof (jobject));
|
memcpy (p, &obj, sizeof (jobject));
|
||||||
p += sizeof (jobject);
|
p += size_per_arg;
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int arg = 0; i < param_count; ++i, ++arg)
|
for (int arg = 0; i < param_count; ++i, ++arg)
|
||||||
{
|
{
|
||||||
int tsize;
|
int tsize;
|
||||||
|
|
||||||
|
argtypes[i] = get_ffi_type (paramelts[arg]);
|
||||||
if (paramelts[arg]->isPrimitive())
|
if (paramelts[arg]->isPrimitive())
|
||||||
tsize = paramelts[arg]->size();
|
tsize = paramelts[arg]->size();
|
||||||
else
|
else
|
||||||
|
@ -406,9 +390,16 @@ _Jv_CallAnyMethodA (jobject obj,
|
||||||
// Copy appropriate bits from the jvalue into the ffi array.
|
// Copy appropriate bits from the jvalue into the ffi array.
|
||||||
// FIXME: we could do this copying all in one loop, above, by
|
// FIXME: we could do this copying all in one loop, above, by
|
||||||
// over-allocating a bit.
|
// over-allocating a bit.
|
||||||
|
// How do we do this without breaking big-endian platforms?
|
||||||
values[i] = p;
|
values[i] = p;
|
||||||
memcpy (p, &args[arg], tsize);
|
memcpy (p, &args[arg], tsize);
|
||||||
p += tsize;
|
p += size_per_arg;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ffi_prep_cif (&cif, FFI_DEFAULT_ABI, param_count,
|
||||||
|
rtype, argtypes) != FFI_OK)
|
||||||
|
{
|
||||||
|
// FIXME: throw some kind of VirtualMachineError here.
|
||||||
}
|
}
|
||||||
|
|
||||||
using namespace java::lang;
|
using namespace java::lang;
|
||||||
|
|
|
@ -47,6 +47,12 @@ Java_calls_docall (JNIEnv *env, jobject _this)
|
||||||
if (l != 2033)
|
if (l != 2033)
|
||||||
++fails;
|
++fails;
|
||||||
|
|
||||||
|
method = (*env)->GetStaticMethodID (env, klass, "longpb_f", "(BJBJBJ)J");
|
||||||
|
l = (*env)->CallStaticLongMethod (env, klass, method, (jbyte) 13, (jlong) 3,
|
||||||
|
(jbyte) 13, (jlong) 3, (jbyte) 13, (jlong) 4);
|
||||||
|
if (l != 3033)
|
||||||
|
++fails;
|
||||||
|
|
||||||
method = (*env)->GetMethodID (env, klass, "void_f", "()V");
|
method = (*env)->GetMethodID (env, klass, "void_f", "()V");
|
||||||
(*env)->CallVoidMethod (env, _this, method);
|
(*env)->CallVoidMethod (env, _this, method);
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,12 @@ public class calls extends base
|
||||||
return q + 2023;
|
return q + 2023;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static long longpb_f (byte b1, long q1, byte b2, long q2,
|
||||||
|
byte b3, long q3)
|
||||||
|
{
|
||||||
|
return q1 + q2 + q3 + 3023;
|
||||||
|
}
|
||||||
|
|
||||||
public void void_f ()
|
public void void_f ()
|
||||||
{
|
{
|
||||||
System.out.println ("void");
|
System.out.println ("void");
|
||||||
|
|
Loading…
Reference in New Issue