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
This commit is contained in:
Andrew Pinski 2004-11-26 18:04:45 +00:00 committed by Andrew Pinski
parent e57df6fed9
commit 532815a787
6 changed files with 57 additions and 25 deletions

View 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

View 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);

View 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. */

View 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);

View 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);

View 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