diff options
author | Geoffrey Keating <geoffk@redhat.com> | 2002-06-04 07:11:05 +0000 |
---|---|---|
committer | Geoffrey Keating <geoffk@gcc.gnu.org> | 2002-06-04 07:11:05 +0000 |
commit | e2500fedef1a1c5b9e818fd1e2c281adff80df4a (patch) | |
tree | 720630adca0f6b357e05c4feb8cbe33d556925ce /gcc/java | |
parent | c2ae66169b8326bbf9b1dfa63083d2560fea7ddf (diff) | |
download | gcc-e2500fedef1a1c5b9e818fd1e2c281adff80df4a.zip gcc-e2500fedef1a1c5b9e818fd1e2c281adff80df4a.tar.gz gcc-e2500fedef1a1c5b9e818fd1e2c281adff80df4a.tar.bz2 |
Merge from pch-branch up to tag pch-commit-20020603.
From-SVN: r54232
Diffstat (limited to 'gcc/java')
-rw-r--r-- | gcc/java/ChangeLog | 92 | ||||
-rw-r--r-- | gcc/java/Make-lang.in | 29 | ||||
-rw-r--r-- | gcc/java/builtins.c | 20 | ||||
-rw-r--r-- | gcc/java/check-init.c | 30 | ||||
-rw-r--r-- | gcc/java/class.c | 140 | ||||
-rw-r--r-- | gcc/java/config-lang.in | 2 | ||||
-rw-r--r-- | gcc/java/constants.c | 12 | ||||
-rw-r--r-- | gcc/java/decl.c | 76 | ||||
-rw-r--r-- | gcc/java/expr.c | 75 | ||||
-rw-r--r-- | gcc/java/java-tree.h | 145 | ||||
-rw-r--r-- | gcc/java/jcf-parse.c | 6 | ||||
-rw-r--r-- | gcc/java/jcf-write.c | 11 | ||||
-rw-r--r-- | gcc/java/lang.c | 24 | ||||
-rw-r--r-- | gcc/java/mangle.c | 15 | ||||
-rw-r--r-- | gcc/java/parse.y | 271 |
15 files changed, 468 insertions, 480 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 1de79df..5a7fc58 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,95 @@ +2002-06-03 Geoffrey Keating <geoffk@redhat.com> + + * check-init.c (attach_initialized_static_class): Delete, unused. + * parse.y: Use htab_t instead of struct hashtable, update + all uses. + * java-tree.h: Include hashtab.h instead of hash.h. + (struct lang_decl_func): Use htab_t, set up for gengtype. + (struct init_test_hash_entry): Delete. + (struct treetreehash_entry): New. + (java_treetreehash_find): New + (java_treetreehash_new): New prototype. + (java_treetreehash_create): New prototype. + (java_mark_tree): Delete prototype. + (java_hash_hash_tree_node): Delete prototype. + (java_hash_compare_tree_node): Delete prototype. + (attach_initialized_static_class): Delete prototype. + * expr.c (build_class_init): Update to use java_treetreehash + functions. + (java_expand_expr): Update to use htab_t. + (emit_init_test_initialization): Likewise. + * decl.c (java_mark_tree): Delete. + * class.c (init_test_hash_newfunc): Delete. + (java_hash_hash_tree_node): Delete. + (java_hash_compare_tree_node): Delete. + (add_method_1): Update to use java_treetreehash functions. + (JAVA_TREEHASHHASH_H): New macro. + (java_treetreehash_hash): New function. + (java_treetreehash_compare): New function. + (java_treetreehash_find): New function. + (java_treetreehash_new): New function. + (java_treetreehash_create): New function. + * Make-lang.in (JAVA_TREE_H): Replace hash.h by HASHTAB_H. + + * Make-lang.in (java/parse.o): Depend on debug.h. + * java-tree.h (struct lang_identifier): Use gengtype. + (union lang_tree_node): New. + (struct lang_decl_func): Use gengtype. + (struct lang_decl_var): Likewise. + (struct lang_decl): Likewise. + * parse.y: Include debug.h. + * lang.c (LANG_HOOKS_MARK_TREE): Delete. + + * lang.c (struct language_function): New dummy structure. + + * java-tree.h (MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC): Set + descriminator for DECL_LANG_SPECIFIC. + (struct lang_decl_func): Rename from struct lang_decl. + (enum lang_decl_desc): New. + (struct lang_decl): Make it a union. Update all the accessor macros. + (struct lang_type): Use gengtype. + * class.c (add_method_1): Set descriminator for DECL_LANG_SPECIFIC. + * decl.c (java_dup_lang_specific_decl): All lang_decl structures + are now the same size. + (lang_mark_tree): Use gengtype to mark TYPE_LANG_SPECIFIC; + use discriminator to mark DECL_LANG_SPECIFIC. + + * Make-lang.in (gt-java-builtins.h): New rule. + (java/builtins.o): Add dependency on gt-<filename>.h. + * builtins.c: Use gengtype for roots. + (union string_or_tree): Use gengtype. + (struct builtin_record): Use gengtype. + * config-lang.in (gtfiles): Add builtins.c. + + * Make-lang.in (gt-java-class.h, gt-java-constants.h, + gt-java-decl.h, gt-java-expr.h, gt-java-jcf-parse.h, + gt-java-jcf-write.h, gt-java-lang.h, gt-java-mangle.h, + gt-java-parse.h, gtype-java.h): Add rules to generate. + (parse.o): Add dependency on gt-java-parse.h, gt-java.h. + (class.o): Add dependency on gt-*.h. + (constants.o): Likewise. + (decl.o): Likewise. + (expr.o): Likewise. + (jcf-parse.o): Likewise. + (jcf-write.o): Likewise. + (lang.o): Likewise. + * config-lang.in (gtfiles): New. + * class.c: Replace uses of ggc_add_* with GTY markers. Include gt-*.h. + * constants.c: Replace uses of ggc_add_* with GTY markers. + Include gt-*.h. + * decl.c: Replace uses of ggc_add_* with GTY markers. Include gt-*.h. + * expr.c: Replace uses of ggc_add_* with GTY markers. Include gt-*.h. + * java-tree.h: Replace uses of ggc_add_* with GTY markers. + * jcf-parse.c: Replace uses of ggc_add_* with GTY markers. + Include gt-*.h. + * jcf-write.c: Replace uses of ggc_add_* with GTY markers. + Include gt-*.h. + * lang.c: Replace uses of ggc_add_* with GTY markers. Include gt-*.h. + * mangle.c: Replace uses of ggc_add_* with GTY markers. Include + gt-*.h. + * parse.y: Replace uses of ggc_add_* with GTY markers. Include gt-*.h. + Include gtype-java.h. + 2002-06-02 Tom Tromey <tromey@redhat.com> Fix for PR java/5913: diff --git a/gcc/java/Make-lang.in b/gcc/java/Make-lang.in index c8bce83..05dc9ea 100644 --- a/gcc/java/Make-lang.in +++ b/gcc/java/Make-lang.in @@ -98,6 +98,11 @@ $(srcdir)/java/keyword.h: $(srcdir)/java/keyword.gperf exit 1; } ; \ mv -f k$$$$.h keyword.h) +gt-java-class.h gt-java-constants.h gt-java-decl.h : s-gtype ; @true +gt-java-expr.h gt-java-jcf-parse.h gt-java-jcf-write.h : s-gtype ; @true +gt-java-lang.h gt-java-mangle.h gt-java-parse.h : s-gtype ; @true +gt-java-builtins.h gtype-java.h : s-gtype ; @true + # Executables built by this Makefile: JAVA_OBJS = java/parse.o java/class.o java/decl.o java/expr.o \ java/constants.o java/lang.o java/typeck.o java/except.o java/verify.o \ @@ -251,11 +256,12 @@ java.stage4: stage4-start # # .o:.h dependencies. -JAVA_TREE_H = $(TREE_H) java/java-tree.h java/java-tree.def +JAVA_TREE_H = $(TREE_H) $(HASHTAB_H) java/java-tree.h java/java-tree.def JAVA_LEX_C = java/lex.c java/keyword.h java/chartables.h java/parse.o: java/parse.c java/jcf-reader.c $(CONFIG_H) $(SYSTEM_H) \ - function.h $(JAVA_TREE_H) $(JAVA_LEX_C) java/parse.h java/lex.h $(GGC_H) + function.h $(JAVA_TREE_H) $(JAVA_LEX_C) java/parse.h java/lex.h $(GGC_H) \ + debug.h gt-java-parse.h gtype-java.h java/jcf-dump.o: $(CONFIG_H) $(SYSTEM_H) $(JAVA_TREE_H) java/jcf-dump.c \ java/jcf-reader.c java/jcf.h java/javaop.h java/javaop.def version.h java/gjavah.o: $(CONFIG_H) $(SYSTEM_H) $(JAVA_TREE_H) java/gjavah.c \ @@ -264,37 +270,38 @@ java/boehm.o: java/boehm.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(JAVA_TREE_H) \ java/parse.h toplev.h java/buffer.o: java/buffer.c $(CONFIG_H) java/buffer.h $(SYSTEM_H) toplev.h java/builtins.o: java/builtins.c $(CONFIG_H) $(SYSTEM_H) $(JAVA_TREE_H) \ - $(GGC_H) flags.h builtin-types.def langhooks.h + $(GGC_H) flags.h builtin-types.def langhooks.h gt-java-builtins.h java/check-init.o: java/check-init.c $(CONFIG_H) \ $(JAVA_TREE_H) $(SYSTEM_H) toplev.h java/class.o: java/class.c $(CONFIG_H) $(JAVA_TREE_H) $(RTL_H) java/jcf.h \ - java/parse.h toplev.h $(SYSTEM_H) output.h $(GGC_H) $(TARGET_H) function.h + java/parse.h toplev.h $(SYSTEM_H) output.h $(GGC_H) $(TARGET_H) function.h \ + gt-java-class.h java/constants.o: java/constants.c $(CONFIG_H) $(JAVA_TREE_H) java/jcf.h \ - toplev.h $(SYSTEM_H) $(GGC_H) + toplev.h $(SYSTEM_H) $(GGC_H) gt-java-constants.h java/decl.o: java/decl.c $(CONFIG_H) $(JAVA_TREE_H) $(RTL_H) java/jcf.h \ toplev.h flags.h $(SYSTEM_H) function.h expr.h libfuncs.h except.h \ - java/java-except.h $(GGC_H) real.h + java/java-except.h $(GGC_H) real.h gt-java-decl.h java/except.o: java/except.c $(CONFIG_H) $(JAVA_TREE_H) java/jcf.h real.h \ $(RTL_H) java/javaop.h java/java-opcodes.h except.h java/java-except.h \ toplev.h $(SYSTEM_H) function.h java/expr.o: java/expr.c $(CONFIG_H) $(JAVA_TREE_H) java/jcf.h real.h \ $(RTL_H) $(EXPR_H) java/javaop.h java/java-opcodes.h except.h \ java/java-except.h java/java-except.h java/parse.h toplev.h \ - $(SYSTEM_H) $(GGC_H) + $(SYSTEM_H) $(GGC_H) gt-java-expr.h java/jcf-depend.o: java/jcf-depend.c $(CONFIG_H) $(SYSTEM_H) java/jcf.h java/jcf-parse.o: java/jcf-parse.c $(CONFIG_H) $(JAVA_TREE_H) flags.h \ input.h java/java-except.h $(SYSTEM_H) toplev.h java/parse.h $(GGC_H) \ - debug.h real.h + debug.h real.h gt-java-jcf-parse.h java/jcf-write.o: java/jcf-write.c $(CONFIG_H) $(JAVA_TREE_H) java/jcf.h \ $(RTL_H) java/java-opcodes.h java/parse.h java/buffer.h $(SYSTEM_H) \ - toplev.h $(GGC_H) + toplev.h $(GGC_H) gt-java-jcf-write.h java/jv-scan.o: java/jv-scan.c $(CONFIG_H) $(SYSTEM_H) version.h java/jvgenmain.o: java/jvgenmain.c $(CONFIG_H) $(JAVA_TREE_H) $(SYSTEM_H) java/lang.o: java/lang.c $(CONFIG_H) $(JAVA_TREE_H) java/jcf.h input.h \ toplev.h $(SYSTEM_H) $(RTL_H) $(EXPR_H) diagnostic.h langhooks.h \ - langhooks-def.h + langhooks-def.h gt-java-lang.h java/mangle.o: java/mangle.c $(CONFIG_H) java/jcf.h $(JAVA_TREE_H) $(SYSTEM_H) \ - toplev.h $(GGC_H) + toplev.h $(GGC_H) gt-java-mangle.h java/mangle_name.o: java/mangle_name.c $(CONFIG_H) java/jcf.h $(JAVA_TREE_H) \ $(SYSTEM_H) toplev.h $(GGC_H) java/parse-scan.o: $(CONFIG_H) $(SYSTEM_H) toplev.h $(JAVA_LEX_C) java/parse.h \ diff --git a/gcc/java/builtins.c b/gcc/java/builtins.c index 81be7e3..c167df5 100644 --- a/gcc/java/builtins.c +++ b/gcc/java/builtins.c @@ -83,21 +83,21 @@ typedef tree builtin_creator_function PARAMS ((tree, tree)); /* Hold a char*, before initialization, or a tree, after initialization. */ -union string_or_tree +union string_or_tree GTY(()) { - const char *s; - tree t; + const char * GTY ((tag ("0"))) s; + tree GTY ((tag ("1"))) t; }; /* Used to hold a single builtin record. */ -struct builtin_record +struct builtin_record GTY(()) { - union string_or_tree class_name; - union string_or_tree method_name; - builtin_creator_function *creator; + union string_or_tree GTY ((desc ("1"))) class_name; + union string_or_tree GTY ((desc ("1"))) method_name; + builtin_creator_function * GTY((skip (""))) creator; }; -static struct builtin_record java_builtins[] = +static GTY(()) struct builtin_record java_builtins[] = { { { "java.lang.Math" }, { "min" }, min_builtin }, { { "java.lang.Math" }, { "max" }, max_builtin }, @@ -273,8 +273,6 @@ initialize_builtins () java_builtins[i].class_name.t = klass_id; java_builtins[i].method_name.t = m; - ggc_add_tree_root (&java_builtins[i].class_name.t, 1); - ggc_add_tree_root (&java_builtins[i].method_name.t, 1); } void_list_node = end_params_node; @@ -348,3 +346,5 @@ check_for_builtin (method, call) } return call; } + +#include "gt-java-builtins.h" diff --git a/gcc/java/check-init.c b/gcc/java/check-init.c index 6793533..e022376 100644 --- a/gcc/java/check-init.c +++ b/gcc/java/check-init.c @@ -607,8 +607,10 @@ check_init (exp, before) if (fndecl && METHOD_STATIC (fndecl) && (DECL_INITIAL (decl) == boolean_true_node || (index >= 0 && ASSIGNED_P (tmp, index)))) - hash_lookup (&DECL_FUNCTION_INITIALIZED_CLASS_TABLE (fndecl), - DECL_FUNCTION_INIT_TEST_CLASS(decl), TRUE, NULL); + *(htab_find_slot + (DECL_FUNCTION_INITIALIZED_CLASS_TABLE (fndecl), + DECL_FUNCTION_INIT_TEST_CLASS (decl), INSERT)) = + DECL_FUNCTION_INIT_TEST_CLASS (decl); } DECL_BIT_INDEX (decl) = -1; } @@ -999,27 +1001,3 @@ check_for_initialization (body, mdecl) start_current_locals = num_current_locals = 0; } - -/* 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 && ASSIGNED_P (((word *) ptr), index)))) - hash_lookup (&DECL_FUNCTION_INITIALIZED_CLASS_TABLE (fndecl), - entry->key, TRUE, NULL); - return true; -} diff --git a/gcc/java/class.c b/gcc/java/class.c index 7b8c5e0..0b9c6a9 100644 --- a/gcc/java/class.c +++ b/gcc/java/class.c @@ -55,13 +55,10 @@ static tree get_dispatch_table PARAMS ((tree, tree)); static void add_interface_do PARAMS ((tree, tree, int)); static tree maybe_layout_super_class PARAMS ((tree, tree)); static int assume_compiled PARAMS ((const char *)); -static struct hash_entry *init_test_hash_newfunc PARAMS ((struct hash_entry *, - struct hash_table *, - hash_table_key)); static tree build_method_symbols_entry PARAMS ((tree)); -static rtx registerClass_libfunc; -static rtx registerResource_libfunc; +static GTY(()) rtx registerClass_libfunc; +static GTY(()) rtx registerResource_libfunc; extern struct obstack permanent_obstack; struct obstack temporary_obstack; @@ -95,8 +92,7 @@ static assume_compiled_node *find_assume_compiled_node static assume_compiled_node *assume_compiled_tree; -static tree class_roots[5] -= { NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE }; +static GTY(()) tree class_roots[5]; #define registered_class class_roots[0] #define fields_ident class_roots[1] /* get_identifier ("fields") */ #define info_ident class_roots[2] /* get_identifier ("info") */ @@ -625,43 +621,6 @@ build_java_method_type (fntype, this_class, access_flags) return build_method_type (CLASS_TO_HANDLE_TYPE (this_class), fntype); } -static struct hash_entry * -init_test_hash_newfunc (entry, table, string) - struct hash_entry *entry; - struct hash_table *table; - hash_table_key string ATTRIBUTE_UNUSED; -{ - struct init_test_hash_entry *ret = (struct init_test_hash_entry *) entry; - if (ret == NULL) - { - ret = ((struct init_test_hash_entry *) - hash_allocate (table, sizeof (struct init_test_hash_entry))); - if (ret == NULL) - return NULL; - } - ret->init_test_decl = 0; - return (struct hash_entry *) ret; -} - -/* Hash table helpers. Also reused in find_applicable_accessible_methods_list - (parse.y). The hash of a tree node is its pointer value, comparison - is direct. */ - -unsigned long -java_hash_hash_tree_node (k) - hash_table_key k; -{ - return (long) k; -} - -bool -java_hash_compare_tree_node (k1, k2) - hash_table_key k1; - hash_table_key k2; -{ - return ((tree) k1 == (tree) k2); -} - tree add_method_1 (handle_class, access_flags, name, function_type) tree handle_class; @@ -679,17 +638,17 @@ add_method_1 (handle_class, access_flags, name, function_type) DECL_LANG_SPECIFIC (fndecl) = (struct lang_decl *) ggc_alloc_cleared (sizeof (struct lang_decl)); + DECL_LANG_SPECIFIC (fndecl)->desc = LANG_DECL_FUNC; /* Initialize the static initializer test table. */ - hash_table_init (&DECL_FUNCTION_INIT_TEST_TABLE (fndecl), - init_test_hash_newfunc, java_hash_hash_tree_node, - java_hash_compare_tree_node); + + DECL_FUNCTION_INIT_TEST_TABLE (fndecl) = + java_treetreehash_create (10, 1); /* Initialize the initialized (static) class table. */ if (access_flags & ACC_STATIC) - hash_table_init (&DECL_FUNCTION_INITIALIZED_CLASS_TABLE (fndecl), - init_test_hash_newfunc, java_hash_hash_tree_node, - java_hash_compare_tree_node); + DECL_FUNCTION_INITIALIZED_CLASS_TABLE (fndecl) = + htab_create_ggc (50, htab_hash_pointer, htab_eq_pointer, NULL); /* Initialize the static method invocation compound list */ DECL_FUNCTION_STATIC_METHOD_INVOCATION_COMPOUND (fndecl) = NULL_TREE; @@ -2327,12 +2286,85 @@ emit_offset_symbol_table () void init_class_processing () { - registerClass_libfunc = gen_rtx (SYMBOL_REF, Pmode, "_Jv_RegisterClass"); + registerClass_libfunc = gen_rtx_SYMBOL_REF (Pmode, "_Jv_RegisterClass"); registerResource_libfunc = - gen_rtx (SYMBOL_REF, Pmode, "_Jv_RegisterResource"); - ggc_add_tree_root (class_roots, ARRAY_SIZE (class_roots)); + gen_rtx_SYMBOL_REF (Pmode, "_Jv_RegisterResource"); fields_ident = get_identifier ("fields"); info_ident = get_identifier ("info"); - ggc_add_rtx_root (®isterClass_libfunc, 1); gcc_obstack_init (&temporary_obstack); } + +static hashval_t java_treetreehash_hash PARAMS ((const void *)); +static int java_treetreehash_compare PARAMS ((const void *, const void *)); + +/* A hash table mapping trees to trees. Used generally. */ + +#define JAVA_TREEHASHHASH_H(t) ((hashval_t) (t)) + +static hashval_t +java_treetreehash_hash (k_p) + const void *k_p; +{ + struct treetreehash_entry *k = (struct treetreehash_entry *) k_p; + return JAVA_TREEHASHHASH_H (k->key); +} + +static int +java_treetreehash_compare (k1_p, k2_p) + const void * k1_p; + const void * k2_p; +{ + struct treetreehash_entry * k1 = (struct treetreehash_entry *) k1_p; + tree k2 = (tree) k2_p; + return (k1->key == k2); +} + +tree +java_treetreehash_find (ht, t) + htab_t ht; + tree t; +{ + struct treetreehash_entry *e; + hashval_t hv = JAVA_TREEHASHHASH_H (t); + e = (struct treetreehash_entry *) htab_find_with_hash (ht, t, hv); + if (e == NULL) + return NULL; + else + return e->value; +} + +tree * +java_treetreehash_new (ht, t) + htab_t ht; + tree t; +{ + PTR *e; + struct treetreehash_entry *tthe; + hashval_t hv = JAVA_TREEHASHHASH_H (t); + + e = htab_find_slot_with_hash (ht, t, hv, INSERT); + if (*e == NULL) + { + tthe = (*ht->alloc_f) (1, sizeof (*tthe)); + tthe->key = t; + *e = (PTR) tthe; + } + else + tthe = (struct treetreehash_entry *) *e; + return &tthe->value; +} + +htab_t +java_treetreehash_create (size, gc) + size_t size; + int gc; +{ + if (gc) + return htab_create_ggc (size, java_treetreehash_hash, + java_treetreehash_compare, NULL); + else + return htab_create_alloc (size, java_treetreehash_hash, + java_treetreehash_compare, free, xcalloc, free); +} + +#include "gt-java-class.h" diff --git a/gcc/java/config-lang.in b/gcc/java/config-lang.in index e4524fe..d4511b5 100644 --- a/gcc/java/config-lang.in +++ b/gcc/java/config-lang.in @@ -36,6 +36,8 @@ compilers="jc1\$(exeext) jvgenmain\$(exeext)" stagestuff="jc1\$(exeext) gcj\$(exeext) jvgenmain\$(exeext) gcjh\$(exeext) jv-scan\$(exeext) jcf-dump\$(exeext)" +gtfiles="\$(srcdir)/java/java-tree.h \$(srcdir)/java/builtins.c \$(srcdir)/java/class.c \$(srcdir)/java/constants.c \$(srcdir)/java/decl.c \$(srcdir)/java/expr.c \$(srcdir)/java/jcf-parse.c \$(srcdir)/java/jcf-write.c \$(srcdir)/java/lang.c \$(srcdir)/java/mangle.c \$(srcdir)/java/parse.y" + target_libs=${libgcj_saved} lang_dirs="zlib fastjar" #build_by_default=no diff --git a/gcc/java/constants.c b/gcc/java/constants.c index c51cec9..e3642d5 100644 --- a/gcc/java/constants.c +++ b/gcc/java/constants.c @@ -326,20 +326,12 @@ write_constant_pool (cpool, buffer, length) CPool *outgoing_cpool; +static GTY(()) tree tag_nodes[13]; static tree get_tag_node (tag) int tag; { /* A Cache for build_int_2 (CONSTANT_XXX, 0). */ - static tree tag_nodes[13]; - static int initialized_p; - - /* Register the TAG_NODES with the garbage collector. */ - if (!initialized_p) - { - ggc_add_tree_root (tag_nodes, 13); - initialized_p = 1; - } if (tag_nodes[tag] == NULL_TREE) tag_nodes[tag] = build_int_2 (tag, 0); @@ -492,3 +484,5 @@ build_constants_constructor () FINISH_RECORD_CONSTRUCTOR (cons); return cons; } + +#include "gt-java-constants.h" diff --git a/gcc/java/decl.c b/gcc/java/decl.c index 7026dea..1b883ca 100644 --- a/gcc/java/decl.c +++ b/gcc/java/decl.c @@ -66,12 +66,12 @@ extern int always_initialize_class_p; DECL_LOCAL_SLOT_CHAIN; the index finds the TREE_VEC element, and then we search the chain for a decl with a matching TREE_TYPE. */ -tree decl_map; +static GTY(()) tree decl_map; /* A list of local variables VAR_DECLs for this method that we have seen debug information, but we have not reached their starting (byte) PC yet. */ -static tree pending_local_decls = NULL_TREE; +static GTY(()) tree pending_local_decls; /* Push a local variable or stack slot into the decl_map, and assign it an rtl. */ @@ -908,11 +908,6 @@ java_init_decl_processing () init_jcf_parse (); - /* Register nodes with the garbage collector. */ - ggc_add_tree_root (java_global_trees, ARRAY_SIZE (java_global_trees)); - ggc_add_tree_root (&decl_map, 1); - ggc_add_tree_root (&pending_local_decls, 1); - initialize_builtins (); } @@ -1553,10 +1548,7 @@ java_dup_lang_specific_decl (node) if (!DECL_LANG_SPECIFIC (node)) return; - if (TREE_CODE (node) == VAR_DECL) - lang_decl_size = sizeof (struct lang_decl_var); - else - lang_decl_size = sizeof (struct lang_decl); + lang_decl_size = sizeof (struct lang_decl); x = (struct lang_decl *) ggc_alloc (lang_decl_size); memcpy (x, DECL_LANG_SPECIFIC (node), lang_decl_size); DECL_LANG_SPECIFIC (node) = x; @@ -1829,64 +1821,4 @@ end_java_method () current_function_decl = NULL_TREE; } -/* Mark language-specific parts of T for garbage-collection. */ - -void -java_mark_tree (t) - tree t; -{ - if (TREE_CODE (t) == IDENTIFIER_NODE) - { - struct lang_identifier *li = (struct lang_identifier *) t; - ggc_mark_tree (li->global_value); - ggc_mark_tree (li->local_value); - ggc_mark_tree (li->utf8_ref); - } - else if (TREE_CODE (t) == VAR_DECL - || TREE_CODE (t) == PARM_DECL - || TREE_CODE (t) == FIELD_DECL) - { - struct lang_decl_var *ldv = - ((struct lang_decl_var *) DECL_LANG_SPECIFIC (t)); - if (ldv) - { - ggc_mark (ldv); - ggc_mark_tree (ldv->slot_chain); - ggc_mark_tree (ldv->am); - ggc_mark_tree (ldv->wfl); - } - } - else if (TREE_CODE (t) == FUNCTION_DECL) - { - struct lang_decl *ld = DECL_LANG_SPECIFIC (t); - - if (ld) - { - ggc_mark (ld); - ggc_mark_tree (ld->wfl); - ggc_mark_tree (ld->throws_list); - ggc_mark_tree (ld->function_decl_body); - ggc_mark_tree (ld->called_constructor); - ggc_mark_tree (ld->inner_access); - ggc_mark_tree_hash_table (&ld->init_test_table); - ggc_mark_tree_hash_table (&ld->ict); - ggc_mark_tree (ld->smic); - } - } - else if (TYPE_P (t)) - { - struct lang_type *lt = TYPE_LANG_SPECIFIC (t); - - if (lt) - { - ggc_mark (lt); - ggc_mark_tree (lt->signature); - ggc_mark_tree (lt->cpool_data_ref); - ggc_mark_tree (lt->finit_stmt_list); - ggc_mark_tree (lt->clinit_stmt_list); - ggc_mark_tree (lt->ii_block); - ggc_mark_tree (lt->dot_class); - ggc_mark_tree (lt->package_list); - } - } -} +#include "gt-java-decl.h" diff --git a/gcc/java/expr.c b/gcc/java/expr.c index f17fef8..34be4d5 100644 --- a/gcc/java/expr.c +++ b/gcc/java/expr.c @@ -81,15 +81,15 @@ static tree build_java_throw_out_of_bounds_exception PARAMS ((tree)); static tree build_java_check_indexed_type PARAMS ((tree, tree)); static tree case_identity PARAMS ((tree, tree)); static unsigned char peek_opcode_at_pc PARAMS ((struct JCF *, int, int)); -static bool emit_init_test_initialization PARAMS ((struct hash_entry *, - PTR ptr)); +static int emit_init_test_initialization PARAMS ((void **entry, + void * ptr)); static int get_offset_table_index PARAMS ((tree)); -static tree operand_type[59]; +static GTY(()) tree operand_type[59]; extern struct obstack permanent_obstack; -static tree methods_ident = NULL_TREE; -static tree ncode_ident = NULL_TREE; +static GTY(()) tree methods_ident; +static GTY(()) tree ncode_ident; tree dtable_ident = NULL_TREE; /* Set to non-zero value in order to emit class initilization code @@ -123,10 +123,10 @@ int always_initialize_class_p; So dup cannot just add an extra element to the quick_stack, but iadd can. */ -static tree quick_stack = NULL_TREE; +static GTY(()) tree quick_stack; /* A free-list of unused permamnet TREE_LIST nodes. */ -static tree tree_list_free_list = NULL_TREE; +static GTY((deletable (""))) tree tree_list_free_list; /* The stack pointer of the Java virtual machine. This does include the size of the quick_stack. */ @@ -144,11 +144,6 @@ init_expr_processing() operand_type[23] = operand_type[56] = float_type_node; operand_type[24] = operand_type[57] = double_type_node; operand_type[25] = operand_type[58] = ptr_type_node; - ggc_add_tree_root (operand_type, 59); - ggc_add_tree_root (&methods_ident, 1); - ggc_add_tree_root (&ncode_ident, 1); - ggc_add_tree_root (&quick_stack, 1); - ggc_add_tree_root (&tree_list_free_list, 1); } tree @@ -1756,7 +1751,6 @@ build_class_init (clas, expr) tree clas, expr; { tree init; - struct init_test_hash_entry *ite; if (inherits_from_p (current_class, clas)) return expr; @@ -1770,25 +1764,24 @@ build_class_init (clas, expr) } else { - ite = (struct init_test_hash_entry *) - hash_lookup (&DECL_FUNCTION_INIT_TEST_TABLE (current_function_decl), - (const hash_table_key) clas, - TRUE, NULL); - - if (ite->init_test_decl == 0) + tree *init_test_decl; + init_test_decl = java_treetreehash_new + (DECL_FUNCTION_INIT_TEST_TABLE (current_function_decl), clas); + + if (*init_test_decl == NULL) { /* Build a declaration and mark it as a flag used to track static class initializations. */ - ite->init_test_decl = build_decl (VAR_DECL, NULL_TREE, - boolean_type_node); - MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC (ite->init_test_decl); - LOCAL_CLASS_INITIALIZATION_FLAG (ite->init_test_decl) = 1; - DECL_CONTEXT (ite->init_test_decl) = current_function_decl; - DECL_FUNCTION_INIT_TEST_CLASS (ite->init_test_decl) = clas; + *init_test_decl = build_decl (VAR_DECL, NULL_TREE, + boolean_type_node); + MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC (*init_test_decl); + LOCAL_CLASS_INITIALIZATION_FLAG (*init_test_decl) = 1; + DECL_CONTEXT (*init_test_decl) = current_function_decl; + DECL_FUNCTION_INIT_TEST_CLASS (*init_test_decl) = clas; /* Tell the check-init code to ignore this decl when not optimizing class initialization. */ if (!STATIC_CLASS_INIT_OPT_P ()) - DECL_BIT_INDEX(ite->init_test_decl) = -1; + DECL_BIT_INDEX(*init_test_decl) = -1; } init = build (CALL_EXPR, void_type_node, @@ -1798,12 +1791,12 @@ build_class_init (clas, expr) TREE_SIDE_EFFECTS (init) = 1; init = build (COND_EXPR, void_type_node, build (EQ_EXPR, boolean_type_node, - ite->init_test_decl, boolean_false_node), + *init_test_decl, boolean_false_node), init, integer_zero_node); TREE_SIDE_EFFECTS (init) = 1; init = build (COMPOUND_EXPR, TREE_TYPE (expr), init, build (MODIFY_EXPR, boolean_type_node, - ite->init_test_decl, boolean_true_node)); + *init_test_decl, boolean_true_node)); TREE_SIDE_EFFECTS (init) = 1; } @@ -1976,11 +1969,11 @@ build_invokevirtual (dtable, method) return func; } +static GTY(()) tree class_ident; tree build_invokeinterface (dtable, method) tree dtable, method; { - static tree class_ident = NULL_TREE; tree lookup_arg; tree interface; tree idx; @@ -1995,7 +1988,6 @@ build_invokeinterface (dtable, method) if (class_ident == NULL_TREE) { class_ident = get_identifier ("class"); - ggc_add_tree_root (&class_ident, 1); } dtable = build_java_indirect_ref (dtable_type, dtable, flag_check_references); @@ -2588,8 +2580,8 @@ java_expand_expr (exp, target, tmode, modifier) if (! always_initialize_class_p && current_function_decl && found_class_initialization_flag) - hash_traverse - (&DECL_FUNCTION_INIT_TEST_TABLE (current_function_decl), + htab_traverse + (DECL_FUNCTION_INIT_TEST_TABLE (current_function_decl), emit_init_test_initialization, NULL); /* Avoid deep recursion for long block. */ @@ -3458,19 +3450,19 @@ force_evaluation_order (node) /* Called for every element in DECL_FUNCTION_INIT_TEST_TABLE of a method in order to emit initialization code for each test flag. */ -static bool -emit_init_test_initialization (entry, key) - struct hash_entry *entry; - hash_table_key key ATTRIBUTE_UNUSED; +static int +emit_init_test_initialization (entry, x) + void * * entry; + void * x ATTRIBUTE_UNUSED; { - struct init_test_hash_entry *ite = (struct init_test_hash_entry *) entry; - tree klass = build_class_ref ((tree) entry->key); + struct treetreehash_entry *ite = (struct treetreehash_entry *) *entry; + tree klass = build_class_ref (ite->key); tree rhs; /* If the DECL_INITIAL of the test flag is set to true, it means that the class is already initialized the time it is in use. */ - if (DECL_INITIAL (ite->init_test_decl) == boolean_true_node) + if (DECL_INITIAL (ite->value) == boolean_true_node) rhs = boolean_true_node; /* Otherwise, we initialize the class init check variable by looking at the `state' field of the class to see if it is already @@ -3485,6 +3477,9 @@ emit_init_test_initialization (entry, key) build_int_2 (JV_STATE_DONE, 0)); expand_expr_stmt (build (MODIFY_EXPR, boolean_type_node, - ite->init_test_decl, rhs)); + ite->value, rhs)); return true; } + +#include "gt-java-expr.h" + diff --git a/gcc/java/java-tree.h b/gcc/java/java-tree.h index 29a7553..71a6388 100644 --- a/gcc/java/java-tree.h +++ b/gcc/java/java-tree.h @@ -26,7 +26,7 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */ /* Hacked by Per Bothner <bothner@cygnus.com> February 1996. */ -#include "hash.h" +#include "hashtab.h" /* Java language-specific tree codes. */ #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) SYM, @@ -404,7 +404,7 @@ enum java_tree_index JTI_MAX }; -extern tree java_global_trees[JTI_MAX]; +extern GTY(()) tree java_global_trees[JTI_MAX]; /* "Promoted types" that are used for primitive types smaller than int. We could use int_type_node, but then we would lose @@ -679,16 +679,27 @@ extern struct CPool *outgoing_cpool; extern const char *cyclic_inheritance_report; -struct lang_identifier +struct lang_identifier GTY(()) { struct tree_identifier ignore; - tree global_value, local_value; + tree global_value; + tree local_value; /* If non-NULL: An ADDR_REF to a VAR_DECL that contains * the Utf8Const representation of the identifier. */ tree utf8_ref; }; +/* The resulting tree type. */ +union lang_tree_node + GTY((desc ("TREE_CODE (&%h.generic) == IDENTIFIER_NODE"))) +{ + union tree_node GTY ((tag ("0"), + desc ("tree_node_structure (&%h)"))) + generic; + struct lang_identifier GTY ((tag ("1"))) identifier; +}; + /* Macros for access to language-specific slots in an identifier. */ /* Unless specified, each of these slots contains a DECL node or null. */ @@ -728,41 +739,43 @@ struct lang_identifier /* For a FUNCTION_DECL, if we are compiling a .class file, then this is the position in the .class file of the method code. Specifically, this is the code itself, not the code attribute. */ -#define DECL_CODE_OFFSET(DECL) (DECL_LANG_SPECIFIC(DECL)->code_offset) +#define DECL_CODE_OFFSET(DECL) (DECL_LANG_SPECIFIC(DECL)->u.f.code_offset) /* Similarly, the length of the bytecode. */ -#define DECL_CODE_LENGTH(DECL) (DECL_LANG_SPECIFIC(DECL)->code_length) +#define DECL_CODE_LENGTH(DECL) (DECL_LANG_SPECIFIC(DECL)->u.f.code_length) /* Similarly, the position of the LineNumberTable attribute. */ #define DECL_LINENUMBERS_OFFSET(DECL) \ - (DECL_LANG_SPECIFIC(DECL)->linenumbers_offset) + (DECL_LANG_SPECIFIC(DECL)->u.f.linenumbers_offset) /* Similarly, the position of the LocalVariableTable attribute (following the standard attribute header). */ #define DECL_LOCALVARIABLES_OFFSET(DECL) \ - (DECL_LANG_SPECIFIC(DECL)->localvariables_offset) + (DECL_LANG_SPECIFIC(DECL)->u.f.localvariables_offset) -#define DECL_MAX_LOCALS(DECL) (DECL_LANG_SPECIFIC(DECL)->max_locals) -#define DECL_MAX_STACK(DECL) (DECL_LANG_SPECIFIC(DECL)->max_stack) +#define DECL_MAX_LOCALS(DECL) (DECL_LANG_SPECIFIC(DECL)->u.f.max_locals) +#define DECL_MAX_STACK(DECL) (DECL_LANG_SPECIFIC(DECL)->u.f.max_stack) /* Number of local variable slots needed for the arguments of this function. */ -#define DECL_ARG_SLOT_COUNT(DECL) (DECL_LANG_SPECIFIC(DECL)->arg_slot_count) +#define DECL_ARG_SLOT_COUNT(DECL) \ + (DECL_LANG_SPECIFIC(DECL)->u.f.arg_slot_count) /* Information on declaration location */ -#define DECL_FUNCTION_WFL(DECL) (DECL_LANG_SPECIFIC(DECL)->wfl) +#define DECL_FUNCTION_WFL(DECL) (DECL_LANG_SPECIFIC(DECL)->u.f.wfl) /* List of checked thrown exceptions, as specified with the `throws' keyword */ -#define DECL_FUNCTION_THROWS(DECL) (DECL_LANG_SPECIFIC(DECL)->throws_list) +#define DECL_FUNCTION_THROWS(DECL) (DECL_LANG_SPECIFIC(DECL)->u.f.throws_list) /* List of other constructors of the same class that this constructor calls */ #define DECL_CONSTRUCTOR_CALLS(DECL) \ - (DECL_LANG_SPECIFIC(DECL)->called_constructor) + (DECL_LANG_SPECIFIC(DECL)->u.f.called_constructor) /* When the function is an access function, the DECL it was trying to access */ #define DECL_FUNCTION_ACCESS_DECL(DECL) \ - (DECL_LANG_SPECIFIC(DECL)->called_constructor) + (DECL_LANG_SPECIFIC(DECL)->u.f.called_constructor) /* The identifier of the access method used to invoke this method from an inner class. */ #define DECL_FUNCTION_INNER_ACCESS(DECL) \ - (DECL_LANG_SPECIFIC(DECL)->inner_access) + (DECL_LANG_SPECIFIC(DECL)->u.f.inner_access) /* Pointer to the function's current's COMPOUND_EXPR tree (while completing its body) or the function's block */ -#define DECL_FUNCTION_BODY(DECL) (DECL_LANG_SPECIFIC(DECL)->function_decl_body) +#define DECL_FUNCTION_BODY(DECL) \ + (DECL_LANG_SPECIFIC(DECL)->u.f.function_decl_body) /* How specific the function is (for method selection - Java source code front-end */ #define DECL_SPECIFIC_COUNT(DECL) DECL_ARG_SLOT_COUNT(DECL) @@ -771,31 +784,33 @@ struct lang_identifier boolean decls. The variables are intended to be TRUE when the class has been initialized in this function, and FALSE otherwise. */ #define DECL_FUNCTION_INIT_TEST_TABLE(DECL) \ - (DECL_LANG_SPECIFIC(DECL)->init_test_table) + (DECL_LANG_SPECIFIC(DECL)->u.f.init_test_table) /* If LOCAL_CLASS_INITIALIZATION_FLAG_P(decl), give class it initializes. */ #define DECL_FUNCTION_INIT_TEST_CLASS(DECL) \ - (((struct lang_decl_var*)DECL_LANG_SPECIFIC(DECL))->slot_chain) + (DECL_LANG_SPECIFIC(DECL)->u.v.slot_chain) /* For each static function decl, itc contains a hash table whose entries are keyed on class named that are definitively initialized in DECL. */ #define DECL_FUNCTION_INITIALIZED_CLASS_TABLE(DECL) \ - (DECL_LANG_SPECIFIC(DECL)->ict) + (DECL_LANG_SPECIFIC(DECL)->u.f.ict) /* A list of all the static method calls in the method DECL (if optimizing). Actually each TREE_VALUE points to a COMPONT_EXPR that wraps the invoation so we can later patch it. */ #define DECL_FUNCTION_STATIC_METHOD_INVOCATION_COMPOUND(DECL) \ - (DECL_LANG_SPECIFIC(DECL)->smic) + (DECL_LANG_SPECIFIC(DECL)->u.f.smic) /* The Number of Artificial Parameters (NAP) DECL contains. this$<n> is excluded, because sometimes created as a parameter before the function decl exists. */ -#define DECL_FUNCTION_NAP(DECL) (DECL_LANG_SPECIFIC(DECL)->nap) +#define DECL_FUNCTION_NAP(DECL) (DECL_LANG_SPECIFIC(DECL)->u.f.nap) /* True if DECL is a synthetic ctor. */ #define DECL_FUNCTION_SYNTHETIC_CTOR(DECL) \ - (DECL_LANG_SPECIFIC(DECL)->synthetic_ctor) -#define DECL_FIXED_CONSTRUCTOR_P(DECL) (DECL_LANG_SPECIFIC(DECL)->fixed_ctor) + (DECL_LANG_SPECIFIC(DECL)->u.f.synthetic_ctor) +#define DECL_FIXED_CONSTRUCTOR_P(DECL) \ + (DECL_LANG_SPECIFIC(DECL)->u.f.fixed_ctor) /* A constructor that calls this. */ -#define DECL_INIT_CALLS_THIS(DECL) (DECL_LANG_SPECIFIC(DECL)->init_calls_this) +#define DECL_INIT_CALLS_THIS(DECL) \ + (DECL_LANG_SPECIFIC(DECL)->u.f.init_calls_this) /* True when DECL aliases an outer context local variable. */ #define FIELD_LOCAL_ALIAS(DECL) DECL_LANG_FLAG_6 (DECL) @@ -858,31 +873,31 @@ struct lang_identifier /* The slot number for this local variable. */ #define DECL_LOCAL_SLOT_NUMBER(NODE) \ - (((struct lang_decl_var*)DECL_LANG_SPECIFIC(NODE))->slot_number) + (DECL_LANG_SPECIFIC(NODE)->u.v.slot_number) /* The start (bytecode) pc for the valid range of this local variable. */ #define DECL_LOCAL_START_PC(NODE) \ - (((struct lang_decl_var*)DECL_LANG_SPECIFIC(NODE))->start_pc) + (DECL_LANG_SPECIFIC(NODE)->u.v.start_pc) /* The end (bytecode) pc for the valid range of this local variable. */ #define DECL_LOCAL_END_PC(NODE) \ - (((struct lang_decl_var*)DECL_LANG_SPECIFIC(NODE))->end_pc) + (DECL_LANG_SPECIFIC(NODE)->u.v.end_pc) /* For a VAR_DECLor PARM_DECL, used to chain decls with the same slot_number in decl_map. */ #define DECL_LOCAL_SLOT_CHAIN(NODE) \ - (((struct lang_decl_var*)DECL_LANG_SPECIFIC(NODE))->slot_chain) + (DECL_LANG_SPECIFIC(NODE)->u.v.slot_chain) /* For a FIELD_DECL, holds the name of the access method. Used to read/write the content of the field from an inner class. */ #define FIELD_INNER_ACCESS(DECL) \ - (((struct lang_decl_var*)DECL_LANG_SPECIFIC(DECL))->am) + (DECL_LANG_SPECIFIC(DECL)->u.v.am) /* Safely tests whether FIELD_INNER_ACCESS exists or not. */ #define FIELD_INNER_ACCESS_P(DECL) \ DECL_LANG_SPECIFIC (DECL) && FIELD_INNER_ACCESS (DECL) /* True if a final variable was initialized upon its declaration, or (if a field) in an initializer. Set after definite assignment. */ #define DECL_FIELD_FINAL_IUD(NODE) \ - (((struct lang_decl_var*)DECL_LANG_SPECIFIC(NODE))->final_iud) + (DECL_LANG_SPECIFIC(NODE)->u.v.final_iud) /* The original WFL of a final variable. */ #define DECL_FIELD_FINAL_WFL(NODE) \ - (((struct lang_decl_var*)DECL_LANG_SPECIFIC(NODE))->wfl) + (DECL_LANG_SPECIFIC(NODE)->u.v.wfl) /* True if NODE is a local variable final. */ #define LOCAL_FINAL_P(NODE) (DECL_LANG_SPECIFIC (NODE) && DECL_FINAL (NODE)) /* True if NODE is a final field. */ @@ -893,7 +908,7 @@ struct lang_identifier /* True if NODE is a class initialization flag. This macro accesses the flag to read or set it. */ #define LOCAL_CLASS_INITIALIZATION_FLAG(NODE) \ - (((struct lang_decl_var*)DECL_LANG_SPECIFIC(NODE))->cif) + (DECL_LANG_SPECIFIC(NODE)->u.v.cif) /* True if NODE is a class initialization flag. */ #define LOCAL_CLASS_INITIALIZATION_FLAG_P(NODE) \ (DECL_LANG_SPECIFIC (NODE) && LOCAL_CLASS_INITIALIZATION_FLAG(NODE)) @@ -903,7 +918,8 @@ struct lang_identifier { \ DECL_LANG_SPECIFIC ((T)) \ = ((struct lang_decl *) \ - ggc_alloc_cleared (sizeof (struct lang_decl_var))); \ + ggc_alloc_cleared (sizeof (struct lang_decl))); \ + DECL_LANG_SPECIFIC (T)->desc = LANG_DECL_VAR; \ } /* A ConstantExpression, after folding and name resolution. */ @@ -920,7 +936,7 @@ struct lang_identifier #define DECL_BIT_INDEX(DECL) (DECL_CHECK (DECL)->decl.pointer_alias_set) /* DECL_LANG_SPECIFIC for FUNCTION_DECLs. */ -struct lang_decl +struct lang_decl_func GTY(()) { /* tree chain; not yet used. */ long code_offset; @@ -928,15 +944,21 @@ struct lang_decl long linenumbers_offset; long localvariables_offset; int arg_slots; - int max_locals, max_stack, arg_slot_count; + int max_locals; + int max_stack; + int arg_slot_count; tree wfl; /* Information on the original location */ tree throws_list; /* Exception specified by `throws' */ tree function_decl_body; /* Hold all function's statements */ tree called_constructor; /* When decl is a constructor, the list of other constructor it calls */ - struct hash_table init_test_table; - /* Class initialization test variables */ - struct hash_table ict; /* Initialized (static) Class Table */ + + /* Class initialization test variables */ + htab_t GTY ((param_is (struct treetreehash_entry))) init_test_table; + + /* Initialized (static) Class Table */ + htab_t GTY ((param_is (union tree_node))) ict; + tree smic; /* Static method invocation compound */ tree inner_access; /* The identifier of the access method used for invocation from inner classes */ @@ -949,16 +971,19 @@ struct lang_decl unsigned int strictfp : 1; }; -/* init_test_table hash table entry structure. */ -struct init_test_hash_entry +struct treetreehash_entry GTY(()) { - struct hash_entry root; - tree init_test_decl; + tree key; + tree value; }; +extern tree java_treetreehash_find PARAMS ((htab_t, tree)); +extern tree * java_treetreehash_new PARAMS ((htab_t, tree)); +extern htab_t java_treetreehash_create PARAMS ((size_t size, int ggc)); + /* DECL_LANG_SPECIFIC for VAR_DECL, PARM_DECL and sometimes FIELD_DECL (access methods on outer class fields) and final fields. */ -struct lang_decl_var +struct lang_decl_var GTY(()) { int slot_number; int start_pc; @@ -970,6 +995,22 @@ struct lang_decl_var unsigned int cif : 1; /* True: decl is a class initialization flag */ }; +/* This is what 'lang_decl' really points to. */ + +enum lang_decl_desc { + LANG_DECL_FUNC, + LANG_DECL_VAR +}; + +struct lang_decl GTY(()) +{ + enum lang_decl_desc desc; + union lang_decl_u { + struct lang_decl_func GTY ((tag ("LANG_DECL_FUNC"))) f; + struct lang_decl_var GTY ((tag ("LANG_DECL_VAR"))) v; + } GTY ((desc ("%0.desc"))) u; +}; + /* Macro to access fields in `struct lang_type'. */ #define TYPE_SIGNATURE(T) (TYPE_LANG_SPECIFIC(T)->signature) @@ -997,11 +1038,11 @@ struct lang_decl_var #define TYPE_PROTECTED_INNER_CLASS(T) (TYPE_LANG_SPECIFIC(T)->poic) #define TYPE_STRICTFP(T) (TYPE_LANG_SPECIFIC(T)->strictfp) -struct lang_type +struct lang_type GTY(()) { tree signature; - struct JCF *jcf; - struct CPool *cpool; + struct JCF * GTY ((skip (""))) jcf; + struct CPool * GTY ((skip (""))) cpool; tree cpool_data_ref; /* Cached */ tree finit_stmt_list; /* List of statements finit$ will use */ tree clinit_stmt_list; /* List of statements <clinit> will use */ @@ -1038,7 +1079,6 @@ struct lang_type #define JCF_u2 unsigned short extern void java_parse_file PARAMS ((int)); -extern void java_mark_tree PARAMS ((tree)); extern bool java_mark_addressable PARAMS ((tree)); extern tree java_type_for_mode PARAMS ((enum machine_mode, int)); extern tree java_type_for_size PARAMS ((unsigned int, int)); @@ -1234,11 +1274,6 @@ extern void safe_layout_class PARAMS ((tree)); extern tree get_boehm_type_descriptor PARAMS ((tree)); extern bool class_has_finalize_method PARAMS ((tree)); -extern unsigned long java_hash_hash_tree_node PARAMS ((hash_table_key)); -extern bool java_hash_compare_tree_node PARAMS ((hash_table_key, - hash_table_key)); -extern bool attach_initialized_static_class PARAMS ((struct hash_entry *, - PTR)); extern void java_check_methods PARAMS ((tree)); extern void init_jcf_parse PARAMS((void)); extern void init_src_parse PARAMS((void)); @@ -1269,10 +1304,10 @@ struct rtx_def * java_expand_expr PARAMS ((tree, rtx, enum machine_mode, #define METHOD_STATIC(DECL) DECL_LANG_FLAG_2 (DECL) #define METHOD_FINAL(DECL) DECL_FINAL (DECL) #define METHOD_SYNCHRONIZED(DECL) DECL_LANG_FLAG_4 (DECL) -#define METHOD_NATIVE(DECL) (DECL_LANG_SPECIFIC(DECL)->native) +#define METHOD_NATIVE(DECL) (DECL_LANG_SPECIFIC(DECL)->u.f.native) #define METHOD_ABSTRACT(DECL) DECL_LANG_FLAG_5 (DECL) #define METHOD_TRANSIENT(DECL) DECL_LANG_FLAG_6 (DECL) -#define METHOD_STRICTFP(DECL) (DECL_LANG_SPECIFIC (DECL)->strictfp) +#define METHOD_STRICTFP(DECL) (DECL_LANG_SPECIFIC (DECL)->u.f.strictfp) #define JAVA_FILE_P(NODE) TREE_LANG_FLAG_2 (NODE) #define CLASS_FILE_P(NODE) TREE_LANG_FLAG_3 (NODE) diff --git a/gcc/java/jcf-parse.c b/gcc/java/jcf-parse.c index b88270d..af9022b 100644 --- a/gcc/java/jcf-parse.c +++ b/gcc/java/jcf-parse.c @@ -74,7 +74,7 @@ extern struct obstack permanent_obstack; before static field references. */ extern int always_initialize_class_p; -static tree parse_roots[3] = { NULL_TREE, NULL_TREE, NULL_TREE }; +static GTY(()) tree parse_roots[3]; /* The FIELD_DECL for the current field. */ #define current_field parse_roots[0] @@ -1270,9 +1270,9 @@ void init_jcf_parse () { /* Register roots with the garbage collector. */ - ggc_add_tree_root (parse_roots, ARRAY_SIZE (parse_roots)); - ggc_add_root (¤t_jcf, 1, sizeof (JCF), (void (*)(void *))ggc_mark_jcf); init_src_parse (); } + +#include "gt-java-jcf-parse.h" diff --git a/gcc/java/jcf-write.c b/gcc/java/jcf-write.c index 491b561..7ddca44 100644 --- a/gcc/java/jcf-write.c +++ b/gcc/java/jcf-write.c @@ -2853,6 +2853,7 @@ release_jcf_state (state) in the .class file representation. The list can be written to a .class file using write_chunks. Allocate chunks from obstack WORK. */ +static GTY(()) tree SourceFile_node; static struct chunk * generate_classfile (clas, state) tree clas; @@ -2866,7 +2867,6 @@ generate_classfile (clas, state) int fields_count = 0; char *methods_count_ptr; int methods_count = 0; - static tree SourceFile_node = NULL_TREE; tree part; int total_supers = clas == object_type_node ? 0 @@ -3154,7 +3154,6 @@ generate_classfile (clas, state) if (SourceFile_node == NULL_TREE) { SourceFile_node = get_identifier ("SourceFile"); - ggc_add_tree_root (&SourceFile_node, 1); } i = find_utf8_constant (&state->cpool, SourceFile_node); @@ -3174,18 +3173,17 @@ generate_classfile (clas, state) return state->first; } +static GTY(()) tree Synthetic_node; static unsigned char * append_synthetic_attribute (state) struct jcf_partial *state; { - static tree Synthetic_node = NULL_TREE; unsigned char *ptr = append_chunk (NULL, 6, state); int i; if (Synthetic_node == NULL_TREE) { Synthetic_node = get_identifier ("Synthetic"); - ggc_add_tree_root (&Synthetic_node, 1); } i = find_utf8_constant (&state->cpool, Synthetic_node); PUT2 (i); /* Attribute string index */ @@ -3212,12 +3210,12 @@ append_gcj_attribute (state, class) PUT4 (0); /* Attribute length */ } +static tree InnerClasses_node; static void append_innerclasses_attribute (state, class) struct jcf_partial *state; tree class; { - static tree InnerClasses_node = NULL_TREE; tree orig_decl = TYPE_NAME (class); tree current, decl; int length = 0, i; @@ -3231,7 +3229,6 @@ append_innerclasses_attribute (state, class) if (InnerClasses_node == NULL_TREE) { InnerClasses_node = get_identifier ("InnerClasses"); - ggc_add_tree_root (&InnerClasses_node, 1); } i = find_utf8_constant (&state->cpool, InnerClasses_node); PUT2 (i); @@ -3406,3 +3403,5 @@ write_classfile (clas) string concatenation synchronized statement */ + +#include "gt-java-jcf-write.h" diff --git a/gcc/java/lang.c b/gcc/java/lang.c index c699da3..a0f823f 100644 --- a/gcc/java/lang.c +++ b/gcc/java/lang.c @@ -213,6 +213,11 @@ static int dependency_tracking = 0; #define DEPEND_TARGET_SET 4 #define DEPEND_FILE_ALREADY_SET 8 +struct language_function GTY(()) +{ + int unused; +}; + #undef LANG_HOOKS_NAME #define LANG_HOOKS_NAME "GNU Java" #undef LANG_HOOKS_INIT @@ -225,8 +230,6 @@ static int dependency_tracking = 0; #define LANG_HOOKS_DECODE_OPTION java_decode_option #undef LANG_HOOKS_PARSE_FILE #define LANG_HOOKS_PARSE_FILE java_parse_file -#undef LANG_HOOKS_MARK_TREE -#define LANG_HOOKS_MARK_TREE java_mark_tree #undef LANG_HOOKS_MARK_ADDRESSABLE #define LANG_HOOKS_MARK_ADDRESSABLE java_mark_addressable #undef LANG_HOOKS_EXPAND_EXPR @@ -694,24 +697,13 @@ lang_printable_name_wls (decl, v) /* Print on stderr the current class and method context. This function is the value of the hook print_error_function. */ +static GTY(()) tree last_error_function_context; +static GTY(()) tree last_error_function; static void java_print_error_function (context, file) diagnostic_context *context __attribute__((__unused__)); const char *file; { - static tree last_error_function_context = NULL_TREE; - static tree last_error_function = NULL; - static int initialized_p; - - /* Register LAST_ERROR_FUNCTION_CONTEXT and LAST_ERROR_FUNCTION with - the garbage collector. */ - if (!initialized_p) - { - ggc_add_tree_root (&last_error_function_context, 1); - ggc_add_tree_root (&last_error_function, 1); - initialized_p = 1; - } - /* Don't print error messages with bogus function prototypes. */ if (inhibit_error_function_printing) return; @@ -770,3 +762,5 @@ java_init_options () /* In Java floating point operations never trap. */ flag_trapping_math = 0; } + +#include "gt-java-lang.h" diff --git a/gcc/java/mangle.c b/gcc/java/mangle.c index 590a9ad..ef70ff9 100644 --- a/gcc/java/mangle.c +++ b/gcc/java/mangle.c @@ -245,7 +245,7 @@ mangle_type (type) COMPRESSION_NEXT is the index to the location of the next insertion of an element. */ -static tree compression_table; +static GTY(()) tree compression_table; static int compression_next; /* Find a POINTER_TYPE in the compression table. Use a special @@ -431,12 +431,12 @@ mangle_pointer_type (type) the template indicator where already used an compress appropriately. It handles pointers. */ +/* atms: array template mangled string. */ +static GTY(()) tree atms; static void mangle_array_type (p_type) tree p_type; { - /* atms: array template mangled string. */ - static tree atms = NULL_TREE; tree type, elt_type; int match; @@ -450,7 +450,6 @@ mangle_array_type (p_type) if (!atms) { atms = get_identifier ("6JArray"); - ggc_add_tree_root (&atms, 1); } /* Maybe we have what we're looking in the compression table. */ @@ -602,9 +601,7 @@ compression_table_add (type) for (i = 0; i < compression_next; i++) TREE_VEC_ELT (new, i) = TREE_VEC_ELT (compression_table, i); - ggc_del_root (&compression_table); compression_table = new; - ggc_add_tree_root (&compression_table, 1); } TREE_VEC_ELT (compression_table, compression_next++) = type; } @@ -624,9 +621,6 @@ init_mangling (obstack) /* Mangled name are to be suffixed */ obstack_grow (mangle_obstack, "_Z", 2); - - /* Register the compression table with the GC */ - ggc_add_tree_root (&compression_table, 1); } /* Mangling finalization routine. The mangled name is returned as a @@ -641,7 +635,6 @@ finish_mangling () /* Mangling already finished. */ abort (); - ggc_del_root (&compression_table); compression_table = NULL_TREE; compression_next = 0; obstack_1grow (mangle_obstack, '\0'); @@ -652,3 +645,5 @@ finish_mangling () #endif return result; } + +#include "gt-java-mangle.h" diff --git a/gcc/java/parse.y b/gcc/java/parse.y index 197816f..960bd90 100644 --- a/gcc/java/parse.y +++ b/gcc/java/parse.y @@ -66,6 +66,7 @@ definitions and other extensions. */ #include "function.h" #include "except.h" #include "ggc.h" +#include "debug.h" #ifndef DIR_SEPARATOR #define DIR_SEPARATOR '/' @@ -298,8 +299,7 @@ static tree maybe_make_nested_class_name PARAMS ((tree)); static int make_nested_class_name PARAMS ((tree)); static void set_nested_class_simple_name_value PARAMS ((tree, int)); static void link_nested_class_to_enclosing PARAMS ((void)); -static tree resolve_inner_class PARAMS ((struct hash_table *, tree, tree *, - tree *, tree)); +static tree resolve_inner_class PARAMS ((htab_t, tree, tree *, tree *, tree)); static tree find_as_inner_class PARAMS ((tree, tree, tree)); static tree find_as_inner_class_do PARAMS ((tree, tree)); static int check_inner_class_redefinition PARAMS ((tree, tree)); @@ -334,9 +334,8 @@ static void create_new_parser_context PARAMS ((int)); static void mark_parser_ctxt PARAMS ((void *)); static tree maybe_build_class_init_for_field PARAMS ((tree, tree)); -static bool attach_init_test_initialization_flags PARAMS ((struct hash_entry *, - PTR)); -static bool emit_test_initialization PARAMS ((struct hash_entry *, PTR)); +static int attach_init_test_initialization_flags PARAMS ((PTR *, PTR)); +static int emit_test_initialization PARAMS ((PTR *, PTR)); static char *string_convert_int_cst PARAMS ((tree)); @@ -376,58 +375,58 @@ static const enum tree_code binop_lookup[19] = #define BINOP_COMPOUND_CANDIDATES 11 /* The "$L" identifier we use to create labels. */ -static tree label_id = NULL_TREE; +static GTY(()) tree label_id; /* The "StringBuffer" identifier used for the String `+' operator. */ -static tree wfl_string_buffer = NULL_TREE; +static GTY(()) tree wfl_string_buffer; /* The "append" identifier used for String `+' operator. */ -static tree wfl_append = NULL_TREE; +static GTY(()) tree wfl_append; /* The "toString" identifier used for String `+' operator. */ -static tree wfl_to_string = NULL_TREE; +static GTY(()) tree wfl_to_string; /* The "java.lang" import qualified name. */ -static tree java_lang_id = NULL_TREE; +static GTY(()) tree java_lang_id; /* The generated `inst$' identifier used for generated enclosing instance/field access functions. */ -static tree inst_id = NULL_TREE; +static GTY(()) tree inst_id; /* The "java.lang.Cloneable" qualified name. */ -static tree java_lang_cloneable = NULL_TREE; +static GTY(()) tree java_lang_cloneable; /* The "java.io.Serializable" qualified name. */ -static tree java_io_serializable = NULL_TREE; +static GTY(()) tree java_io_serializable; /* Context and flag for static blocks */ -static tree current_static_block = NULL_TREE; +static GTY(()) tree current_static_block; /* The generated `write_parm_value$' identifier. */ -static tree wpv_id; +static GTY(()) tree wpv_id; /* The list of all packages we've seen so far */ -static tree package_list = NULL_TREE; +static GTY(()) tree package_list; /* Hold THIS for the scope of the current method decl. */ -static tree current_this; +static GTY(()) tree current_this; /* Hold a list of catch clauses list. The first element of this list is the list of the catch clauses of the currently analysed try block. */ -static tree currently_caught_type_list; +static GTY(()) tree currently_caught_type_list; /* This holds a linked list of all the case labels for the current switch statement. It is only used when checking to see if there are duplicate labels. FIXME: probably this should just be attached to the switch itself; then it could be referenced via `ctxp->current_loop'. */ -static tree case_label_list; +static GTY(()) tree case_label_list; /* Anonymous class counter. Will be reset to 1 every time a non anonymous class gets created. */ static int anonymous_class_counter = 1; -static tree src_parse_roots[1]; +static GTY(()) tree src_parse_roots[1]; /* All classes seen from source code */ #define gclass_list src_parse_roots[0] @@ -614,20 +613,6 @@ goal: { /* Register static variables with the garbage collector. */ - ggc_add_tree_root (&label_id, 1); - ggc_add_tree_root (&wfl_string_buffer, 1); - ggc_add_tree_root (&wfl_append, 1); - ggc_add_tree_root (&wfl_to_string, 1); - ggc_add_tree_root (&java_lang_id, 1); - ggc_add_tree_root (&inst_id, 1); - ggc_add_tree_root (&java_lang_cloneable, 1); - ggc_add_tree_root (&java_io_serializable, 1); - ggc_add_tree_root (¤t_static_block, 1); - ggc_add_tree_root (&wpv_id, 1); - ggc_add_tree_root (&package_list, 1); - ggc_add_tree_root (¤t_this, 1); - ggc_add_tree_root (¤tly_caught_type_list, 1); - ggc_add_tree_root (&case_label_list, 1); ggc_add_root (&ctxp, 1, sizeof (struct parser_ctxt *), mark_parser_ctxt); @@ -3550,7 +3535,7 @@ check_inner_class_redefinition (raw_name, cl) static tree resolve_inner_class (circularity_hash, cl, enclosing, super, class_type) - struct hash_table *circularity_hash; + htab_t circularity_hash; tree cl, *enclosing, *super, class_type; { tree local_enclosing = *enclosing; @@ -3560,8 +3545,8 @@ resolve_inner_class (circularity_hash, cl, enclosing, super, class_type) { tree intermediate, decl; - hash_lookup (circularity_hash, - (const hash_table_key) local_enclosing, TRUE, NULL); + *htab_find_slot (circularity_hash, local_enclosing, INSERT) = + local_enclosing; if ((decl = find_as_inner_class (local_enclosing, class_type, cl))) return decl; @@ -3589,8 +3574,7 @@ resolve_inner_class (circularity_hash, cl, enclosing, super, class_type) /* We may not have checked for circular inheritance yet, so do so here to prevent an infinite loop. */ - if (hash_lookup (circularity_hash, - (const hash_table_key) local_super, FALSE, NULL)) + if (htab_find (circularity_hash, local_super) != NULL) { if (!cl) cl = lookup_cl (local_enclosing); @@ -4840,32 +4824,23 @@ constructor_circularity_msg (from, to) /* Verify a circular call to METH. Return 1 if an error is found, 0 otherwise. */ +static GTY(()) tree vcc_list; static int verify_constructor_circularity (meth, current) tree meth, current; { - static tree list = NULL_TREE; - static int initialized_p; tree c; - /* If we haven't already registered LIST with the garbage collector, - do so now. */ - if (!initialized_p) - { - ggc_add_tree_root (&list, 1); - initialized_p = 1; - } - for (c = DECL_CONSTRUCTOR_CALLS (current); c; c = TREE_CHAIN (c)) { if (TREE_VALUE (c) == meth) { char *t; - if (list) + if (vcc_list) { tree liste; - list = nreverse (list); - for (liste = list; liste; liste = TREE_CHAIN (liste)) + vcc_list = nreverse (vcc_list); + for (liste = vcc_list; liste; liste = TREE_CHAIN (liste)) { parse_error_context (TREE_PURPOSE (TREE_PURPOSE (liste)), "%s", @@ -4879,16 +4854,16 @@ verify_constructor_circularity (meth, current) "%s: recursive invocation of constructor `%s'", constructor_circularity_msg (current, meth), t); free (t); - list = NULL_TREE; + vcc_list = NULL_TREE; return 1; } } for (c = DECL_CONSTRUCTOR_CALLS (current); c; c = TREE_CHAIN (c)) { - list = tree_cons (c, current, list); + vcc_list = tree_cons (c, current, vcc_list); if (verify_constructor_circularity (meth, TREE_VALUE (c))) return 1; - list = TREE_CHAIN (list); + vcc_list = TREE_CHAIN (vcc_list); } return 0; } @@ -5782,14 +5757,14 @@ do_resolve_class (enclosing, class_type, decl, cl) tree new_class_decl = NULL_TREE, super = NULL_TREE; tree saved_enclosing_type = enclosing ? TREE_TYPE (enclosing) : NULL_TREE; tree decl_result; - struct hash_table _ht, *circularity_hash = &_ht; + htab_t circularity_hash; /* This hash table is used to register the classes we're going through when searching the current class as an inner class, in order to detect circular references. Remember to free it before returning the section 0- of this function. */ - hash_table_init (circularity_hash, hash_newfunc, - java_hash_hash_tree_node, java_hash_compare_tree_node); + circularity_hash = htab_create (20, htab_hash_pointer, htab_eq_pointer, + NULL); /* 0- Search in the current class as an inner class. Maybe some code here should be added to load the class or @@ -5811,7 +5786,7 @@ do_resolve_class (enclosing, class_type, decl, cl) enclosing = NULL_TREE; } - hash_table_free (circularity_hash); + htab_delete (circularity_hash); if (new_class_decl) return new_class_decl; @@ -6668,34 +6643,33 @@ lookup_java_method2 (clas, method_decl, do_interface) /* Return the line that matches DECL line number, and try its best to position the column number. Used during error reports. */ +static GTY(()) tree cl_v; static tree lookup_cl (decl) tree decl; { - static tree cl = NULL_TREE; char *line, *found; if (!decl) return NULL_TREE; - if (cl == NULL_TREE) + if (cl_v == NULL_TREE) { - cl = build_expr_wfl (NULL_TREE, NULL, 0, 0); - ggc_add_tree_root (&cl, 1); + cl_v = build_expr_wfl (NULL_TREE, NULL, 0, 0); } - EXPR_WFL_FILENAME_NODE (cl) = get_identifier (DECL_SOURCE_FILE (decl)); - EXPR_WFL_SET_LINECOL (cl, DECL_SOURCE_LINE_FIRST (decl), -1); + EXPR_WFL_FILENAME_NODE (cl_v) = get_identifier (DECL_SOURCE_FILE (decl)); + EXPR_WFL_SET_LINECOL (cl_v, DECL_SOURCE_LINE_FIRST (decl), -1); - line = java_get_line_col (EXPR_WFL_FILENAME (cl), - EXPR_WFL_LINENO (cl), EXPR_WFL_COLNO (cl)); + line = java_get_line_col (EXPR_WFL_FILENAME (cl_v), + EXPR_WFL_LINENO (cl_v), EXPR_WFL_COLNO (cl_v)); found = strstr ((const char *)line, (const char *)IDENTIFIER_POINTER (DECL_NAME (decl))); if (found) - EXPR_WFL_SET_LINECOL (cl, EXPR_WFL_LINENO (cl), found - line); + EXPR_WFL_SET_LINECOL (cl_v, EXPR_WFL_LINENO (cl_v), found - line); - return cl; + return cl_v; } /* Look for a simple name in the single-type import list */ @@ -7044,19 +7018,17 @@ static void register_package (name) tree name; { - static struct hash_table _pht, *pht = NULL; + static htab_t pht; + PTR *e; - if (!pht) - { - hash_table_init (&_pht, hash_newfunc, - java_hash_hash_tree_node, java_hash_compare_tree_node); - pht = &_pht; - } - - if (!hash_lookup (pht, (const hash_table_key) name, FALSE, NULL)) + if (pht == NULL) + pht = htab_create (50, htab_hash_pointer, htab_eq_pointer, NULL); + + e = htab_find_slot (pht, name, INSERT); + if (*e == NULL) { package_list = chainon (package_list, build_tree_list (name, NULL)); - hash_lookup (pht, (const hash_table_key) name, TRUE, NULL); + *e = name; } } @@ -7559,20 +7531,12 @@ void java_layout_seen_class_methods () } } +static GTY(()) tree stop_reordering; void java_reorder_fields () { - static tree stop_reordering = NULL_TREE; - static int initialized_p; tree current; - /* Register STOP_REORDERING with the garbage collector. */ - if (!initialized_p) - { - ggc_add_tree_root (&stop_reordering, 1); - initialized_p = 1; - } - for (current = gclass_list; current; current = TREE_CHAIN (current)) { current_class = TREE_TYPE (TREE_VALUE (current)); @@ -8060,7 +8024,7 @@ java_complete_expand_method (mdecl) /* Before we check initialization, attached all class initialization variable to the block_body */ - hash_traverse (&DECL_FUNCTION_INIT_TEST_TABLE (mdecl), + htab_traverse (DECL_FUNCTION_INIT_TEST_TABLE (mdecl), attach_init_test_initialization_flags, block_body); if (! flag_emit_xref && ! METHOD_NATIVE (mdecl)) @@ -8077,9 +8041,11 @@ java_complete_expand_method (mdecl) MDECL. This used with caution helps removing extra initialization of self. */ if (METHOD_STATIC (mdecl)) - hash_lookup (&DECL_FUNCTION_INITIALIZED_CLASS_TABLE (mdecl), - (hash_table_key) DECL_CONTEXT (mdecl), - TRUE, NULL); + { + *(htab_find_slot + (DECL_FUNCTION_INITIALIZED_CLASS_TABLE (mdecl), + DECL_CONTEXT (mdecl), INSERT)) = DECL_CONTEXT (mdecl); + } } } ctxp->explicit_constructor_p = 0; @@ -8147,7 +8113,7 @@ java_expand_method_bodies (class) /* For each class definitely initialized in CALLED_METHOD, fill ASSIGNMENT_COMPOUND with assignment to the class initialization flag. */ - hash_traverse (&DECL_FUNCTION_INITIALIZED_CLASS_TABLE (called_method), + htab_traverse (DECL_FUNCTION_INITIALIZED_CLASS_TABLE (called_method), emit_test_initialization, assignment_compound_list); @@ -8635,27 +8601,19 @@ maybe_build_thisn_access_method (type) This function can be invoked with TYPE to NULL, available and then has to count the parser context. */ +static GTY(()) tree saved_thisn; +static GTY(()) tree saved_type; + static tree build_current_thisn (type) tree type; { static int saved_i = -1; - static tree saved_thisn = NULL_TREE; - static tree saved_type = NULL_TREE; static int saved_type_i = 0; - static int initialized_p; tree decl; char buffer [24]; int i = 0; - /* Register SAVED_THISN and SAVED_TYPE with the garbage collector. */ - if (!initialized_p) - { - ggc_add_tree_root (&saved_thisn, 1); - ggc_add_tree_root (&saved_type, 1); - initialized_p = 1; - } - if (type) { if (type == saved_type) @@ -8712,6 +8670,9 @@ build_thisn_assign () throw new NoClassDefFoundError(e.getMessage());} } */ +static GTY(()) tree get_message_wfl; +static GTY(()) tree type_parm_wfl; + static tree build_dot_class_method (class) tree class; @@ -8721,14 +8682,10 @@ build_dot_class_method (class) tree args, tmp, saved_current_function_decl, mdecl; tree stmt, throw_stmt; - static tree get_message_wfl, type_parm_wfl; - if (!get_message_wfl) { get_message_wfl = build_wfl_node (get_identifier ("getMessage")); type_parm_wfl = build_wfl_node (get_identifier ("type$")); - ggc_add_tree_root (&get_message_wfl, 1); - ggc_add_tree_root (&type_parm_wfl, 1); } /* Build the arguments */ @@ -8985,6 +8942,7 @@ verify_constructor_super (mdecl) /* Generate code for all context remembered for code generation. */ +static GTY(()) tree reversed_class_list; void java_expand_classes () { @@ -9066,7 +9024,7 @@ java_expand_classes () for (cur_ctxp = ctxp_for_generation; cur_ctxp; cur_ctxp = cur_ctxp->next) { tree current; - tree reversed_class_list = NULL; + reversed_class_list = NULL; ctxp = cur_ctxp; @@ -9083,7 +9041,6 @@ java_expand_classes () current = TREE_CHAIN (current)) reversed_class_list = tree_cons (NULL_TREE, current, reversed_class_list); - ggc_add_tree_root (&reversed_class_list, 1); for (current = reversed_class_list; current; @@ -9101,8 +9058,6 @@ java_expand_classes () finish_class (); } } - - ggc_del_root (&reversed_class_list); } } @@ -10094,15 +10049,15 @@ check_deprecation (wfl, decl) /* Returns 1 if class was declared in the current package, 0 otherwise */ +static GTY(()) tree cicp_cache; static int class_in_current_package (class) tree class; { - static tree cache = NULL_TREE; int qualified_flag; tree left; - if (cache == class) + if (cicp_cache == class) return 1; qualified_flag = QUALIFIED_P (DECL_NAME (TYPE_NAME (class))); @@ -10123,15 +10078,7 @@ class_in_current_package (class) breakdown_qualified (&left, NULL, DECL_NAME (TYPE_NAME (class))); if (ctxp->package == left) { - static int initialized_p; - /* Register CACHE with the garbage collector. */ - if (!initialized_p) - { - ggc_add_tree_root (&cache, 1); - initialized_p = 1; - } - - cache = class; + cicp_cache = class; return 1; } return 0; @@ -10939,7 +10886,7 @@ find_applicable_accessible_methods_list (lc, class, name, arglist) int lc; tree class, name, arglist; { - static struct hash_table t, *searched_classes = NULL; + static htab_t searched_classes; static int search_not_done = 0; tree list = NULL_TREE, all_list = NULL_TREE; @@ -10947,20 +10894,17 @@ find_applicable_accessible_methods_list (lc, class, name, arglist) already. */ if (searched_classes) { - if (hash_lookup (searched_classes, - (const hash_table_key) class, FALSE, NULL)) - return NULL; + if (htab_find (searched_classes, class) != NULL) + return NULL; } else { - hash_table_init (&t, hash_newfunc, java_hash_hash_tree_node, - java_hash_compare_tree_node); - searched_classes = &t; + searched_classes = htab_create (10, htab_hash_pointer, + htab_eq_pointer, NULL); } search_not_done++; - hash_lookup (searched_classes, - (const hash_table_key) class, TRUE, NULL); + *htab_find_slot (searched_classes, class, INSERT) = class; if (!CLASS_LOADED_P (class) && !CLASS_FROM_SOURCE_P (class)) { @@ -11040,15 +10984,13 @@ find_applicable_accessible_methods_list (lc, class, name, arglist) { if (!lc && TYPE_METHODS (object_type_node) - && !hash_lookup (searched_classes, - (const hash_table_key) object_type_node, - FALSE, NULL)) + && htab_find (searched_classes, object_type_node) == NULL) { search_applicable_methods_list (lc, TYPE_METHODS (object_type_node), name, arglist, &list, &all_list); } - hash_table_free (searched_classes); + htab_delete (searched_classes); searched_classes = NULL; } @@ -11178,25 +11120,15 @@ find_most_specific_methods_list (list) corresponding parameter of M1. Implementation expects M2_OR_ARGLIST to change less often than M1. */ +static GTY(()) tree m2_arg_value; +static GTY(()) tree m2_arg_cache; + static int argument_types_convertible (m1, m2_or_arglist) tree m1, m2_or_arglist; { - static tree m2_arg_value = NULL_TREE; - static tree m2_arg_cache = NULL_TREE; - static int initialized_p; - register tree m1_arg, m2_arg; - /* Register M2_ARG_VALUE and M2_ARG_CACHE with the garbage - collector. */ - if (!initialized_p) - { - ggc_add_tree_root (&m2_arg_value, 1); - ggc_add_tree_root (&m2_arg_cache, 1); - initialized_p = 1; - } - SKIP_THIS_AND_ARTIFICIAL_PARMS (m1_arg, m1) if (m2_arg_value == m2_or_arglist) @@ -16140,9 +16072,6 @@ mark_parser_ctxt (p) void init_src_parse () { - /* Register roots with the garbage collector. */ - ggc_add_tree_root (src_parse_roots, ARRAY_SIZE (src_parse_roots)); - /* Sanity check; we've been bit by this before. */ if (ARRAY_SIZE (ctxp->modifier_ctx) != MODIFIER_TK - PUBLIC_TK) abort (); @@ -16155,16 +16084,16 @@ init_src_parse () /* Attach to PTR (a block) the declaration found in ENTRY. */ -static bool +static int attach_init_test_initialization_flags (entry, ptr) - struct hash_entry *entry; + PTR *entry; PTR ptr; { tree block = (tree)ptr; - struct init_test_hash_entry *ite = (struct init_test_hash_entry *) entry; + struct treetreehash_entry *ite = (struct treetreehash_entry *) *entry; - TREE_CHAIN (ite->init_test_decl) = BLOCK_EXPR_DECLS (block); - BLOCK_EXPR_DECLS (block) = ite->init_test_decl; + TREE_CHAIN (ite->value) = BLOCK_EXPR_DECLS (block); + BLOCK_EXPR_DECLS (block) = ite->value; return true; } @@ -16174,28 +16103,29 @@ attach_init_test_initialization_flags (entry, ptr) initialized static class flags if a flag already existed, otherwise a new one is created. */ -static bool -emit_test_initialization (entry, info) - struct hash_entry *entry; +static int +emit_test_initialization (entry_p, info) + PTR *entry_p; PTR info; { tree l = (tree) info; tree decl, init; - - struct init_test_hash_entry *ite = (struct init_test_hash_entry *) - hash_lookup (&DECL_FUNCTION_INIT_TEST_TABLE (current_function_decl), - entry->key, - current_function_decl != TREE_PURPOSE (l), NULL); + tree key = (tree) *entry_p; + tree *ite; + htab_t cf_ht = DECL_FUNCTION_INIT_TEST_TABLE (current_function_decl); /* If we haven't found a flag and we're dealing with self registered with current_function_decl, then don't do anything. Self is always added as definitely initialized but this information is valid only if used outside the current function. */ - if (! ite) + if (current_function_decl == TREE_PURPOSE (l) + && java_treetreehash_find (cf_ht, key) == NULL) return true; + + ite = java_treetreehash_new (cf_ht, key); /* If we don't have a variable, create one and install it. */ - if (! ite->init_test_decl) + if (*ite == NULL) { tree block; @@ -16209,10 +16139,10 @@ emit_test_initialization (entry, info) block = BLOCK_SUBBLOCKS (GET_CURRENT_BLOCK (current_function_decl)); TREE_CHAIN (decl) = BLOCK_EXPR_DECLS (block); BLOCK_EXPR_DECLS (block) = decl; - ite->init_test_decl = decl; + *ite = decl; } else - decl = ite->init_test_decl; + decl = *ite; /* Now simply augment the compound that holds all the assignments pertaining to this method invocation. */ @@ -16223,3 +16153,6 @@ emit_test_initialization (entry, info) return true; } + +#include "gt-java-parse.h" +#include "gtype-java.h" |