aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@cygnus.com>2000-05-09 01:51:59 +0000
committerTom Tromey <tromey@gcc.gnu.org>2000-05-09 01:51:59 +0000
commit4c6a897328a8f500dba1470273bd657791ee47c6 (patch)
treed7ea94ce23ff98760b30bdc5876fc8b1e3052ba7
parent209bbe34b3c541273c81346df020613a7cfde615 (diff)
downloadgcc-4c6a897328a8f500dba1470273bd657791ee47c6.zip
gcc-4c6a897328a8f500dba1470273bd657791ee47c6.tar.gz
gcc-4c6a897328a8f500dba1470273bd657791ee47c6.tar.bz2
expr.c (build_jni_stub): Cache the result of _Jv_LookupJNIMethod.
* expr.c (build_jni_stub): Cache the result of _Jv_LookupJNIMethod. From-SVN: r33786
-rw-r--r--gcc/java/ChangeLog5
-rw-r--r--gcc/java/expr.c24
2 files changed, 25 insertions, 4 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog
index f4ce31e..0fc8b70 100644
--- a/gcc/java/ChangeLog
+++ b/gcc/java/ChangeLog
@@ -1,3 +1,8 @@
+2000-05-08 Tom Tromey <tromey@cygnus.com>
+
+ * expr.c (build_jni_stub): Cache the result of
+ _Jv_LookupJNIMethod.
+
2000-05-05 Alexandre Petit-Bianco <apbianco@cygnus.com>
* decl.c (predef_filenames_size): Now 7.
diff --git a/gcc/java/expr.c b/gcc/java/expr.c
index 7a92a8c..b417bac 100644
--- a/gcc/java/expr.c
+++ b/gcc/java/expr.c
@@ -1855,6 +1855,7 @@ build_jni_stub (method)
tree jni_func_type, tem;
tree env_var, res_var = NULL_TREE, block;
tree method_args, res_type;
+ tree meth_var;
tree klass = DECL_CONTEXT (method);
int from_class = ! CLASS_FROM_SOURCE_P (klass);
@@ -1867,13 +1868,25 @@ build_jni_stub (method)
DECL_EXTERNAL (method) = 0;
env_var = build_decl (VAR_DECL, get_identifier ("env"), ptr_type_node);
+ DECL_CONTEXT (env_var) = method;
+
if (TREE_TYPE (TREE_TYPE (method)) != void_type_node)
{
res_var = build_decl (VAR_DECL, get_identifier ("res"),
TREE_TYPE (TREE_TYPE (method)));
+ DECL_CONTEXT (res_var) = method;
TREE_CHAIN (env_var) = res_var;
}
+ push_obstacks (&permanent_obstack, &permanent_obstack);
+ meth_var = build_decl (VAR_DECL, get_identifier ("meth"), ptr_type_node);
+ TREE_STATIC (meth_var) = 1;
+ TREE_PUBLIC (meth_var) = 0;
+ DECL_EXTERNAL (meth_var) = 0;
+ make_decl_rtl (meth_var, NULL, 0);
+ meth_var = pushdecl_top_level (meth_var);
+ pop_obstacks ();
+
/* One strange way that the front ends are different is that they
store arguments differently. */
if (from_class)
@@ -1936,9 +1949,13 @@ build_jni_stub (method)
= build_pointer_type (build_function_type (TREE_TYPE (TREE_TYPE (method)),
arg_types));
- jnifunc = build (CALL_EXPR, ptr_type_node,
- build_address_of (soft_lookupjnimethod_node),
- lookup_arg, NULL_TREE);
+ jnifunc = build (COND_EXPR, ptr_type_node,
+ meth_var, meth_var,
+ build (MODIFY_EXPR, ptr_type_node,
+ meth_var,
+ build (CALL_EXPR, ptr_type_node,
+ build_address_of (soft_lookupjnimethod_node),
+ lookup_arg, NULL_TREE)));
/* Now we make the actual JNI call via the resulting function
pointer. */
@@ -2003,7 +2020,6 @@ build_jni_stub (method)
return block;
}
-
/* Expand an operation to extract from or store into a field.
IS_STATIC is 1 iff the field is static.
IS_PUTTING is 1 for putting into a field; 0 for getting from the field.