diff options
author | Hans Boehm <Hans_Boehm@hp.com> | 2003-02-28 17:26:29 +0000 |
---|---|---|
committer | Hans Boehm <hboehm@gcc.gnu.org> | 2003-02-28 17:26:29 +0000 |
commit | a6fdf2d3bf5c3802e1e3982eed1bee911815b88f (patch) | |
tree | 123264cc97cae659f3f16d4926edb3a263796a95 /libjava/java | |
parent | b8c53e96add72de918819b4d13308715faeaa7af (diff) | |
download | gcc-a6fdf2d3bf5c3802e1e3982eed1bee911815b88f.zip gcc-a6fdf2d3bf5c3802e1e3982eed1bee911815b88f.tar.gz gcc-a6fdf2d3bf5c3802e1e3982eed1bee911815b88f.tar.bz2 |
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
Diffstat (limited to 'libjava/java')
-rw-r--r-- | libjava/java/lang/reflect/natMethod.cc | 47 |
1 files changed, 19 insertions, 28 deletions
diff --git a/libjava/java/lang/reflect/natMethod.cc b/libjava/java/lang/reflect/natMethod.cc index 9b697d2..c0f7077 100644 --- a/libjava/java/lang/reflect/natMethod.cc +++ b/libjava/java/lang/reflect/natMethod.cc @@ -358,46 +358,30 @@ _Jv_CallAnyMethodA (jobject obj, obj = JvAllocObject (return_type); } - int i = 0; - int size = 0; - if (needs_this) - { - // The `NULL' type is `Object'. - 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); - } - + const int size_per_arg = sizeof(jvalue); 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 *)); + char *p = (char *) __builtin_alloca (param_count * size_per_arg); + // Overallocate to get correct alignment. + void **values = (void **) + __builtin_alloca (param_count * sizeof (void *)); - i = 0; + int i = 0; if (needs_this) { + // The `NULL' type is `Object'. + argtypes[i] = get_ffi_type (NULL); values[i] = p; memcpy (p, &obj, sizeof (jobject)); - p += sizeof (jobject); + p += size_per_arg; ++i; } for (int arg = 0; i < param_count; ++i, ++arg) { int tsize; + + argtypes[i] = get_ffi_type (paramelts[arg]); if (paramelts[arg]->isPrimitive()) tsize = paramelts[arg]->size(); else @@ -406,9 +390,16 @@ _Jv_CallAnyMethodA (jobject obj, // Copy appropriate bits from the jvalue into the ffi array. // FIXME: we could do this copying all in one loop, above, by // over-allocating a bit. + // How do we do this without breaking big-endian platforms? values[i] = p; 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; |