decl.c (java_init_decl_processing): Change soft_lookupjnimethod_node to reflect the...
authorRanjit Mathew <rmathew@hotmail.com>
Wed, 12 Feb 2003 23:39:50 +0000 (23:39 +0000)
committerTom Tromey <tromey@gcc.gnu.org>
Wed, 12 Feb 2003 23:39:50 +0000 (23:39 +0000)
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

gcc/java/ChangeLog
gcc/java/decl.c
gcc/java/expr.c

index 01d8e212a97766b2b6ab200ae682117d7014bf9d..084a704aa621afa4bb46f60282716dbf386d0f7e 100644 (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
index 218d4baae925cc676425cd6c2800edd0d4bb161c..05f80ea03c58fa5b1f2e1ef127380e8b238f0513 100644 (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),
index 5ce92e00376d703550105cc21fc43e647a70f101..48e67dfe2278dc1ab0f84ccb4ba39c4a8b7d26a7 100644 (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);
+
+#ifdef MODIFY_JNI_METHOD_CALL
+  tem = MODIFY_JNI_METHOD_CALL (tem);
+#endif
 
-  jni_func_type
-    = build_pointer_type (build_function_type (TREE_TYPE (TREE_TYPE (method)),
-                                              arg_types));
+  jni_func_type = build_pointer_type (tem);
 
   jnifunc = build (COND_EXPR, ptr_type_node,
                   meth_var, meth_var,