aboutsummaryrefslogtreecommitdiff
path: root/gcc/java/expr.c
diff options
context:
space:
mode:
authorAndrew Haley <aph@redhat.com>2007-02-07 18:28:20 +0000
committerAndrew Haley <aph@gcc.gnu.org>2007-02-07 18:28:20 +0000
commit56c9f04bb7bfff97a61286bcb792e1ed8c66d50f (patch)
tree1afcda01214ff45731eb75ffc792a20cf75aa0c2 /gcc/java/expr.c
parent08452f45531ca2ec479e61b9f7e37d3fadd95a7b (diff)
downloadgcc-56c9f04bb7bfff97a61286bcb792e1ed8c66d50f.zip
gcc-56c9f04bb7bfff97a61286bcb792e1ed8c66d50f.tar.gz
gcc-56c9f04bb7bfff97a61286bcb792e1ed8c66d50f.tar.bz2
class.c (uncache_this_class_ref): New.
2007-02-07 Andrew Haley <aph@redhat.com> * class.c (uncache_this_class_ref): New. * expr.c (build_jni_stub): Initialize the class. (expand_byte_code): Call uncache_this_class_ref after generating code. From-SVN: r121695
Diffstat (limited to 'gcc/java/expr.c')
-rw-r--r--gcc/java/expr.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/gcc/java/expr.c b/gcc/java/expr.c
index f7d35c6..ed5103f 100644
--- a/gcc/java/expr.c
+++ b/gcc/java/expr.c
@@ -2799,6 +2799,21 @@ build_jni_stub (tree method)
build1 (RETURN_EXPR, res_type, res_var));
TREE_SIDE_EFFECTS (body) = 1;
+ /* Prepend class initialization for static methods reachable from
+ other classes. */
+ if (METHOD_STATIC (method)
+ && (! METHOD_PRIVATE (method)
+ || INNER_CLASS_P (DECL_CONTEXT (method))))
+ {
+ tree init = build3 (CALL_EXPR, void_type_node,
+ build_address_of (soft_initclass_node),
+ build_tree_list (NULL_TREE,
+ klass),
+ NULL_TREE);
+ body = build2 (COMPOUND_EXPR, void_type_node, init, body);
+ TREE_SIDE_EFFECTS (body) = 1;
+ }
+
bind = build3 (BIND_EXPR, void_type_node, BLOCK_VARS (block),
body, block);
return bind;
@@ -3227,6 +3242,8 @@ expand_byte_code (JCF *jcf, tree method)
maybe_poplevels (PC);
} /* for */
+ uncache_this_class_ref (method);
+
if (dead_code_index != -1)
{
/* We've just reached the end of a region of dead code. */