decl.c (java_init_decl_processing): Change soft_lookupjnimethod_node to reflect the change in signature of...

2003-02-12  Ranjit Mathew  <rmathew@hotmail.com>

	* decl.c (java_init_decl_processing): Change
	soft_lookupjnimethod_node to reflect the change in
	signature of _Jv_LookupJNIMethod in libjava/jni.cc
	* expr.c (build_jni_stub): Calculate and pass the size
	on the stack of the arguments to a JNI function. Use
	new target macro MODIFY_JNI_METHOD_CALL to allow a
	target to modify the call to a JNI method.

From-SVN: r62795
This commit is contained in:
Ranjit Mathew 2003-02-12 23:39:50 +00:00 committed by Tom Tromey
parent 2bbfc54272
commit 697ec3260d
3 changed files with 40 additions and 10 deletions

View file

@ -1,3 +1,13 @@
2003-02-12 Ranjit Mathew <rmathew@hotmail.com>
* decl.c (java_init_decl_processing): Change
soft_lookupjnimethod_node to reflect the change in
signature of _Jv_LookupJNIMethod in libjava/jni.cc
* expr.c (build_jni_stub): Calculate and pass the size
on the stack of the arguments to a JNI function. Use
new target macro MODIFY_JNI_METHOD_CALL to allow a
target to modify the call to a JNI method.
2003-02-08 Roger Sayle <roger@eyesopen.com>
* jcf-io.c (java_or_class_file): Use libiberty's lbasename

View file

@ -868,7 +868,9 @@ java_init_decl_processing (void)
t = tree_cons (NULL_TREE, object_ptr_type_node,
tree_cons (NULL_TREE, ptr_type_node,
tree_cons (NULL_TREE, ptr_type_node, endlink)));
tree_cons (NULL_TREE, ptr_type_node,
tree_cons (NULL_TREE, int_type_node,
endlink))));
soft_lookupjnimethod_node
= builtin_function ("_Jv_LookupJNIMethod",
build_function_type (ptr_type_node, t),

View file

@ -2087,6 +2087,8 @@ build_jni_stub (tree method)
tree method_args, res_type;
tree meth_var;
int args_size = 0;
tree klass = DECL_CONTEXT (method);
int from_class = ! CLASS_FROM_SOURCE_P (klass);
klass = build_class_ref (klass);
@ -2148,7 +2150,16 @@ build_jni_stub (tree method)
special way, we would do that here. */
args = NULL_TREE;
for (tem = method_args; tem != NULL_TREE; tem = TREE_CHAIN (tem))
args = tree_cons (NULL_TREE, tem, args);
{
int arg_bits = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (tem)));
#ifdef PARM_BOUNDARY
arg_bits = (((arg_bits + PARM_BOUNDARY - 1) / PARM_BOUNDARY)
* PARM_BOUNDARY);
#endif
args_size += (arg_bits / BITS_PER_UNIT);
args = tree_cons (NULL_TREE, tem, args);
}
args = nreverse (args);
arg_types = TYPE_ARG_TYPES (TREE_TYPE (method));
@ -2157,31 +2168,38 @@ build_jni_stub (tree method)
available in the argument list. */
if (METHOD_STATIC (method))
{
args_size += int_size_in_bytes (TREE_TYPE (klass));
args = tree_cons (NULL_TREE, klass, args);
arg_types = tree_cons (NULL_TREE, object_ptr_type_node, arg_types);
}
/* The JNIEnv structure is the first argument to the JNI function. */
args_size += int_size_in_bytes (TREE_TYPE (env_var));
args = tree_cons (NULL_TREE, env_var, args);
arg_types = tree_cons (NULL_TREE, ptr_type_node, arg_types);
/* We call _Jv_LookupJNIMethod to find the actual underlying
function pointer. _Jv_LookupJNIMethod will throw the appropriate
exception if this function is not found at runtime. */
tem = build_tree_list (NULL_TREE, build_int_2 (args_size, 0));
method_sig = build_java_signature (TREE_TYPE (method));
lookup_arg =
build_tree_list (NULL_TREE,
build_utf8_ref (unmangle_classname
(IDENTIFIER_POINTER (method_sig),
IDENTIFIER_LENGTH (method_sig))));
lookup_arg = tree_cons (NULL_TREE,
build_utf8_ref (unmangle_classname
(IDENTIFIER_POINTER (method_sig),
IDENTIFIER_LENGTH (method_sig))),
tem);
tem = DECL_NAME (method);
lookup_arg
= tree_cons (NULL_TREE, klass,
tree_cons (NULL_TREE, build_utf8_ref (tem), lookup_arg));
tem = build_function_type (TREE_TYPE (TREE_TYPE (method)), arg_types);
jni_func_type
= build_pointer_type (build_function_type (TREE_TYPE (TREE_TYPE (method)),
arg_types));
#ifdef MODIFY_JNI_METHOD_CALL
tem = MODIFY_JNI_METHOD_CALL (tem);
#endif
jni_func_type = build_pointer_type (tem);
jnifunc = build (COND_EXPR, ptr_type_node,
meth_var, meth_var,