aboutsummaryrefslogtreecommitdiff
path: root/gcc/java
diff options
context:
space:
mode:
authorAndrew Haley <aph@redhat.com>2002-10-14 18:12:12 +0000
committerAndrew Haley <aph@redhat.com>2002-10-14 18:12:12 +0000
commit2835ac3617083a3fd54c6e90d78215989128701d (patch)
tree53b1e0a1a868f57ff4e3b0a8d8b515b98e20cf7d /gcc/java
parentc3b0a2179b199fbe4e4a83f90f06ce7fcfd38476 (diff)
2002-10-14 Andrew Haley <aph@redhat.com>
* tree-inline.c (remap_block): All local class initialization flags go in the outermost scope. (expand_call_inline): Call java_inlining_map_static_initializers. (expand_call_inline): Call java_inlining_merge_static_initializers. * java/lang.c (merge_init_test_initialization): New. (java_inlining_merge_static_initializers): New. (inline_init_test_initialization): New. (java_inlining_map_static_initializers): New. * tree-inline.c (expand_call_inline): Convert retvar to expected type. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@58129 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/java')
-rw-r--r--gcc/java/ChangeLog11
-rw-r--r--gcc/java/lang.c125
2 files changed, 130 insertions, 6 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog
index 5c22fe92a2e..307d225e240 100644
--- a/gcc/java/ChangeLog
+++ b/gcc/java/ChangeLog
@@ -1,3 +1,14 @@
+2002-10-14 Andrew Haley <aph@redhat.com>
+
+ * tree-inline.c (remap_block): All local class initialization
+ flags go in the outermost scope.
+ (expand_call_inline): Call java_inlining_map_static_initializers.
+ (expand_call_inline): Call java_inlining_merge_static_initializers.
+ * java/lang.c (merge_init_test_initialization): New.
+ (java_inlining_merge_static_initializers): New.
+ (inline_init_test_initialization): New.
+ (java_inlining_map_static_initializers): New.
+
2002-10-11 Mark Wielaard <mark@klomp.org>
* gcj.texi (Compatibility): Add Limitations and Extensions section.
diff --git a/gcc/java/lang.c b/gcc/java/lang.c
index 706b4f12776..6f19961f65c 100644
--- a/gcc/java/lang.c
+++ b/gcc/java/lang.c
@@ -41,6 +41,7 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */
#include "ggc.h"
#include "diagnostic.h"
#include "tree-inline.h"
+#include "splay-tree.h"
struct string_option
{
@@ -62,15 +63,18 @@ static void java_print_error_function PARAMS ((diagnostic_context *,
static int process_option_with_no PARAMS ((const char *,
const struct string_option *,
int));
-static tree java_tree_inlining_walk_subtrees PARAMS ((tree *,
- int *,
- walk_tree_fn,
- void *,
- void *));
+static tree java_tree_inlining_walk_subtrees PARAMS ((tree *,
+ int *,
+ walk_tree_fn,
+ void *,
+ void *));
static int java_unsafe_for_reeval PARAMS ((tree));
+static int merge_init_test_initialization PARAMS ((void * *,
+ void *));
+static int inline_init_test_initialization PARAMS ((void * *,
+ void *));
static bool java_can_use_bit_fields_p PARAMS ((void));
-
#ifndef TARGET_OBJECT_SUFFIX
# define TARGET_OBJECT_SUFFIX ".o"
#endif
@@ -928,4 +932,113 @@ java_unsafe_for_reeval (t)
return -1;
}
+/* Every call to a static constructor has an associated boolean
+ variable which is in the outermost scope of the calling method.
+ This variable is used to avoid multiple calls to the static
+ constructor for each class.
+
+ It looks somthing like this:
+
+ foo ()
+ {
+ boolean dummy = OtherClass.is_initialized;
+
+ ...
+
+ if (! dummy)
+ OtherClass.initialize();
+
+ ... use OtherClass.data ...
+ }
+
+ Each of these boolean variables has an entry in the
+ DECL_FUNCTION_INIT_TEST_TABLE of a method. When inlining a method
+ we must merge the DECL_FUNCTION_INIT_TEST_TABLE from the function
+ being linlined and create the boolean variables in the outermost
+ scope of the method being inlined into. */
+
+/* Create a mapping from a boolean variable in a method being inlined
+ to one in the scope of the method being inlined into. */
+
+static int
+merge_init_test_initialization (entry, x)
+ void * * entry;
+ void * x;
+{
+ struct treetreehash_entry *ite = (struct treetreehash_entry *) *entry;
+ splay_tree decl_map = (splay_tree)x;
+ splay_tree_node n;
+ tree *init_test_decl;
+
+ /* See if we have remapped this declaration. If we haven't there's
+ a bug in the inliner. */
+ n = splay_tree_lookup (decl_map, (splay_tree_key) ite->value);
+ if (! n)
+ abort ();
+
+ /* Create a new entry for the class and its remapped boolean
+ variable. If we already have a mapping for this class we've
+ already initialized it, so don't overwrite the value. */
+ init_test_decl = java_treetreehash_new
+ (DECL_FUNCTION_INIT_TEST_TABLE (current_function_decl), ite->key);
+ if (!*init_test_decl)
+ *init_test_decl = (tree)n->value;
+
+ return true;
+}
+
+/* Merge the DECL_FUNCTION_INIT_TEST_TABLE from the function we're
+ inlining. */
+
+void
+java_inlining_merge_static_initializers (fn, decl_map)
+ tree fn;
+ void *decl_map;
+{
+ htab_traverse
+ (DECL_FUNCTION_INIT_TEST_TABLE (fn),
+ merge_init_test_initialization, decl_map);
+}
+
+/* Lookup a DECL_FUNCTION_INIT_TEST_TABLE entry in the method we're
+ inlining into. If we already have a corresponding entry in that
+ class we don't need to create another one, so we create a mapping
+ from the variable in the inlined class to the corresponding
+ pre-existing one. */
+
+static int
+inline_init_test_initialization (entry, x)
+ void * * entry;
+ void * x;
+{
+ struct treetreehash_entry *ite = (struct treetreehash_entry *) *entry;
+ splay_tree decl_map = (splay_tree)x;
+
+ tree h = java_treetreehash_find
+ (DECL_FUNCTION_INIT_TEST_TABLE (current_function_decl), ite->key);
+ if (! h)
+ return true;
+
+ splay_tree_insert (decl_map,
+ (splay_tree_key) ite->value,
+ (splay_tree_value) h);
+
+ return true;
+}
+
+/* Look up the boolean variables in the DECL_FUNCTION_INIT_TEST_TABLE
+ of a method being inlined. For each hone, if we already have a
+ variable associated with the same class in the method being inlined
+ into, create a new mapping for it. */
+
+void
+java_inlining_map_static_initializers (fn, decl_map)
+ tree fn;
+ void *decl_map;
+{
+ htab_traverse
+ (DECL_FUNCTION_INIT_TEST_TABLE (fn),
+ inline_init_test_initialization, decl_map);
+}
+
#include "gt-java-lang.h"