diff options
author | Tom Tromey <tromey@cygnus.com> | 2000-05-09 01:51:59 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2000-05-09 01:51:59 +0000 |
commit | 4c6a897328a8f500dba1470273bd657791ee47c6 (patch) | |
tree | d7ea94ce23ff98760b30bdc5876fc8b1e3052ba7 /gcc/java/expr.c | |
parent | 209bbe34b3c541273c81346df020613a7cfde615 (diff) | |
download | gcc-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
Diffstat (limited to 'gcc/java/expr.c')
-rw-r--r-- | gcc/java/expr.c | 24 |
1 files changed, 20 insertions, 4 deletions
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. |