diff options
author | Andrew Pinski <pinskia@physics.uc.edu> | 2004-11-26 18:04:45 +0000 |
---|---|---|
committer | Andrew Pinski <pinskia@gcc.gnu.org> | 2004-11-26 10:04:45 -0800 |
commit | 532815a787849962ca2f2101aef12ec1d57b2cfd (patch) | |
tree | fd510bfba4be46b5f8449a5f32932ed69e327402 | |
parent | e57df6fed97f4e7dd58dd00a1946c698b5a22d92 (diff) | |
download | gcc-532815a787849962ca2f2101aef12ec1d57b2cfd.zip gcc-532815a787849962ca2f2101aef12ec1d57b2cfd.tar.gz gcc-532815a787849962ca2f2101aef12ec1d57b2cfd.tar.bz2 |
re PR java/18305 (Class initialization optimization is not done when compiled from .class)
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
-rw-r--r-- | gcc/java/ChangeLog | 12 | ||||
-rw-r--r-- | gcc/java/decl.c | 11 | ||||
-rw-r--r-- | gcc/java/expr.c | 33 | ||||
-rw-r--r-- | gcc/java/java-tree.h | 1 | ||||
-rw-r--r-- | gcc/java/jcf-parse.c | 4 | ||||
-rw-r--r-- | gcc/java/parse.y | 21 |
6 files changed, 57 insertions, 25 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index ce06a29..74a18c9 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -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 diff --git a/gcc/java/decl.c b/gcc/java/decl.c index 54f788e..103a112 100644 --- a/gcc/java/decl.c +++ b/gcc/java/decl.c @@ -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); diff --git a/gcc/java/expr.c b/gcc/java/expr.c index 305ab5b..0fef94d 100644 --- a/gcc/java/expr.c +++ b/gcc/java/expr.c @@ -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. */ diff --git a/gcc/java/java-tree.h b/gcc/java/java-tree.h index e8144ee..54cf01b 100644 --- a/gcc/java/java-tree.h +++ b/gcc/java/java-tree.h @@ -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); diff --git a/gcc/java/jcf-parse.c b/gcc/java/jcf-parse.c index a7cd57a..429e3db 100644 --- a/gcc/java/jcf-parse.c +++ b/gcc/java/jcf-parse.c @@ -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); diff --git a/gcc/java/parse.y b/gcc/java/parse.y index 91776c6..2b3d3a4 100644 --- a/gcc/java/parse.y +++ b/gcc/java/parse.y @@ -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 |