diff options
author | Alexandre Petit-Bianco <apbianco@redhat.com> | 2001-08-08 21:19:12 -0700 |
---|---|---|
committer | Alexandre Petit-Bianco <apbianco@gcc.gnu.org> | 2001-08-08 21:19:12 -0700 |
commit | 4009bb7d50ece62b164d3717d218ed16b51bddf4 (patch) | |
tree | 1c89de048bc9427066e52a374b05b125c6ec6ba2 /gcc/java/check-init.c | |
parent | 6351543d13052c85f87b6e1e8af0273279a5c771 (diff) | |
download | gcc-4009bb7d50ece62b164d3717d218ed16b51bddf4.zip gcc-4009bb7d50ece62b164d3717d218ed16b51bddf4.tar.gz gcc-4009bb7d50ece62b164d3717d218ed16b51bddf4.tar.bz2 |
check-init.c (flags.h): Include
2001-08-08 Alexandre Petit-Bianco <apbianco@redhat.com>
* check-init.c (flags.h): Include
(check_init): Don't report uninitialized static class
initialization flags, don't free bit index when doing static class
initialization optimization.
(check_for_initialization): Return type changed to `unsigned int.'
(attach_initialized_static_class): New function.
* class.c (add_method_1): Create the initialized static class
table if necessary.
(finish_class): Always emit deferred inline methods.
* decl.c (emit_init_test_initialization): Moved to expr.c
(complete_start_java_method): Don't traverse
DECL_FUNCTION_INIT_TEST_TABLE.
(lang_mark_tree): Mark hash tables in function decls.
* expr.c (emit_init_test_initialization): Moved from decl.c.
(build_class_init): Create LAG_DECL_SPECIFIC for the static class
initialization flag, set DECL_CONTEXT and
LOCAL_CLASS_INITIALIZATION_FLAG.
(java_lang_expand_expr): Emit initialization code for static class
initialized flags when entering block, if necessary.
* gcj.texi (-fno-optimize-static-class-initialization): Documented.
* java-tree.h (flag_optimize_sci): New global variable declaration.
(DECL_FUNCTION_INITIALIZED_CLASS_TABLE): New macro.
(DECL_FUNCTION_STATIC_METHOD_INVOCATION_COMPOUND): Likewise.
(LOCAL_FINAL_P): Fixed typo in comment.
(FINAL_VARIABLE_P): Likewise.
(LOCAL_CLASS_INITIALIZATIO_FLAG): New macro.
(LOCAL_CLASS_INITIALIZATIO_FLAG_P): Likewise.
(struct lang_decl): New fields `ict', `smic' and `cif.'
(check_for_initialization): New returned value for global.
(attach_initialized_static_class): New global function.
(STATIC_CLASS_INIT_OPT_P): New macro.
* lang-options.h (-fno-optimize-static-class-initialization): New flag.
* lang.c (java_decode_option): Handle
`-fno-optimize-static-class-initialization'
* parse.y (start_complete_expand_method): New function.
(java_expand_method_bodies): Likewise.
(attach_init_test_initialization_flags): Likewise.
(adjust_init_test_initialization): Likewise.
(emit_test_initialization): Likewise.
(java_complete_expand_methods): Nullify abstract and native method
bodies.
(java_complete_expand_method): New locals `fbody', `block_body'
and `exception_copy.' Reorganized: directly return on empty method
bodies, call `start_complete_expand_method', remember definitely
initialized static class in function, don't expand method bodies.
(java_expand_classes): Call `java_expand_method_bodies' before
`finish_class' when compiling to native.
(resolve_expression_name): Use `orig' after building outer class
field access.
(patch_invoke): Remember static method invokations.
(http://gcc.gnu.org/ml/gcc-patches/2001-08/msg00454.html)
From-SVN: r44733
Diffstat (limited to 'gcc/java/check-init.c')
-rw-r--r-- | gcc/java/check-init.c | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/gcc/java/check-init.c b/gcc/java/check-init.c index 0e340dd..b108c45 100644 --- a/gcc/java/check-init.c +++ b/gcc/java/check-init.c @@ -25,6 +25,7 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */ #include "config.h" #include "system.h" #include "tree.h" +#include "flags.h" /* Needed for optimize. */ #include "java-tree.h" #include "toplev.h" /* Needed for fatal. */ @@ -370,7 +371,12 @@ check_init (exp, before) if (! FIELD_STATIC (exp) && DECL_NAME (exp) != NULL_TREE) { int index = DECL_BIT_INDEX (exp); - if (index >= 0 && ! SET_P (before, index)) + /* We don't want to report and mark as non initialized flags + the are, they will be marked initialized later on when + assigned to `true.' */ + if ((STATIC_CLASS_INIT_OPT_P () + && ! LOCAL_CLASS_INITIALIZATION_FLAG_P (exp)) + && index >= 0 && ! SET_P (before, index)) { parse_error_context (wfl, "Variable `%s' may not have been initialized", @@ -398,8 +404,13 @@ check_init (exp, before) if (index >= 0) SET_BIT (before, index); - /* Minor optimization. See comment for start_current_locals. */ - if (index >= start_current_locals + /* Minor optimization. See comment for start_current_locals. + If we're optimizing for class initialization, we keep + this information to check whether the variable is + definitely assigned when once we checked the whole + function. */ + if (! STATIC_CLASS_INIT_OPT_P () + && index >= start_current_locals && index == num_current_locals - 1) { num_current_locals--; @@ -732,10 +743,35 @@ check_init (exp, before) } } -void +unsigned int check_for_initialization (body) tree body; { word before = 0; check_init (body, &before); + return before; +} + +/* Call for every element in DECL_FUNCTION_INITIALIZED_CLASS_TABLE of + a method to consider whether the type indirectly described by ENTRY + is definitly initialized and thus remembered as such. */ + +bool +attach_initialized_static_class (entry, ptr) + struct hash_entry *entry; + PTR ptr; +{ + struct init_test_hash_entry *ite = (struct init_test_hash_entry *) entry; + tree fndecl = DECL_CONTEXT (ite->init_test_decl); + int index = DECL_BIT_INDEX (ite->init_test_decl); + + /* If the initializer flag has been definitly assigned (not taking + into account its first mandatory assignment which has been + already added but escaped analysis.) */ + if (fndecl && METHOD_STATIC (fndecl) + && (DECL_INITIAL (ite->init_test_decl) == boolean_true_node + || (index >= 0 && SET_P (((word *) ptr), index)))) + hash_lookup (&DECL_FUNCTION_INITIALIZED_CLASS_TABLE (fndecl), + entry->key, TRUE, NULL); + return true; } |