re PR java/18305 (Class initialization optimization is not done when compiled from...
authorAndrew Pinski <pinskia@physics.uc.edu>
Fri, 26 Nov 2004 18:04:45 +0000 (18:04 +0000)
committerAndrew Pinski <pinskia@gcc.gnu.org>
Fri, 26 Nov 2004 18:04:45 +0000 (10:04 -0800)
2004-11-26  Andrew Pinski  <pinskia@physics.uc.edu>

        PR java/18305
        * decl.c (end_java_method): Call
        attach_init_test_initialization_flags on all the init_decls.
        * parse.y (attach_init_test_initialization_flags): Move to ...
        * expr.c (attach_init_test_initialization_flags): here and
        support BIND_EXPR also.
        * java-tree.h (attach_init_test_initialization_flags): Prototype.
        * jcf-parse.c (parse_class_file): Don't disable class init
        optimization.

From-SVN: r91343

gcc/java/ChangeLog
gcc/java/decl.c
gcc/java/expr.c
gcc/java/java-tree.h
gcc/java/jcf-parse.c
gcc/java/parse.y

index ce06a29633e6d9b31b6b80df06e5f0164f2ad289..74a18c994fe044e6973b85d8c2c08168ebbe0bbc 100644 (file)
@@ -1,3 +1,15 @@
+2004-11-26  Andrew Pinski  <pinskia@physics.uc.edu>
+
+       PR java/18305
+       * decl.c (end_java_method): Call
+       attach_init_test_initialization_flags on all the init_decls.
+       * parse.y (attach_init_test_initialization_flags): Move to ...
+       * expr.c (attach_init_test_initialization_flags): here and
+       support BIND_EXPR also.
+       * java-tree.h (attach_init_test_initialization_flags): Prototype.
+       * jcf-parse.c (parse_class_file): Don't disable class init
+       optimization.
+
 2004-11-25  Joseph S. Myers  <joseph@codesourcery.com>
 
        * gjavah.c, jcf-dump.c, jv-scan.c, jvspec.c: Avoid ` as left quote
index 54f788e0d7dbe628d243180e695c36480e166b40..103a11225e9cbcb5b6a431ff517bc20fe57c1516 100644 (file)
@@ -1931,6 +1931,17 @@ end_java_method (void)
   poplevel (1, 0, 1);
 
   BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl;
+  
+  if (DECL_SAVED_TREE (fndecl))
+    {
+      tree fbody, block_body;
+      /* Before we check initialization, attached all class initialization
+        variable to the block_body */
+      fbody = DECL_SAVED_TREE (fndecl);
+      block_body = BIND_EXPR_BODY (fbody);
+      htab_traverse (DECL_FUNCTION_INIT_TEST_TABLE (fndecl),
+                    attach_init_test_initialization_flags, block_body);
+    }
 
   flag_unit_at_a_time = 0;
   finish_method (fndecl);
index 305ab5bdfee0fc16c0cf617d81ae6f26e0feba15..0fef94db9d488665a5ed9489fefdb05365bb4669 100644 (file)
@@ -1935,6 +1935,39 @@ pop_arguments (tree arg_types)
   abort ();
 }
 
+/* Attach to PTR (a block) the declaration found in ENTRY. */
+
+int
+attach_init_test_initialization_flags (void **entry, void *ptr)
+{
+  tree block = (tree)ptr;
+  struct treetreehash_entry *ite = (struct treetreehash_entry *) *entry;
+
+  if (block != error_mark_node)
+    {
+      if (TREE_CODE (block) == BIND_EXPR)
+        {
+         tree body = BIND_EXPR_BODY (block);
+         TREE_CHAIN (ite->value) = BIND_EXPR_VARS (block);
+         BIND_EXPR_VARS (block) = ite->value;
+         body = build2 (COMPOUND_EXPR, void_type_node,
+                        build1 (DECL_EXPR, void_type_node, ite->value), body);
+         BIND_EXPR_BODY (block) = body;
+       }
+      else
+       {
+         tree body = BLOCK_SUBBLOCKS (block);
+         TREE_CHAIN (ite->value) = BLOCK_EXPR_DECLS (block);
+         BLOCK_EXPR_DECLS (block) = ite->value;
+         body = build2 (COMPOUND_EXPR, void_type_node,
+                        build1 (DECL_EXPR, void_type_node, ite->value), body);
+         BLOCK_SUBBLOCKS (block) = body;
+        }
+      
+    }
+  return true;
+}
+
 /* Build an expression to initialize the class CLAS.
    if EXPR is non-NULL, returns an expression to first call the initializer
    (if it is needed) and then calls EXPR. */
index e8144ee908c2eefda9a2631d039ce6b24db2e9e6..54cf01bbc0c54d0a89b1236c6fd12c76b9d3d80e 100644 (file)
@@ -1255,6 +1255,7 @@ extern void initialize_builtins (void);
 extern tree lookup_name (tree);
 extern tree build_known_method_ref (tree, tree, tree, tree, tree);
 extern tree build_class_init (tree, tree);
+extern int attach_init_test_initialization_flags (void **, void *);
 extern tree build_invokevirtual (tree, tree);
 extern tree build_invokeinterface (tree, tree);
 extern tree build_jni_stub (tree);
index a7cd57a6d77acdc92057d0be0e7a1d765ee91a32..429e3db3a22c1abb426b832ee3dc671c7a9cfc4a 100644 (file)
@@ -827,10 +827,6 @@ parse_class_file (void)
   file_start_location = input_location;
   (*debug_hooks->start_source_file) (input_line, input_filename);
 
-  /* Currently we always have to emit calls to _Jv_InitClass when
-     compiling from class files.  */
-  always_initialize_class_p = 1;
-
   gen_indirect_dispatch_tables (current_class);
 
   java_mark_class_local (current_class);
index 91776c6f7f53cc6f8efee11fe79cc04ffcbdb0b5..2b3d3a4a795db23191d4b457bd4821350db2a0b9 100644 (file)
@@ -347,7 +347,6 @@ static tree build_dot_class_method_invocation (tree, tree);
 static void create_new_parser_context (int);
 static tree maybe_build_class_init_for_field (tree, tree);
 
-static int attach_init_test_initialization_flags (void **, void *);
 static int emit_test_initialization (void **, void *);
 
 static char *string_convert_int_cst (tree);
@@ -16345,26 +16344,6 @@ init_src_parse (void)
 /* This section deals with the functions that are called when tables
    recording class initialization information are traversed.  */
 
-/* Attach to PTR (a block) the declaration found in ENTRY. */
-
-static int
-attach_init_test_initialization_flags (void **entry, void *ptr)
-{
-  tree block = (tree)ptr;
-  struct treetreehash_entry *ite = (struct treetreehash_entry *) *entry;
-
-  if (block != error_mark_node)
-    {
-      tree body = BLOCK_SUBBLOCKS (block);
-      TREE_CHAIN (ite->value) = BLOCK_EXPR_DECLS (block);
-      BLOCK_EXPR_DECLS (block) = ite->value;
-      body = build2 (COMPOUND_EXPR, void_type_node,
-                     build1 (DECL_EXPR, void_type_node, ite->value), body);
-      BLOCK_SUBBLOCKS (block) = body;
-    }
-  return true;
-}
-
 /* This function is called for each class that is known definitely
    initialized when a given static method was called. This function
    augments a compound expression (INFO) storing all assignment to