diff options
author | aph <aph@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-02-07 18:28:20 +0000 |
---|---|---|
committer | aph <aph@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-02-07 18:28:20 +0000 |
commit | 0ab206a123dabe894de40f135233f4d657794b85 (patch) | |
tree | 1afcda01214ff45731eb75ffc792a20cf75aa0c2 | |
parent | 7ff59ae90b930096347695fb5ed51d87663749da (diff) | |
download | gcc-0ab206a123dabe894de40f135233f4d657794b85.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@121695 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/java/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/java/class.c | 9 | ||||
-rw-r--r-- | gcc/java/expr.c | 17 | ||||
-rw-r--r-- | gcc/java/java-tree.h | 1 |
4 files changed, 34 insertions, 0 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 1361a6e000b..03c4f962e15 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,10 @@ +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. + 2007-02-06 Tom Tromey <tromey@redhat.com> PR java/30714: diff --git a/gcc/java/class.c b/gcc/java/class.c index ec94a3c9534..804c239fcfa 100644 --- a/gcc/java/class.c +++ b/gcc/java/class.c @@ -1047,6 +1047,15 @@ cache_this_class_ref (tree fndecl) } } +/* Remove the reference to the local variable that holds the current + class$. */ + +void +uncache_this_class_ref (tree fndecl ATTRIBUTE_UNUSED) +{ + this_classdollar = build_classdollar_field (output_class); +} + /* Build a reference to the class TYPE. Also handles primitive types and array types. */ diff --git a/gcc/java/expr.c b/gcc/java/expr.c index f7d35c68a25..ed5103f5988 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. */ diff --git a/gcc/java/java-tree.h b/gcc/java/java-tree.h index ab3ff47e467..732e0cde115 100644 --- a/gcc/java/java-tree.h +++ b/gcc/java/java-tree.h @@ -1130,6 +1130,7 @@ extern int get_interface_method_index (tree, tree); extern tree layout_class_method (tree, tree, tree, tree); extern void layout_class_methods (tree); extern void cache_this_class_ref (tree); +extern void uncache_this_class_ref (tree); extern tree build_class_ref (tree); extern tree build_dtable_decl (tree); extern tree build_internal_class_name (tree); |