From f15b9af9843e58e7c03df81098a8a15646f5058e Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Sun, 1 Oct 2000 19:19:30 +0000 Subject: c-decl.c (c_expand_body): Don't generate RTL if flag_syntax_only. * c-decl.c (c_expand_body): Don't generate RTL if flag_syntax_only. (lang_mark_false_label_stack): Remove. * c-lex.c (init_c_lex): Add file_info_tree as GC root. Allocate string in GC area. (mark_splay_tree_node): New function. (mark_splay_tree): Likewise. * except.c (mark_eh_status): Only call lang_mark_false_label_stack if it exists. * ggc-callbacks.c (lang_mark_false_label_stack): Remove. * ggc-common.c (lang_mark_false_label_stack): Change type. * ggc.h (ggc_alloc_string): Add comment. (ggc_strdup): New function. * decl.c (lang_mark_false_label_stack): Remove. * lex.c (cp_mang_lang_type): Use ggc_alloc_cleared. * com.c (lang_mark_false_label_stack): Remove. Convert to GC. * Make-lang.in (s-java): Don't depend on ggc-callbacks.o. * Makefile.in (BACKEND): Don't include ggc-callbacks.o. (typeck.o): Depend on ggc.h. * class.c (add_method_1): Use GC functions for allocation. (init_class_processing): Register roots. * decl.c (ggc_p): Set to 1. (pending_local_decls): Make it static. (push_jvm_slot): Use GC functions for allocation. (init_decl_processing): Register roots. (give_name_to_locals): Use GC functions for allocation. (lang_mark_tree): New function. * java-tree.h (MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC): Use GC functions for allocation. * jcf-parse.c (jcf_parse_source): Use ggc_strdup. * lex.c (java_lex): Use build_string, rather than replicating it inline. * parse.y (goal): Add more roots. (mark_parser_ctxt): New function. * typeck.c: Include ggc.h. * splay-tree.c (splay_tree_insert): Fix formatting. From-SVN: r36687 --- gcc/java/ChangeLog | 23 ++++++++++++++++++ gcc/java/Make-lang.in | 2 +- gcc/java/Makefile.in | 4 ++-- gcc/java/class.c | 4 ++-- gcc/java/decl.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++--- gcc/java/java-tree.h | 14 +++++------ gcc/java/jcf-parse.c | 2 +- gcc/java/lex.c | 9 +------ gcc/java/parse.y | 45 ++++++++++++++++++++++++++++++++++- gcc/java/typeck.c | 1 + 10 files changed, 144 insertions(+), 26 deletions(-) (limited to 'gcc/java') diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 632707b..4b6d307 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,26 @@ +2000-10-01 Mark Mitchell + + Convert to GC. + * Make-lang.in (s-java): Don't depend on ggc-callbacks.o. + * Makefile.in (BACKEND): Don't include ggc-callbacks.o. + (typeck.o): Depend on ggc.h. + * class.c (add_method_1): Use GC functions for allocation. + (init_class_processing): Register roots. + * decl.c (ggc_p): Set to 1. + (pending_local_decls): Make it static. + (push_jvm_slot): Use GC functions for allocation. + (init_decl_processing): Register roots. + (give_name_to_locals): Use GC functions for allocation. + (lang_mark_tree): New function. + * java-tree.h (MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC): Use GC + functions for allocation. + * jcf-parse.c (jcf_parse_source): Use ggc_strdup. + * lex.c (java_lex): Use build_string, rather than replicating it + inline. + * parse.y (goal): Add more roots. + (mark_parser_ctxt): New function. + * typeck.c: Include ggc.h. + 2000-09-29 Alexandre Petit-Bianco * parse.y (maybe_yank_clinit): Also keep if its body diff --git a/gcc/java/Make-lang.in b/gcc/java/Make-lang.in index 1a17a98..6036f60 100644 --- a/gcc/java/Make-lang.in +++ b/gcc/java/Make-lang.in @@ -139,7 +139,7 @@ JCF_DUMP_SOURCES = $(srcdir)/java/jcf-dump.c $(srcdir)/java/jcf-io.c \ jc1$(exeext) gcjh$(exeext) jv-scan$(exeext) jcf-dump$(exeext): s-java -s-java: $(P) $(JAVA_SRCS) $(LIBDEPS) $(BACKEND) ggc-callbacks.o \ +s-java: $(P) $(JAVA_SRCS) $(LIBDEPS) $(BACKEND) \ $(GCJH_SOURCES) $(LIBDEPS) $(TREE_H) \ $(JV_SCAN_SOURCES) $(BACKEND) $(LIBDEPS) \ $(JCF_DUMP_SOURCES) diff --git a/gcc/java/Makefile.in b/gcc/java/Makefile.in index 794ec66..7cec285 100644 --- a/gcc/java/Makefile.in +++ b/gcc/java/Makefile.in @@ -181,7 +181,7 @@ JAVA_OBJS = parse.o class.o decl.o expr.o constants.o lang.o typeck.o \ JAVA_OBJS_LITE = parse-scan.o jv-scan.o # Language-independent object files. -BACKEND = ../toplev.o ../ggc-callbacks.o ../libbackend.a +BACKEND = ../toplev.o ../libbackend.a compiler: ../jc1$(exeext) ../jv-scan$(exeext) ../jc1$(exeext): $(P) $(JAVA_OBJS) $(BACKEND) $(LIBDEPS) @@ -317,7 +317,7 @@ mangle.o : mangle.c $(CONFIG_H) jcf.h $(JAVA_TREE_H) $(srcdir)/../system.h \ parse-scan.o : $(CONFIG_H) $(srcdir)/../system.h $(srcdir)/../toplev.h \ $(srcdir)/lex.c $(PARSE_H) $(srcdir)/lex.h typeck.o : typeck.c $(CONFIG_H) $(JAVA_TREE_H) jcf.h convert.h \ - $(srcdir)/../toplev.h $(srcdir)/../system.h + $(srcdir)/../toplev.h $(srcdir)/../system.h $(srcdir)/../ggc.h verify.o : verify.c $(CONFIG_H) $(JAVA_TREE_H) jcf.h javaop.h java-opcodes.h \ java-except.h $(srcdir)/../toplev.h $(srcdir)/../system.h xref.o : xref.c xref.h $(CONFIG_H) $(JAVA_TREE_H) $(srcdir)/../toplev.h \ diff --git a/gcc/java/class.c b/gcc/java/class.c index b69bfc1..f9300bc 100644 --- a/gcc/java/class.c +++ b/gcc/java/class.c @@ -655,8 +655,7 @@ add_method_1 (handle_class, access_flags, name, function_type) DECL_CONTEXT (fndecl) = handle_class; DECL_LANG_SPECIFIC (fndecl) - = (struct lang_decl *) permalloc (sizeof (struct lang_decl)); - bzero ((PTR) DECL_LANG_SPECIFIC (fndecl), sizeof (struct lang_decl)); + = (struct lang_decl *) ggc_alloc_cleared (sizeof (struct lang_decl)); /* Initialize the static initializer test table. */ hash_table_init (&DECL_FUNCTION_INIT_TEST_TABLE (fndecl), @@ -2121,4 +2120,5 @@ init_class_processing () { registerClass_libfunc = gen_rtx (SYMBOL_REF, Pmode, "_Jv_RegisterClass"); ggc_add_tree_root (®istered_class, 1); + ggc_add_rtx_root (®isterClass_libfunc, 1); } diff --git a/gcc/java/decl.c b/gcc/java/decl.c index e1c630db..da44ca6 100644 --- a/gcc/java/decl.c +++ b/gcc/java/decl.c @@ -55,6 +55,10 @@ static tree create_primitive_vtable PARAMS ((const char *)); before static field references. */ extern int always_initialize_class_p; +/* Use garbage collection. */ + +int ggc_p = 1; + /* The DECL_MAP is a mapping from (index, type) to a decl node. If index < max_locals, it is the index of a local variable. if index >= max_locals, then index-max_locals is a stack slot. @@ -68,7 +72,7 @@ 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. */ -tree pending_local_decls = NULL_TREE; +static tree pending_local_decls = NULL_TREE; tree throw_node [2]; @@ -126,7 +130,7 @@ push_jvm_slot (index, decl) if (DECL_LANG_SPECIFIC (decl) == NULL) { DECL_LANG_SPECIFIC (decl) - = (struct lang_decl *) permalloc (sizeof (struct lang_decl_var)); + = (struct lang_decl *) ggc_alloc (sizeof (struct lang_decl_var)); DECL_LOCAL_START_PC (decl) = 0; DECL_LOCAL_END_PC (decl) = DECL_CODE_LENGTH (current_function_decl); DECL_LOCAL_SLOT_NUMBER (decl) = index; @@ -851,6 +855,8 @@ init_decl_processing () sizeof (throw_node) / sizeof (tree)); ggc_add_tree_root (predef_filenames, sizeof (predef_filenames) / sizeof (tree)); + ggc_add_tree_root (&decl_map, 1); + ggc_add_tree_root (&pending_local_decls, 1); } @@ -1548,7 +1554,7 @@ give_name_to_locals (jcf) end_pc = DECL_CODE_LENGTH (current_function_decl); } DECL_LANG_SPECIFIC (decl) - = (struct lang_decl *) permalloc (sizeof (struct lang_decl_var)); + = (struct lang_decl *) ggc_alloc (sizeof (struct lang_decl_var)); DECL_LOCAL_SLOT_NUMBER (decl) = slot; DECL_LOCAL_START_PC (decl) = start_pc; #if 0 @@ -1818,3 +1824,57 @@ end_java_method () permanent_allocation (1); asynchronous_exceptions = flag_asynchronous_exceptions; } + +/* Mark language-specific parts of T for garbage-collection. */ + +void +lang_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) + { + struct lang_decl_var *ldv = + ((struct lang_decl_var *) DECL_LANG_SPECIFIC (t)); + if (ldv) + { + ggc_mark (ldv); + ggc_mark_tree (ldv->slot_chain); + } + } + else if (TREE_CODE (t) == FUNCTION_DECL) + { + struct lang_decl *ld = DECL_LANG_SPECIFIC (t); + + if (ld) + { + ggc_mark (ld); + 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); + } + } + 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); + } + } +} diff --git a/gcc/java/java-tree.h b/gcc/java/java-tree.h index 0b75387..d22efec 100644 --- a/gcc/java/java-tree.h +++ b/gcc/java/java-tree.h @@ -829,14 +829,12 @@ struct lang_decl_var #define TYPE_JCF(T) (TYPE_LANG_SPECIFIC(T)->jcf) #define TYPE_CPOOL(T) (TYPE_LANG_SPECIFIC(T)->cpool) #define TYPE_CPOOL_DATA_REF(T) (TYPE_LANG_SPECIFIC(T)->cpool_data_ref) -#define MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC(T) \ - if (TYPE_LANG_SPECIFIC ((T)) == NULL) \ - { \ - TYPE_LANG_SPECIFIC ((T)) = \ - (struct lang_type *) xmalloc (sizeof (struct lang_type)); \ - \ - bzero ((char *) TYPE_LANG_SPECIFIC ((T)), \ - sizeof (struct lang_type)); \ +#define MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC(T) \ + if (TYPE_LANG_SPECIFIC ((T)) == NULL) \ + { \ + TYPE_LANG_SPECIFIC ((T)) = \ + ((struct lang_type *) \ + ggc_alloc_cleared (sizeof (struct lang_type))); \ } #define TYPE_FINIT_STMT_LIST(T) (TYPE_LANG_SPECIFIC(T)->finit_stmt_list) diff --git a/gcc/java/jcf-parse.c b/gcc/java/jcf-parse.c index 7abd1cb..ccfba7d 100644 --- a/gcc/java/jcf-parse.c +++ b/gcc/java/jcf-parse.c @@ -568,7 +568,7 @@ jcf_parse_source () java_parser_context_save_global (); java_push_parser_context (); - input_filename = current_jcf->filename; + input_filename = ggc_strdup (current_jcf->filename); file = get_identifier (input_filename); current_class = NULL_TREE; current_function_decl = NULL_TREE; diff --git a/gcc/java/lex.c b/gcc/java/lex.c index 4179b1d..5d106c4 100644 --- a/gcc/java/lex.c +++ b/gcc/java/lex.c @@ -1081,14 +1081,7 @@ java_lex (java_lval) if (!no_error || (c != '"')) java_lval->node = error_mark_node; /* Requires futher testing FIXME */ else - { - tree s = make_node (STRING_CST); - TREE_STRING_LENGTH (s) = strlen (string); - TREE_STRING_POINTER (s) = - obstack_alloc (expression_obstack, TREE_STRING_LENGTH (s)+1); - strcpy (TREE_STRING_POINTER (s), string); - java_lval->node = s; - } + java_lval->node = build_string (strlen (string), string); #endif return STRING_LIT_TK; } diff --git a/gcc/java/parse.y b/gcc/java/parse.y index e6aeb32..9ebeb44 100644 --- a/gcc/java/parse.y +++ b/gcc/java/parse.y @@ -323,6 +323,7 @@ static void add_inner_class_fields PARAMS ((tree, tree)); static tree build_dot_class_method PARAMS ((tree)); static tree build_dot_class_method_invocation PARAMS ((tree)); static void create_new_parser_context PARAMS ((int)); +static void mark_parser_ctxt PARAMS ((void *)); /* Number of error found so far. */ int java_error_count; @@ -332,7 +333,7 @@ int java_warning_count; int do_not_fold; /* Cyclic inheritance report, as it can be set by layout_class */ char *cyclic_inheritance_report; - + /* Tell when we're within an instance initializer */ static int in_instance_initializer; @@ -597,6 +598,12 @@ goal: 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_root (&ctxp, 1, + sizeof (struct parser_ctxt *), + mark_parser_ctxt); + ggc_add_root (&ctxp_for_generation, 1, + sizeof (struct parser_ctxt *), + mark_parser_ctxt); } compilation_unit {} @@ -15215,3 +15222,39 @@ resolve_qualified_name (name, context) { } #endif + +/* Mark P, which is really a `struct parser_ctxt **' for GC. */ + +static void +mark_parser_ctxt (p) + void *p; +{ + struct parser_ctxt *pc = *((struct parser_ctxt **) p); + int i; + + if (!pc) + return; + +#ifndef JC1_LITE + for (i = 0; i < 11; ++i) + ggc_mark_tree (pc->modifier_ctx[i]); + ggc_mark_tree (pc->class_type); + ggc_mark_tree (pc->function_decl); + ggc_mark_tree (pc->package); + ggc_mark_tree (pc->incomplete_class); + ggc_mark_tree (pc->gclass_list); + ggc_mark_tree (pc->class_list); + ggc_mark_tree (pc->current_parsed_class); + ggc_mark_tree (pc->current_parsed_class_un); + ggc_mark_tree (pc->non_static_initialized); + ggc_mark_tree (pc->static_initialized); + ggc_mark_tree (pc->instance_initializers); + ggc_mark_tree (pc->import_list); + ggc_mark_tree (pc->import_demand_list); + ggc_mark_tree (pc->current_loop); + ggc_mark_tree (pc->current_labeled_block); +#endif /* JC1_LITE */ + + if (pc->next) + mark_parser_ctxt (&pc->next); +} diff --git a/gcc/java/typeck.c b/gcc/java/typeck.c index cb0305d..08ab30f 100644 --- a/gcc/java/typeck.c +++ b/gcc/java/typeck.c @@ -33,6 +33,7 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */ #include "jcf.h" #include "convert.h" #include "toplev.h" +#include "ggc.h" static tree convert_ieee_real_to_integer PARAMS ((tree, tree)); static tree parse_signature_type PARAMS ((const unsigned char **, -- cgit v1.1