diff options
Diffstat (limited to 'gcc/java')
-rw-r--r-- | gcc/java/ChangeLog | 72 | ||||
-rw-r--r-- | gcc/java/class.c | 37 | ||||
-rw-r--r-- | gcc/java/constants.c | 8 | ||||
-rw-r--r-- | gcc/java/decl.c | 13 | ||||
-rw-r--r-- | gcc/java/except.c | 26 | ||||
-rw-r--r-- | gcc/java/expr.c | 22 | ||||
-rw-r--r-- | gcc/java/java-tree.h | 2 | ||||
-rw-r--r-- | gcc/java/jcf-parse.c | 17 | ||||
-rw-r--r-- | gcc/java/lex.c | 5 | ||||
-rw-r--r-- | gcc/java/parse.h | 18 | ||||
-rw-r--r-- | gcc/java/parse.y | 70 | ||||
-rw-r--r-- | gcc/java/typeck.c | 6 |
12 files changed, 134 insertions, 162 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 1f0229a9a3a..aa9bb2bb546 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,75 @@ +2000-10-12 Mark Mitchell <mark@codesourcery.com> + + * class.c (temporary_obstack): Remove. + (make_class): Don't mess with obstascks. + (push_class): Likewise. + (set_super_info): Likewise. + (add_method_1): Likewise. + (add_method): Likewise. + (add_field): Likewise. + (build_utf8_ref): Likewise. + (build_class_ref): Likewise. + (build_static_field_ref): Likewise. + (finish_class): Likewise. + (push_super_field): Likewise. + (layout_class): Likewise. + (layout_class_methods): Likewise. + (init_class_processing): Likewise. + * constants.c (get_tag_node): Likewise. + (build_constant_data_ref): Likewise. + * decl.c (ggc_p): Remove. + (copy_lang_decl): Use ggc_alloc. + (complete_start_java_method): Don't mess with obstacks. + (start_java_method): Likewise. + (end_java_method): Likewise. + * except.c (link_handler): Use xmalloc. + (free_eh_ranges): New function. + (method_init_exceptions): Use it. + (add_handler): Use xmalloc. + (expand_start_java_handler): Don't mess with obstacks. + (prepare_eh_table_type): Likewise. + (expand_end_java_handler): Likewise. + * expr.c (push_value): Likewise. + (create_label_decl): Likewise. + (build_jni_stub): Likewise. + (java_lang_expand_expr): Likewise. + (note_instructions): Use xrealloc. + (java_push_constant_from_pool): Don't mess with obstacks. + (process_jvm_instruction): Likewise. + * java-tree.h (cyclic_inheritance_report): Remove duplicate + declaration. + * jcf-parse.c (get_constant): Don't mess with obstacks. + (read_class): Likewise. + (jcf_parse): Likewise. + * lex.c (expresion_obstack): Remove. + (java_lex): Don't use obstack_free. + * parse.h (exit_java_complete_class): Don't mess with obstacks. + (MANGLE_OUTER_LOCAL_VARIABLE_NAME): Adjust. + (MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_ID): Likewise. + (MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_STRING): Likewise. + * parse.y (gaol): Add more GC roots. + (add_inner_class_fields): Adjust calls to MANGLE_* macros. + (lookup_field_wrapper): Likewise. + (obtain_incomplete_type): Don't mess with obstacks. + (build_alias_initializer_paramter_list): Adjust calls to MANGLE_* + macros. + (craft_constructor): Don't mess with obstacks. + (safe_layout_class): Likewise. + (java_complete_class): Likewise. + (source_end_java_method): Likewise. + (build_outer_field_access_methods): Likewise. + (build_outer_method_access_method): Likewise. + (maybe_build_thisn_access_method): Likewise. + (build_dot_class_method_invocation): Likewise. + (java_complete_tree): Likewise. + (java_complete_lhs): Likewise. + (do_merge_string_cste): Likewise. + (patch_string_cst): Likewise. + (array_constructor_check_entry): Likewise. + * typeck.c (build_java_array_type): Likewise. + (parse_signature_string): Likewise. + (build_java_signature): Likewise. + 2000-10-12 Tom Tromey <tromey@cygnus.com> Fix for PR gcj/356: diff --git a/gcc/java/class.c b/gcc/java/class.c index b029da55538..1b184975dfa 100644 --- a/gcc/java/class.c +++ b/gcc/java/class.c @@ -59,7 +59,7 @@ static tree mangle_field PARAMS ((tree, tree)); static rtx registerClass_libfunc; extern struct obstack permanent_obstack; -extern struct obstack temporary_obstack; +struct obstack temporary_obstack; /* The compiler generates different code depending on whether or not it can assume certain classes have been compiled down to native @@ -272,7 +272,6 @@ tree make_class () { tree type; - push_obstacks (&permanent_obstack, &permanent_obstack); type = make_node (RECORD_TYPE); #ifdef JAVA_USE_HANDLES tree field1 = build_decl (FIELD_DECL, get_identifier ("obj"), @@ -290,7 +289,6 @@ make_class () TYPE_BINFO (type) = make_tree_vec (6); #endif MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC (type); - pop_obstacks (); return type; } @@ -327,7 +325,6 @@ push_class (class_type, class_name) const char *save_input_filename = input_filename; int save_lineno = lineno; tree source_name = identifier_subst (class_name, "", '.', '/', ".java"); - push_obstacks (&permanent_obstack, &permanent_obstack); CLASS_P (class_type) = 1; input_filename = IDENTIFIER_POINTER (source_name); lineno = 0; @@ -353,7 +350,6 @@ push_class (class_type, class_name) } #endif - pop_obstacks (); return decl; } @@ -384,7 +380,6 @@ set_super_info (access_flags, this_class, super_class, interfaces_count) if (super_class) total_supers++; - push_obstacks (&permanent_obstack, &permanent_obstack); TYPE_BINFO_BASETYPES (this_class) = make_tree_vec (total_supers); if (super_class) { @@ -396,7 +391,6 @@ set_super_info (access_flags, this_class, super_class, interfaces_count) = super_binfo; CLASS_HAS_SUPER (this_class) = 1; } - pop_obstacks (); if (access_flags & ACC_PUBLIC) CLASS_PUBLIC (class_decl) = 1; if (access_flags & ACC_FINAL) CLASS_FINAL (class_decl) = 1; @@ -649,7 +643,6 @@ add_method_1 (handle_class, access_flags, name, function_type) tree function_type; { tree method_type, fndecl; - push_obstacks (&permanent_obstack, &permanent_obstack); method_type = build_java_method_type (function_type, handle_class, access_flags); @@ -667,7 +660,6 @@ add_method_1 (handle_class, access_flags, name, function_type) TREE_CHAIN (fndecl) = TYPE_METHODS (handle_class); TYPE_METHODS (handle_class) = fndecl; - pop_obstacks (); if (access_flags & ACC_PUBLIC) METHOD_PUBLIC (fndecl) = 1; if (access_flags & ACC_PROTECTED) METHOD_PROTECTED (fndecl) = 1; @@ -702,13 +694,11 @@ add_method (this_class, access_flags, name, method_sig) tree handle_class = CLASS_TO_HANDLE_TYPE (this_class); tree function_type, fndecl; const unsigned char *sig = (const unsigned char*)IDENTIFIER_POINTER (method_sig); - push_obstacks (&permanent_obstack, &permanent_obstack); if (sig[0] != '(') fatal ("bad method signature"); function_type = get_type_from_signature (method_sig); fndecl = add_method_1 (handle_class, access_flags, name, function_type); set_java_signature (TREE_TYPE (fndecl), method_sig); - pop_obstacks (); return fndecl; } @@ -721,10 +711,7 @@ add_field (class, name, field_type, flags) { int is_static = (flags & ACC_STATIC) != 0; tree field; - /* Push the obstack of field_type ? FIXME */ - push_obstacks (&permanent_obstack, &permanent_obstack); field = build_decl (is_static ? VAR_DECL : FIELD_DECL, name, field_type); - pop_obstacks (); TREE_CHAIN (field) = TYPE_FIELDS (class); TYPE_FIELDS (class) = field; DECL_CONTEXT (field) = class; @@ -820,7 +807,6 @@ build_utf8_ref (name) if (ref != NULL_TREE) return ref; - push_obstacks (&permanent_obstack, &permanent_obstack); ctype = make_node (RECORD_TYPE); str_type = build_prim_array_type (unsigned_byte_type_node, name_len + 1); /* Allow for final '\0'. */ @@ -872,7 +858,6 @@ build_utf8_ref (name) make_decl_rtl (decl, (char*) 0, 1); ref = build1 (ADDR_EXPR, utf8const_ptr_type, decl); IDENTIFIER_UTF8_REF (name) = ref; - pop_obstacks (); return ref; } @@ -898,7 +883,6 @@ build_class_ref (type) decl = IDENTIFIER_GLOBAL_VALUE (decl_name); if (decl == NULL_TREE) { - push_obstacks (&permanent_obstack, &permanent_obstack); decl = build_decl (VAR_DECL, decl_name, class_type_node); DECL_SIZE (decl) = TYPE_SIZE (class_type_node); DECL_SIZE_UNIT (decl) = TYPE_SIZE_UNIT (class_type_node); @@ -911,7 +895,6 @@ build_class_ref (type) pushdecl_top_level (decl); if (is_compiled == 1) DECL_EXTERNAL (decl) = 1; - pop_obstacks (); } } else @@ -957,7 +940,6 @@ build_class_ref (type) decl = IDENTIFIER_GLOBAL_VALUE (decl_name); if (decl == NULL_TREE) { - push_obstacks (&permanent_obstack, &permanent_obstack); decl = build_decl (VAR_DECL, decl_name, class_type_node); TREE_STATIC (decl) = 1; TREE_PUBLIC (decl) = 1; @@ -965,7 +947,6 @@ build_class_ref (type) pushdecl_top_level (decl); if (is_compiled == 1) DECL_EXTERNAL (decl) = 1; - pop_obstacks (); } } @@ -976,11 +957,9 @@ build_class_ref (type) { int index; tree cl; - push_obstacks (&permanent_obstack, &permanent_obstack); index = alloc_class_constant (type); cl = build_ref_from_constant_pool (index); TREE_TYPE (cl) = promote_type (class_ptr_type); - pop_obstacks (); return cl; } } @@ -995,9 +974,7 @@ build_static_field_ref (fdecl) { if (DECL_RTL (fdecl) == 0) { - push_obstacks (&permanent_obstack, &permanent_obstack); make_decl_rtl (fdecl, NULL, 1); - pop_obstacks (); if (is_compiled == 1) DECL_EXTERNAL (fdecl) = 1; } @@ -1502,9 +1479,7 @@ finish_class () || ! METHOD_PRIVATE (method) || saw_native_method) { - temporary_allocation (); output_inline_function (method); - permanent_allocation (1); /* Scan the list again to see if there are any earlier methods to emit. */ method = type_methods; @@ -1749,9 +1724,7 @@ push_super_field (this_class, super_class) /* Don't insert the field if we're just re-laying the class out. */ if (TYPE_FIELDS (this_class) && !DECL_NAME (TYPE_FIELDS (this_class))) return; - push_obstacks (&permanent_obstack, &permanent_obstack); base_decl = build_decl (FIELD_DECL, NULL_TREE, super_class); - pop_obstacks (); DECL_IGNORED_P (base_decl) = 1; TREE_CHAIN (base_decl) = TYPE_FIELDS (this_class); TYPE_FIELDS (this_class) = base_decl; @@ -1814,6 +1787,7 @@ layout_class (this_class) if (CLASS_BEING_LAIDOUT (this_class)) { char buffer [1024]; + char *report; tree current; sprintf (buffer, " with `%s'", @@ -1831,7 +1805,9 @@ layout_class (this_class) obstack_grow (&temporary_obstack, buffer, strlen (buffer)); } obstack_1grow (&temporary_obstack, '\0'); - cyclic_inheritance_report = obstack_finish (&temporary_obstack); + report = obstack_finish (&temporary_obstack); + cyclic_inheritance_report = ggc_strdup (report); + obstack_free (&temporary_obstack, report); TYPE_SIZE (this_class) = error_mark_node; return; } @@ -1883,7 +1859,6 @@ layout_class_methods (this_class) if (TYPE_NVIRTUALS (this_class)) return; - push_obstacks (&permanent_obstack, &permanent_obstack); super_class = CLASSTYPE_SUPER (this_class); handle_type = CLASS_TO_HANDLE_TYPE (this_class); @@ -1909,7 +1884,6 @@ layout_class_methods (this_class) #ifdef JAVA_USE_HANDLES layout_type (handle_type); #endif - pop_obstacks (); } /* A sorted list of all C++ keywords. */ @@ -2230,4 +2204,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); + gcc_obstack_init (&temporary_obstack); } diff --git a/gcc/java/constants.c b/gcc/java/constants.c index c1dd6719caa..ad2ed21f213 100644 --- a/gcc/java/constants.c +++ b/gcc/java/constants.c @@ -335,11 +335,7 @@ get_tag_node (tag) } if (tag_nodes[tag] == NULL_TREE) - { - push_obstacks (&permanent_obstack, &permanent_obstack); - tag_nodes[tag] = build_int_2 (tag, 0); - pop_obstacks (); - } + tag_nodes[tag] = build_int_2 (tag, 0); return tag_nodes[tag]; } @@ -402,13 +398,11 @@ build_constant_data_ref () { tree decl; tree decl_name = mangled_classname ("_CD_", current_class); - push_obstacks (&permanent_obstack, &permanent_obstack); decl = build_decl (VAR_DECL, decl_name, build_array_type (ptr_type_node, one_elt_array_domain_type)); TREE_STATIC (decl) = 1; make_decl_rtl (decl, NULL, 1); - pop_obstacks (); TYPE_CPOOL_DATA_REF (current_class) = current_constant_pool_data_ref = build1 (ADDR_EXPR, ptr_type_node, decl); } diff --git a/gcc/java/decl.c b/gcc/java/decl.c index dd36ff02674..7d5c165f5e2 100644 --- a/gcc/java/decl.c +++ b/gcc/java/decl.c @@ -57,10 +57,6 @@ static tree check_local_unnamed_variable PARAMS ((tree, tree, tree)); 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. @@ -1558,7 +1554,7 @@ copy_lang_decl (node) int lang_decl_size = TREE_CODE (node) == VAR_DECL ? sizeof (struct lang_decl_var) : sizeof (struct lang_decl); - struct lang_decl *x = (struct lang_decl *) oballoc (lang_decl_size); + struct lang_decl *x = (struct lang_decl *) ggc_alloc (lang_decl_size); bcopy ((PTR) DECL_LANG_SPECIFIC (node), (PTR) x, lang_decl_size); DECL_LANG_SPECIFIC (node) = x; } @@ -1733,10 +1729,6 @@ complete_start_java_method (fndecl) emit_init_test_initialization, 0); } - /* Allocate further tree nodes temporarily during compilation - of this function only. */ - temporary_allocation (); - #if 0 /* If this fcn was already referenced via a block-scope `extern' decl (or an implicit decl), propagate certain information about the usage. */ @@ -1812,7 +1804,7 @@ start_java_method (fndecl) i = DECL_MAX_LOCALS(fndecl) + DECL_MAX_STACK(fndecl); decl_map = make_tree_vec (i); - type_map = (tree *) oballoc (i * sizeof (tree)); + type_map = (tree *) xrealloc (type_map, i * sizeof (tree)); #if defined(DEBUG_JAVA_BINDING_LEVELS) fprintf (stderr, "%s:\n", (*decl_printable_name) (fndecl, 2)); @@ -1891,7 +1883,6 @@ end_java_method () rest_of_compilation (fndecl); current_function_decl = NULL_TREE; - permanent_allocation (1); asynchronous_exceptions = flag_asynchronous_exceptions; } diff --git a/gcc/java/except.c b/gcc/java/except.c index 9075e6168f8..258bbc0b2a1 100644 --- a/gcc/java/except.c +++ b/gcc/java/except.c @@ -43,6 +43,7 @@ static struct eh_range *find_handler_in_range PARAMS ((int, struct eh_range *, struct eh_range *)); static void link_handler PARAMS ((struct eh_range *, struct eh_range *)); static void check_start_handlers PARAMS ((struct eh_range *, int)); +static void free_eh_ranges PARAMS ((struct eh_range *range)); extern struct obstack permanent_obstack; @@ -156,7 +157,7 @@ link_handler (range, outer) if (range->start_pc < outer->start_pc || range->end_pc > outer->end_pc) { struct eh_range *h - = (struct eh_range *) oballoc (sizeof (struct eh_range)); + = (struct eh_range *) xmalloc (sizeof (struct eh_range)); if (range->start_pc < outer->start_pc) { h->start_pc = range->start_pc; @@ -221,12 +222,27 @@ handle_nested_ranges () } } +/* Free RANGE as well as its children and siblings. */ + +static void +free_eh_ranges (range) + struct eh_range *range; +{ + while (range) + { + struct eh_range *next = range->next_sibling; + free_eh_ranges (range->first_child); + free (range); + range = next; + } +} /* Called to re-initialize the exception machinery for a new method. */ void method_init_exceptions () { + free_eh_ranges (&whole_range); whole_range.start_pc = 0; whole_range.end_pc = DECL_CODE_LENGTH (current_function_decl) + 1; whole_range.outer = NULL; @@ -279,7 +295,7 @@ add_handler (start_pc, end_pc, handler, type) prev = ptr; } - h = (struct eh_range *) oballoc (sizeof (struct eh_range)); + h = (struct eh_range *) xmalloc (sizeof (struct eh_range)); h->start_pc = start_pc; h->end_pc = end_pc; h->first_child = NULL; @@ -306,9 +322,7 @@ expand_start_java_handler (range) current_pc, range->end_pc); #endif /* defined(DEBUG_JAVA_BINDING_LEVELS) */ range->expanded = 1; - push_obstacks (&permanent_obstack, &permanent_obstack); expand_eh_region_start (); - pop_obstacks (); } tree @@ -323,7 +337,6 @@ prepare_eh_table_type (type) * c) a pointer to the Utf8Const name of the class, plus one * (which yields a value with low-order bit 1). */ - push_obstacks (&permanent_obstack, &permanent_obstack); if (type == NULL_TREE) exp = CATCH_ALL_TYPE; else if (is_compiled_class (type)) @@ -333,7 +346,6 @@ prepare_eh_table_type (type) (PLUS_EXPR, ptr_type_node, build_utf8_ref (build_internal_class_name (type)), size_one_node)); - pop_obstacks (); return exp; } @@ -345,9 +357,7 @@ expand_end_java_handler (range) { tree handler = range->handlers; force_poplevels (range->start_pc); - push_obstacks (&permanent_obstack, &permanent_obstack); expand_start_all_catch (); - pop_obstacks (); for ( ; handler != NULL_TREE; handler = TREE_CHAIN (handler)) { start_catch_handler (prepare_eh_table_type (TREE_PURPOSE (handler))); diff --git a/gcc/java/expr.c b/gcc/java/expr.c index 1dd26c38c4d..6dc5184ad5a 100644 --- a/gcc/java/expr.c +++ b/gcc/java/expr.c @@ -281,7 +281,7 @@ push_value (value) } push_type (type); if (tree_list_free_list == NULL_TREE) - quick_stack = perm_tree_cons (NULL_TREE, value, quick_stack); + quick_stack = tree_cons (NULL_TREE, value, quick_stack); else { tree node = tree_list_free_list; @@ -1463,10 +1463,8 @@ create_label_decl (name) tree name; { tree decl; - push_obstacks (&permanent_obstack, &permanent_obstack); decl = build_decl (LABEL_DECL, name, TREE_TYPE (return_address_type_node)); - pop_obstacks (); DECL_CONTEXT (decl) = current_function_decl; DECL_IGNORED_P (decl) = 1; return decl; @@ -1985,14 +1983,12 @@ build_jni_stub (method) TREE_CHAIN (env_var) = res_var; } - push_obstacks (&permanent_obstack, &permanent_obstack); meth_var = build_decl (VAR_DECL, get_identifier ("meth"), ptr_type_node); TREE_STATIC (meth_var) = 1; TREE_PUBLIC (meth_var) = 0; DECL_EXTERNAL (meth_var) = 0; make_decl_rtl (meth_var, NULL, 0); meth_var = pushdecl_top_level (meth_var); - pop_obstacks (); /* One strange way that the front ends are different is that they store arguments differently. */ @@ -2334,7 +2330,6 @@ java_lang_expand_expr (exp, target, tmode, modifier) { tree temp, value, init_decl; struct rtx_def *r; - push_obstacks (&permanent_obstack, &permanent_obstack); START_RECORD_CONSTRUCTOR (temp, object_type_node); PUSH_FIELD_VALUE (temp, "vtable", get_primitive_array_vtable (element_type)); @@ -2358,7 +2353,6 @@ java_lang_expand_expr (exp, target, tmode, modifier) make_decl_rtl (init_decl, NULL, 1); init = build1 (ADDR_EXPR, TREE_TYPE (exp), init_decl); r = expand_expr (init, target, tmode, modifier); - pop_obstacks (); return r; } @@ -2371,7 +2365,6 @@ java_lang_expand_expr (exp, target, tmode, modifier) && ilength >= 10 && JPRIMITIVE_TYPE_P (element_type)) { tree init_decl; - push_obstacks (&permanent_obstack, &permanent_obstack); init_decl = build_decl (VAR_DECL, generate_name (), TREE_TYPE (init)); pushdecl_top_level (init_decl); @@ -2381,7 +2374,6 @@ java_lang_expand_expr (exp, target, tmode, modifier) TREE_READONLY (init_decl) = 1; TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (init_decl)) = 1; make_decl_rtl (init_decl, NULL, 1); - pop_obstacks (); init = init_decl; } expand_assignment (build (COMPONENT_REF, TREE_TYPE (data_fld), @@ -2449,13 +2441,9 @@ java_lang_expand_expr (exp, target, tmode, modifier) /* We expand a try[-catch] block */ /* Expand the try block */ - push_obstacks (&permanent_obstack, &permanent_obstack); expand_eh_region_start (); - pop_obstacks (); expand_expr_stmt (TREE_OPERAND (exp, 0)); - push_obstacks (&permanent_obstack, &permanent_obstack); expand_start_all_catch (); - pop_obstacks (); /* Expand all catch clauses (EH handlers) */ for (current = TREE_OPERAND (exp, 1); current; @@ -2517,7 +2505,7 @@ note_instructions (jcf, method) JCF_SEEK (jcf, DECL_CODE_OFFSET (method)); byte_ops = jcf->read_ptr; - instruction_bits = oballoc (length + 1); + instruction_bits = xrealloc (instruction_bits, length + 1); bzero (instruction_bits, length + 1); /* This pass figures out which PC can be the targets of jumps. */ @@ -2748,12 +2736,10 @@ java_push_constant_from_pool (jcf, index) if (JPOOL_TAG (jcf, index) == CONSTANT_String) { tree name; - push_obstacks (&permanent_obstack, &permanent_obstack); name = get_name_constant (jcf, JPOOL_USHORT1 (jcf, index)); index = alloc_name_constant (CONSTANT_String, name); c = build_ref_from_constant_pool (index); TREE_TYPE (c) = promote_type (string_type_node); - pop_obstacks (); } else c = get_constant (jcf, index); @@ -2881,7 +2867,6 @@ process_jvm_instruction (PC, byte_ops, length) tree type = TREE_TYPE (selector); \ flush_quick_stack (); \ expand_start_case (0, selector, type, "switch statement");\ - push_momentary (); \ while (--npairs >= 0) \ { \ jint match = IMMEDIATE_s4; jint offset = IMMEDIATE_s4; \ @@ -2894,7 +2879,6 @@ process_jvm_instruction (PC, byte_ops, length) label = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE); \ pushcase (NULL_TREE, 0, label, &duplicate); \ expand_java_goto (oldpc + default_offset); \ - pop_momentary (); \ expand_end_case (selector); \ } @@ -2906,7 +2890,6 @@ process_jvm_instruction (PC, byte_ops, length) tree type = TREE_TYPE (selector); \ flush_quick_stack (); \ expand_start_case (0, selector, type, "switch statement");\ - push_momentary (); \ for (; low <= high; low++) \ { \ jint offset = IMMEDIATE_s4; \ @@ -2919,7 +2902,6 @@ process_jvm_instruction (PC, byte_ops, length) label = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE); \ pushcase (NULL_TREE, 0, label, &duplicate); \ expand_java_goto (oldpc + default_offset); \ - pop_momentary (); \ expand_end_case (selector); \ } diff --git a/gcc/java/java-tree.h b/gcc/java/java-tree.h index 17b76925c28..f1f205427fc 100644 --- a/gcc/java/java-tree.h +++ b/gcc/java/java-tree.h @@ -602,8 +602,6 @@ extern struct CPool *outgoing_cpool; extern char *cyclic_inheritance_report; -extern char *cyclic_inheritance_report; - struct lang_identifier { struct tree_identifier ignore; diff --git a/gcc/java/jcf-parse.c b/gcc/java/jcf-parse.c index 71503e3cdf5..b11d949a9e3 100644 --- a/gcc/java/jcf-parse.c +++ b/gcc/java/jcf-parse.c @@ -255,7 +255,6 @@ get_constant (jcf, index) tag = JPOOL_TAG (jcf, index); if ((tag & CONSTANT_ResolvedFlag) || tag == CONSTANT_Utf8) return (tree) jcf->cpool.data[index]; - push_obstacks (&permanent_obstack, &permanent_obstack); switch (tag) { case CONSTANT_Integer: @@ -327,7 +326,6 @@ get_constant (jcf, index) #endif /* TARGET_FLOAT_FORMAT == IEEE_FLOAT_FORMAT */ case CONSTANT_String: { - extern struct obstack *expression_obstack; tree name = get_name_constant (jcf, JPOOL_USHORT1 (jcf, index)); const char *utf8_ptr = IDENTIFIER_POINTER (name); unsigned char *str_ptr; @@ -350,8 +348,7 @@ get_constant (jcf, index) value = make_node (STRING_CST); TREE_TYPE (value) = build_pointer_type (string_type_node); TREE_STRING_LENGTH (value) = 2 * str_len; - TREE_STRING_POINTER (value) - = obstack_alloc (expression_obstack, 2 * str_len); + TREE_STRING_POINTER (value) = ggc_alloc (2 * str_len); str_ptr = (unsigned char *) TREE_STRING_POINTER (value); str = (const unsigned char *)utf8_ptr; for (i = 0; i < str_len; i++) @@ -391,7 +388,6 @@ get_constant (jcf, index) default: goto bad; } - pop_obstacks (); JPOOL_TAG(jcf, index) = tag | CONSTANT_ResolvedFlag; jcf->cpool.data [index] = (jword) value; return value; @@ -486,17 +482,12 @@ read_class (name) if (current_jcf->read_state) saved_pos = ftell (current_jcf->read_state); - push_obstacks (&permanent_obstack, &permanent_obstack); - /* Search in current zip first. */ if (find_in_current_zip (IDENTIFIER_POINTER (name), &jcf) == 0) { if (find_class (IDENTIFIER_POINTER (name), IDENTIFIER_LENGTH (name), &this_jcf, 1) == 0) - { - pop_obstacks (); /* FIXME: one pop_obstack() per function */ - return 0; - } + return 0; else { this_jcf.seen_in_zip = 0; @@ -519,7 +510,6 @@ read_class (name) if (!current_jcf->seen_in_zip) JCF_FINISH (current_jcf); - pop_obstacks (); current_class = save_current_class; input_filename = save_input_filename; @@ -639,7 +629,6 @@ jcf_parse (jcf) if (current_class != class_type_node && current_class != object_type_node) TYPE_FIELDS (current_class) = nreverse (TYPE_FIELDS (current_class)); - push_obstacks (&permanent_obstack, &permanent_obstack); layout_class (current_class); if (current_class == object_type_node) layout_class_methods (object_type_node); @@ -651,8 +640,6 @@ jcf_parse (jcf) for (current = DECL_INNER_CLASS_LIST (TYPE_NAME (current_class)); current; current = TREE_CHAIN (current)) load_class (DECL_NAME (TREE_PURPOSE (current)), 1); - - pop_obstacks (); } void diff --git a/gcc/java/lex.c b/gcc/java/lex.c index 8fb6a15a6fd..1775441d329 100644 --- a/gcc/java/lex.c +++ b/gcc/java/lex.c @@ -36,10 +36,6 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */ #include "keyword.h" -#ifndef JC1_LITE -extern struct obstack *expression_obstack; -#endif - /* Function declaration */ static int java_lineterminator PARAMS ((unicode_t)); static char *java_sprint_unicode PARAMS ((struct java_line *, int)); @@ -1104,6 +1100,7 @@ java_lex (java_lval) else java_lval->node = build_string (strlen (string), string); #endif + obstack_free (&temporary_obstack, string); return STRING_LIT_TK; } diff --git a/gcc/java/parse.h b/gcc/java/parse.h index 0f0aa9b9ca9..40fad4aef2d 100644 --- a/gcc/java/parse.h +++ b/gcc/java/parse.h @@ -111,7 +111,6 @@ extern tree stabilize_reference PARAMS ((tree)); /* Misc. */ #define exit_java_complete_class() \ { \ - pop_obstacks (); \ return; \ } @@ -229,11 +228,14 @@ extern tree stabilize_reference PARAMS ((tree)); scope local variables. */ #define MANGLE_OUTER_LOCAL_VARIABLE_NAME(N, O) \ { \ + char *mangled_name; \ obstack_grow (&temporary_obstack, "val$", 4); \ - obstack_grow (&temporary_obstack, \ + obstack_grow (&temporary_obstack, \ IDENTIFIER_POINTER ((O)), IDENTIFIER_LENGTH ((O))); \ obstack_1grow (&temporary_obstack, '\0'); \ - (N) = obstack_finish (&temporary_obstack); \ + mangled_name = obstack_finish (&temporary_obstack); \ + (N) = get_identifier (mangled_name); \ + obstack_free (&temporary_obstack, mangled_name); \ } /* Build the string parm$<O> and store in into the identifier N. This @@ -241,19 +243,25 @@ extern tree stabilize_reference PARAMS ((tree)); initialize outer scope aliases. */ #define MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_ID(N, O) \ { \ + char *mangled_name; \ obstack_grow (&temporary_obstack, "parm$", 5); \ obstack_grow (&temporary_obstack, \ IDENTIFIER_POINTER ((O)), IDENTIFIER_LENGTH ((O))); \ obstack_1grow (&temporary_obstack, '\0'); \ - (N) = obstack_finish (&temporary_obstack); \ + mangled_name = obstack_finish (&temporary_obstack); \ + (N) = get_identifier (mangled_name); \ + obstack_free (&temporary_obstack, mangled_name); \ } #define MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_STR(N, S) \ { \ + char *mangled_name; \ obstack_grow (&temporary_obstack, "parm$", 5); \ obstack_grow (&temporary_obstack, (S), strlen ((S))); \ obstack_1grow (&temporary_obstack, '\0'); \ - (N) = obstack_finish (&temporary_obstack); \ + mangled_name = obstack_finish (&temporary_obstack); \ + (N) = get_identifier (mangled_name); \ + obstack_free (&temporary_obstack, mangled_name); \ } /* Skip THIS and artificial parameters found in function decl M and diff --git a/gcc/java/parse.y b/gcc/java/parse.y index e66d2f55634..e9fe4b3bb57 100644 --- a/gcc/java/parse.y +++ b/gcc/java/parse.y @@ -598,6 +598,7 @@ 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_string_root (&cyclic_inheritance_report, 1); ggc_add_root (&ctxp, 1, sizeof (struct parser_ctxt *), mark_parser_ctxt); @@ -3938,7 +3939,7 @@ add_inner_class_fields (class_decl, fct_decl) tree decl; for (decl = BLOCK_EXPR_DECLS (block); decl; decl = TREE_CHAIN (decl)) { - char *name, *pname; + tree name, pname; tree wfl, init, list; /* Avoid non final arguments. */ @@ -3947,8 +3948,8 @@ add_inner_class_fields (class_decl, fct_decl) MANGLE_OUTER_LOCAL_VARIABLE_NAME (name, DECL_NAME (decl)); MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_ID (pname, DECL_NAME (decl)); - wfl = build_wfl_node (get_identifier (name)); - init = build_wfl_node (get_identifier (pname)); + wfl = build_wfl_node (name); + init = build_wfl_node (pname); /* Build an initialization for the field: it will be initialized by a parameter added to finit$, bearing a mangled name of the field itself (param$<n>.) The @@ -4036,10 +4037,8 @@ lookup_field_wrapper (class, name) context. We try to look for it now. */ if (INNER_CLASS_TYPE_P (class)) { - char *alias_buffer; tree new_name; - MANGLE_OUTER_LOCAL_VARIABLE_NAME (alias_buffer, name); - new_name = get_identifier (alias_buffer); + MANGLE_OUTER_LOCAL_VARIABLE_NAME (new_name, name); decl = lookup_field (&type, new_name); if (decl && decl != error_mark_node) FIELD_LOCAL_ALIAS_USED (decl) = 1; @@ -4959,10 +4958,8 @@ obtain_incomplete_type (type_name) if (!ptr) { - push_obstacks (&permanent_obstack, &permanent_obstack); BUILD_PTR_FROM_NAME (ptr, name); layout_type (ptr); - pop_obstacks (); TREE_CHAIN (ptr) = ctxp->incomplete_class; ctxp->incomplete_class = ptr; } @@ -5060,12 +5057,14 @@ build_alias_initializer_parameter_list (mode, class_type, parm, artificial) { const char *buffer = IDENTIFIER_POINTER (DECL_NAME (field)); tree purpose = NULL_TREE, value = NULL_TREE, name = NULL_TREE; + tree mangled_id; switch (mode) { case AIPL_FUNCTION_DECLARATION: - MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_STR (buffer, &buffer [4]); - purpose = build_wfl_node (get_identifier (buffer)); + MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_STR (mangled_id, + &buffer [4]); + purpose = build_wfl_node (mangled_id); if (TREE_CODE (TREE_TYPE (field)) == POINTER_TYPE) value = build_wfl_node (TYPE_NAME (TREE_TYPE (field))); else @@ -5073,13 +5072,14 @@ build_alias_initializer_parameter_list (mode, class_type, parm, artificial) break; case AIPL_FUNCTION_CREATION: - MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_STR (buffer, &buffer [4]); - purpose = get_identifier (buffer); + MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_STR (purpose, + &buffer [4]); value = TREE_TYPE (field); break; case AIPL_FUNCTION_FINIT_INVOCATION: - MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_STR (buffer, &buffer [4]); + MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_STR (mangled_id, + &buffer [4]); /* Now, this is wrong. purpose should always be the NAME of something and value its matching value (decl, type, etc...) FIXME -- but there is a lot to fix. */ @@ -5087,7 +5087,7 @@ build_alias_initializer_parameter_list (mode, class_type, parm, artificial) /* When invoked for this kind of operation, we already know whether a field is used or not. */ purpose = TREE_TYPE (field); - value = build_wfl_node (get_identifier (buffer)); + value = build_wfl_node (mangled_id); break; case AIPL_FUNCTION_CTOR_INVOCATION: @@ -5136,8 +5136,6 @@ craft_constructor (class_decl, args) tree decl, ctor_name; char buffer [80]; - push_obstacks (&permanent_obstack, &permanent_obstack); - /* The constructor name is <init> unless we're dealing with an anonymous class, in which case the name will be fixed after having be expanded. */ @@ -5174,8 +5172,6 @@ craft_constructor (class_decl, args) fix_method_argument_names (parm, decl); /* Now, mark the artificial parameters. */ DECL_FUNCTION_NAP (decl) = artificial; - - pop_obstacks (); DECL_CONSTRUCTOR_P (decl) = 1; } @@ -5227,10 +5223,7 @@ safe_layout_class (class) const char *save_input_filename = input_filename; int save_lineno = lineno; - push_obstacks (&permanent_obstack, &permanent_obstack); - layout_class (class); - pop_obstacks (); current_class = save_current_class; input_filename = save_input_filename; @@ -5270,8 +5263,6 @@ java_complete_class () int error_found; tree type; - push_obstacks (&permanent_obstack, &permanent_obstack); - /* Process imports */ process_imports (); @@ -5306,10 +5297,8 @@ java_complete_class () /* We do part of the job done in add_field */ tree field_decl = JDEP_DECL (dep); tree field_type = TREE_TYPE (decl); - push_obstacks (&permanent_obstack, &permanent_obstack); if (TREE_CODE (field_type) == RECORD_TYPE) field_type = promote_type (field_type); - pop_obstacks (); TREE_TYPE (field_decl) = field_type; DECL_ALIGN (field_decl) = 0; DECL_USER_ALIGN (field_decl) = 0; @@ -5350,7 +5339,6 @@ java_complete_class () if (!error_found) { tree mdecl = JDEP_DECL (dep), signature; - push_obstacks (&permanent_obstack, &permanent_obstack); /* Recompute and reset the signature, check first that all types are now defined. If they're not, dont build the signature. */ @@ -5359,7 +5347,6 @@ java_complete_class () signature = build_java_signature (TREE_TYPE (mdecl)); set_java_signature (TREE_TYPE (mdecl), signature); } - pop_obstacks (); } else continue; @@ -5404,7 +5391,6 @@ java_complete_class () } } } - pop_obstacks (); return; } @@ -7245,7 +7231,6 @@ source_end_java_method () } current_function_decl = NULL_TREE; - permanent_allocation (1); java_parser_context_restore_global (); asynchronous_exceptions = flag_asynchronous_exceptions; } @@ -8005,8 +7990,6 @@ build_outer_field_access_methods (decl) if (FIELD_INNER_ACCESS (decl)) return FIELD_INNER_ACCESS (decl); - push_obstacks (&permanent_obstack, &permanent_obstack); - /* Create the identifier and a function named after it. */ id = build_new_access_id (); @@ -8036,7 +8019,6 @@ build_outer_field_access_methods (decl) mdecl = build_outer_field_access_method (DECL_CONTEXT (decl), TREE_TYPE (decl), id, args, stmt); DECL_FUNCTION_ACCESS_DECL (mdecl) = decl; - pop_obstacks (); /* Return the access name */ return FIELD_INNER_ACCESS (decl) = id; @@ -8093,8 +8075,6 @@ build_outer_method_access_method (decl) id = build_new_access_id (); OUTER_FIELD_ACCESS_IDENTIFIER_P (id) = 1; - push_obstacks (&permanent_obstack, &permanent_obstack); - carg = TYPE_ARG_TYPES (TREE_TYPE (decl)); /* Create the arguments, as much as the original */ for (; carg && carg != end_params_node; @@ -8141,7 +8121,6 @@ build_outer_method_access_method (decl) java_method_add_stmt (mdecl,body); end_artificial_method_body (mdecl); current_function_decl = saved_current_function_decl; - pop_obstacks (); /* Back tag the access function so it know what it accesses */ DECL_FUNCTION_ACCESS_DECL (decl) = mdecl; @@ -8212,7 +8191,6 @@ maybe_build_thisn_access_method (type) /* We generate the method. The method looks like: static <outer_of_type> access$0 (<type> inst$) { return inst$.this$<n>; } */ - push_obstacks (&permanent_obstack, &permanent_obstack); args = build_tree_list (inst_id, build_pointer_type (type)); TREE_CHAIN (args) = end_params_node; rtype = build_pointer_type (TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type)))); @@ -8230,7 +8208,6 @@ maybe_build_thisn_access_method (type) java_method_add_stmt (mdecl, stmt); end_artificial_method_body (mdecl); current_function_decl = saved_current_function_decl; - pop_obstacks (); CLASS_ACCESS0_GENERATED_P (type) = 1; @@ -8432,11 +8409,8 @@ build_dot_class_method_invocation (type) else sig_id = DECL_NAME (TYPE_NAME (type)); - s = make_node (STRING_CST); - TREE_STRING_LENGTH (s) = IDENTIFIER_LENGTH (sig_id); - TREE_STRING_POINTER (s) = obstack_alloc (expression_obstack, - TREE_STRING_LENGTH (s)+1); - strcpy (TREE_STRING_POINTER (s), IDENTIFIER_POINTER (sig_id)); + s = build_string (IDENTIFIER_LENGTH (sig_id), + IDENTIFIER_POINTER (sig_id)); return build_method_invocation (build_wfl_node (get_identifier ("class$")), build_tree_list (NULL_TREE, s)); } @@ -10899,9 +10873,7 @@ java_complete_tree (node) { tree value = DECL_INITIAL (node); DECL_INITIAL (node) = NULL_TREE; - push_obstacks (&permanent_obstack, &permanent_obstack); value = fold_constant_for_init (value, node); - pop_obstacks (); DECL_INITIAL (node) = value; if (value != NULL_TREE) { @@ -11114,10 +11086,8 @@ java_complete_lhs (node) && FIELD_FINAL (TREE_OPERAND (cn, 1)) && DECL_INITIAL (TREE_OPERAND (cn, 1))) { - push_obstacks (&permanent_obstack, &permanent_obstack); cn = fold_constant_for_init (DECL_INITIAL (TREE_OPERAND (cn, 1)), TREE_OPERAND (cn, 1)); - pop_obstacks (); } if (!TREE_CONSTANT (cn) && !flag_emit_xref) @@ -11395,9 +11365,7 @@ java_complete_lhs (node) { tree value; - push_obstacks (&permanent_obstack, &permanent_obstack); value = fold_constant_for_init (nn, nn); - pop_obstacks (); if (value != NULL_TREE) { @@ -13029,7 +12997,7 @@ do_merge_string_cste (cste, string, string_len, after) cste = make_node (STRING_CST); TREE_STRING_LENGTH (cste) = len; - new = TREE_STRING_POINTER (cste) = obstack_alloc (expression_obstack, len+1); + new = TREE_STRING_POINTER (cste) = ggc_alloc (len+1); if (after) { @@ -13234,11 +13202,9 @@ patch_string_cst (node) int location; if (! flag_emit_class_files) { - push_obstacks (&permanent_obstack, &permanent_obstack); node = get_identifier (TREE_STRING_POINTER (node)); location = alloc_name_constant (CONSTANT_String, node); node = build_ref_from_constant_pool (location); - pop_obstacks (); } TREE_TYPE (node) = string_ptr_type_node; TREE_CONSTANT (node) = 1; @@ -13972,7 +13938,6 @@ array_constructor_check_entry (type, entry) new_value = NULL_TREE; wfl_value = TREE_VALUE (entry); - push_obstacks (&permanent_obstack, &permanent_obstack); value = java_complete_tree (TREE_VALUE (entry)); /* patch_string return error_mark_node if arg is error_mark_node */ if ((patched = patch_string (value))) @@ -13989,7 +13954,6 @@ array_constructor_check_entry (type, entry) if (!new_value && (new_value = try_reference_assignconv (type, value))) type_value = promote_type (type); - pop_obstacks (); /* Check and report errors */ if (!new_value) { diff --git a/gcc/java/typeck.c b/gcc/java/typeck.c index 0b406a7a545..ad78ffbf621 100644 --- a/gcc/java/typeck.c +++ b/gcc/java/typeck.c @@ -407,7 +407,6 @@ build_java_array_type (element_type, length) TYPE_ARRAY_ELEMENT (t) = element_type; /* Add length pseudo-field. */ - push_obstacks (&permanent_obstack, &permanent_obstack); fld = build_decl (FIELD_DECL, get_identifier ("length"), int_type_node); TYPE_FIELDS (t) = fld; DECL_CONTEXT (fld) = t; @@ -447,7 +446,6 @@ build_java_array_type (element_type, length) #endif TYPE_ALIGN (t) = desired_align; } - pop_obstacks (); /* We could layout_class, but that loads java.lang.Object prematurely. * This is called by the parser, and it is a bad idea to do load_class @@ -552,7 +550,6 @@ parse_signature_string (sig_string, sig_length) const unsigned char *str = sig_string; const unsigned char *limit = str + sig_length; - push_obstacks (&permanent_obstack, &permanent_obstack); if (str < limit && str[0] == '(') { tree argtype_list = NULL_TREE; @@ -572,7 +569,6 @@ parse_signature_string (sig_string, sig_length) result_type = parse_signature_type (&str, limit); if (str != limit) error ("junk at end of signature string"); - pop_obstacks (); return result_type; } @@ -633,7 +629,6 @@ build_java_signature (type) tree type; { tree sig, t; - push_obstacks (&permanent_obstack, &permanent_obstack); while (TREE_CODE (type) == POINTER_TYPE) type = TREE_TYPE (type); MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC (type); @@ -705,7 +700,6 @@ build_java_signature (type) } TYPE_SIGNATURE (type) = sig; } - pop_obstacks (); return sig; } |