]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
utils.c (init_gnat_to_gnu): Use typed GC allocation.
authorLaurynas Biveinis <laurynas.biveinis@gmail.com>
Tue, 8 Jun 2010 07:25:24 +0000 (07:25 +0000)
committerLaurynas Biveinis <lauras@gcc.gnu.org>
Tue, 8 Jun 2010 07:25:24 +0000 (07:25 +0000)
gcc/ada:

2010-06-08  Laurynas Biveinis  <laurynas.biveinis@gmail.com>

* gcc-interface/utils.c (init_gnat_to_gnu): Use typed GC
allocation.
(init_dummy_type): Likewise.
(gnat_pushlevel): Likewise.

* gcc-interface/trans.c (Attribute_to_gnu): Likewise.
(Subprogram_Body_to_gnu): Likewise.
(Compilation_Unit_to_gnu): Likewise.
(start_stmt_group): Likewise.
(extract_encoding): Likewise.
(decode_name): Likewise.

* gcc-interface/misc.c (gnat_printable_name): Likewise.

* gcc-interface/decl.c (annotate_value): Likewise.

* gcc-interface/ada-tree.h (struct lang_type): Add variable_size
GTY option.
(struct lang_decl): Likewise.
(SET_TYPE_LANG_SPECIFIC): Use typed GC allocation.
(SET_DECL_LANG_SPECIFIC): Likewise.

gcc/c-family:

2010-06-08  Laurynas Biveinis  <laurynas.biveinis@gmail.com>

* c-pragma.c (push_alignment): Use typed GC allocation.
(handle_pragma_push_options): Likewise.

* c-common.c (parse_optimize_options): Likewise.

* c-common.h (struct sorted_fields_type): Add variable_size GTY
option.

gcc/cp:

2010-06-08  Laurynas Biveinis  <laurynas.biveinis@gmail.com>

* typeck2.c (abstract_virtuals_error): Likewise.

* pt.c (maybe_process_partial_specialization): Likewise.
(register_specialization): Likewise.
(add_pending_template): Likewise.
(lookup_template_class): Likewise.
(push_tinst_level): Likewise.

* parser.c (cp_lexer_new_main): Likewise.
(cp_lexer_new_from_tokens): Likewise.
(cp_token_cache_new): Likewise.
(cp_parser_context_new): Likewise.
(cp_parser_new): Likewise.
(cp_parser_nested_name_specifier_opt): Likewise.
(cp_parser_template_id): Likewise.

* name-lookup.c (binding_entry_make): Likewise.
(binding_table_construct): Likewise.
(binding_table_new): Likewise.
(cxx_binding_make): Likewise.
(pushdecl_maybe_friend): Likewise.
(begin_scope): Likewise.
(push_to_top_level): Likewise.

* lex.c (init_reswords): Likewise.
(retrofit_lang_decl): Likewise.
(cxx_dup_lang_specific_decl): Likewise.
(copy_lang_type): Likewise.
(cxx_make_type): Likewise.

* decl.c (make_label_decl): Likewise.
(check_goto): Likewise.
(start_preparsed_function): Likewise.
(save_function_data): Likewise.

* cp-tree.h (TYPE_SET_PTRMEMFUNC_TYPE): Likewise.

* cp-objcp-common.c (decl_shadowed_for_var_insert): Likewise.

* class.c (finish_struct_1): Likewise.

* cp-tree.h (struct lang_type): Add variable_size GTY option.
(struct lang_decl): Likewise.

* parser.c (cp_parser_new): Update comment to not reference
ggc_alloc.

gcc/fortran:

2010-06-08  Laurynas Biveinis  <laurynas.biveinis@gmail.com>

* trans-types.c (gfc_get_nodesc_array_type): Use typed GC
allocation.
(gfc_get_array_type_bounds): Likewise.

* trans-decl.c (gfc_allocate_lang_decl): Likewise.
(gfc_find_module): Likewise.

* f95-lang.c (pushlevel): Likewise.

* trans.h (struct lang_type): Add variable_size GTY option.
(struct lang_decl): Likewise.

gcc/java:

2010-06-08  Laurynas Biveinis  <laurynas.biveinis@gmail.com>

* jcf-reader.c (jcf_parse_constant_pool): Use typed GC allocation.

* jcf-parse.c (java_parse_file): Likewise.
(process_zip_dir): Likewise.

* java-tree.h (MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC): Likewise.
(MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC): Likewise.

* expr.c (add_type_assertion): Likewise.

* decl.c (make_binding_level): Likewise.
(java_dup_lang_specific_decl): Likewise.

* constants.c (set_constant_entry): Likewise.
(cpool_for_class): Likewise.

* class.c (add_method_1): Likewise.
(java_treetreehash_new): Likewise.

* java-tree.h (struct lang_type): Add variable_size GTY option.
(struct lang_decl): Likewise.

* jch.h (struct cpool_entry): Likewise.

* java-tree.h (java_treetreehash_create): Remove parameter ggc.

* except.c (prepare_eh_table_type): Update
java_treetreehash_create call.

* class.c (add_method_1): Update java_treetreehash_create call.
(java_treetreehash_create): Remove parameter gc.  Use
htab_create_ggc.

gcc/lto:

2010-06-08  Laurynas Biveinis  <laurynas.biveinis@gmail.com>

* lto.c (lto_read_in_decl_state): Use typed GC allocation.
(lto_file_read): Likewise.
(new_partition): Likewise.
(read_cgraph_and_symbols): Likewise.

gcc/objc:

2010-06-08  Laurynas Biveinis  <laurynas.biveinis@gmail.com>

* objc-act.h (ALLOC_OBJC_TYPE_LANG_SPECIFIC): Use typed GC
allocation.

* objc-act.c (objc_volatilize_decl): Likewise.
(objc_build_string_object): Likewise.
(hash_init): Likewise.
(hash_enter): Likewise.
(hash_add_attr): Likewise.
(add_class): Likewise.
(start_class): Likewise.

gcc/objcp:

2010-06-08  Laurynas Biveinis  <laurynas.biveinis@gmail.com>

* objcp-decl.h (ALLOC_OBJC_TYPE_LANG_SPECIFIC): Use typed GC
allocation.

gcc:

2010-06-08  Laurynas Biveinis  <laurynas.biveinis@gmail.com>

* doc/tm.texi (Per-Function Data): Do not reference ggc_alloc.

* doc/gty.texi (GTY Options): Document typed GC allocation and
variable_size GTY option.

* ggc-internal.h: New.

* ggc.h: Update copyright year.
(digit_string): Move to stringpool.c.
(ggc_mark_stringpool, ggc_purge_stringpool, ggc_mark_roots)
(gt_pch_save_stringpool, gt_pch_fixup_stringpool)
(gt_pach_restore_stringpool, gt_pch_p_S, gt_pch_note_object)
(init_ggc_pch, ggc_pch_count_object, ggc_pch_total_size)
(ggc_pch_this_base, ggc_pch_alloc_object, ggc_pch_prepare_write)
(ggc_pch_write_object, ggc_pch_finish, ggc_pch_read)
(ggc_force_collect, ggc_get_size, ggc_statistics)
(ggc_print_common_statistics): Move to ggc-internal.h.
(digit_vector, new_ggc_zone, destroy_ggc_zone, ggc_alloc_stat)
(ggc_alloc, ggc_alloc_cleared, ggc_realloc, ggc_calloc, GGC_NEW)
(GGC_CNEW, GGC_NEWVEC, GGC_CNEWVEC, GGC_NEWVAR, ggc_alloc_rtvec)
(ggc_alloc_tree, gt_pch_save, ggc_min_expand_heuristic)
(ggc_min_heapsize_heuristic, ggc_alloc_zone)
(ggc_alloc_zone_pass_stat): Remove.
(ggc_internal_alloc_stat, ggc_internal_alloc)
(ggc_internal_cleared_alloc_stat): New.
(GGC_RESIZEVEC, GGC_RESIZEVAR): Redefine.
(ggc_internal_vec_alloc_stat)
(ggc_internal_cleared_vec_alloc_stat)
(ggc_internal_vec_alloc_stat, ggc_internal_cleared_vec_alloc)
(ggc_alloc_atomic_stat, ggc_alloc_atomic)
(ggc_alloc_cleared_atomic, ggc_cleared_alloc_htab_ignore_args)
(ggc_cleared_alloc_ptr_array_two_args): New.
(htab_create_ggc, splay_tree_new_ggc): Redefine.
(ggc_splay_alloc): Change the type of the first argument to
enum gt_types_enum.
(ggc_alloc_string): Make macro.
(ggc_alloc_string_stat): New.
(ggc_strdup): Redefine.
(rtl_zone, tree_zone, tree_id_zone): Declare unconditionally.
(ggc_alloc_rtvec_sized): New.
(ggc_alloc_zone_stat): Rename to ggc_internal_alloc_zone_stat.
(ggc_internal_alloc_zone_pass_stat, ggc_internal_alloc_zone_stat)
(ggc_internal_cleared_alloc_zone_stat)
(ggc_internal_zone_alloc_stat)
(ggc_internal_zone_cleared_alloc_stat)
(ggc_internal_zone_vec_alloc_stat)
(ggc_alloc_zone_rtx_def_stat)
(ggc_alloc_zone_tree_node_stat)
(ggc_alloc_zone_cleared_tree_node_stat)
(ggc_alloc_cleared_gimple_statement_d_stat): New.

* ggc-common.c: Include ggc-internal.h.
(ggc_internal_cleared_alloc_stat): Rename from
ggc_alloc_cleared_stat.
(ggc_realloc_stat): Use ggc_internal_alloc_stat.
(ggc_calloc): Remove.
(ggc_cleared_alloc_htab_ignore_args): New.
(ggc_cleared_alloc_ptr_array_two_args): New.
(ggc_splay_alloc): Add obj_type parameter.
(init_ggc_heuristics): Formatting fixes.

* ggc-none.c: Update copyright year.
(ggc_alloc_stat): Rename to ggc_alloc_stat.
(ggc_alloc_cleared_stat): Rename to
ggc_internal_cleared_alloc_stat.
(struct alloc_zone, rtl_zone, tree_zone, tree_id_zone): New.

* ggc-page.c: Update copyright year.  Include ggc-internal.h.
Remove references to ggc_alloc in comments.
(ggc_alloc_typed_stat): Call ggc_internal_alloc_stat.
(ggc_alloc_stat): Rename to ggc_internal_alloc_stat.
(new_ggc_zone, destroy_ggc_zone): Remove.
(struct alloc_zone, rtl_zone, tree_zone, tree_id_zone): New.

* ggc-zone.c: Include ggc-internal.h.  Remove references to
ggc_alloc in comments.
(ggc_alloc_zone_stat): ggc_internal_alloc_zone_stat.
(ggc_internal_alloc_zone_pass_stat): New.
(ggc_internal_cleared_alloc_zone_stat): New.
(ggc_alloc_typed_stat): Use ggc_internal_alloc_zone_pass_stat.
(ggc_alloc_stat): Rename ggc_internal_alloc_stat.
(new_ggc_zone, destroy_ggc_zone): Remove.

* stringpool.c: Update copyright year.  Include ggc-internal.h
(digit_vector): Make static.
(digit_string): Moved from ggc.h.
(stringpool_ggc_alloc): Use ggc_alloc_atomic.
(ggc_alloc_string): Rename to ggc_alloc_string_stat.

* Makefile.in (GGC_INTERNAL_H): New.
(ggc_common.o, ggc-page.o, ggc-zone.o, stringpool.o): Add
$(GGC_INTERNAL_H) to dependencies.

* gentype.c: Update copyright year.
(walk_type): Accept variable_size GTY option.
(USED_BY_TYPED_GC_P): New macro.
(write_enum_defn): Use USED_BY_TYPED_GC_P.  Do not output
whitespace at the end of strings.
(get_type_specifier, variable_size_p): New functions.
(alloc_quantity, alloc_zone): New enums.
(write_typed_alloc_def): New function.
(write_typed_struct_alloc_def): Likewise.
(write_typed_typed_typedef_alloc_def): Likewise.
(write_typed_alloc_defns): Likewise.
(output_typename, write_splay_tree_allocator_def): Likewise.
(write_splay_tree_allocators): Likewise.
(main): Call write_typed_alloc_defns and
write_splay_tree_allocators.

* lto-streamer.h (lto_file_decl_data_ptr): New.

* passes.c (order): Define using cgraph_node_ptr.

* strinpool.c (struct string_pool_data): Declare nested_ptr using
ht_identifier_ptr.

* gimple.h (union gimple_statement_d): Likewise.

* rtl.h (struct rtx_def): Likewise.
(struct rtvec_def): Likewise.

* tree.h (union tree_node): Likewise.

* tree-ssa-operands.h (struct ssa_operand_memory_d): Likewise.

* cfgloop.c (record_loop_exits): Use htab_create_ggc.

* tree-scalar-evolution.c (scev_initialize): Likewise.

* alias.c (record_alias_subset): Update splay_tree_new_ggc call.

* dwarf2asm.c (dw2_force_const_mem): Likewise.

* omp-low.c (lower_omp_critical): Likewise.

* bitmap.h (struct bitmap_head_def): Update comment to not
reference ggc_alloc.

* config/pa/pa.c (get_deferred_label): Use GGC_RESIZEVEC.

* ira.c (fix_reg_equiv_init): Use GGC_RESIZEVEC.

* ipa-prop.c (duplicate_ggc_array): Rename to
duplicate_ipa_jump_func_array.  Use typed GC allocation.
(ipa_edge_duplication_hook): Call duplicate_ipa_jump_func_array.

* gimple.c (gimple_alloc_stat): Use
ggc_alloc_cleared_gimple_statement_d_stat.

* varasm.c (create_block_symbol): Use ggc_alloc_zone_rtx_def.

* tree.c (make_node_stat): Use
ggc_alloc_zone_cleared_tree_node_stat.
(make_tree_vec_stat): Likewise.
(build_vl_exp_stat): Likewise.
(copy_node_stat): Use ggc_alloc_zone_tree_node_stat.
(make_tree_binfo_stat): Likewise.
(tree_cons_stat): Likewise.

* rtl.c (rtx_alloc_stat): Use ggc_alloc_zone_rtx_def_stat.
(shallow_copy_rtx_stat): Likewise.
(make_node_stat): Likewise.

* lto-symtab.c: Fix comment.

* tree-cfg.c (create_bb): Update comment to not reference
ggc_alloc_cleared.
* tree-ssa-structalias.c (struct heapvar_for_stmt): Fix param_is
value.

* varpool.c (varpool_node): Use typed GC allocation.
(varpool_extra_name_alias): Likewise.

* varasm.c (emutls_decl): Likewise.
(get_unnamed_section): Likewise.
(get_noswitch_section): Likewise.
(get_section): Likewise.
(get_block_for_section): Likewise.
(build_constant_desc): Likewise.
(create_constant_pool): Likewise.
(force_const_mem): Likewise.

* tree.c (build_vl_exp_stat): Likewise.
(build_real): Likewise.
(build_string): Likewise.
(decl_debug_expr_insert): Likewise.
(decl_value_expr_insert): Likewise.
(type_hash_add): Likewise.
(build_omp_clause): Likewise.

* tree-ssanames.c (duplicate_ssa_name_ptr_info): Likewise.

* tree-ssa.c (init_tree_ssa): Likewise.

* tree-ssa-structalias.c (heapvar_insert): Likewise.

* tree-ssa-operands.c (ssa_operand_alloc): Likewise.

* tree-ssa-loop-niter.c (record_estimate): Likewise.

* tree-ssa-alias.c (get_ptr_info): Likewise.

* tree-scalar-evolution.c (new_scev_info_str): Likewise.

* tree-phinodes.c (allocate_phi_node): Likewise.

* tree-iterator.c (tsi_link_before): Likewise.
(tsi_link_after): Likewise.

* tree-eh.c (add_stmt_to_eh_lp_fn): Likewise.

* tree-dfa.c (create_var_ann): Likewise.

* tree-cfg.c (create_bb): Likewise.

* toplev.c (alloc_for_identifier_to_locale): Likewise.
(general_init): Likewise.

* stringpool.c (stringpool_ggc_alloc): Likewise.
(gt_pch_save_stringpool): Likewise.

* sese.c (if_region_set_false_region): Likewise.

* passes.c (do_per_function_toporder): Likewise.

* optabs.c (set_optab_libfunc): Likewise.
(set_conv_libfunc): Likewise.

* lto-symtab.c (lto_symtab_register_decl): Likewise.

* lto-streamer-in.c (lto_input_eh_catch_list): Likewise.
(input_eh_region): Likewise.
(input_eh_lp): Likewise.
(make_new_block): Likewise.
(unpack_ts_real_cst_value_fields): Likewise.

* lto-section-in.c (lto_new_in_decl_state): Likewise.

* lto-cgraph.c (input_node_opt_summary): Likewise.

* loop-init.c (loop_optimizer_init): Likewise.

* lambda.h (lambda_vector_new): Likewise.

* lambda-code.c (replace_uses_equiv_to_x_with_y): Likewise.

* ira.c (update_equiv_regs): Likewise.

* ipa.c (cgraph_node_set_new): Likewise.
(cgraph_node_set_add): Likewise.
(varpool_node_set_new): Likewise.
(varpool_node_set_add): Likewise.

* ipa-prop.c (ipa_compute_jump_functions_for_edge): Likewise.
(duplicate_ipa_jump_func_array): Likewise.
(ipa_read_node_info): Likewise.

* ipa-cp.c (ipcp_create_replace_map): Likewise.

* integrate.c (get_hard_reg_initial_val): Likewise.

* gimple.c (gimple_alloc_stat): Likewise.
(gimple_build_omp_for): Likewise.
(gimple_seq_alloc): Likewise.
(gimple_copy): Likewise.

* gimple-iterator.c (gsi_insert_before_without_update): Likewise.
(gsi_insert_after_without_update): Likewise.

* function.c (add_frame_space): Likewise.
(insert_temp_slot_address): Likewise.
(assign_stack_temp_for_type): Likewise.
(allocate_struct_function): Likewise.
(types_used_by_var_decl_insert): Likewise.

* except.c (init_eh_for_function): Likewise.
(gen_eh_region): Likewise.
(gen_eh_region_catch): Likewise.
(gen_eh_landing_pad): Likewise.
(add_call_site): Likewise.

* emit-rtl.c (get_mem_attrs): Likewise.
(get_reg_attrs): Likewise.
(start_sequence): Likewise.
(init_emit): Likewise.

* dwarf2out.c (new_cfi): Likewise.
(queue_reg_save): Likewise.
(dwarf2out_frame_init): Likewise.
(new_loc_descr): Likewise.
(find_AT_string): Likewise.
(new_die): Likewise.
(add_var_loc_to_decl): Likewise.
(clone_die): Likewise.
(clone_as_declaration): Likewise.
(break_out_comdat_types): Likewise.
(new_loc_list): Likewise.
(loc_descriptor): Likewise.
(add_loc_descr_to_each): Likewise.
(add_const_value_attribute): Likewise.
(tree_add_const_value_attribute): Likewise.
(add_comp_dir_attribute): Likewise.
(add_name_and_src_coords_attributes): Likewise.
(lookup_filename): Likewise.
(store_vcall_insn): Likewise.
(dwarf2out_init): Likewise.

* dbxout.c (dbxout_init): Likewise.

* config/xtensa/xtensa.c (xtensa_init_machine_status): Likewise.

* config/sparc/sparc.c (sparc_init_machine_status): Likewise.

* config/score/score7.c (score7_output_external): Likewise.

* config/score/score3.c (score3_output_external): Likewise.

* config/s390/s390.c (s390_init_machine_status): Likewise.

* config/rs6000/rs6000.c (builtin_function_type): Likewise.
(rs6000_init_machine_status): Likewise.
(output_toc): Likewise.

* config/pa/pa.c (pa_init_machine_status): Likewise.
(get_deferred_plabel): Likewise.

* config/moxie/moxie.c (moxie_init_machine_status): Likewise.

* config/mmix/mmix.c (mmix_init_machine_status): Likewise.

* config/mips/mips.c (mflip_mips16_use_mips16_p): Likewise.

* config/mep/mep.c (mep_init_machine_status): Likewise.
(mep_note_pragma_flag): Likewise.

* config/m32c/m32c.c (m32c_init_machine_status): Likewise.

* config/iq2000/iq2000.c (iq2000_init_machine_status): Likewise.

* config/ia64/ia64.c (ia64_init_machine_status): Likewise.

* config/i386/winnt.c (i386_pe_record_external_function): Likewise.
(i386_pe_maybe_record_exported_symbol): Likewise.

* config/i386/i386.c (get_dllimport_decl): Likewise.
(ix86_init_machine_status): Likewise.
(assign_386_stack_local): Likewise.

* config/frv/frv.c (frv_init_machine_status): Likewise.

* config/darwin.c (machopic_indirection_name): Likewise.

* config/cris/cris.c (cris_init_machine_status): Likewise.

* config/bfin/bfin.c (bfin_init_machine_status): Likewise.

* config/avr/avr.c (avr_init_machine_status): Likewise.

* config/arm/arm.c (arm_init_machine_status): Likewise.

* config/alpha/alpha.c (alpha_init_machine_status): Likewise.
(alpha_need_linkage): Likewise.
(alpha_use_linkage): Likewise.

* cgraph.c (cgraph_allocate_node): Likewise.
(cgraph_create_edge_1): Likewise.
(cgraph_create_indirect_edge): Likewise.
(cgraph_add_asm_node): Likewise.

* cfgrtl.c (init_rtl_bb_info): Likewise.

* cfgloop.c (alloc_loop): Likewise.
(rescan_loop_exit): Likewise.

* cfg.c (init_flow): Likewise.
(alloc_block): Likewise.
(unchecked_make_edge): Likewise.

* c-parser.c (c_parse_init): Likewise.
(c_parse_file): Likewise.

* c-decl.c (bind): Likewise.
(record_inline_static): Likewise.
(push_scope): Likewise.
(make_label): Likewise.
(lookup_label_for_goto): Likewise.
(finish_struct): Likewise.
(finish_enum): Likewise.
(c_push_function_context): Likewise.

* bitmap.c (bitmap_element_allocate): Likewise.
(bitmap_gc_alloc_stat): Likewise.

* alias.c (record_alias_subset): Likewise.
(init_alias_analysis): Likewise.

include:

2010-06-08  Laurynas Biveinis  <laurynas.biveinis@gmail.com>

* splay-tree.h: Update copyright years.
(splay_tree_s): Document fields.
(splay_tree_new_typed_alloc): New.

* hashtab.h: Update copyright years.
(htab_create_typed_alloc): New.

libcpp:

2010-06-08  Laurynas Biveinis  <laurynas.biveinis@gmail.com>

* include/symtab.h (ht_identifier_ptr): New.

libiberty:

2010-06-08  Laurynas Biveinis  <laurynas.biveinis@gmail.com>

* splay-tree.c: Update copyright years.
(splay_tree_new_typed_alloc): New.
(splay_tree_new_with_allocator): Use it.

* hashtab.c: Update copyright years.
(htab_create_typed_alloc): New.
(htab_create_alloc): Use it.

* functions.texi: Regenerate.

From-SVN: r160425

141 files changed:
gcc/ChangeLog
gcc/Makefile.in
gcc/ada/ChangeLog
gcc/ada/gcc-interface/ada-tree.h
gcc/ada/gcc-interface/decl.c
gcc/ada/gcc-interface/misc.c
gcc/ada/gcc-interface/trans.c
gcc/ada/gcc-interface/utils.c
gcc/alias.c
gcc/bitmap.c
gcc/bitmap.h
gcc/c-decl.c
gcc/c-family/ChangeLog
gcc/c-family/c-common.c
gcc/c-family/c-common.h
gcc/c-family/c-pragma.c
gcc/c-parser.c
gcc/cfg.c
gcc/cfgloop.c
gcc/cfgrtl.c
gcc/cgraph.c
gcc/config/alpha/alpha.c
gcc/config/arm/arm.c
gcc/config/avr/avr.c
gcc/config/bfin/bfin.c
gcc/config/cris/cris.c
gcc/config/darwin.c
gcc/config/frv/frv.c
gcc/config/i386/i386.c
gcc/config/i386/winnt.c
gcc/config/ia64/ia64.c
gcc/config/iq2000/iq2000.c
gcc/config/m32c/m32c.c
gcc/config/mep/mep.c
gcc/config/mips/mips.c
gcc/config/mmix/mmix.c
gcc/config/moxie/moxie.c
gcc/config/pa/pa.c
gcc/config/rs6000/rs6000.c
gcc/config/s390/s390.c
gcc/config/score/score3.c
gcc/config/score/score7.c
gcc/config/sparc/sparc.c
gcc/config/xtensa/xtensa.c
gcc/cp/ChangeLog
gcc/cp/class.c
gcc/cp/cp-objcp-common.c
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/lex.c
gcc/cp/name-lookup.c
gcc/cp/parser.c
gcc/cp/pt.c
gcc/cp/typeck2.c
gcc/dbxout.c
gcc/doc/gty.texi
gcc/doc/tm.texi
gcc/dwarf2asm.c
gcc/dwarf2out.c
gcc/emit-rtl.c
gcc/except.c
gcc/fortran/ChangeLog
gcc/fortran/f95-lang.c
gcc/fortran/trans-decl.c
gcc/fortran/trans-types.c
gcc/fortran/trans.h
gcc/function.c
gcc/gengtype.c
gcc/ggc-common.c
gcc/ggc-internal.h [new file with mode: 0644]
gcc/ggc-none.c
gcc/ggc-page.c
gcc/ggc-zone.c
gcc/ggc.h
gcc/gimple-iterator.c
gcc/gimple.c
gcc/gimple.h
gcc/integrate.c
gcc/ipa-cp.c
gcc/ipa-prop.c
gcc/ipa.c
gcc/ira.c
gcc/java/ChangeLog
gcc/java/class.c
gcc/java/constants.c
gcc/java/decl.c
gcc/java/except.c
gcc/java/expr.c
gcc/java/java-tree.h
gcc/java/jcf-parse.c
gcc/java/jcf-reader.c
gcc/java/jcf.h
gcc/lambda-code.c
gcc/lambda.h
gcc/loop-init.c
gcc/lto-cgraph.c
gcc/lto-section-in.c
gcc/lto-streamer-in.c
gcc/lto-streamer.h
gcc/lto-symtab.c
gcc/lto/ChangeLog
gcc/lto/lto.c
gcc/objc/ChangeLog
gcc/objc/objc-act.c
gcc/objc/objc-act.h
gcc/objcp/ChangeLog
gcc/objcp/objcp-decl.h
gcc/omp-low.c
gcc/optabs.c
gcc/passes.c
gcc/rtl.c
gcc/rtl.h
gcc/sese.c
gcc/stringpool.c
gcc/toplev.c
gcc/tree-cfg.c
gcc/tree-dfa.c
gcc/tree-eh.c
gcc/tree-iterator.c
gcc/tree-phinodes.c
gcc/tree-scalar-evolution.c
gcc/tree-ssa-alias.c
gcc/tree-ssa-loop-niter.c
gcc/tree-ssa-operands.c
gcc/tree-ssa-operands.h
gcc/tree-ssa-structalias.c
gcc/tree-ssa.c
gcc/tree-ssanames.c
gcc/tree.c
gcc/tree.h
gcc/varasm.c
gcc/varpool.c
include/ChangeLog
include/hashtab.h
include/splay-tree.h
libcpp/ChangeLog
libcpp/include/symtab.h
libiberty/ChangeLog
libiberty/functions.texi
libiberty/hashtab.c
libiberty/splay-tree.c

index 1711151e2f67d2d57e8cec8878af160d6c0d4049..46703abeece468d82b2eb07078f2a926cbf40a80 100644 (file)
@@ -1,3 +1,401 @@
+2010-06-08  Laurynas Biveinis  <laurynas.biveinis@gmail.com>
+
+       * doc/tm.texi (Per-Function Data): Do not reference ggc_alloc.
+
+       * doc/gty.texi (GTY Options): Document typed GC allocation and
+       variable_size GTY option.
+
+       * ggc-internal.h: New.
+
+       * ggc.h: Update copyright year.
+       (digit_string): Move to stringpool.c.
+       (ggc_mark_stringpool, ggc_purge_stringpool, ggc_mark_roots)
+       (gt_pch_save_stringpool, gt_pch_fixup_stringpool)
+       (gt_pach_restore_stringpool, gt_pch_p_S, gt_pch_note_object)
+       (init_ggc_pch, ggc_pch_count_object, ggc_pch_total_size)
+       (ggc_pch_this_base, ggc_pch_alloc_object, ggc_pch_prepare_write)
+       (ggc_pch_write_object, ggc_pch_finish, ggc_pch_read)
+       (ggc_force_collect, ggc_get_size, ggc_statistics)
+       (ggc_print_common_statistics): Move to ggc-internal.h.
+       (digit_vector, new_ggc_zone, destroy_ggc_zone, ggc_alloc_stat)
+       (ggc_alloc, ggc_alloc_cleared, ggc_realloc, ggc_calloc, GGC_NEW)
+       (GGC_CNEW, GGC_NEWVEC, GGC_CNEWVEC, GGC_NEWVAR, ggc_alloc_rtvec)
+       (ggc_alloc_tree, gt_pch_save, ggc_min_expand_heuristic)
+       (ggc_min_heapsize_heuristic, ggc_alloc_zone)
+       (ggc_alloc_zone_pass_stat): Remove.
+       (ggc_internal_alloc_stat, ggc_internal_alloc)
+       (ggc_internal_cleared_alloc_stat): New.
+       (GGC_RESIZEVEC, GGC_RESIZEVAR): Redefine.
+       (ggc_internal_vec_alloc_stat)
+       (ggc_internal_cleared_vec_alloc_stat)
+       (ggc_internal_vec_alloc_stat, ggc_internal_cleared_vec_alloc)
+       (ggc_alloc_atomic_stat, ggc_alloc_atomic)
+       (ggc_alloc_cleared_atomic, ggc_cleared_alloc_htab_ignore_args)
+       (ggc_cleared_alloc_ptr_array_two_args): New.
+       (htab_create_ggc, splay_tree_new_ggc): Redefine.
+       (ggc_splay_alloc): Change the type of the first argument to
+       enum gt_types_enum.
+       (ggc_alloc_string): Make macro.
+       (ggc_alloc_string_stat): New.
+       (ggc_strdup): Redefine.
+       (rtl_zone, tree_zone, tree_id_zone): Declare unconditionally.
+       (ggc_alloc_rtvec_sized): New.
+       (ggc_alloc_zone_stat): Rename to ggc_internal_alloc_zone_stat.
+       (ggc_internal_alloc_zone_pass_stat, ggc_internal_alloc_zone_stat)
+       (ggc_internal_cleared_alloc_zone_stat)
+       (ggc_internal_zone_alloc_stat)
+       (ggc_internal_zone_cleared_alloc_stat)
+       (ggc_internal_zone_vec_alloc_stat)
+       (ggc_alloc_zone_rtx_def_stat)
+       (ggc_alloc_zone_tree_node_stat)
+       (ggc_alloc_zone_cleared_tree_node_stat)
+       (ggc_alloc_cleared_gimple_statement_d_stat): New.
+
+       * ggc-common.c: Include ggc-internal.h.
+       (ggc_internal_cleared_alloc_stat): Rename from
+       ggc_alloc_cleared_stat.
+       (ggc_realloc_stat): Use ggc_internal_alloc_stat.
+       (ggc_calloc): Remove.
+       (ggc_cleared_alloc_htab_ignore_args): New.
+       (ggc_cleared_alloc_ptr_array_two_args): New.
+       (ggc_splay_alloc): Add obj_type parameter.
+       (init_ggc_heuristics): Formatting fixes.
+
+       * ggc-none.c: Update copyright year.
+       (ggc_alloc_stat): Rename to ggc_alloc_stat.
+       (ggc_alloc_cleared_stat): Rename to
+       ggc_internal_cleared_alloc_stat.
+       (struct alloc_zone, rtl_zone, tree_zone, tree_id_zone): New.
+
+       * ggc-page.c: Update copyright year.  Include ggc-internal.h.
+       Remove references to ggc_alloc in comments.
+       (ggc_alloc_typed_stat): Call ggc_internal_alloc_stat.
+       (ggc_alloc_stat): Rename to ggc_internal_alloc_stat.
+       (new_ggc_zone, destroy_ggc_zone): Remove.
+       (struct alloc_zone, rtl_zone, tree_zone, tree_id_zone): New.
+
+       * ggc-zone.c: Include ggc-internal.h.  Remove references to
+       ggc_alloc in comments.
+       (ggc_alloc_zone_stat): ggc_internal_alloc_zone_stat.
+       (ggc_internal_alloc_zone_pass_stat): New.
+       (ggc_internal_cleared_alloc_zone_stat): New.
+       (ggc_alloc_typed_stat): Use ggc_internal_alloc_zone_pass_stat.
+       (ggc_alloc_stat): Rename ggc_internal_alloc_stat.
+       (new_ggc_zone, destroy_ggc_zone): Remove.
+
+       * stringpool.c: Update copyright year.  Include ggc-internal.h
+       (digit_vector): Make static.
+       (digit_string): Moved from ggc.h.
+       (stringpool_ggc_alloc): Use ggc_alloc_atomic.
+       (ggc_alloc_string): Rename to ggc_alloc_string_stat.
+
+       * Makefile.in (GGC_INTERNAL_H): New.
+       (ggc_common.o, ggc-page.o, ggc-zone.o, stringpool.o): Add
+       $(GGC_INTERNAL_H) to dependencies.
+
+       * gentype.c: Update copyright year.
+       (walk_type): Accept variable_size GTY option.
+       (USED_BY_TYPED_GC_P): New macro.
+       (write_enum_defn): Use USED_BY_TYPED_GC_P.  Do not output
+       whitespace at the end of strings.
+       (get_type_specifier, variable_size_p): New functions.
+       (alloc_quantity, alloc_zone): New enums.
+       (write_typed_alloc_def): New function.
+       (write_typed_struct_alloc_def): Likewise.
+       (write_typed_typed_typedef_alloc_def): Likewise.
+       (write_typed_alloc_defns): Likewise.
+       (output_typename, write_splay_tree_allocator_def): Likewise.
+       (write_splay_tree_allocators): Likewise.
+       (main): Call write_typed_alloc_defns and
+       write_splay_tree_allocators.
+
+       * lto-streamer.h (lto_file_decl_data_ptr): New.
+
+       * passes.c (order): Define using cgraph_node_ptr.
+
+       * strinpool.c (struct string_pool_data): Declare nested_ptr using
+       ht_identifier_ptr.
+
+       * gimple.h (union gimple_statement_d): Likewise.
+
+       * rtl.h (struct rtx_def): Likewise.
+       (struct rtvec_def): Likewise.
+
+       * tree.h (union tree_node): Likewise.
+
+       * tree-ssa-operands.h (struct ssa_operand_memory_d): Likewise.
+
+       * cfgloop.c (record_loop_exits): Use htab_create_ggc.
+
+       * tree-scalar-evolution.c (scev_initialize): Likewise.
+
+       * alias.c (record_alias_subset): Update splay_tree_new_ggc call.
+
+       * dwarf2asm.c (dw2_force_const_mem): Likewise.
+
+       * omp-low.c (lower_omp_critical): Likewise.
+
+       * bitmap.h (struct bitmap_head_def): Update comment to not
+       reference ggc_alloc.
+
+       * config/pa/pa.c (get_deferred_label): Use GGC_RESIZEVEC.
+
+       * ira.c (fix_reg_equiv_init): Use GGC_RESIZEVEC.
+
+       * ipa-prop.c (duplicate_ggc_array): Rename to
+       duplicate_ipa_jump_func_array.  Use typed GC allocation.
+       (ipa_edge_duplication_hook): Call duplicate_ipa_jump_func_array.
+
+       * gimple.c (gimple_alloc_stat): Use
+       ggc_alloc_cleared_gimple_statement_d_stat.
+
+       * varasm.c (create_block_symbol): Use ggc_alloc_zone_rtx_def.
+
+       * tree.c (make_node_stat): Use
+       ggc_alloc_zone_cleared_tree_node_stat.
+       (make_tree_vec_stat): Likewise.
+       (build_vl_exp_stat): Likewise.
+       (copy_node_stat): Use ggc_alloc_zone_tree_node_stat.
+       (make_tree_binfo_stat): Likewise.
+       (tree_cons_stat): Likewise.
+
+       * rtl.c (rtx_alloc_stat): Use ggc_alloc_zone_rtx_def_stat.
+       (shallow_copy_rtx_stat): Likewise.
+       (make_node_stat): Likewise.
+
+       * lto-symtab.c: Fix comment.
+
+       * tree-cfg.c (create_bb): Update comment to not reference
+       ggc_alloc_cleared.
+       * tree-ssa-structalias.c (struct heapvar_for_stmt): Fix param_is
+       value.
+
+       * varpool.c (varpool_node): Use typed GC allocation.
+       (varpool_extra_name_alias): Likewise.
+
+       * varasm.c (emutls_decl): Likewise.
+       (get_unnamed_section): Likewise.
+       (get_noswitch_section): Likewise.
+       (get_section): Likewise.
+       (get_block_for_section): Likewise.
+       (build_constant_desc): Likewise.
+       (create_constant_pool): Likewise.
+       (force_const_mem): Likewise.
+
+       * tree.c (build_vl_exp_stat): Likewise.
+       (build_real): Likewise.
+       (build_string): Likewise.
+       (decl_debug_expr_insert): Likewise.
+       (decl_value_expr_insert): Likewise.
+       (type_hash_add): Likewise.
+       (build_omp_clause): Likewise.
+
+       * tree-ssanames.c (duplicate_ssa_name_ptr_info): Likewise.
+
+       * tree-ssa.c (init_tree_ssa): Likewise.
+
+       * tree-ssa-structalias.c (heapvar_insert): Likewise.
+
+       * tree-ssa-operands.c (ssa_operand_alloc): Likewise.
+
+       * tree-ssa-loop-niter.c (record_estimate): Likewise.
+
+       * tree-ssa-alias.c (get_ptr_info): Likewise.
+
+       * tree-scalar-evolution.c (new_scev_info_str): Likewise.
+
+       * tree-phinodes.c (allocate_phi_node): Likewise.
+
+       * tree-iterator.c (tsi_link_before): Likewise.
+       (tsi_link_after): Likewise.
+
+       * tree-eh.c (add_stmt_to_eh_lp_fn): Likewise.
+
+       * tree-dfa.c (create_var_ann): Likewise.
+
+       * tree-cfg.c (create_bb): Likewise.
+
+       * toplev.c (alloc_for_identifier_to_locale): Likewise.
+       (general_init): Likewise.
+
+       * stringpool.c (stringpool_ggc_alloc): Likewise.
+       (gt_pch_save_stringpool): Likewise.
+
+       * sese.c (if_region_set_false_region): Likewise.
+
+       * passes.c (do_per_function_toporder): Likewise.
+
+       * optabs.c (set_optab_libfunc): Likewise.
+       (set_conv_libfunc): Likewise.
+
+       * lto-symtab.c (lto_symtab_register_decl): Likewise.
+
+       * lto-streamer-in.c (lto_input_eh_catch_list): Likewise.
+       (input_eh_region): Likewise.
+       (input_eh_lp): Likewise.
+       (make_new_block): Likewise.
+       (unpack_ts_real_cst_value_fields): Likewise.
+
+       * lto-section-in.c (lto_new_in_decl_state): Likewise.
+
+       * lto-cgraph.c (input_node_opt_summary): Likewise.
+
+       * loop-init.c (loop_optimizer_init): Likewise.
+
+       * lambda.h (lambda_vector_new): Likewise.
+
+       * lambda-code.c (replace_uses_equiv_to_x_with_y): Likewise.
+
+       * ira.c (update_equiv_regs): Likewise.
+
+       * ipa.c (cgraph_node_set_new): Likewise.
+       (cgraph_node_set_add): Likewise.
+       (varpool_node_set_new): Likewise.
+       (varpool_node_set_add): Likewise.
+
+       * ipa-prop.c (ipa_compute_jump_functions_for_edge): Likewise.
+       (duplicate_ipa_jump_func_array): Likewise.
+       (ipa_read_node_info): Likewise.
+
+       * ipa-cp.c (ipcp_create_replace_map): Likewise.
+
+       * integrate.c (get_hard_reg_initial_val): Likewise.
+
+       * gimple.c (gimple_alloc_stat): Likewise.
+       (gimple_build_omp_for): Likewise.
+       (gimple_seq_alloc): Likewise.
+       (gimple_copy): Likewise.
+
+       * gimple-iterator.c (gsi_insert_before_without_update): Likewise.
+       (gsi_insert_after_without_update): Likewise.
+
+       * function.c (add_frame_space): Likewise.
+       (insert_temp_slot_address): Likewise.
+       (assign_stack_temp_for_type): Likewise.
+       (allocate_struct_function): Likewise.
+       (types_used_by_var_decl_insert): Likewise.
+
+       * except.c (init_eh_for_function): Likewise.
+       (gen_eh_region): Likewise.
+       (gen_eh_region_catch): Likewise.
+       (gen_eh_landing_pad): Likewise.
+       (add_call_site): Likewise.
+
+       * emit-rtl.c (get_mem_attrs): Likewise.
+       (get_reg_attrs): Likewise.
+       (start_sequence): Likewise.
+       (init_emit): Likewise.
+
+       * dwarf2out.c (new_cfi): Likewise.
+       (queue_reg_save): Likewise.
+       (dwarf2out_frame_init): Likewise.
+       (new_loc_descr): Likewise.
+       (find_AT_string): Likewise.
+       (new_die): Likewise.
+       (add_var_loc_to_decl): Likewise.
+       (clone_die): Likewise.
+       (clone_as_declaration): Likewise.
+       (break_out_comdat_types): Likewise.
+       (new_loc_list): Likewise.
+       (loc_descriptor): Likewise.
+       (add_loc_descr_to_each): Likewise.
+       (add_const_value_attribute): Likewise.
+       (tree_add_const_value_attribute): Likewise.
+       (add_comp_dir_attribute): Likewise.
+       (add_name_and_src_coords_attributes): Likewise.
+       (lookup_filename): Likewise.
+       (store_vcall_insn): Likewise.
+       (dwarf2out_init): Likewise.
+
+       * dbxout.c (dbxout_init): Likewise.
+
+       * config/xtensa/xtensa.c (xtensa_init_machine_status): Likewise.
+
+       * config/sparc/sparc.c (sparc_init_machine_status): Likewise.
+
+       * config/score/score7.c (score7_output_external): Likewise.
+
+       * config/score/score3.c (score3_output_external): Likewise.
+
+       * config/s390/s390.c (s390_init_machine_status): Likewise.
+
+       * config/rs6000/rs6000.c (builtin_function_type): Likewise.
+       (rs6000_init_machine_status): Likewise.
+       (output_toc): Likewise.
+
+       * config/pa/pa.c (pa_init_machine_status): Likewise.
+       (get_deferred_plabel): Likewise.
+
+       * config/moxie/moxie.c (moxie_init_machine_status): Likewise.
+
+       * config/mmix/mmix.c (mmix_init_machine_status): Likewise.
+
+       * config/mips/mips.c (mflip_mips16_use_mips16_p): Likewise.
+
+       * config/mep/mep.c (mep_init_machine_status): Likewise.
+       (mep_note_pragma_flag): Likewise.
+
+       * config/m32c/m32c.c (m32c_init_machine_status): Likewise.
+
+       * config/iq2000/iq2000.c (iq2000_init_machine_status): Likewise.
+
+       * config/ia64/ia64.c (ia64_init_machine_status): Likewise.
+
+       * config/i386/winnt.c (i386_pe_record_external_function): Likewise.
+       (i386_pe_maybe_record_exported_symbol): Likewise.
+
+       * config/i386/i386.c (get_dllimport_decl): Likewise.
+       (ix86_init_machine_status): Likewise.
+       (assign_386_stack_local): Likewise.
+
+       * config/frv/frv.c (frv_init_machine_status): Likewise.
+
+       * config/darwin.c (machopic_indirection_name): Likewise.
+
+       * config/cris/cris.c (cris_init_machine_status): Likewise.
+
+       * config/bfin/bfin.c (bfin_init_machine_status): Likewise.
+
+       * config/avr/avr.c (avr_init_machine_status): Likewise.
+
+       * config/arm/arm.c (arm_init_machine_status): Likewise.
+
+       * config/alpha/alpha.c (alpha_init_machine_status): Likewise.
+       (alpha_need_linkage): Likewise.
+       (alpha_use_linkage): Likewise.
+
+       * cgraph.c (cgraph_allocate_node): Likewise.
+       (cgraph_create_edge_1): Likewise.
+       (cgraph_create_indirect_edge): Likewise.
+       (cgraph_add_asm_node): Likewise.
+
+       * cfgrtl.c (init_rtl_bb_info): Likewise.
+
+       * cfgloop.c (alloc_loop): Likewise.
+       (rescan_loop_exit): Likewise.
+
+       * cfg.c (init_flow): Likewise.
+       (alloc_block): Likewise.
+       (unchecked_make_edge): Likewise.
+
+       * c-parser.c (c_parse_init): Likewise.
+       (c_parse_file): Likewise.
+
+       * c-decl.c (bind): Likewise.
+       (record_inline_static): Likewise.
+       (push_scope): Likewise.
+       (make_label): Likewise.
+       (lookup_label_for_goto): Likewise.
+       (finish_struct): Likewise.
+       (finish_enum): Likewise.
+       (c_push_function_context): Likewise.
+
+       * bitmap.c (bitmap_element_allocate): Likewise.
+       (bitmap_gc_alloc_stat): Likewise.
+
+       * alias.c (record_alias_subset): Likewise.
+       (init_alias_analysis): Likewise.
+
 2010-06-08  Shujing Zhao  <pearly.zhao@oracle.com>
        
        * fold-const.c (fold_comparison): Remove redundant parenthesis.
index fed7fe8d498c848fb76e8f0e8d81175ba5627898..a19022564b3813b1e58cc4c7320aaf5d21f7217e 100644 (file)
@@ -914,6 +914,7 @@ RESOURCE_H = resource.h hard-reg-set.h $(DF_H)
 DDG_H = ddg.h sbitmap.h $(DF_H)
 GCC_H = gcc.h version.h $(DIAGNOSTIC_CORE_H)
 GGC_H = ggc.h gtype-desc.h statistics.h
+GGC_INTERNAL_H = ggc-internal.h $(GGC_H)
 TIMEVAR_H = timevar.h timevar.def
 INSN_ATTR_H = insn-attr.h $(INSN_ADDR_H)
 INSN_ADDR_H = $(srcdir)/insn-addr.h vecprim.h
@@ -2246,20 +2247,21 @@ gtype-desc.o: gtype-desc.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
 
 ggc-common.o: ggc-common.c $(CONFIG_H) $(SYSTEM_H) coretypes.h         \
        $(GGC_H) $(HASHTAB_H) $(TOPLEV_H) $(PARAMS_H) hosthooks.h       \
-       $(HOSTHOOKS_DEF_H) $(VEC_H) $(PLUGIN_H) $(TIMEVAR_H)
+       $(HOSTHOOKS_DEF_H) $(VEC_H) $(PLUGIN_H) $(GGC_INTERNAL_H) $(TIMEVAR_H)
 
 ggc-page.o: ggc-page.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(TREE_H) \
-       $(FLAGS_H) $(TOPLEV_H) $(GGC_H) $(TIMEVAR_H) $(TM_P_H) $(PARAMS_H) $(TREE_FLOW_H) $(PLUGIN_H)
+       $(FLAGS_H) $(TOPLEV_H) $(GGC_H) $(TIMEVAR_H) $(TM_P_H) $(PARAMS_H) \
+       $(TREE_FLOW_H) $(PLUGIN_H) $(GGC_INTERNAL_H)
 
 ggc-zone.o: ggc-zone.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
        $(TREE_H) $(FLAGS_H) $(TOPLEV_H) $(GGC_H) $(TIMEVAR_H) $(TM_P_H) \
-       $(PARAMS_H) $(BITMAP_H) $(PLUGIN_H)
+       $(PARAMS_H) $(BITMAP_H) $(PLUGIN_H) $(GGC_INTERNAL_H)
 
 ggc-none.o: ggc-none.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(GGC_H) \
        $(BCONFIG_H)
 
 stringpool.o: stringpool.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
-       $(TREE_H) $(GGC_H) gt-stringpool.h $(CPPLIB_H) $(SYMTAB_H)
+       $(TREE_H) $(GGC_H) $(GGC_INTERNAL_H) gt-stringpool.h $(CPPLIB_H) $(SYMTAB_H)
 
 convert.o: convert.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
    $(FLAGS_H) convert.h $(TOPLEV_H) langhooks.h
index 2c2b307062ece7e8970f5a3716c5d0d04699f844..accf5bbda62855f062357c8b1251c72538c9f4e1 100644 (file)
@@ -1,3 +1,27 @@
+2010-06-08  Laurynas Biveinis  <laurynas.biveinis@gmail.com>
+
+       * gcc-interface/utils.c (init_gnat_to_gnu): Use typed GC
+       allocation.
+       (init_dummy_type): Likewise.
+       (gnat_pushlevel): Likewise.
+
+       * gcc-interface/trans.c (Attribute_to_gnu): Likewise.
+       (Subprogram_Body_to_gnu): Likewise.
+       (Compilation_Unit_to_gnu): Likewise.
+       (start_stmt_group): Likewise.
+       (extract_encoding): Likewise.
+       (decode_name): Likewise.
+
+       * gcc-interface/misc.c (gnat_printable_name): Likewise.
+
+       * gcc-interface/decl.c (annotate_value): Likewise.
+
+       * gcc-interface/ada-tree.h (struct lang_type): Add variable_size
+       GTY option.
+       (struct lang_decl): Likewise.
+       (SET_TYPE_LANG_SPECIFIC): Use typed GC allocation.
+       (SET_DECL_LANG_SPECIFIC): Likewise.
+
 2010-06-04  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gnatlink.adb (gnatlink): Remove support for -fsjlj switch.
index 60a5595fe22c3609fababc8740c06bf6e59029b9..220ed57c215482b083c3b138f4015856ca1c4e6f 100644 (file)
@@ -32,32 +32,37 @@ union GTY((desc ("0"),
                       desc ("tree_node_structure (&%h)"))) generic;
 };
 
-/* Ada uses the lang_decl and lang_type fields to hold a tree.  */
-struct GTY(()) lang_type { tree t; };
-struct GTY(()) lang_decl { tree t; };
+/* Ada uses the lang_decl and lang_type fields to hold a tree.
+   FIXME: the variable_size annotation here is needed because these types are
+   variable-sized in some other frontends.  Due to gengtype deficiency the GTY
+   options of such types have to agree across all frontends. */
+struct GTY((variable_size)) lang_type { tree t; };
+struct GTY((variable_size)) lang_decl { tree t; };
 
 /* Macros to get and set the tree in TYPE_LANG_SPECIFIC.  */
 #define GET_TYPE_LANG_SPECIFIC(NODE) \
   (TYPE_LANG_SPECIFIC (NODE) ? TYPE_LANG_SPECIFIC (NODE)->t : NULL_TREE)
 
-#define SET_TYPE_LANG_SPECIFIC(NODE, X)                            \
-do {                                                       \
-  tree tmp = (X);                                          \
-  if (!TYPE_LANG_SPECIFIC (NODE))                          \
-    TYPE_LANG_SPECIFIC (NODE) = GGC_NEW (struct lang_type); \
-  TYPE_LANG_SPECIFIC (NODE)->t = tmp;                      \
+#define SET_TYPE_LANG_SPECIFIC(NODE, X)                       \
+do {                                                  \
+  tree tmp = (X);                                     \
+  if (!TYPE_LANG_SPECIFIC (NODE))                     \
+    TYPE_LANG_SPECIFIC (NODE) = ggc_alloc_lang_type    \
+      (sizeof (struct lang_type));                    \
+  TYPE_LANG_SPECIFIC (NODE)->t = tmp;                 \
 } while (0)
 
 /* Macros to get and set the tree in DECL_LANG_SPECIFIC.  */
 #define GET_DECL_LANG_SPECIFIC(NODE) \
   (DECL_LANG_SPECIFIC (NODE) ? DECL_LANG_SPECIFIC (NODE)->t : NULL_TREE)
 
-#define SET_DECL_LANG_SPECIFIC(NODE, X)                            \
-do {                                                       \
-  tree tmp = (X);                                          \
-  if (!DECL_LANG_SPECIFIC (NODE))                          \
-    DECL_LANG_SPECIFIC (NODE) = GGC_NEW (struct lang_decl); \
-  DECL_LANG_SPECIFIC (NODE)->t = tmp;                      \
+#define SET_DECL_LANG_SPECIFIC(NODE, X)                       \
+do {                                                  \
+  tree tmp = (X);                                     \
+  if (!DECL_LANG_SPECIFIC (NODE))                     \
+    DECL_LANG_SPECIFIC (NODE) = ggc_alloc_lang_decl    \
+      (sizeof (struct lang_decl));                    \
+  DECL_LANG_SPECIFIC (NODE)->t = tmp;                 \
 } while (0)
 
 
index cf9f025ba2cacc415009b00e2bebc5ec2a070e85..fb4769b7bb24aba524a87065fd952fe3210f6b12 100644 (file)
@@ -7296,7 +7296,7 @@ annotate_value (tree gnu_size)
   /* Save the result in the cache.  */
   if (h)
     {
-      *h = GGC_NEW (struct tree_int_map);
+      *h = ggc_alloc_tree_int_map ();
       (*h)->base.from = gnu_size;
       (*h)->to = ret;
     }
index a80afbdc80e393a2e9e42db23385c11f6b501737..229663b7ce206347bffe458937ecd219942f9cce 100644 (file)
@@ -574,7 +574,7 @@ static const char *
 gnat_printable_name (tree decl, int verbosity)
 {
   const char *coded_name = IDENTIFIER_POINTER (DECL_NAME (decl));
-  char *ada_name = (char *) ggc_alloc (strlen (coded_name) * 2 + 60);
+  char *ada_name = (char *) ggc_alloc_atomic (strlen (coded_name) * 2 + 60);
 
   __gnat_decode (coded_name, ada_name, 0);
 
index 1732069b699b6443f51fb60f64ecdcf5b8d42339..7a94393b0e0d3ac46fd75acf2ad32c00217d8d71 100644 (file)
@@ -1605,7 +1605,7 @@ Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute)
 
            if (!pa)
              {
-               pa = GGC_CNEW (struct parm_attr_d);
+               pa = ggc_alloc_cleared_parm_attr_d ();
                pa->id = gnat_param;
                pa->dim = Dimension;
                VEC_safe_push (parm_attr, gc, f_parm_attr_cache, pa);
@@ -2441,7 +2441,7 @@ Subprogram_Body_to_gnu (Node_Id gnat_node)
   /* Initialize the information structure for the function.  */
   allocate_struct_function (gnu_subprog_decl, false);
   DECL_STRUCT_FUNCTION (gnu_subprog_decl)->language
-    = GGC_CNEW (struct language_function);
+    = ggc_alloc_cleared_language_function ();
   set_cfun (NULL);
 
   begin_subprog_body (gnu_subprog_decl);
@@ -3626,7 +3626,7 @@ Compilation_Unit_to_gnu (Node_Id gnat_node)
 
   /* Save away what we've made so far and record this potential elaboration
      procedure.  */
-  info = (struct elab_info *) ggc_alloc (sizeof (struct elab_info));
+  info = ggc_alloc_elab_info ();
   set_current_block_context (gnu_elab_proc_decl);
   gnat_poplevel ();
   DECL_SAVED_TREE (gnu_elab_proc_decl) = end_stmt_group ();
@@ -5722,7 +5722,7 @@ start_stmt_group (void)
   if (group)
     stmt_group_free_list = group->previous;
   else
-    group = (struct stmt_group *) ggc_alloc (sizeof (struct stmt_group));
+    group = ggc_alloc_stmt_group ();
 
   group->previous = current_stmt_group;
   group->stmt_list = group->block = group->cleanups = NULL_TREE;
@@ -7498,7 +7498,7 @@ set_expr_location_from_node (tree node, Node_Id gnat_node)
 static const char *
 extract_encoding (const char *name)
 {
-  char *encoding = GGC_NEWVEC (char, strlen (name));
+  char *encoding = (char *) ggc_alloc_atomic (strlen (name));
   get_encoding (name, encoding);
   return encoding;
 }
@@ -7508,7 +7508,7 @@ extract_encoding (const char *name)
 static const char *
 decode_name (const char *name)
 {
-  char *decoded = GGC_NEWVEC (char, strlen (name) * 2 + 60);
+  char *decoded = (char *) ggc_alloc_atomic (strlen (name) * 2 + 60);
   __gnat_decode (name, decoded, 0);
   return decoded;
 }
index f10b788fe1a1dbe62811fafbaf6a5268b14c0339..ebb70259c453c84fc504185f9fa9552732a9db2f 100644 (file)
@@ -206,8 +206,7 @@ static void process_attributes (tree, struct attrib *);
 void
 init_gnat_to_gnu (void)
 {
-  associate_gnat_to_gnu
-    = (tree *) ggc_alloc_cleared (max_gnat_nodes * sizeof (tree));
+  associate_gnat_to_gnu = ggc_alloc_cleared_vec_tree (max_gnat_nodes);
 }
 
 /* GNAT_ENTITY is a GNAT tree node for an entity.   GNU_DECL is the GCC tree
@@ -257,8 +256,7 @@ present_gnu_tree (Entity_Id gnat_entity)
 void
 init_dummy_type (void)
 {
-  dummy_node_table
-    = (tree *) ggc_alloc_cleared (max_gnat_nodes * sizeof (tree));
+  dummy_node_table = ggc_alloc_cleared_vec_tree (max_gnat_nodes);
 }
 
 /* Make a dummy type corresponding to GNAT_TYPE.  */
@@ -321,9 +319,7 @@ gnat_pushlevel (void)
       free_binding_level = free_binding_level->chain;
     }
   else
-    newlevel
-      = (struct gnat_binding_level *)
-       ggc_alloc (sizeof (struct gnat_binding_level));
+    newlevel = ggc_alloc_gnat_binding_level ();
 
   /* Use a free BLOCK, if any; otherwise, allocate one.  */
   if (free_block_chain)
index a4083a1a13b1e9b43b0dfa5d38f8fa42f43b63f2..382093161189ee61e849753e006b288ca23e0f8b 100644 (file)
@@ -823,10 +823,12 @@ record_alias_subset (alias_set_type superset, alias_set_type subset)
     {
       /* Create an entry for the SUPERSET, so that we have a place to
         attach the SUBSET.  */
-      superset_entry = GGC_NEW (struct alias_set_entry_d);
+      superset_entry = ggc_alloc_cleared_alias_set_entry_d ();
       superset_entry->alias_set = superset;
       superset_entry->children
-       = splay_tree_new_ggc (splay_tree_compare_ints);
+       = splay_tree_new_ggc (splay_tree_compare_ints,
+                             ggc_alloc_splay_tree_scalar_scalar_splay_tree_s,
+                             ggc_alloc_splay_tree_scalar_scalar_splay_tree_node_s);
       superset_entry->has_zero_child = 0;
       VEC_replace (alias_set_entry, alias_sets, superset, superset_entry);
     }
@@ -2639,7 +2641,7 @@ init_alias_analysis (void)
   timevar_push (TV_ALIAS_ANALYSIS);
 
   reg_known_value_size = maxreg - FIRST_PSEUDO_REGISTER;
-  reg_known_value = GGC_CNEWVEC (rtx, reg_known_value_size);
+  reg_known_value = ggc_alloc_cleared_vec_rtx (reg_known_value_size);
   reg_known_equiv_p = XCNEWVEC (bool, reg_known_value_size);
 
   /* If we have memory allocated from the previous run, use it.  */
index 8f4a56606bd8f487e66d08e4fbc8c844dbd38637..21a05fc4fa15b2368545c38cad608de82b4bb209 100644 (file)
@@ -230,7 +230,7 @@ bitmap_element_allocate (bitmap head)
          /*  Inner list was just a singleton.  */
          bitmap_ggc_free = element->prev;
       else
-       element = GGC_NEW (bitmap_element);
+       element = ggc_alloc_bitmap_element_def ();
     }
 
 #ifdef GATHER_STATISTICS
@@ -375,7 +375,7 @@ bitmap_gc_alloc_stat (ALONE_MEM_STAT_DECL)
 {
   bitmap map;
 
-  map = GGC_NEW (struct bitmap_head_def);
+  map = ggc_alloc_bitmap_head_def ();
   bitmap_initialize_stat (map, NULL PASS_MEM_STAT);
 #ifdef GATHER_STATISTICS
   register_overhead (map, sizeof (bitmap_head));
index bbc0e20cfefe778894f4e766daedc5085ab37ef0..1163b2f53d18e648f3639f2aecb4564d3f5d2fdc 100644 (file)
@@ -77,7 +77,7 @@ typedef struct GTY(()) bitmap_head_def {
   bitmap_element *current;     /* Last element looked at.  */
   unsigned int indx;           /* Index of last element looked at.  */
   bitmap_obstack *obstack;     /* Obstack to allocate elements from.
-                                  If NULL, then use ggc_alloc.  */
+                                  If NULL, then use GGC allocation.  */
 #ifdef GATHER_STATISTICS
   struct bitmap_descriptor GTY((skip)) *desc;
 #endif
index 96ef29998445cc4c6760efe0861adf5ec5f7c1a2..740ca3588f0c723d35a7bbafdda32799ad13cae6 100644 (file)
@@ -590,7 +590,7 @@ bind (tree name, tree decl, struct c_scope *scope, bool invisible,
       binding_freelist = b->prev;
     }
   else
-    b = GGC_NEW (struct c_binding);
+    b = ggc_alloc_c_binding ();
 
   b->shadowed = 0;
   b->decl = decl;
@@ -704,7 +704,7 @@ void
 record_inline_static (location_t loc, tree func, tree decl,
                      enum c_inline_static_type type)
 {
-  struct c_inline_static *csi = GGC_NEW (struct c_inline_static);
+  struct c_inline_static *csi = ggc_alloc_c_inline_static ();
   csi->location = loc;
   csi->function = func;
   csi->static_decl = decl;
@@ -928,7 +928,7 @@ push_scope (void)
          scope_freelist = scope->outer;
        }
       else
-       scope = GGC_CNEW (struct c_scope);
+       scope = ggc_alloc_cleared_c_scope ();
 
       /* The FLOAT_CONST_DECIMAL64 pragma applies to nested scopes.  */
       if (current_scope)
@@ -3007,7 +3007,7 @@ make_label (location_t location, tree name, bool defining,
   DECL_CONTEXT (label) = current_function_decl;
   DECL_MODE (label) = VOIDmode;
 
-  label_vars = GGC_NEW (struct c_label_vars);
+  label_vars = ggc_alloc_c_label_vars ();
   label_vars->shadowed = NULL;
   set_spot_bindings (&label_vars->label_bindings, defining);
   label_vars->decls_in_scope = make_tree_vector ();
@@ -3105,7 +3105,7 @@ lookup_label_for_goto (location_t loc, tree name)
     {
       struct c_goto_bindings *g;
 
-      g = GGC_NEW (struct c_goto_bindings);
+      g = ggc_alloc_c_goto_bindings ();
       g->loc = loc;
       set_spot_bindings (&g->goto_bindings, true);
       VEC_safe_push (c_goto_bindings_p, gc, label_vars->gotos, g);
@@ -6987,9 +6987,9 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes,
          ensure that this lives as long as the rest of the struct decl.
          All decls in an inline function need to be saved.  */
 
-       space = GGC_CNEW (struct lang_type);
-       space2 = GGC_NEWVAR (struct sorted_fields_type,
-                            sizeof (struct sorted_fields_type) + len * sizeof (tree));
+       space = ggc_alloc_cleared_lang_type (sizeof (struct lang_type));
+       space2 = ggc_alloc_sorted_fields_type
+         (sizeof (struct sorted_fields_type) + len * sizeof (tree));
 
        len = 0;
        space->s = space2;
@@ -7270,7 +7270,7 @@ finish_enum (tree enumtype, tree values, tree attributes)
 
   /* Record the min/max values so that we can warn about bit-field
      enumerations that are too small for the values.  */
-  lt = GGC_CNEW (struct lang_type);
+  lt = ggc_alloc_cleared_lang_type (sizeof (struct lang_type));
   lt->enum_min = minnode;
   lt->enum_max = maxnode;
   TYPE_LANG_SPECIFIC (enumtype) = lt;
@@ -8293,7 +8293,7 @@ void
 c_push_function_context (void)
 {
   struct language_function *p;
-  p = GGC_NEW (struct language_function);
+  p = ggc_alloc_language_function ();
   cfun->language = p;
 
   p->base.x_stmt_tree = c_stmt_tree;
index d0b51567eae5fbe5a248fffece43e8f05a8b1510..5370a8e8b329ab425f8b9bd0c00536a0c10803b0 100644 (file)
@@ -1,3 +1,13 @@
+2010-06-08  Laurynas Biveinis  <laurynas.biveinis@gmail.com>
+
+       * c-pragma.c (push_alignment): Use typed GC allocation.
+       (handle_pragma_push_options): Likewise.
+
+       * c-common.c (parse_optimize_options): Likewise.
+
+       * c-common.h (struct sorted_fields_type): Add variable_size GTY
+       option.
+
 2010-06-07  Joseph Myers  <joseph@codesourcery.com>
 
        * c-common.c (flag_preprocess_only, flag_undef, flag_no_builtin,
index c3fa8e654dc5ec18c758a7dc796aaa1123c56f0f..7c841b1d07693c66cb60900a8d9e04820c045d43 100644 (file)
@@ -7684,7 +7684,7 @@ parse_optimize_options (tree args, bool attr_p)
                  next_p = NULL;
                }
 
-             r = q = (char *) ggc_alloc (len2 + 3);
+             r = q = (char *) ggc_alloc_atomic (len2 + 3);
 
              /* If the user supplied -Oxxx or -fxxx, only allow -Oxxx or -fxxx
                 options.  */
index c6701b8bb073d57c84f1a500aac8403e5188c079..6948b8231e8f31453d01b8acdaf82a7b24f13437 100644 (file)
@@ -373,7 +373,7 @@ extern GTY(()) tree c_global_trees[CTI_MAX];
 
 /* In a RECORD_TYPE, a sorted array of the fields of the type, not a
    tree for size reasons.  */
-struct GTY(()) sorted_fields_type {
+struct GTY((variable_size)) sorted_fields_type {
   int len;
   tree GTY((length ("%h.len"))) elts[1];
 };
index a48bf4fc50e62eb6a8ac9c9808872f83a0729f9b..ab922696dddba8c4c8055a8aa0aa4e028470fa17 100644 (file)
@@ -77,7 +77,7 @@ push_alignment (int alignment, tree id)
 {
   align_stack * entry;
 
-  entry = GGC_NEW (align_stack);
+  entry = ggc_alloc_align_stack ();
 
   entry->alignment  = alignment;
   entry->id        = id;
@@ -914,7 +914,7 @@ handle_pragma_push_options (cpp_reader *ARG_UNUSED(dummy))
       return;
     }
 
-  p = GGC_NEW (opt_stack);
+  p = ggc_alloc_opt_stack ();
   p->prev = options_stack;
   options_stack = p;
 
index 56d5d83eccdf074004c531f08ca6e87d4048c8af..04506df176e25391b20fb31983668cc0619e779a 100644 (file)
@@ -86,7 +86,7 @@ c_parse_init (void)
   if (!c_dialect_objc ())
     mask |= D_OBJC | D_CXX_OBJC;
 
-  ridpointers = GGC_CNEWVEC (tree, (int) RID_MAX);
+  ridpointers = ggc_alloc_cleared_vec_tree ((int) RID_MAX);
   for (i = 0; i < num_c_common_reswords; i++)
     {
       /* If a keyword is disabled, do not enter it into the table
@@ -8882,7 +8882,7 @@ c_parse_file (void)
   if (c_parser_peek_token (&tparser)->pragma_kind == PRAGMA_GCC_PCH_PREPROCESS)
     c_parser_pragma_pch_preprocess (&tparser);
 
-  the_parser = GGC_NEW (c_parser);
+  the_parser = ggc_alloc_c_parser ();
   *the_parser = tparser;
 
   /* Initialize EH, if we've been told to do so.  */
index ee6af69746855c3ca68ce3bcb2db68f271d7abc7..563582ff29646148a9461bb4c55ea796db2792d8 100644 (file)
--- a/gcc/cfg.c
+++ b/gcc/cfg.c
@@ -84,13 +84,13 @@ void
 init_flow (struct function *the_fun)
 {
   if (!the_fun->cfg)
-    the_fun->cfg = GGC_CNEW (struct control_flow_graph);
+    the_fun->cfg = ggc_alloc_cleared_control_flow_graph ();
   n_edges_for_function (the_fun) = 0;
   ENTRY_BLOCK_PTR_FOR_FUNCTION (the_fun)
-    = GGC_CNEW (struct basic_block_def);
+    = ggc_alloc_cleared_basic_block_def ();
   ENTRY_BLOCK_PTR_FOR_FUNCTION (the_fun)->index = ENTRY_BLOCK;
   EXIT_BLOCK_PTR_FOR_FUNCTION (the_fun)
-    = GGC_CNEW (struct basic_block_def);
+    = ggc_alloc_cleared_basic_block_def ();
   EXIT_BLOCK_PTR_FOR_FUNCTION (the_fun)->index = EXIT_BLOCK;
   ENTRY_BLOCK_PTR_FOR_FUNCTION (the_fun)->next_bb
     = EXIT_BLOCK_PTR_FOR_FUNCTION (the_fun);
@@ -139,7 +139,7 @@ basic_block
 alloc_block (void)
 {
   basic_block bb;
-  bb = GGC_CNEW (struct basic_block_def);
+  bb = ggc_alloc_cleared_basic_block_def ();
   return bb;
 }
 
@@ -277,7 +277,7 @@ edge
 unchecked_make_edge (basic_block src, basic_block dst, int flags)
 {
   edge e;
-  e = GGC_CNEW (struct edge_def);
+  e = ggc_alloc_cleared_edge_def ();
   n_edges++;
 
   e->src = src;
index 858e75b3f52c38426db82ae95067f71faeb71768..c0d9a4cacc2649b5d70287fe90f91b48c3be9d8f 100644 (file)
@@ -334,9 +334,9 @@ flow_loop_tree_node_remove (struct loop *loop)
 struct loop *
 alloc_loop (void)
 {
-  struct loop *loop = GGC_CNEW (struct loop);
+  struct loop *loop = ggc_alloc_cleared_loop ();
 
-  loop->exits = GGC_CNEW (struct loop_exit);
+  loop->exits = ggc_alloc_cleared_loop_exit ();
   loop->exits->next = loop->exits->prev = loop->exits;
   loop->can_be_parallel = false;
   loop->single_iv = NULL_TREE;
@@ -1026,7 +1026,7 @@ rescan_loop_exit (edge e, bool new_edge, bool removed)
           aloop != cloop;
           aloop = loop_outer (aloop))
        {
-         exit = GGC_NEW (struct loop_exit);
+         exit = ggc_alloc_loop_exit ();
          exit->e = e;
 
          exit->next = aloop->exits->next;
@@ -1076,11 +1076,9 @@ record_loop_exits (void)
   loops_state_set (LOOPS_HAVE_RECORDED_EXITS);
 
   gcc_assert (current_loops->exits == NULL);
-  current_loops->exits = htab_create_alloc (2 * number_of_loops (),
-                                           loop_exit_hash,
-                                           loop_exit_eq,
-                                           loop_exit_free,
-                                           ggc_calloc, ggc_free);
+  current_loops->exits = htab_create_ggc (2 * number_of_loops (),
+                                         loop_exit_hash, loop_exit_eq,
+                                         loop_exit_free);
 
   FOR_EACH_BB (bb)
     {
index abdbf9d8598f8785e69c3793328d427462913ac0..bf617373762c00d9051522ecfc0f35c3fccb3ddb 100644 (file)
@@ -3080,7 +3080,7 @@ void
 init_rtl_bb_info (basic_block bb)
 {
   gcc_assert (!bb->il.rtl);
-  bb->il.rtl = GGC_CNEW (struct rtl_bb_info);
+  bb->il.rtl = ggc_alloc_cleared_rtl_bb_info ();
 }
 
 
index 105cdab14a63c505e31e209abe4b5fa8c973e2e5..557c205e3d1f45ff5262feffc831130c94a6a6d1 100644 (file)
@@ -442,7 +442,7 @@ cgraph_allocate_node (void)
     }
   else
     {
-      node = GGC_CNEW (struct cgraph_node);
+      node = ggc_alloc_cleared_cgraph_node ();
       node->uid = cgraph_max_uid++;
     }
 
@@ -970,7 +970,7 @@ cgraph_create_edge_1 (struct cgraph_node *caller, struct cgraph_node *callee,
     }
   else
     {
-      edge = GGC_NEW (struct cgraph_edge);
+      edge = ggc_alloc_cgraph_edge ();
       edge->uid = cgraph_edge_max_uid++;
     }
 
@@ -1045,7 +1045,7 @@ cgraph_create_indirect_edge (struct cgraph_node *caller, gimple call_stmt,
   edge->indirect_unknown_callee = 1;
   initialize_inline_failed (edge);
 
-  edge->indirect_info = GGC_CNEW (struct cgraph_indirect_call_info);
+  edge->indirect_info = ggc_alloc_cleared_cgraph_indirect_call_info ();
   edge->indirect_info->param_index = -1;
   edge->indirect_info->ecf_flags = ecf_flags;
 
@@ -1973,7 +1973,7 @@ cgraph_add_asm_node (tree asm_str)
 {
   struct cgraph_asm_node *node;
 
-  node = GGC_CNEW (struct cgraph_asm_node);
+  node = ggc_alloc_cleared_cgraph_asm_node ();
   node->asm_str = asm_str;
   node->order = cgraph_order++;
   node->next = NULL;
index 4daf3df4d652bc2d81552a89ec0e0a6defc6b930..0246d5a5b6d37dfeae61f27f2f0bd791b8f1f007 100644 (file)
@@ -4806,8 +4806,7 @@ struct GTY(()) machine_function
 static struct machine_function *
 alpha_init_machine_status (void)
 {
-  return ((struct machine_function *)
-               ggc_alloc_cleared (sizeof (struct machine_function)));
+  return ggc_alloc_cleared_machine_function ();
 }
 
 /* Support for frame based VMS condition handlers.  */
@@ -9904,7 +9903,7 @@ alpha_need_linkage (const char *name, int is_local)
         alpha_funcs_tree = splay_tree_new_ggc ((splay_tree_compare_fn)
                                               splay_tree_compare_pointers);
 
-      cfaf = (struct alpha_funcs *) ggc_alloc (sizeof (struct alpha_funcs));
+      cfaf = ggc_alloc_alpha_funcs ();
 
       cfaf->links = 0;
       cfaf->num = ++alpha_funcs_num;
@@ -9940,7 +9939,7 @@ alpha_need_linkage (const char *name, int is_local)
   else
     alpha_links_tree = splay_tree_new_ggc ((splay_tree_compare_fn) strcmp);
 
-  al = (struct alpha_links *) ggc_alloc (sizeof (struct alpha_links));
+  al = ggc_alloc_alpha_links ();
   name = ggc_strdup (name);
 
   /* Assume external if no definition.  */
@@ -10012,7 +10011,7 @@ alpha_use_linkage (rtx func, tree cfundecl, int lflag, int rflag)
       name_len = strlen (name);
       linksym = (char *) alloca (name_len + 50);
 
-      al = (struct alpha_links *) ggc_alloc (sizeof (struct alpha_links));
+      al = ggc_alloc_alpha_links ();
       al->num = cfaf->num;
 
       node = splay_tree_lookup (alpha_links_tree, (splay_tree_key) name);
index 31c13543e908727ced60f3425899c4e4d014ed64..e44e94946fbeddeb981f7ad637f4c6b6642dd79c 100644 (file)
@@ -19280,7 +19280,7 @@ static struct machine_function *
 arm_init_machine_status (void)
 {
   struct machine_function *machine;
-  machine = (machine_function *) ggc_alloc_cleared (sizeof (machine_function));
+  machine = ggc_alloc_cleared_machine_function ();
 
 #if ARM_FT_UNKNOWN != 0
   machine->func_type = ARM_FT_UNKNOWN;
index d8942c5c0810e98122de5f5a8bd15b2d69eb0ce2..531a4128bf31da100dc43f3637196eddd1bf4761 100644 (file)
@@ -243,8 +243,7 @@ static const enum reg_class reg_class_tab[]={
 static struct machine_function *
 avr_init_machine_status (void)
 {
-  return ((struct machine_function *) 
-          ggc_alloc_cleared (sizeof (struct machine_function)));
+  return ggc_alloc_cleared_machine_function ();
 }
 
 /* Return register class for register R.  */
index 152e910ee6754b4500b92f397f1b5dc0f796b1f9..c187bf3bbc7dd37037cbb2974acaf05502071d4a 100644 (file)
@@ -2634,11 +2634,7 @@ bfin_handle_option (size_t code, const char *arg, int value)
 static struct machine_function *
 bfin_init_machine_status (void)
 {
-  struct machine_function *f;
-
-  f = GGC_CNEW (struct machine_function);
-
-  return f;
+  return ggc_alloc_cleared_machine_function ();
 }
 
 /* Implement the macro OVERRIDE_OPTIONS.  */
index 62ee7d0c3309078487a73acea31bfe038aeed9fe..9d38d0fee47fdab53ce5884271c4f12e30faf44e 100644 (file)
@@ -2583,7 +2583,7 @@ cris_init_expanders (void)
 static struct machine_function *
 cris_init_machine_status (void)
 {
-  return GGC_CNEW (struct machine_function);
+  return ggc_alloc_cleared_machine_function ();
 }
 
 /* Split a 2 word move (DI or presumably DF) into component parts.
index 9a9dde160c597d2393b22a66b6b95deedd552865..7eedd95eab303745ba64f31eb4d312c4d469eaff 100644 (file)
@@ -429,7 +429,7 @@ machopic_indirection_name (rtx sym_ref, bool stub_p)
     }
   else
     {
-      p = (machopic_indirection *) ggc_alloc (sizeof (machopic_indirection));
+      p = ggc_alloc_machopic_indirection ();
       p->symbol = sym_ref;
       p->ptr_name = xstrdup (buffer);
       p->stub_p = stub_p;
index d4009693cd8d2208ad09eb73561f935c00a5e1f2..e72dd2af1f9212d262307e30646548cf1520d0f1 100644 (file)
@@ -7054,7 +7054,7 @@ frv_assemble_integer (rtx value, unsigned int size, int aligned_p)
 static struct machine_function *
 frv_init_machine_status (void)
 {
-  return GGC_CNEW (struct machine_function);
+  return ggc_alloc_cleared_machine_function ();
 }
 \f
 /* Implement TARGET_SCHED_ISSUE_RATE.  */
index df18fdbd7eb4b9b6b8a60c264cd60ff58462c1ae..1bdc6891df3f5b05c9e0656595a36ea438e4ad56 100644 (file)
@@ -10641,7 +10641,7 @@ get_dllimport_decl (tree decl)
   if (h)
     return h->to;
 
-  *loc = h = GGC_NEW (struct tree_map);
+  *loc = h = ggc_alloc_tree_map ();
   h->hash = in.hash;
   h->base.from = decl;
   h->to = to = build_decl (DECL_SOURCE_LOCATION (decl),
@@ -19504,7 +19504,7 @@ ix86_init_machine_status (void)
 {
   struct machine_function *f;
 
-  f = GGC_CNEW (struct machine_function);
+  f = ggc_alloc_cleared_machine_function ();
   f->use_fast_prologue_epilogue_nregs = -1;
   f->tls_descriptor_call_expanded_p = 0;
   f->call_abi = ix86_abi;
@@ -19532,8 +19532,7 @@ assign_386_stack_local (enum machine_mode mode, enum ix86_stack_slot n)
     if (s->mode == mode && s->n == n)
       return copy_rtx (s->rtl);
 
-  s = (struct stack_local_entry *)
-    ggc_alloc (sizeof (struct stack_local_entry));
+  s = ggc_alloc_stack_local_entry ();
   s->n = n;
   s->mode = mode;
   s->rtl = assign_stack_local (mode, GET_MODE_SIZE (mode), 0);
index 3750e0c4b08712ffc0d65d63b1026e4edadc1f7b..c20a2ae89fc3885b70d956a0f3a70c18e928e4de 100644 (file)
@@ -576,7 +576,7 @@ i386_pe_record_external_function (tree decl, const char *name)
 {
   struct extern_list *p;
 
-  p = (struct extern_list *) ggc_alloc (sizeof *p);
+  p = ggc_alloc_extern_list ();
   p->next = extern_head;
   p->decl = decl;
   p->name = name;
@@ -617,7 +617,7 @@ i386_pe_maybe_record_exported_symbol (tree decl, const char *name, int is_data)
 
   gcc_assert (TREE_PUBLIC (decl));
 
-  p = (struct export_list *) ggc_alloc (sizeof *p);
+  p = ggc_alloc_export_list ();
   p->next = export_head;
   p->name = name;
   p->is_data = is_data;
index e1e3dff8b59dffee139e82121966da57c266ec8b..a568ee4f849fdde752a4abf2dc6d1bea9cdbaa6b 100644 (file)
@@ -5540,7 +5540,7 @@ void ia64_init_expanders (void)
 static struct machine_function *
 ia64_init_machine_status (void)
 {
-  return GGC_CNEW (struct machine_function);
+  return ggc_alloc_cleared_machine_function ();
 }
 \f
 static enum attr_itanium_class ia64_safe_itanium_class (rtx);
index 0e51eca796577dfffd862d0913c134bbb7a0f38b..fc8c4e56789384ff72616d9339b9f4c73fb8cb25 100644 (file)
@@ -1385,11 +1385,7 @@ iq2000_va_start (tree valist, rtx nextarg)
 static struct machine_function *
 iq2000_init_machine_status (void)
 {
-  struct machine_function *f;
-
-  f = GGC_CNEW (struct machine_function);
-
-  return f;
+  return ggc_alloc_cleared_machine_function ();
 }
 
 /* Implement TARGET_HANDLE_OPTION.  */
index cfc4a1593b61d7f8c9289e69f261a044d44941b2..3280d14e78eb09f0b4e0dd1bb5018d88f55c4a51 100644 (file)
@@ -435,11 +435,7 @@ m32c_override_options (void)
 static struct machine_function *
 m32c_init_machine_status (void)
 {
-  struct machine_function *machine;
-  machine =
-    (machine_function *) ggc_alloc_cleared (sizeof (machine_function));
-
-  return machine;
+  return ggc_alloc_cleared_machine_function ();
 }
 
 /* Implements INIT_EXPANDERS.  We just set up to call the above
index a4b167da4b76ac8c77037bfe9269c424087ea3b0..4d5e68218e8b78e502db471381c956de85b943db 100644 (file)
@@ -2369,11 +2369,7 @@ mep_register_move_cost (enum machine_mode mode, enum reg_class from, enum reg_cl
 static struct machine_function *
 mep_init_machine_status (void)
 {
-  struct machine_function *f;
-
-  f = (struct machine_function *) ggc_alloc_cleared (sizeof (struct machine_function));
-
-  return f;
+  return ggc_alloc_cleared_machine_function ();
 }
 
 static rtx
@@ -4234,7 +4230,7 @@ mep_note_pragma_flag (const char *funcname, int flag)
 
   if (!*slot)
     {
-      *slot = GGC_NEW (pragma_entry);
+      *slot = ggc_alloc_pragma_entry ();
       (*slot)->flag = 0;
       (*slot)->used = 0;
       (*slot)->funcname = ggc_strdup (funcname);
index 33f6047e166c91ad0f25a0326c3002b0744ba51e..a699238ba1c01539f73437d99a0ca77fe58be729 100644 (file)
@@ -1217,7 +1217,7 @@ mflip_mips16_use_mips16_p (tree decl)
   if (!entry)
     {
       mips16_flipper = !mips16_flipper;
-      entry = GGC_NEW (struct mflip_mips16_entry);
+      entry = ggc_alloc_mflip_mips16_entry ();
       entry->name = name;
       entry->mips16_p = mips16_flipper ? !mips_base_mips16 : mips_base_mips16;
       *slot = entry;
@@ -5851,7 +5851,7 @@ mips16_local_alias (rtx func)
       SYMBOL_REF_FLAGS (local) = SYMBOL_REF_FLAGS (func) | SYMBOL_FLAG_LOCAL;
 
       /* Create a new structure to represent the mapping.  */
-      alias = GGC_NEW (struct mips16_local_alias);
+      alias = ggc_alloc_mips16_local_alias ();
       alias->func = func;
       alias->local = local;
       *slot = alias;
@@ -15221,8 +15221,7 @@ mips_set_current_function (tree fndecl)
 static struct machine_function *
 mips_init_machine_status (void)
 {
-  return ((struct machine_function *)
-         ggc_alloc_cleared (sizeof (struct machine_function)));
+  return ggc_alloc_cleared_machine_function ();
 }
 
 /* Return the processor associated with the given ISA level, or null
index de66ac4e40d762a4bd2788b4bd780d607576220b..4b35e06df4f97c31acb6095626b1a19bdc4dbe1b 100644 (file)
@@ -263,7 +263,7 @@ mmix_init_expanders (void)
 static struct machine_function *
 mmix_init_machine_status (void)
 {
-  return GGC_CNEW (struct machine_function);
+  return ggc_alloc_cleared_machine_function ();
 }
 
 /* DATA_ALIGNMENT.
index 1e692b18d7ebd1182d24583803f9fe513090835e..b87b80f4744d6b37ec8176f5c65d411c0e76d97b 100644 (file)
@@ -205,7 +205,7 @@ struct GTY(()) machine_function
 static struct machine_function *
 moxie_init_machine_status (void)
 {
-  return GGC_CNEW (struct machine_function);
+  return ggc_alloc_cleared_machine_function ();
 }
 
 
index 5ef405b4f44115610bde5610365850b1d50f15ee..024053e413fd99c4fdfea4d31f64215745792934 100644 (file)
@@ -558,7 +558,7 @@ pa_init_builtins (void)
 static struct machine_function *
 pa_init_machine_status (void)
 {
-  return GGC_CNEW (machine_function);
+  return ggc_alloc_cleared_machine_function ();
 }
 
 /* If FROM is a probable pointer register, mark TO as a probable
@@ -5375,13 +5375,11 @@ get_deferred_plabel (rtx symbol)
       tree id;
 
       if (deferred_plabels == 0)
-       deferred_plabels = (struct deferred_plabel *)
-         ggc_alloc (sizeof (struct deferred_plabel));
+       deferred_plabels =  ggc_alloc_deferred_plabel ();
       else
-       deferred_plabels = (struct deferred_plabel *)
-         ggc_realloc (deferred_plabels,
-                      ((n_deferred_plabels + 1)
-                       * sizeof (struct deferred_plabel)));
+        deferred_plabels = GGC_RESIZEVEC (struct deferred_plabel,
+                                          deferred_plabels,
+                                          n_deferred_plabels + 1);
 
       i = n_deferred_plabels++;
       deferred_plabels[i].internal_label = gen_label_rtx ();
index 9e31a22e5f8425193cc1fe3845ce619bbd1676c2..a4f847d99bdb8593739afab4ae8e6efcec9b83b4 100644 (file)
@@ -12569,7 +12569,7 @@ builtin_function_type (enum machine_mode mode_ret, enum machine_mode mode_arg0,
   found = htab_find_slot (builtin_hash_table, &h, INSERT);
   if (*found == NULL)
     {
-      h2 = GGC_NEW (struct builtin_hash_struct);
+      h2 = ggc_alloc_builtin_hash_struct ();
       *h2 = h;
       *found = (void *)h2;
       args = void_list_node;
@@ -14465,7 +14465,7 @@ rs6000_got_register (rtx value ATTRIBUTE_UNUSED)
 static struct machine_function *
 rs6000_init_machine_status (void)
 {
-  return GGC_CNEW (machine_function);
+  return ggc_alloc_cleared_machine_function ();
 }
 \f
 /* These macros test for integers and extract the low-order bits.  */
@@ -21194,7 +21194,7 @@ output_toc (FILE *file, rtx x, int labelno, enum machine_mode mode)
        toc_hash_table = htab_create_ggc (1021, toc_hash_function,
                                          toc_hash_eq, NULL);
 
-      h = GGC_NEW (struct toc_hash_struct);
+      h = ggc_alloc_toc_hash_struct ();
       h->key = x;
       h->key_mode = mode;
       h->labelno = labelno;
index fb6913f2d603158fe85c20262148118abb83a05b..1b742357f26e57279f3c598c9fbeded901831550 100644 (file)
@@ -1453,7 +1453,7 @@ s390_narrow_logical_operator (enum rtx_code code, rtx *memop, rtx *immop)
 static struct machine_function *
 s390_init_machine_status (void)
 {
-  return GGC_CNEW (struct machine_function);
+  return ggc_alloc_cleared_machine_function ();
 }
 
 /* Change optimizations to be performed, depending on the
index 724cf61bc649a63e7154300c813c453589a0fefa..3e20f16dc33de478cb149ab3c06667708ff9e7fb 100644 (file)
@@ -1186,7 +1186,7 @@ score3_output_external (FILE *file ATTRIBUTE_UNUSED,
 
   if (score3_in_small_data_p (decl))
     {
-      p = (struct extern_list *) ggc_alloc (sizeof (struct extern_list));
+      p = ggc_alloc_extern_list ();
       p->next = extern_head;
       p->name = name;
       p->size = int_size_in_bytes (TREE_TYPE (decl));
index 547ac00517af86320a9d10171d74c3ef5d6ce0ab..464d97cee22b2901b39d145b8e2fb9a0652f639c 100644 (file)
@@ -1174,7 +1174,7 @@ score7_output_external (FILE *file ATTRIBUTE_UNUSED,
 
   if (score7_in_small_data_p (decl))
     {
-      p = (struct extern_list *) ggc_alloc (sizeof (struct extern_list));
+      p = ggc_alloc_extern_list ();
       p->next = extern_head;
       p->name = name;
       p->size = int_size_in_bytes (TREE_TYPE (decl));
index 9e33c740b01501c0eab82f121de6c19673653a9c..8b44dbeb80dd8182f89a5310718cc03c6e64c46b 100644 (file)
@@ -9032,7 +9032,7 @@ sparc_can_output_mi_thunk (const_tree thunk_fndecl ATTRIBUTE_UNUSED,
 static struct machine_function *
 sparc_init_machine_status (void)
 {
-  return GGC_CNEW (struct machine_function);
+  return ggc_alloc_cleared_machine_function ();
 }
 
 /* Locate some local-dynamic symbol still in use by this function
index 76e872dddb36852e7409c8732facd447c8f481f1..fe66711af3909c78a742808f6c6d9a19225e9054 100644 (file)
@@ -1281,7 +1281,7 @@ xtensa_expand_nonlocal_goto (rtx *operands)
 static struct machine_function *
 xtensa_init_machine_status (void)
 {
-  return GGC_CNEW (struct machine_function);
+  return ggc_alloc_cleared_machine_function ();
 }
 
 
index bf6833664cf0183124b07304ff9d486b21f6e9c7..931cbe141ebee3e7ec2c777b7203bad0d120af42 100644 (file)
@@ -1,3 +1,52 @@
+2010-06-08  Laurynas Biveinis  <laurynas.biveinis@gmail.com>
+
+       * typeck2.c (abstract_virtuals_error): Use typed GC allocation.
+
+       * pt.c (maybe_process_partial_specialization): Likewise.
+       (register_specialization): Likewise.
+       (add_pending_template): Likewise.
+       (lookup_template_class): Likewise.
+       (push_tinst_level): Likewise.
+
+       * parser.c (cp_lexer_new_main): Likewise.
+       (cp_lexer_new_from_tokens): Likewise.
+       (cp_token_cache_new): Likewise.
+       (cp_parser_context_new): Likewise.
+       (cp_parser_new): Likewise.
+       (cp_parser_nested_name_specifier_opt): Likewise.
+       (cp_parser_template_id): Likewise.
+
+       * name-lookup.c (binding_entry_make): Likewise.
+       (binding_table_construct): Likewise.
+       (binding_table_new): Likewise.
+       (cxx_binding_make): Likewise.
+       (pushdecl_maybe_friend): Likewise.
+       (begin_scope): Likewise.
+       (push_to_top_level): Likewise.
+
+       * lex.c (init_reswords): Likewise.
+       (retrofit_lang_decl): Likewise.
+       (cxx_dup_lang_specific_decl): Likewise.
+       (copy_lang_type): Likewise.
+       (cxx_make_type): Likewise.
+
+       * decl.c (make_label_decl): Likewise.
+       (check_goto): Likewise.
+       (start_preparsed_function): Likewise.
+       (save_function_data): Likewise.
+
+       * cp-tree.h (TYPE_SET_PTRMEMFUNC_TYPE): Likewise.
+
+       * cp-objcp-common.c (decl_shadowed_for_var_insert): Likewise.
+
+       * class.c (finish_struct_1): Likewise.
+
+       * cp-tree.h (struct lang_type): Add variable_size GTY option.
+       (struct lang_decl): Likewise.
+
+       * parser.c (cp_parser_new): Update comment to not reference
+       ggc_alloc.
+
 2010-06-07  Jason Merrill  <jason@redhat.com>
 
        PR c++/44366
index c6da4cd28bbaebf5e05e4bc5b94e79f049c69bfb..14224aa694d4097ab0140420cafb227cb6e883c8 100644 (file)
@@ -5437,9 +5437,8 @@ finish_struct_1 (tree t)
   n_fields = count_fields (TYPE_FIELDS (t));
   if (n_fields > 7)
     {
-      struct sorted_fields_type *field_vec = GGC_NEWVAR
-        (struct sorted_fields_type,
-         sizeof (struct sorted_fields_type) + n_fields * sizeof (tree));
+      struct sorted_fields_type *field_vec = ggc_alloc_sorted_fields_type
+        (sizeof (struct sorted_fields_type) + n_fields * sizeof (tree));
       field_vec->len = n_fields;
       add_fields_to_record_type (TYPE_FIELDS (t), field_vec, 0);
       qsort (field_vec->elts, n_fields, sizeof (tree),
index 63ce56b3c3025c8cdd2ec106fd03433ab6fe87dd..9cfe7702acade01de38d1a75a4aa506a516248aa 100644 (file)
@@ -203,7 +203,7 @@ decl_shadowed_for_var_insert (tree from, tree to)
   struct tree_decl_map *h;
   void **loc;
 
-  h = GGC_NEW (struct tree_decl_map);
+  h = ggc_alloc_tree_decl_map ();
   h->base.from = from;
   h->to = to;
   loc = htab_find_slot_with_hash (shadowed_var_for_decl, h, DECL_UID (from),
index f507a21a78da1202d6a96c0e8351fc3bc9b3fc95..eaf34591cc9ba4cc828da950cfb6e2c0b49f3245 100644 (file)
@@ -1333,7 +1333,7 @@ struct GTY(()) lang_type_ptrmem {
   tree record;
 };
 
-struct GTY(()) lang_type {
+struct GTY((variable_size)) lang_type {
   union lang_type_u
   {
     struct lang_type_header GTY((skip (""))) h;
@@ -1884,7 +1884,7 @@ struct GTY(()) lang_decl_parm {
    union rather than a struct containing a union as its only field, but
    tree.h declares it as a struct.  */
 
-struct GTY(()) lang_decl {
+struct GTY((variable_size)) lang_decl {
   union GTY((desc ("%h.base.selector"))) lang_decl_u {
     struct lang_decl_base GTY ((default)) base;
     struct lang_decl_min GTY((tag ("0"))) min;
@@ -3271,8 +3271,8 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter)
   do {                                                                 \
     if (TYPE_LANG_SPECIFIC (NODE) == NULL)                             \
       {                                                                        \
-       TYPE_LANG_SPECIFIC (NODE) = GGC_CNEWVAR                         \
-        (struct lang_type, sizeof (struct lang_type_ptrmem));          \
+       TYPE_LANG_SPECIFIC (NODE) = ggc_alloc_cleared_lang_type         \
+        (sizeof (struct lang_type_ptrmem));                            \
        TYPE_LANG_SPECIFIC (NODE)->u.ptrmem.h.is_lang_type_class = 0;   \
       }                                                                        \
     TYPE_LANG_SPECIFIC (NODE)->u.ptrmem.record = (VALUE);              \
index 171e160b2af54c2039cade27e153ec2744c6834b..706eee9b6669085cd2aedf19b6ac1995915cd6bf 100644 (file)
@@ -2449,7 +2449,7 @@ make_label_decl (tree id, int local_p)
   /* Record this label on the list of labels used in this function.
      We do this before calling make_label_decl so that we get the
      IDENTIFIER_LABEL_VALUE before the new label is declared.  */
-  ent = GGC_CNEW (struct named_label_entry);
+  ent = ggc_alloc_cleared_named_label_entry ();
   ent->label_decl = decl;
 
   slot = htab_find_slot (named_labels, ent, INSERT);
@@ -2669,7 +2669,7 @@ check_goto (tree decl)
          && ent->uses->names_in_scope == current_binding_level->names)
        return;
 
-      new_use = GGC_NEW (struct named_label_use_entry);
+      new_use = ggc_alloc_named_label_use_entry ();
       new_use->binding_level = current_binding_level;
       new_use->names_in_scope = current_binding_level->names;
       new_use->o_goto_locus = input_location;
@@ -12016,7 +12016,7 @@ start_preparsed_function (tree decl1, tree attrs, int flags)
 
   /* Initialize the language data structures.  Whenever we start
      a new function, we destroy temporaries in the usual way.  */
-  cfun->language = GGC_CNEW (struct language_function);
+  cfun->language = ggc_alloc_cleared_language_function ();
   current_stmt_tree ()->stmts_are_full_exprs_p = 1;
   current_binding_level = bl;
 
@@ -12317,7 +12317,7 @@ save_function_data (tree decl)
   gcc_assert (!DECL_PENDING_INLINE_P (decl));
 
   /* Make a copy.  */
-  f = GGC_NEW (struct language_function);
+  f = ggc_alloc_language_function ();
   memcpy (f, cp_function_chain, sizeof (struct language_function));
   DECL_SAVED_FUNCTION_DATA (decl) = f;
 
index 1bae86fd69264d1c3de8d82c1cca663c14abfc2d..9e3b57b75ef8656f4f12acb76debaa6307c89109 100644 (file)
@@ -184,7 +184,7 @@ init_reswords (void)
   /* The Objective-C keywords are all context-dependent.  */
   mask |= D_OBJC;
 
-  ridpointers = GGC_CNEWVEC (tree, (int) RID_MAX);
+  ridpointers = ggc_alloc_cleared_vec_tree ((int) RID_MAX);
   for (i = 0; i < num_c_common_reswords; i++)
     {
       if (c_common_reswords[i].disable & D_CONLY)
@@ -540,7 +540,7 @@ retrofit_lang_decl (tree t)
   else
     gcc_unreachable ();
 
-  ld = GGC_CNEWVAR (struct lang_decl, size);
+  ld = ggc_alloc_cleared_lang_decl (size);
 
   ld->u.base.selector = sel;
 
@@ -581,7 +581,7 @@ cxx_dup_lang_specific_decl (tree node)
   else
     gcc_unreachable ();
 
-  ld = GGC_NEWVAR (struct lang_decl, size);
+  ld = ggc_alloc_lang_decl (size);
   memcpy (ld, DECL_LANG_SPECIFIC (node), size);
   DECL_LANG_SPECIFIC (node) = ld;
 
@@ -618,7 +618,7 @@ copy_lang_type (tree node)
     size = sizeof (struct lang_type);
   else
     size = sizeof (struct lang_type_ptrmem);
-  lt = GGC_NEWVAR (struct lang_type, size);
+  lt = ggc_alloc_lang_type (size);
   memcpy (lt, TYPE_LANG_SPECIFIC (node), size);
   TYPE_LANG_SPECIFIC (node) = lt;
 
@@ -649,7 +649,8 @@ cxx_make_type (enum tree_code code)
   if (RECORD_OR_UNION_CODE_P (code)
       || code == BOUND_TEMPLATE_TEMPLATE_PARM)
     {
-      struct lang_type *pi = GGC_CNEW (struct lang_type);
+      struct lang_type *pi
+          = ggc_alloc_cleared_lang_type (sizeof (struct lang_type));
 
       TYPE_LANG_SPECIFIC (t) = pi;
       pi->u.c.h.is_lang_type_class = 1;
index 0c759c6404a06fdf8e4d36ada871e526b9512bfc..db4246c5f70c1ef719d8c3b8268a30f9c7e0a040 100644 (file)
@@ -102,7 +102,7 @@ binding_entry_make (tree name, tree type)
       free_binding_entry = entry->chain;
     }
   else
-    entry = GGC_NEW (struct binding_entry_s);
+    entry = ggc_alloc_binding_entry_s ();
 
   entry->name = name;
   entry->type = type;
@@ -144,7 +144,7 @@ binding_table_construct (binding_table table, size_t chain_count)
 {
   table->chain_count = chain_count;
   table->entry_count = 0;
-  table->chain = GGC_CNEWVEC (binding_entry, table->chain_count);
+  table->chain = ggc_alloc_cleared_vec_binding_entry (table->chain_count);
 }
 
 /* Make TABLE's entries ready for reuse.  */
@@ -178,7 +178,7 @@ binding_table_free (binding_table table)
 static inline binding_table
 binding_table_new (size_t chain_count)
 {
-  binding_table table = GGC_NEW (struct binding_table_s);
+  binding_table table = ggc_alloc_binding_table_s ();
   table->chain = NULL;
   binding_table_construct (table, chain_count);
   return table;
@@ -292,7 +292,7 @@ cxx_binding_make (tree value, tree type)
       free_bindings = binding->previous;
     }
   else
-    binding = GGC_NEW (cxx_binding);
+    binding = ggc_alloc_cxx_binding ();
 
   cxx_binding_init (binding, value, type);
 
@@ -707,7 +707,7 @@ pushdecl_maybe_friend (tree x, bool is_friend)
                      = htab_create_ggc (20, cxx_int_tree_map_hash,
                                         cxx_int_tree_map_eq, NULL);
 
-                 h = GGC_NEW (struct cxx_int_tree_map);
+                 h = ggc_alloc_cxx_int_tree_map ();
                  h->uid = DECL_UID (x);
                  h->to = t;
                  loc = htab_find_slot_with_hash
@@ -1384,7 +1384,7 @@ begin_scope (scope_kind kind, tree entity)
       free_binding_level = scope->level_chain;
     }
   else
-    scope = GGC_CNEW (cxx_scope);
+    scope = ggc_alloc_cleared_cxx_scope ();
 
   scope->this_entity = entity;
   scope->more_cleanups_ok = true;
@@ -5406,7 +5406,7 @@ push_to_top_level (void)
   bool need_pop;
 
   timevar_push (TV_NAME_LOOKUP);
-  s = GGC_CNEW (struct saved_scope);
+  s = ggc_alloc_cleared_saved_scope ();
 
   b = scope_chain ? current_binding_level : 0;
 
index 92f778619eb19c22169657d1d12008230f1cc582..0a7006a7d1bc224a0cc9798bcdba78a7b8ba0a6c 100644 (file)
@@ -393,7 +393,7 @@ cp_lexer_new_main (void)
   c_common_no_more_pch ();
 
   /* Allocate the memory.  */
-  lexer = GGC_CNEW (cp_lexer);
+  lexer = ggc_alloc_cleared_cp_lexer ();
 
 #ifdef ENABLE_CHECKING
   /* Initially we are not debugging.  */
@@ -404,7 +404,7 @@ cp_lexer_new_main (void)
 
   /* Create the buffer.  */
   alloc = CP_LEXER_BUFFER_SIZE;
-  buffer = GGC_NEWVEC (cp_token, alloc);
+  buffer = ggc_alloc_vec_cp_token (alloc);
 
   /* Put the first token in the buffer.  */
   space = alloc;
@@ -445,7 +445,7 @@ cp_lexer_new_from_tokens (cp_token_cache *cache)
 {
   cp_token *first = cache->first;
   cp_token *last = cache->last;
-  cp_lexer *lexer = GGC_CNEW (cp_lexer);
+  cp_lexer *lexer = ggc_alloc_cleared_cp_lexer ();
 
   /* We do not own the buffer.  */
   lexer->buffer = NULL;
@@ -946,7 +946,7 @@ cp_lexer_stop_debugging (cp_lexer* lexer)
 static cp_token_cache *
 cp_token_cache_new (cp_token *first, cp_token *last)
 {
-  cp_token_cache *cache = GGC_NEW (cp_token_cache);
+  cp_token_cache *cache = ggc_alloc_cp_token_cache ();
   cache->first = first;
   cache->last = last;
   return cache;
@@ -1496,7 +1496,7 @@ cp_parser_context_new (cp_parser_context* next)
       memset (context, 0, sizeof (*context));
     }
   else
-    context = GGC_CNEW (cp_parser_context);
+    context = ggc_alloc_cleared_cp_parser_context ();
 
   /* No errors have occurred yet in this context.  */
   context->status = CP_PARSER_STATUS_KIND_NO_ERROR;
@@ -3093,7 +3093,7 @@ cp_parser_new (void)
   cp_lexer *lexer;
   unsigned i;
 
-  /* cp_lexer_new_main is called before calling ggc_alloc because
+  /* cp_lexer_new_main is called before doing GC allocation because
      cp_lexer_new_main might load a PCH file.  */
   lexer = cp_lexer_new_main ();
 
@@ -3102,7 +3102,7 @@ cp_parser_new (void)
   for (i = 0; i < sizeof (binops) / sizeof (binops[0]); i++)
     binops_by_token[binops[i].token_type] = binops[i];
 
-  parser = GGC_CNEW (cp_parser);
+  parser = ggc_alloc_cleared_cp_parser ();
   parser->lexer = lexer;
   parser->context = cp_parser_context_new (NULL);
 
@@ -4605,7 +4605,7 @@ cp_parser_nested_name_specifier_opt (cp_parser *parser,
       token->type = CPP_NESTED_NAME_SPECIFIER;
       /* Retrieve any deferred checks.  Do not pop this access checks yet
         so the memory will not be reclaimed during token replacing below.  */
-      token->u.tree_check_value = GGC_CNEW (struct tree_check);
+      token->u.tree_check_value = ggc_alloc_cleared_tree_check ();
       token->u.tree_check_value->value = parser->scope;
       token->u.tree_check_value->checks = get_deferred_access_checks ();
       token->u.tree_check_value->qualifying_scope =
@@ -11275,7 +11275,7 @@ cp_parser_template_id (cp_parser *parser,
       token->type = CPP_TEMPLATE_ID;
       /* Retrieve any deferred checks.  Do not pop this access checks yet
         so the memory will not be reclaimed during token replacing below.  */
-      token->u.tree_check_value = GGC_CNEW (struct tree_check);
+      token->u.tree_check_value = ggc_alloc_cleared_tree_check ();
       token->u.tree_check_value->value = template_id;
       token->u.tree_check_value->checks = get_deferred_access_checks ();
       token->keyword = RID_MAX;
index d66c1bf6e2b2409146c46151757b55b4b5ae598d..58b746fe16db827e746cf6c7767a1b535e4086ca 100644 (file)
@@ -888,7 +888,7 @@ maybe_process_partial_specialization (tree type)
 
                  slot = (spec_entry **)
                    htab_find_slot (type_specializations, &elt, INSERT);
-                 *slot = GGC_NEW (spec_entry);
+                 *slot = ggc_alloc_spec_entry ();
                  **slot = elt;
                }
              else if (COMPLETE_OR_OPEN_TYPE_P (inst))
@@ -1401,7 +1401,7 @@ register_specialization (tree spec, tree tmpl, tree args, bool is_friend,
   if (!optimize_specialization_lookup_p (tmpl))
     {
       gcc_assert (tmpl && args && spec);
-      *slot = GGC_NEW (spec_entry);
+      *slot = ggc_alloc_spec_entry ();
       **slot = elt;
       if (TREE_CODE (spec) == FUNCTION_DECL && DECL_NAMESPACE_SCOPE_P (spec)
          && PRIMARY_TEMPLATE_P (tmpl)
@@ -6155,7 +6155,7 @@ add_pending_template (tree d)
   if (level)
     push_tinst_level (d);
 
-  pt = GGC_NEW (struct pending_template);
+  pt = ggc_alloc_pending_template ();
   pt->next = NULL;
   pt->tinst = current_tinst_level;
   if (last_pending_template)
@@ -6718,7 +6718,7 @@ lookup_template_class (tree d1,
       elt.spec = t;
       slot = (spec_entry **) htab_find_slot_with_hash (type_specializations,
                                                       &elt, hash, INSERT);
-      *slot = GGC_NEW (spec_entry);
+      *slot = ggc_alloc_spec_entry ();
       **slot = elt;
 
       /* Note this use of the partial instantiation so we can check it
@@ -7076,7 +7076,7 @@ push_tinst_level (tree d)
       return 0;
     }
 
-  new_level = GGC_NEW (struct tinst_level);
+  new_level = ggc_alloc_tinst_level ();
   new_level->decl = d;
   new_level->locus = input_location;
   new_level->in_system_header_p = in_system_header;
index e7b97c4d5c780edd54989b2fecb21c43e2d4181b..335b1f3499a0b4baaa2d016c69747a2a12c44595 100644 (file)
@@ -352,7 +352,7 @@ abstract_virtuals_error (tree decl, tree type)
       slot = htab_find_slot_with_hash (abstract_pending_vars, type,
                                      (hashval_t)TYPE_UID (type), INSERT);
 
-      pat = GGC_NEW (struct pending_abstract_type);
+      pat = ggc_alloc_pending_abstract_type ();
       pat->type = type;
       pat->decl = decl;
       pat->locus = ((decl && DECL_P (decl))
index a314e7b4430dca73c70faee7f9757422948124c1..be1e6fdcd0d8bc6f79c2db119c9a3650a2becaa2 100644 (file)
@@ -1004,7 +1004,7 @@ dbxout_init (const char *input_file_name)
   const char *mapped_name;
 
   typevec_len = 100;
-  typevec = GGC_CNEWVEC (struct typeinfo, typevec_len);
+  typevec = ggc_alloc_cleared_vec_typeinfo (typevec_len);
 
   /* stabstr_ob contains one string, which will be just fine with
      1-byte alignment.  */
index 56da9b55fc97cdf34a7c748d3f0e451bb8044228..05a279c7d7c14a6bb6b18216f4b03edfb06f80f9 100644 (file)
@@ -149,20 +149,17 @@ option is a fragment of C code that calculates the length.
 The second case is when a structure or a global variable contains a
 pointer to an array, like this:
 @smallexample
-tree *
-  GTY ((length ("%h.regno_pointer_align_length"))) regno_decl;
+struct gimple_omp_for_iter * GTY((length ("%h.collapse"))) iter;
 @end smallexample
-In this case, @code{regno_decl} has been allocated by writing something like
+In this case, @code{iter} has been allocated by writing something like
 @smallexample
-  x->regno_decl =
-    ggc_alloc (x->regno_pointer_align_length * sizeof (tree));
+  x->iter = ggc_alloc_cleared_vec_gimple_omp_for_iter (collapse);
 @end smallexample
-and the @code{length} provides the length of the field.
+and the @code{collapse} provides the length of the field.
 
 This second use of @code{length} also works on global variables, like:
 @verbatim
-  static GTY((length ("reg_base_value_size")))
-    rtx *reg_base_value;
+static GTY((length("reg_known_value_size"))) rtx *reg_known_value;
 @end verbatim
 
 @findex skip
@@ -353,6 +350,30 @@ of pointers.  @code{reorder} functions can be expensive.  When
 possible, it is better to depend on properties of the data, like an ID
 number or the hash of a string instead.
 
+@findex variable_size
+@item variable_size
+
+The type machinery expects the types to be of constant size.  When this
+is not true, for example, with structs that have array fields or unions,
+the type machinery cannot tell how many bytes need to be allocated at 
+each allocation.  The @code{variable_size} is used to mark such types.
+The type machinery then provides allocators that take a parameter 
+indicating an exact size of object being allocated.  
+
+For example,
+@smallexample
+struct GTY((variable_size)) sorted_fields_type @{
+  int len;
+  tree GTY((length ("%h.len"))) elts[1];
+@};
+@end smallexample
+
+Then the objects of @code{struct sorted_fields_type} are allocated in GC 
+memory as follows:
+@smallexample
+  field_vec = ggc_alloc_sorted_fields_type (size);
+@end smallexample
+
 @findex special
 @item special ("@var{name}")
 
index 34f94c6e29d36acc17c5ce6609be292cd7e0e8c2..12f7d81b68f4214a4ec3a1360e5f6e43d7ef164d 100644 (file)
@@ -924,7 +924,7 @@ used to initialize the @code{machine} of that structure.
 
 @code{struct machine_function} structures are expected to be freed by GC@.
 Generally, any memory that they reference must be allocated by using
-@code{ggc_alloc}, including the structure itself.
+GC allocation, including the structure itself.
 @end deftypevar
 
 @node Storage Layout
index 516a26004f0b115a738cd1e18d49858987ef3bbb..8e16a21d0314cb8df953f02dc4cdc7471d433e11 100644 (file)
@@ -816,7 +816,9 @@ dw2_force_const_mem (rtx x, bool is_public)
   if (! indirect_pool)
     /* We use strcmp, rather than just comparing pointers, so that the
        sort order will not depend on the host system.  */
-    indirect_pool = splay_tree_new_ggc (splay_tree_compare_strings);
+    indirect_pool = splay_tree_new_ggc (splay_tree_compare_strings,
+                                       ggc_alloc_splay_tree_str_tree_node_splay_tree_s,
+                                       ggc_alloc_splay_tree_str_tree_node_splay_tree_node_s);
 
   gcc_assert (GET_CODE (x) == SYMBOL_REF);
 
index 0cdd2dc274d3683dc28daa34fc7509f3cccde96a..6cbe8dc092c18847b40795c236711d182f6adf8c 100644 (file)
@@ -722,7 +722,7 @@ dwarf_cfi_name (unsigned int cfi_opc)
 static inline dw_cfi_ref
 new_cfi (void)
 {
-  dw_cfi_ref cfi = GGC_NEW (dw_cfi_node);
+  dw_cfi_ref cfi = ggc_alloc_dw_cfi_node ();
 
   cfi->dw_cfi_next = NULL;
   cfi->dw_cfi_oprnd1.dw_cfi_reg_num = 0;
@@ -1694,7 +1694,7 @@ queue_reg_save (const char *label, rtx reg, rtx sreg, HOST_WIDE_INT offset)
 
   if (q == NULL)
     {
-      q = GGC_NEW (struct queued_reg_save);
+      q = ggc_alloc_queued_reg_save ();
       q->next = queued_reg_saves;
       queued_reg_saves = q;
     }
@@ -4049,7 +4049,7 @@ void
 dwarf2out_frame_init (void)
 {
   /* Allocate the initial hunk of the fde_table.  */
-  fde_table = GGC_CNEWVEC (dw_fde_node, FDE_TABLE_INCREMENT);
+  fde_table = ggc_alloc_cleared_vec_dw_fde_node (FDE_TABLE_INCREMENT);
   fde_table_allocated = FDE_TABLE_INCREMENT;
   fde_table_in_use = 0;
 
@@ -4605,7 +4605,7 @@ static inline dw_loc_descr_ref
 new_loc_descr (enum dwarf_location_atom op, unsigned HOST_WIDE_INT oprnd1,
               unsigned HOST_WIDE_INT oprnd2)
 {
-  dw_loc_descr_ref descr = GGC_CNEW (dw_loc_descr_node);
+  dw_loc_descr_ref descr = ggc_alloc_cleared_dw_loc_descr_node ();
 
   descr->dw_loc_opc = op;
   descr->dw_loc_oprnd1.val_class = dw_val_class_unsigned_const;
@@ -7058,8 +7058,7 @@ find_AT_string (const char *str)
                                   htab_hash_string (str), INSERT);
   if (*slot == NULL)
     {
-      node = (struct indirect_string_node *)
-              ggc_alloc_cleared (sizeof (struct indirect_string_node));
+      node = ggc_alloc_cleared_indirect_string_node ();
       node->str = ggc_strdup (str);
       *slot = node;
     }
@@ -7684,7 +7683,7 @@ splice_child_die (dw_die_ref parent, dw_die_ref child)
 static inline dw_die_ref
 new_die (enum dwarf_tag tag_value, dw_die_ref parent_die, tree t)
 {
-  dw_die_ref die = GGC_CNEW (die_node);
+  dw_die_ref die = ggc_alloc_cleared_die_node ();
 
   die->die_tag = tag_value;
 
@@ -7694,7 +7693,7 @@ new_die (enum dwarf_tag tag_value, dw_die_ref parent_die, tree t)
     {
       limbo_die_node *limbo_node;
 
-      limbo_node = GGC_CNEW (limbo_die_node);
+      limbo_node = ggc_alloc_cleared_limbo_die_node ();
       limbo_node->die = die;
       limbo_node->created_for = t;
       limbo_node->next = limbo_die_list;
@@ -7957,7 +7956,7 @@ add_var_loc_to_decl (tree decl, rtx loc_note, const char *label)
   slot = htab_find_slot_with_hash (decl_loc_table, decl, decl_id, INSERT);
   if (*slot == NULL)
     {
-      temp = GGC_CNEW (var_loc_list);
+      temp = ggc_alloc_cleared_var_loc_list ();
       temp->decl_id = decl_id;
       *slot = temp;
     }
@@ -8047,7 +8046,7 @@ add_var_loc_to_decl (tree decl, rtx loc_note, const char *label)
              memset (loc, '\0', sizeof (*loc));
            }
          else
-           loc = GGC_CNEW (struct var_loc_node);
+           loc = ggc_alloc_cleared_var_loc_node ();
          if (bitsize == -1 || piece_loc == NULL)
            loc->loc = construct_piece_list (loc_note, bitpos, bitsize);
          else
@@ -8064,7 +8063,7 @@ add_var_loc_to_decl (tree decl, rtx loc_note, const char *label)
     }
   else
     {
-      loc = GGC_CNEW (struct var_loc_node);
+      loc = ggc_alloc_cleared_var_loc_node ();
       temp->first = loc;
       temp->last = loc;
       loc->loc = construct_piece_list (loc_note, bitpos, bitsize);
@@ -9554,7 +9553,7 @@ clone_die (dw_die_ref die)
   dw_attr_ref a;
   unsigned ix;
 
-  clone = GGC_CNEW (die_node);
+  clone = ggc_alloc_cleared_die_node ();
   clone->die_tag = die->die_tag;
 
   for (ix = 0; VEC_iterate (dw_attr_node, die->die_attr, ix, a); ix++)
@@ -9595,7 +9594,7 @@ clone_as_declaration (dw_die_ref die)
   if (decl != NULL)
     return clone_die (decl);
 
-  clone = GGC_CNEW (die_node);
+  clone = ggc_alloc_cleared_die_node ();
   clone->die_tag = die->die_tag;
 
   for (ix = 0; VEC_iterate (dw_attr_node, die->die_attr, ix, a); ix++)
@@ -9814,7 +9813,7 @@ break_out_comdat_types (dw_die_ref die)
         unit = new_die (DW_TAG_type_unit, NULL, NULL);
         add_AT_unsigned (unit, DW_AT_language,
                          get_AT_unsigned (comp_unit_die, DW_AT_language));
-        type_node = GGC_CNEW (comdat_type_node);
+        type_node = ggc_alloc_cleared_comdat_type_node ();
         type_node->root_die = unit;
         type_node->next = comdat_type_list;
         comdat_type_list = type_node;
@@ -10612,7 +10611,7 @@ static inline dw_loc_list_ref
 new_loc_list (dw_loc_descr_ref expr, const char *begin, const char *end,
              const char *section)
 {
-  dw_loc_list_ref retlist = GGC_CNEW (dw_loc_list_node);
+  dw_loc_list_ref retlist = ggc_alloc_cleared_dw_loc_list_node ();
 
   retlist->begin = begin;
   retlist->end = end;
@@ -14133,7 +14132,8 @@ loc_descriptor (rtx rtl, enum machine_mode mode,
          if (SCALAR_FLOAT_MODE_P (mode))
            {
              unsigned int length = GET_MODE_SIZE (mode);
-             unsigned char *array = GGC_NEWVEC (unsigned char, length);
+             unsigned char *array
+                  = (unsigned char*) ggc_alloc_atomic (length);
 
              insert_float (rtl, array);
              loc_result->dw_loc_oprnd2.val_class = dw_val_class_vec;
@@ -14158,7 +14158,8 @@ loc_descriptor (rtx rtl, enum machine_mode mode,
        {
          unsigned int elt_size = GET_MODE_UNIT_SIZE (GET_MODE (rtl));
          unsigned int length = CONST_VECTOR_NUNITS (rtl);
-         unsigned char *array = GGC_NEWVEC (unsigned char, length * elt_size);
+         unsigned char *array = (unsigned char *)
+           ggc_alloc_atomic (length * elt_size);
          unsigned int i;
          unsigned char *p;
 
@@ -14642,12 +14643,12 @@ add_loc_descr_to_each (dw_loc_list_ref list, dw_loc_descr_ref ref)
   list = list->dw_loc_next;
   while (list)
     {
-      copy = GGC_CNEW (dw_loc_descr_node);
+      copy = ggc_alloc_dw_loc_descr_node ();
       memcpy (copy, ref, sizeof (dw_loc_descr_node));
       add_loc_descr (&list->expr, copy);
       while (copy->dw_loc_next)
        {
-         dw_loc_descr_ref new_copy = GGC_CNEW (dw_loc_descr_node);
+         dw_loc_descr_ref new_copy = ggc_alloc_dw_loc_descr_node ();
          memcpy (new_copy, copy->dw_loc_next, sizeof (dw_loc_descr_node));
          copy->dw_loc_next = new_copy;
          copy = new_copy;
@@ -15803,7 +15804,7 @@ add_const_value_attribute (dw_die_ref die, rtx rtl)
        if (SCALAR_FLOAT_MODE_P (mode))
          {
            unsigned int length = GET_MODE_SIZE (mode);
-           unsigned char *array = GGC_NEWVEC (unsigned char, length);
+           unsigned char *array = (unsigned char *) ggc_alloc_atomic (length);
 
            insert_float (rtl, array);
            add_AT_vec (die, DW_AT_const_value, length / 4, 4, array);
@@ -15819,7 +15820,8 @@ add_const_value_attribute (dw_die_ref die, rtx rtl)
        enum machine_mode mode = GET_MODE (rtl);
        unsigned int elt_size = GET_MODE_UNIT_SIZE (mode);
        unsigned int length = CONST_VECTOR_NUNITS (rtl);
-       unsigned char *array = GGC_NEWVEC (unsigned char, length * elt_size);
+       unsigned char *array = (unsigned char *) ggc_alloc_atomic
+         (length * elt_size);
        unsigned int i;
        unsigned char *p;
 
@@ -16569,7 +16571,8 @@ tree_add_const_value_attribute (dw_die_ref die, tree t)
       HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (init));
       if (size > 0 && (int) size == size)
        {
-         unsigned char *array = GGC_CNEWVEC (unsigned char, size);
+         unsigned char *array = (unsigned char *)
+           ggc_alloc_cleared_atomic (size);
 
          if (native_encode_initializer (init, array, size))
            {
@@ -16757,7 +16760,7 @@ add_comp_dir_attribute (dw_die_ref die)
       int wdlen;
 
       wdlen = strlen (wd);
-      wd1 = GGC_NEWVEC (char, wdlen + 2);
+      wd1 = (char *) ggc_alloc_atomic (wdlen + 2);
       strcpy (wd1, wd);
       wd1 [wdlen] = DIR_SEPARATOR;
       wd1 [wdlen + 1] = 0;
@@ -17207,7 +17210,7 @@ add_name_and_src_coords_attributes (dw_die_ref die, tree decl)
            {
              limbo_die_node *asm_name;
 
-             asm_name = GGC_CNEW (limbo_die_node);
+             asm_name = ggc_alloc_cleared_limbo_die_node ();
              asm_name->die = die;
              asm_name->created_for = decl;
              asm_name->next = deferred_asm_name;
@@ -20678,7 +20681,7 @@ lookup_filename (const char *file_name)
   if (*slot)
     return (struct dwarf_file_data *) *slot;
 
-  created = GGC_NEW (struct dwarf_file_data);
+  created = ggc_alloc_dwarf_file_data ();
   created->filename = file_name;
   created->emitted_number = 0;
   *slot = created;
@@ -20834,7 +20837,7 @@ vcall_insn_table_eq (const void *x, const void *y)
 static void
 store_vcall_insn (unsigned int vtable_slot, int insn_uid)
 {
-  struct vcall_insn *item = GGC_NEW (struct vcall_insn);
+  struct vcall_insn *item = ggc_alloc_vcall_insn ();
   struct vcall_insn **slot;
 
   gcc_assert (item);
@@ -21192,13 +21195,15 @@ dwarf2out_init (const char *filename ATTRIBUTE_UNUSED)
   decl_scope_table = VEC_alloc (tree, gc, 256);
 
   /* Allocate the initial hunk of the abbrev_die_table.  */
-  abbrev_die_table = GGC_CNEWVEC (dw_die_ref, ABBREV_DIE_TABLE_INCREMENT);
+  abbrev_die_table = ggc_alloc_cleared_vec_dw_die_ref
+    (ABBREV_DIE_TABLE_INCREMENT);
   abbrev_die_table_allocated = ABBREV_DIE_TABLE_INCREMENT;
   /* Zero-th entry is allocated, but unused.  */
   abbrev_die_table_in_use = 1;
 
   /* Allocate the initial hunk of the line_info_table.  */
-  line_info_table = GGC_CNEWVEC (dw_line_info_entry, LINE_INFO_TABLE_INCREMENT);
+  line_info_table = ggc_alloc_cleared_vec_dw_line_info_entry
+    (LINE_INFO_TABLE_INCREMENT);
   line_info_table_allocated = LINE_INFO_TABLE_INCREMENT;
 
   /* Zero-th entry is allocated, but unused.  */
index 3f7fb5f895abb21236a449144bc43283ba8e9a5c..eb3ea93c9b3493bad1653e99b138984824aa19bf 100644 (file)
@@ -341,7 +341,7 @@ get_mem_attrs (alias_set_type alias, tree expr, rtx offset, rtx size,
   slot = htab_find_slot (mem_attrs_htab, &attrs, INSERT);
   if (*slot == 0)
     {
-      *slot = ggc_alloc (sizeof (mem_attrs));
+      *slot = ggc_alloc_mem_attrs ();
       memcpy (*slot, &attrs, sizeof (mem_attrs));
     }
 
@@ -390,7 +390,7 @@ get_reg_attrs (tree decl, int offset)
   slot = htab_find_slot (reg_attrs_htab, &attrs, INSERT);
   if (*slot == 0)
     {
-      *slot = ggc_alloc (sizeof (reg_attrs));
+      *slot = ggc_alloc_reg_attrs ();
       memcpy (*slot, &attrs, sizeof (reg_attrs));
     }
 
@@ -5240,7 +5240,7 @@ start_sequence (void)
       free_sequence_stack = tem->next;
     }
   else
-    tem = GGC_NEW (struct sequence_stack);
+    tem = ggc_alloc_sequence_stack ();
 
   tem->next = seq_stack;
   tem->first = get_insns ();
@@ -5555,8 +5555,7 @@ init_emit (void)
   crtl->emit.regno_pointer_align
     = XCNEWVEC (unsigned char, crtl->emit.regno_pointer_align_length);
 
-  regno_reg_rtx
-    = GGC_NEWVEC (rtx, crtl->emit.regno_pointer_align_length);
+  regno_reg_rtx = ggc_alloc_vec_rtx (crtl->emit.regno_pointer_align_length);
 
   /* Put copies of all the hard registers into regno_reg_rtx.  */
   memcpy (regno_reg_rtx,
index d166a9a1527da56f864ccabc778c67fadc058007..cb4d8058ba53f0e07a6048ad3ac7ec52e3d8fc38 100644 (file)
@@ -329,7 +329,7 @@ init_eh (void)
 void
 init_eh_for_function (void)
 {
-  cfun->eh = GGC_CNEW (struct eh_status);
+  cfun->eh = ggc_alloc_cleared_eh_status ();
 
   /* Make sure zero'th entries are used.  */
   VEC_safe_push (eh_region, gc, cfun->eh->region_array, NULL);
@@ -350,7 +350,7 @@ gen_eh_region (enum eh_region_type type, eh_region outer)
 #endif
 
   /* Insert a new blank region as a leaf in the tree.  */
-  new_eh = GGC_CNEW (struct eh_region_d);
+  new_eh = ggc_alloc_cleared_eh_region_d ();
   new_eh->type = type;
   new_eh->outer = outer;
   if (outer)
@@ -407,7 +407,7 @@ gen_eh_region_catch (eh_region t, tree type_or_list)
        add_type_for_runtime (TREE_VALUE (type_node));
     }
 
-  c = GGC_CNEW (struct eh_catch_d);
+  c = ggc_alloc_cleared_eh_catch_d ();
   c->type_list = type_list;
   l = t->u.eh_try.last_catch;
   c->prev_catch = l;
@@ -441,7 +441,7 @@ gen_eh_region_must_not_throw (eh_region outer)
 eh_landing_pad
 gen_eh_landing_pad (eh_region region)
 {
-  eh_landing_pad lp = GGC_CNEW (struct eh_landing_pad_d);
+  eh_landing_pad lp = ggc_alloc_cleared_eh_landing_pad_d ();
 
   lp->next_lp = region->landing_pads;
   lp->region = region;
@@ -2368,7 +2368,7 @@ add_call_site (rtx landing_pad, int action, int section)
 {
   call_site_record record;
 
-  record = GGC_NEW (struct call_site_record_d);
+  record = ggc_alloc_call_site_record_d ();
   record->landing_pad = landing_pad;
   record->action = action;
 
index edb50382ee1d120f5fe332bce26a565f23dc4dcc..10fe680f6f4197e195969b44bf329869b91796f2 100644 (file)
@@ -1,3 +1,17 @@
+2010-06-08  Laurynas Biveinis  <laurynas.biveinis@gmail.com>
+
+       * trans-types.c (gfc_get_nodesc_array_type): Use typed GC
+       allocation.
+       (gfc_get_array_type_bounds): Likewise.
+
+       * trans-decl.c (gfc_allocate_lang_decl): Likewise.
+       (gfc_find_module): Likewise.
+
+       * f95-lang.c (pushlevel): Likewise.
+
+       * trans.h (struct lang_type): Add variable_size GTY option.
+       (struct lang_decl): Likewise.
+
 2010-06-08  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/44446
index 14525dc2552680cf92947cd50376d31d2f9ae1d9..f76e75c4b1f56438d26d92274e6034db5e81e829 100644 (file)
@@ -350,8 +350,7 @@ getdecls (void)
 void
 pushlevel (int ignore ATTRIBUTE_UNUSED)
 {
-  struct binding_level *newlevel
-    = (struct binding_level *) ggc_alloc (sizeof (struct binding_level));
+  struct binding_level *newlevel = ggc_alloc_binding_level ();
 
   *newlevel = clear_binding_level;
 
index 224474aeff211553993265bad0341e20e999d789..7ebdac4d1cf0506fcb7b014d05b3c3003a0144fe 100644 (file)
@@ -612,8 +612,8 @@ gfc_finish_var_decl (tree decl, gfc_symbol * sym)
 void
 gfc_allocate_lang_decl (tree decl)
 {
-  DECL_LANG_SPECIFIC (decl) = (struct lang_decl *)
-    ggc_alloc_cleared (sizeof (struct lang_decl));
+  DECL_LANG_SPECIFIC (decl) = ggc_alloc_cleared_lang_decl(sizeof
+                                                         (struct lang_decl));
 }
 
 /* Remember a symbol to generate initialization/cleanup code at function
@@ -3410,7 +3410,7 @@ gfc_find_module (const char *name)
                                   htab_hash_string (name), INSERT);
   if (*slot == NULL)
     {
-      struct module_htab_entry *entry = GGC_CNEW (struct module_htab_entry);
+      struct module_htab_entry *entry = ggc_alloc_cleared_module_htab_entry ();
 
       entry->name = gfc_get_string (name);
       entry->decls = htab_create_ggc (10, module_htab_decls_hash,
index d794c2fb66892490b42bc94829f7f613facc010e..38bae7d4cea2e7ad4012bd84d052e6007aadaf29 100644 (file)
@@ -1390,8 +1390,8 @@ gfc_get_nodesc_array_type (tree etype, gfc_array_spec * as, gfc_packed packed,
   type = make_node (ARRAY_TYPE);
 
   GFC_ARRAY_TYPE_P (type) = 1;
-  TYPE_LANG_SPECIFIC (type) = (struct lang_type *)
-    ggc_alloc_cleared (sizeof (struct lang_type));
+  TYPE_LANG_SPECIFIC (type)
+      = ggc_alloc_cleared_lang_type (sizeof (struct lang_type));
 
   known_stride = (packed != PACKED_NO);
   known_offset = 1;
@@ -1631,8 +1631,8 @@ gfc_get_array_type_bounds (tree etype, int dimen, int codimen, tree * lbound,
   TYPE_NAME (fat_type) = get_identifier (name);
 
   GFC_DESCRIPTOR_TYPE_P (fat_type) = 1;
-  TYPE_LANG_SPECIFIC (fat_type) = (struct lang_type *)
-    ggc_alloc_cleared (sizeof (struct lang_type));
+  TYPE_LANG_SPECIFIC (fat_type)
+    = ggc_alloc_cleared_lang_type (sizeof (struct lang_type));
 
   GFC_TYPE_ARRAY_RANK (fat_type) = dimen;
   GFC_TYPE_ARRAY_DTYPE (fat_type) = NULL_TREE;
index 9ee81480c5b22e5c30db0bc8a66eb1d758c2e403..72f8a4367886f48a8b804112afeefefe5ae242bc 100644 (file)
@@ -630,7 +630,10 @@ enum gfc_array_kind
 };
 
 /* Array types only.  */
-struct GTY(()) lang_type        {
+/* FIXME: the variable_size annotation here is needed because these types are
+   variable-sized in some other frontends.  Due to gengtype deficiency the GTY
+   options of such types have to agree across all frontends. */
+struct GTY((variable_size))    lang_type        {
   int rank;
   enum gfc_array_kind akind;
   tree lbound[GFC_MAX_DIMENSIONS];
@@ -644,7 +647,7 @@ struct GTY(())      lang_type        {
   tree base_decl[2];
 };
 
-struct GTY(()) lang_decl {
+struct GTY((variable_size)) lang_decl {
   /* Dummy variables.  */
   tree saved_descriptor;
   /* Assigned integer nodes.  Stringlength is the IO format string's length.
index 771552913f117f3bb7ec6c4a0887b5d2b3b6c1fa..c5b80b0e15358399f65a68369409b2eb13d48c6c 100644 (file)
@@ -340,7 +340,7 @@ try_fit_stack_local (HOST_WIDE_INT start, HOST_WIDE_INT length,
 static void
 add_frame_space (HOST_WIDE_INT start, HOST_WIDE_INT end)
 {
-  struct frame_space *space = GGC_NEW (struct frame_space);
+  struct frame_space *space = ggc_alloc_frame_space ();
   space->next = crtl->frame_space_list;
   crtl->frame_space_list = space;
   space->start = start;
@@ -683,7 +683,7 @@ static void
 insert_temp_slot_address (rtx address, struct temp_slot *temp_slot)
 {
   void **slot;
-  struct temp_slot_address_entry *t = GGC_NEW (struct temp_slot_address_entry);
+  struct temp_slot_address_entry *t = ggc_alloc_temp_slot_address_entry ();
   t->address = address;
   t->temp_slot = temp_slot;
   t->hash = temp_slot_address_compute_hash (t);
@@ -835,7 +835,7 @@ assign_stack_temp_for_type (enum machine_mode mode, HOST_WIDE_INT size,
 
          if (best_p->size - rounded_size >= alignment)
            {
-             p = GGC_NEW (struct temp_slot);
+             p = ggc_alloc_temp_slot ();
              p->in_use = p->addr_taken = 0;
              p->size = best_p->size - rounded_size;
              p->base_offset = best_p->base_offset + rounded_size;
@@ -859,7 +859,7 @@ assign_stack_temp_for_type (enum machine_mode mode, HOST_WIDE_INT size,
     {
       HOST_WIDE_INT frame_offset_old = frame_offset;
 
-      p = GGC_NEW (struct temp_slot);
+      p = ggc_alloc_temp_slot ();
 
       /* We are passing an explicit alignment request to assign_stack_local.
         One side effect of that is assign_stack_local will not round SIZE
@@ -4196,7 +4196,7 @@ allocate_struct_function (tree fndecl, bool abstract_p)
   tree result;
   tree fntype = fndecl ? TREE_TYPE (fndecl) : NULL_TREE;
 
-  cfun = GGC_CNEW (struct function);
+  cfun = ggc_alloc_cleared_function ();
 
   init_eh_for_function ();
 
@@ -5623,8 +5623,7 @@ types_used_by_var_decl_insert (tree type, tree var_decl)
       if (*slot == NULL)
        {
          struct types_used_by_vars_entry *entry;
-         entry = (struct types_used_by_vars_entry*) ggc_alloc
-                   (sizeof (struct types_used_by_vars_entry));
+         entry = ggc_alloc_types_used_by_vars_entry ();
          entry->type = type;
          entry->var_decl = var_decl;
          *slot = entry;
index 90e643493656d5b496843b8d319cb977204d8a72..b16a33ac04dfe4dc14c44b910ee6ec02b134f41e 100644 (file)
@@ -1895,9 +1895,8 @@ static void output_escaped_param (struct walk_type_data *d,
                                  const char *, const char *);
 static void output_mangled_typename (outf_p, const_type_p);
 static void walk_type (type_p t, struct walk_type_data *d);
-static void write_func_for_structure
-     (type_p orig_s, type_p s, type_p * param,
-      const struct write_types_data *wtd);
+static void write_func_for_structure (type_p orig_s, type_p s, type_p * param,
+                                     const struct write_types_data *wtd);
 static void write_types_process_field
      (type_p f, const struct walk_type_data *d);
 static void write_types (outf_p output_header,
@@ -2088,6 +2087,8 @@ walk_type (type_p t, struct walk_type_data *d)
       ;
     else if (strcmp (oo->name, "reorder") == 0)
       ;
+    else if (strcmp (oo->name, "variable_size") == 0)
+      ;
     else
       error_at_line (d->line, "unknown option `%s'\n", oo->name);
 
@@ -3026,6 +3027,20 @@ write_local (outf_p output_header, type_p structures, type_p param_structs)
       }
 }
 
+/* Nonzero if S is a type for which typed GC allocators should be output.  */
+
+#define USED_BY_TYPED_GC_P(s)                                          \
+  (((s->kind == TYPE_POINTER)                                          \
+    && ((s->u.p->gc_used == GC_POINTED_TO)                             \
+       || (s->u.p->gc_used == GC_USED)))                               \
+   || (UNION_OR_STRUCT_P (s) &&                                                \
+       (((s)->gc_used == GC_POINTED_TO)                                        \
+       || ((s)->gc_used == GC_MAYBE_POINTED_TO                         \
+           && s->u.s.line.file != NULL)                                \
+       || ((s)->gc_used == GC_USED                                     \
+           && strncmp (s->u.s.tag, "anonymous", strlen ("anonymous"))))))
+
+
 /* Write out the 'enum' definition for gt_types_enum.  */
 
 static void
@@ -3038,23 +3053,18 @@ write_enum_defn (type_p structures, type_p param_structs)
   oprintf (header_file, "\n/* Enumeration of types known.  */\n");
   oprintf (header_file, "enum gt_types_enum {\n");
   for (s = structures; s; s = s->next)
-    if (s->gc_used == GC_POINTED_TO
-       || s->gc_used == GC_MAYBE_POINTED_TO)
+    if (USED_BY_TYPED_GC_P (s))
       {
-       if (s->gc_used == GC_MAYBE_POINTED_TO
-           && s->u.s.line.file == NULL)
-         continue;
-
        oprintf (header_file, " gt_ggc_e_");
        output_mangled_typename (header_file, s);
-       oprintf (header_file, ", \n");
+       oprintf (header_file, ",\n");
       }
   for (s = param_structs; s; s = s->next)
     if (s->gc_used == GC_POINTED_TO)
       {
        oprintf (header_file, " gt_e_");
        output_mangled_typename (header_file, s);
-       oprintf (header_file, ", \n");
+       oprintf (header_file, ",\n");
       }
   oprintf (header_file, " gt_types_enum_last\n");
   oprintf (header_file, "};\n");
@@ -3701,6 +3711,213 @@ note_def_vec_alloc (const char *type, const char *astrat, struct fileloc *pos)
   do_typedef (astratname, new_structure (astratname, 0, pos, field, 0), pos);
 }
 
+/* Returns the specifier keyword for a string or union type S, empty string
+   otherwise.  */
+
+static const char *
+get_type_specifier (const type_p s)
+{
+  if (s->kind == TYPE_STRUCT || s->kind == TYPE_LANG_STRUCT)
+    return "struct ";
+  if (s->kind == TYPE_UNION)
+    return "union ";
+  return "";
+}
+
+/* TRUE if type S has the GTY variable_size annotation.  */
+
+static bool
+variable_size_p (const type_p s)
+{
+  options_p o;
+  for (o = s->u.s.opt; o; o = o->next)
+    if (strcmp (o->name, "variable_size") == 0)
+      return true;
+  return false;
+}
+
+enum alloc_quantity { single, vector };
+enum alloc_zone { any_zone, specific_zone };
+
+/* Writes one typed allocator definition for type identifier TYPE_NAME with
+   optional type specifier TYPE_SPECIFIER.  The allocator name will contain
+   ALLOCATOR_TYPE.  If VARIABLE_SIZE is true, the allocator will have an extra
+   parameter specifying number of bytes to allocate.  If QUANTITY is set to
+   VECTOR, a vector allocator will be output, if ZONE is set to SPECIFIC_ZONE,
+   the allocator will be zone-specific.  */
+
+static void
+write_typed_alloc_def (bool variable_size, const char * type_specifier,
+                      const char * type_name, const char * allocator_type,
+                      enum alloc_quantity quantity, enum alloc_zone zone)
+{
+  bool two_args = variable_size && (quantity == vector);
+  bool third_arg = ((zone == specific_zone)
+                   && (variable_size || (quantity == vector)));
+
+  oprintf (header_file, "#define ggc_alloc_%s%s",allocator_type, type_name);
+  oprintf (header_file, "(%s%s%s%s%s) ",
+          (variable_size ? "SIZE" : ""),
+          (two_args ? ", " : ""),
+          (quantity == vector) ? "n" : "",
+          (third_arg ? ", " : ""), (zone == specific_zone) ? "z" : "");
+  oprintf (header_file, "((%s%s *)", type_specifier, type_name);
+  oprintf (header_file, "(ggc_internal_%salloc_stat (", allocator_type);
+  if (zone == specific_zone)
+    oprintf (header_file, "z, ");
+  if (variable_size)
+    oprintf (header_file, "SIZE");
+  else
+    oprintf (header_file, "sizeof (%s%s)", type_specifier, type_name);
+  if (quantity == vector)
+    oprintf (header_file, ", n");
+  oprintf (header_file, " MEM_STAT_INFO)))\n");
+}
+
+/* Writes a typed allocator definition for a struct or union S.  */
+
+static void
+write_typed_struct_alloc_def (const type_p s, const char * allocator_type,
+                             enum alloc_quantity quantity,
+                             enum alloc_zone zone)
+{
+  write_typed_alloc_def (variable_size_p (s), get_type_specifier (s),
+                        s->u.s.tag, allocator_type, quantity, zone);
+}
+
+/* Writes a typed allocator definition for a typedef P.  */
+
+static void
+write_typed_typedef_alloc_def (const pair_p p, const char * allocator_type,
+                              enum alloc_quantity quantity,
+                              enum alloc_zone zone)
+{
+  write_typed_alloc_def (variable_size_p (p->type), "", p->name,
+                        allocator_type, quantity, zone);
+}
+
+/* Writes typed allocator definitions for the types in STRUCTURES and
+   TYPEDEFS that are used by GC.  */
+
+static void
+write_typed_alloc_defns (const type_p structures, const pair_p typedefs)
+{
+  type_p s;
+  pair_p p;
+
+  oprintf (header_file,
+          "\n/* Allocators for known structs and unions.  */\n\n");
+  for (s = structures; s; s = s->next)
+    {
+      if (!USED_BY_TYPED_GC_P (s))
+       continue;
+      write_typed_struct_alloc_def (s, "", single, any_zone);
+      write_typed_struct_alloc_def (s, "cleared_", single, any_zone);
+      write_typed_struct_alloc_def (s, "vec_", vector, any_zone);
+      write_typed_struct_alloc_def (s, "cleared_vec_", vector, any_zone);
+      write_typed_struct_alloc_def (s, "zone_", single, specific_zone);
+      write_typed_struct_alloc_def (s, "zone_cleared_", single,
+                                   specific_zone);
+      write_typed_struct_alloc_def (s, "zone_vec_", vector, specific_zone);
+      write_typed_struct_alloc_def (s, "zone_cleared_vec_", vector,
+                                   specific_zone);
+    }
+
+  oprintf (header_file, "\n/* Allocators for known typedefs.  */\n");
+  for (p = typedefs; p; p = p->next)
+    {
+      s = p->type;
+      if (!USED_BY_TYPED_GC_P (s) || (strcmp (p->name, s->u.s.tag) == 0))
+       continue;
+      write_typed_typedef_alloc_def (p, "", single, any_zone);
+      write_typed_typedef_alloc_def (p, "cleared_", single, any_zone);
+      write_typed_typedef_alloc_def (p, "vec_", vector, any_zone);
+      write_typed_typedef_alloc_def (p, "cleared_vec_", vector, any_zone);
+      write_typed_typedef_alloc_def (p, "zone_", single, specific_zone);
+      write_typed_typedef_alloc_def (p, "zone_cleared_", single,
+                                    specific_zone);
+      write_typed_typedef_alloc_def (p, "zone_cleared_vec_", vector,
+                                    specific_zone);
+    }
+}
+
+/* Prints not-as-ugly version of a typename of T to OF.  Trades the uniquness
+   guaranteee for somewhat increased readability.  If name conflicts do happen,
+   this funcion will have to be adjusted to be more like
+   output_mangled_typename.  */
+
+static void
+output_typename (outf_p of, const_type_p t)
+{
+  switch (t->kind)
+    {
+    case TYPE_STRING:
+      oprintf (of, "str");
+      break;
+    case TYPE_SCALAR:
+      oprintf (of, "scalar");
+      break;
+    case TYPE_POINTER:
+      output_typename (of, t->u.p);
+      break;
+    case TYPE_STRUCT:
+    case TYPE_UNION:
+    case TYPE_LANG_STRUCT:
+      oprintf (of, "%s", t->u.s.tag);
+      break;
+    case TYPE_PARAM_STRUCT:
+      {
+       int i;
+       for (i = 0; i < NUM_PARAM; i++)
+         if (t->u.param_struct.param[i] != NULL) {
+           output_typename (of, t->u.param_struct.param[i]);
+           oprintf (of, "_");
+         }
+       output_typename (of, t->u.param_struct.stru);
+       break;
+      }
+    default:
+      gcc_unreachable();
+    }
+}
+
+/* Writes a typed GC allocator for type S that is suitable as a callback for
+   the splay tree implementation in libiberty.  */
+
+static void
+write_splay_tree_allocator_def (const_type_p s)
+{
+  outf_p of = get_output_file_for_structure(s, NULL);
+  oprintf (of, "void * ggc_alloc_splay_tree_");
+  output_typename (of, s);
+  oprintf (of, " (int sz, void * nl)\n");
+  oprintf (of, "{\n");
+  oprintf (of, "  return ggc_splay_alloc (");
+  oprintf (of, "gt_e_");
+  output_mangled_typename (of, s);
+  oprintf (of, ", sz, nl);\n");
+  oprintf (of, "}\n\n");
+}
+
+/* Writes typed GC allocators for PARAM_STRUCTS that are suitable as callbacks
+   for the splay tree implementation in libiberty.  */
+
+static void
+write_splay_tree_allocators (const_type_p param_structs)
+{
+  const_type_p s;
+
+  oprintf (header_file, "\n/* Splay tree callback allocators.  */\n");
+  for (s = param_structs; s; s = s->next)
+    if (s->gc_used == GC_POINTED_TO)
+      {
+       oprintf (header_file, "extern void * ggc_alloc_splay_tree_");
+       output_typename (header_file, s);
+       oprintf (header_file, " (int, void *);\n");
+       write_splay_tree_allocator_def (s);
+      }
+}
+
 static void dump_pair (int indent, pair_p p);
 static void dump_type (int indent, type_p p);
 static void dump_type_list (int indent, type_p p);
@@ -4021,6 +4238,7 @@ main (int argc, char **argv)
 
   open_base_files ();
   write_enum_defn (structures, param_structs);
+  write_typed_alloc_defns (structures, typedefs);
   output_header = plugin_output ? plugin_output : header_file;
   write_types (output_header, structures, param_structs, &ggc_wtd);
   if (plugin_files == NULL)
@@ -4028,6 +4246,7 @@ main (int argc, char **argv)
       write_types (header_file, structures, param_structs, &pch_wtd);
       write_local (header_file, structures, param_structs);
     }
+  write_splay_tree_allocators (param_structs);
   write_roots (variables, plugin_files == NULL);
   write_rtx_next ();
   close_output_files ();
index 76bf975c86fb9f5ad7d16bc29d27c1a75a85c46b..175629b3129a84f91d16da61091f99c637b61934 100644 (file)
@@ -26,6 +26,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "coretypes.h"
 #include "hashtab.h"
 #include "ggc.h"
+#include "ggc-internal.h"
 #include "toplev.h"
 #include "params.h"
 #include "hosthooks.h"
@@ -193,9 +194,9 @@ ggc_mark_roots (void)
 
 /* Allocate a block of memory, then clear it.  */
 void *
-ggc_alloc_cleared_stat (size_t size MEM_STAT_DECL)
+ggc_internal_cleared_alloc_stat (size_t size MEM_STAT_DECL)
 {
-  void *buf = ggc_alloc_stat (size PASS_MEM_STAT);
+  void *buf = ggc_internal_alloc_stat (size PASS_MEM_STAT);
   memset (buf, 0, size);
   return buf;
 }
@@ -208,7 +209,7 @@ ggc_realloc_stat (void *x, size_t size MEM_STAT_DECL)
   size_t old_size;
 
   if (x == NULL)
-    return ggc_alloc_stat (size PASS_MEM_STAT);
+    return ggc_internal_alloc_stat (size PASS_MEM_STAT);
 
   old_size = ggc_get_size (x);
 
@@ -230,7 +231,7 @@ ggc_realloc_stat (void *x, size_t size MEM_STAT_DECL)
       return x;
     }
 
-  r = ggc_alloc_stat (size PASS_MEM_STAT);
+  r = ggc_internal_alloc_stat (size PASS_MEM_STAT);
 
   /* Since ggc_get_size returns the size of the pool, not the size of the
      individually allocated object, we'd access parts of the old object
@@ -246,19 +247,30 @@ ggc_realloc_stat (void *x, size_t size MEM_STAT_DECL)
   return r;
 }
 
-/* Like ggc_alloc_cleared, but performs a multiplication.  */
 void *
-ggc_calloc (size_t s1, size_t s2)
+ggc_cleared_alloc_htab_ignore_args (size_t c ATTRIBUTE_UNUSED,
+                                   size_t n ATTRIBUTE_UNUSED)
 {
-  return ggc_alloc_cleared (s1 * s2);
+  gcc_assert (c * n == sizeof (struct htab));
+  return ggc_alloc_cleared_htab ();
+}
+
+/* TODO: once we actually use type information in GGC, create a new tag
+   gt_gcc_ptr_array and use it for pointer arrays.  */
+void *
+ggc_cleared_alloc_ptr_array_two_args (size_t c, size_t n)
+{
+  gcc_assert (sizeof (PTR *) == n);
+  return ggc_internal_cleared_vec_alloc (sizeof (PTR *), c);
 }
 
 /* These are for splay_tree_new_ggc.  */
 void *
-ggc_splay_alloc (int sz, void *nl)
+ggc_splay_alloc (enum gt_types_enum obj_type ATTRIBUTE_UNUSED, int sz,
+                void *nl)
 {
   gcc_assert (!nl);
-  return ggc_alloc (sz);
+  return ggc_internal_alloc (sz);
 }
 
 void
@@ -516,7 +528,7 @@ gt_pch_save (FILE *f)
 
   /* Prepare the objects for writing, determine addresses and such.  */
   state.f = f;
-  state.d = init_ggc_pch();
+  state.d = init_ggc_pch ();
   state.count = 0;
   htab_traverse (saving_htab, call_count, &state);
 
@@ -825,7 +837,7 @@ ggc_min_heapsize_heuristic (void)
      the limit, whichever is larger.  If GCC does hit the data limit,
      compilation will fail, so this tries to be conservative.  */
   limit_kbytes = MAX (0, limit_kbytes - MAX (limit_kbytes / 4, 20 * 1024));
-  limit_kbytes = (limit_kbytes * 100) / (110 + ggc_min_expand_heuristic());
+  limit_kbytes = (limit_kbytes * 100) / (110 + ggc_min_expand_heuristic ());
   phys_kbytes = MIN (phys_kbytes, limit_kbytes);
 
   phys_kbytes = MAX (phys_kbytes, 4 * 1024);
@@ -839,8 +851,8 @@ void
 init_ggc_heuristics (void)
 {
 #if !defined ENABLE_GC_CHECKING && !defined ENABLE_GC_ALWAYS_COLLECT
-  set_param_value ("ggc-min-expand", ggc_min_expand_heuristic());
-  set_param_value ("ggc-min-heapsize", ggc_min_heapsize_heuristic());
+  set_param_value ("ggc-min-expand", ggc_min_expand_heuristic ());
+  set_param_value ("ggc-min-heapsize", ggc_min_heapsize_heuristic ());
 #endif
 }
 
diff --git a/gcc/ggc-internal.h b/gcc/ggc-internal.h
new file mode 100644 (file)
index 0000000..7b875ee
--- /dev/null
@@ -0,0 +1,121 @@
+/* Garbage collection for the GNU compiler.  Internal definitions
+   for ggc-*.c and stringpool.c.
+
+   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+#ifndef GCC_GGC_INTERNAL_H
+#define GCC_GGC_INTERNAL_H
+
+#include "ggc.h"
+
+/* Call ggc_set_mark on all the roots.  */
+extern void ggc_mark_roots (void);
+
+/* Stringpool.  */
+
+/* Mark the entries in the string pool.  */
+extern void ggc_mark_stringpool        (void);
+
+/* Purge the entries in the string pool.  */
+extern void ggc_purge_stringpool (void);
+
+/* Save and restore the string pool entries for PCH.  */
+
+extern void gt_pch_save_stringpool (void);
+extern void gt_pch_fixup_stringpool (void);
+extern void gt_pch_restore_stringpool (void);
+
+/* PCH and GGC handling for strings, mostly trivial.  */
+extern void gt_pch_p_S (void *, void *, gt_pointer_operator, void *);
+
+/* PCH.  */
+
+struct ggc_pch_data;
+
+/* Return a new ggc_pch_data structure.  */
+extern struct ggc_pch_data *init_ggc_pch (void);
+
+/* The second parameter and third parameters give the address and size
+   of an object.  Update the ggc_pch_data structure with as much of
+   that information as is necessary. The bool argument should be true
+   if the object is a string.  */
+extern void ggc_pch_count_object (struct ggc_pch_data *, void *, size_t, bool,
+                                 enum gt_types_enum);
+
+/* Return the total size of the data to be written to hold all
+   the objects previously passed to ggc_pch_count_object.  */
+extern size_t ggc_pch_total_size (struct ggc_pch_data *);
+
+/* The objects, when read, will most likely be at the address
+   in the second parameter.  */
+extern void ggc_pch_this_base (struct ggc_pch_data *, void *);
+
+/* Assuming that the objects really do end up at the address
+   passed to ggc_pch_this_base, return the address of this object.
+   The bool argument should be true if the object is a string.  */
+extern char *ggc_pch_alloc_object (struct ggc_pch_data *, void *, size_t, bool,
+                                  enum gt_types_enum);
+
+/* Write out any initial information required.  */
+extern void ggc_pch_prepare_write (struct ggc_pch_data *, FILE *);
+
+/* Write out this object, including any padding.  The last argument should be
+   true if the object is a string.  */
+extern void ggc_pch_write_object (struct ggc_pch_data *, FILE *, void *,
+                                 void *, size_t, bool);
+
+/* All objects have been written, write out any final information
+   required.  */
+extern void ggc_pch_finish (struct ggc_pch_data *, FILE *);
+
+/* A PCH file has just been read in at the address specified second
+   parameter.  Set up the GC implementation for the new objects.  */
+extern void ggc_pch_read (FILE *, void *);
+
+
+/* Allocation and collection.  */
+
+/* When set, ggc_collect will do collection.  */
+extern bool ggc_force_collect;
+
+extern void ggc_record_overhead (size_t, size_t, void * MEM_STAT_DECL);
+
+extern void ggc_free_overhead (void *);
+
+extern void ggc_prune_overhead_list (void);
+
+/* Return the number of bytes allocated at the indicated address.  */
+extern size_t ggc_get_size (const void *);
+
+
+/* Statistics.  */
+
+/* This structure contains the statistics common to all collectors.
+   Particular collectors can extend this structure.  */
+typedef struct ggc_statistics
+{
+  /* At present, we don't really gather any interesting statistics.  */
+  int unused;
+} ggc_statistics;
+
+/* Used by the various collectors to gather and print statistics that
+   do not depend on the collector in use.  */
+extern void ggc_print_common_statistics (FILE *, ggc_statistics *);
+
+#endif
index 2d45a61ca5f9b6c270f5a5f06bd3a5afa143fe6d..f9c48cb8cc5902c3179bafe46e584a39f6ddc4f2 100644 (file)
@@ -1,5 +1,5 @@
 /* Null garbage collection for the GNU compiler.
-   Copyright (C) 1998, 1999, 2000, 2003, 2004, 2005, 2007
+   Copyright (C) 1998, 1999, 2000, 2003, 2004, 2005, 2007, 2010
    Free Software Foundation, Inc.
 
    This file is part of GCC.
@@ -40,13 +40,13 @@ ggc_alloc_typed_stat (enum gt_types_enum ARG_UNUSED (gte), size_t size
 }
 
 void *
-ggc_alloc_stat (size_t size MEM_STAT_DECL)
+ggc_internal_alloc_stat (size_t size MEM_STAT_DECL)
 {
   return xmalloc (size);
 }
 
 void *
-ggc_alloc_cleared_stat (size_t size MEM_STAT_DECL)
+ggc_internal_cleared_alloc_stat (size_t size MEM_STAT_DECL)
 {
   return xcalloc (size, 1);
 }
@@ -62,3 +62,12 @@ ggc_free (void *p)
 {
   free (p);
 }
+
+struct alloc_zone
+{
+  int dummy;
+};
+
+struct alloc_zone rtl_zone;
+struct alloc_zone tree_zone;
+struct alloc_zone tree_id_zone;
index 67483f1934933b4991c4b6d79582d854924542da..27862be8ef40f63e65d3eee6f3d978716bbdc975 100644 (file)
@@ -1,6 +1,6 @@
 /* "Bag-of-pages" garbage collector for the GNU compiler.
-   Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009
-   Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009,
+   2010 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -28,6 +28,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "toplev.h"
 #include "flags.h"
 #include "ggc.h"
+#include "ggc-internal.h"
 #include "timevar.h"
 #include "params.h"
 #include "tree-flow.h"
@@ -437,9 +438,9 @@ static struct globals
 #ifdef GATHER_STATISTICS
   struct
   {
-    /* Total memory allocated with ggc_alloc.  */
+    /* Total GC-allocated memory.  */
     unsigned long long total_allocated;
-    /* Total overhead for memory to be allocated with ggc_alloc.  */
+    /* Total overhead for GC-allocated memory.  */
     unsigned long long total_overhead;
 
     /* Total allocations and overhead for sizes less than 32, 64 and 128.
@@ -689,7 +690,7 @@ alloc_anon (char *pref ATTRIBUTE_UNUSED, size_t size)
   G.bytes_mapped += size;
 
   /* Pretend we don't have access to the allocated pages.  We'll enable
-     access to smaller pieces of the area in ggc_alloc.  Discard the
+     access to smaller pieces of the area in ggc_internal_alloc.  Discard the
      handle to avoid handle leak.  */
   VALGRIND_DISCARD (VALGRIND_MAKE_MEM_NOACCESS (page, size));
 
@@ -1074,13 +1075,13 @@ void *
 ggc_alloc_typed_stat (enum gt_types_enum type ATTRIBUTE_UNUSED, size_t size
                      MEM_STAT_DECL)
 {
-  return ggc_alloc_stat (size PASS_MEM_STAT);
+  return ggc_internal_alloc_stat (size PASS_MEM_STAT);
 }
 
 /* Allocate a chunk of memory of SIZE bytes.  Its contents are undefined.  */
 
 void *
-ggc_alloc_stat (size_t size MEM_STAT_DECL)
+ggc_internal_alloc_stat (size_t size MEM_STAT_DECL)
 {
   size_t order, word, bit, object_offset, object_size;
   struct page_entry *entry;
@@ -1605,20 +1606,6 @@ init_ggc (void)
   G.save_in_use = XNEWVEC (unsigned long *, G.by_depth_max);
 }
 
-/* Start a new GGC zone.  */
-
-struct alloc_zone *
-new_ggc_zone (const char *name ATTRIBUTE_UNUSED)
-{
-  return NULL;
-}
-
-/* Destroy a GGC zone.  */
-void
-destroy_ggc_zone (struct alloc_zone *zone ATTRIBUTE_UNUSED)
-{
-}
-
 /* Merge the SAVE_IN_USE_P and IN_USE_P arrays in P so that IN_USE_P
    reflects reality.  Recalculate NUM_FREE_OBJECTS as well.  */
 
@@ -2383,3 +2370,12 @@ ggc_pch_read (FILE *f, void *addr)
   /* Update the statistics.  */
   G.allocated = G.allocated_last_gc = offs - (char *)addr;
 }
+
+struct alloc_zone
+{
+  int dummy;
+};
+
+struct alloc_zone rtl_zone;
+struct alloc_zone tree_zone;
+struct alloc_zone tree_id_zone;
index a8154cc4de0f3e7714b0fcbcd14d8e1e633a2e30..12dc8740529565cadb55a93108ebc28796c977dc 100644 (file)
@@ -32,6 +32,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "toplev.h"
 #include "flags.h"
 #include "ggc.h"
+#include "ggc-internal.h"
 #include "timevar.h"
 #include "params.h"
 #include "bitmap.h"
@@ -417,9 +418,9 @@ struct alloc_zone
 #ifdef GATHER_STATISTICS
   struct
   {
-    /* Total memory allocated with ggc_alloc.  */
+    /* Total GC-allocated memory.  */
     unsigned long long total_allocated;
-    /* Total overhead for memory to be allocated with ggc_alloc.  */
+    /* Total overhead for GC-allocated memory.  */
     unsigned long long total_overhead;
 
     /* Total allocations and overhead for sizes less than 32, 64 and 128.
@@ -860,7 +861,7 @@ alloc_anon (char *pref ATTRIBUTE_UNUSED, size_t size, struct alloc_zone *zone)
   zone->bytes_mapped += size;
 
   /* Pretend we don't have access to the allocated pages.  We'll enable
-     access to smaller pieces of the area in ggc_alloc.  Discard the
+     access to smaller pieces of the area in ggc_internal_alloc.  Discard the
      handle to avoid handle leak.  */
   VALGRIND_DISCARD (VALGRIND_MAKE_MEM_NOACCESS (page, size));
 
@@ -1089,8 +1090,8 @@ free_chunk (char *ptr, size_t size, struct alloc_zone *zone)
 /* Allocate a chunk of memory of at least ORIG_SIZE bytes, in ZONE.  */
 
 void *
-ggc_alloc_zone_stat (size_t orig_size, struct alloc_zone *zone
-                    MEM_STAT_DECL)
+ggc_internal_alloc_zone_stat (size_t orig_size, struct alloc_zone *zone
+                             MEM_STAT_DECL)
 {
   size_t bin;
   size_t csize;
@@ -1352,6 +1353,19 @@ ggc_alloc_zone_stat (size_t orig_size, struct alloc_zone *zone
   return result;
 }
 
+#define ggc_internal_alloc_zone_pass_stat(s,z)          \
+    ggc_internal_alloc_zone_stat (s,z PASS_MEM_STAT)
+
+void *
+ggc_internal_cleared_alloc_zone_stat (size_t orig_size,
+                                     struct alloc_zone *zone MEM_STAT_DECL)
+{
+  void * result = ggc_internal_alloc_zone_pass_stat (orig_size, zone);
+  memset (result, 0, orig_size);
+  return result;
+}
+
+
 /* Allocate a SIZE of chunk memory of GTE type, into an appropriate zone
    for that type.  */
 
@@ -1362,25 +1376,25 @@ ggc_alloc_typed_stat (enum gt_types_enum gte, size_t size
   switch (gte)
     {
     case gt_ggc_e_14lang_tree_node:
-      return ggc_alloc_zone_pass_stat (size, &tree_zone);
+      return ggc_internal_alloc_zone_pass_stat (size, &tree_zone);
 
     case gt_ggc_e_7rtx_def:
-      return ggc_alloc_zone_pass_stat (size, &rtl_zone);
+      return ggc_internal_alloc_zone_pass_stat (size, &rtl_zone);
 
     case gt_ggc_e_9rtvec_def:
-      return ggc_alloc_zone_pass_stat (size, &rtl_zone);
+      return ggc_internal_alloc_zone_pass_stat (size, &rtl_zone);
 
     default:
-      return ggc_alloc_zone_pass_stat (size, &main_zone);
+      return ggc_internal_alloc_zone_pass_stat (size, &main_zone);
     }
 }
 
-/* Normal ggc_alloc simply allocates into the main zone.  */
+/* Normal GC allocation simply allocates into the main zone.  */
 
 void *
-ggc_alloc_stat (size_t size MEM_STAT_DECL)
+ggc_internal_alloc_stat (size_t size MEM_STAT_DECL)
 {
-  return ggc_alloc_zone_pass_stat (size, &main_zone);
+  return ggc_internal_alloc_zone_pass_stat (size, &main_zone);
 }
 
 /* Poison the chunk.  */
@@ -1715,31 +1729,6 @@ new_ggc_zone_1 (struct alloc_zone *new_zone, const char * name)
   G.zones->next_zone = new_zone;
 }
 
-struct alloc_zone *
-new_ggc_zone (const char * name)
-{
-  struct alloc_zone *new_zone = XCNEW (struct alloc_zone);
-  new_ggc_zone_1 (new_zone, name);
-  return new_zone;
-}
-
-/* Destroy a GGC zone.  */
-void
-destroy_ggc_zone (struct alloc_zone * dead_zone)
-{
-  struct alloc_zone *z;
-
-  for (z = G.zones; z && z->next_zone != dead_zone; z = z->next_zone)
-    /* Just find that zone.  */
-    continue;
-
-  /* We should have found the zone in the list.  Anything else is fatal.  */
-  gcc_assert (z);
-
-  /* z is dead, baby. z is dead.  */
-  z->dead = true;
-}
-
 /* Free all empty pages and objects within a page for a given zone  */
 
 static void
@@ -2488,6 +2477,12 @@ ggc_pch_read (FILE *f, void *addr)
 
   /* We've just read in a PCH file.  So, every object that used to be
      allocated is now free.  */
+#ifdef 0 && GATHER_STATISTICS
+  zone_allocate_marks ();
+  ggc_prune_overhead_list ();
+  zone_free_marks ();
+#endif
+
   for (zone = G.zones; zone; zone = zone->next_zone)
     {
       struct small_page_entry *page, *next_page;
index 33b78f1b03d7c835e0e6fd87f430a8e5b64aba46..7f2144c0f122266f2e4476d8e77d5d5d236dce07 100644 (file)
--- a/gcc/ggc.h
+++ b/gcc/ggc.h
@@ -1,7 +1,7 @@
 /* Garbage collection for the GNU compiler.
 
    Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007,
-   2008, 2009 Free Software Foundation, Inc.
+   2008, 2009, 2010 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -28,11 +28,9 @@ along with GCC; see the file COPYING3.  If not see
 
 /* Constants for general use.  */
 extern const char empty_string[];      /* empty string */
-extern const char digit_vector[];      /* "0" .. "9" */
-#define digit_string(d) (digit_vector + ((d) * 2))
 
 /* Internal functions and data structures used by the GTY
-   machinery.  */
+   machinery, including the generated gt*.[hc] files.  */
 
 /* The first parameter is a pointer to a pointer, the second a cookie.  */
 typedef void (*gt_pointer_operator) (void *, void *);
@@ -118,112 +116,48 @@ extern int ggc_set_mark  (const void *);
    static objects, stack variables, or memory allocated with malloc.  */
 extern int ggc_marked_p        (const void *);
 
-/* Mark the entries in the string pool.  */
-extern void ggc_mark_stringpool        (void);
-
-/* Purge the entries in the string pool.  */
-extern void ggc_purge_stringpool (void);
-
-/* Call ggc_set_mark on all the roots.  */
-
-extern void ggc_mark_roots (void);
-
-/* Save and restore the string pool entries for PCH.  */
-
-extern void gt_pch_save_stringpool (void);
-extern void gt_pch_fixup_stringpool (void);
-extern void gt_pch_restore_stringpool (void);
-
 /* PCH and GGC handling for strings, mostly trivial.  */
-
-extern void gt_pch_p_S (void *, void *, gt_pointer_operator, void *);
 extern void gt_pch_n_S (const void *);
 extern void gt_ggc_m_S (const void *);
 
-/* Initialize the string pool.  */
-extern void init_stringpool (void);
+/* End of GTY machinery API.  */
 
-/* A GC implementation must provide these functions.  They are internal
-   to the GC system.  */
-
-/* Forward declare the zone structure.  Only ggc_zone implements this.  */
 struct alloc_zone;
 
+/* Initialize the string pool.  */
+extern void init_stringpool (void);
+
 /* Initialize the garbage collector.  */
 extern void init_ggc (void);
 
-/* Start a new GGC zone.  */
-extern struct alloc_zone *new_ggc_zone (const char *);
-
-/* Free a complete GGC zone, destroying everything in it.  */
-extern void destroy_ggc_zone (struct alloc_zone *);
-
-struct ggc_pch_data;
-
-/* Return a new ggc_pch_data structure.  */
-extern struct ggc_pch_data *init_ggc_pch (void);
-
-/* The second parameter and third parameters give the address and size
-   of an object.  Update the ggc_pch_data structure with as much of
-   that information as is necessary. The bool argument should be true
-   if the object is a string.  */
-extern void ggc_pch_count_object (struct ggc_pch_data *, void *, size_t, bool,
-                                 enum gt_types_enum);
-
-/* Return the total size of the data to be written to hold all
-   the objects previously passed to ggc_pch_count_object.  */
-extern size_t ggc_pch_total_size (struct ggc_pch_data *);
-
-/* The objects, when read, will most likely be at the address
-   in the second parameter.  */
-extern void ggc_pch_this_base (struct ggc_pch_data *, void *);
-
-/* Assuming that the objects really do end up at the address
-   passed to ggc_pch_this_base, return the address of this object.
-   The bool argument should be true if the object is a string.  */
-extern char *ggc_pch_alloc_object (struct ggc_pch_data *, void *, size_t, bool,
-                                  enum gt_types_enum);
-
-/* Write out any initial information required.  */
-extern void ggc_pch_prepare_write (struct ggc_pch_data *, FILE *);
-/* Write out this object, including any padding.  The last argument should be
-   true if the object is a string.  */
-extern void ggc_pch_write_object (struct ggc_pch_data *, FILE *, void *,
-                                 void *, size_t, bool);
-/* All objects have been written, write out any final information
-   required.  */
-extern void ggc_pch_finish (struct ggc_pch_data *, FILE *);
-
-/* A PCH file has just been read in at the address specified second
-   parameter.  Set up the GC implementation for the new objects.  */
-extern void ggc_pch_read (FILE *, void *);
-
-\f
-/* Allocation.  */
-
-/* When set, ggc_collect will do collection.  */
-extern bool ggc_force_collect;
-
 /* When true, identifier nodes are considered as GC roots.  When
    false, identifier nodes are treated like any other GC-allocated
    object, and the identifier hash table is treated as a weak
    hash.  */
 extern bool ggc_protect_identifiers;
 
+/* Write out all GCed objects to F.  */
+extern void gt_pch_save (FILE *f);
+
+\f
+/* Allocation.  */
+
 /* The internal primitive.  */
-extern void *ggc_alloc_stat (size_t MEM_STAT_DECL);
-#define ggc_alloc(s) ggc_alloc_stat (s MEM_STAT_INFO)
+extern void *ggc_internal_alloc_stat (size_t MEM_STAT_DECL);
+
+#define ggc_internal_alloc(s) ggc_internal_alloc_stat (s MEM_STAT_INFO)
+
 /* Allocate an object of the specified type and size.  */
 extern void *ggc_alloc_typed_stat (enum gt_types_enum, size_t MEM_STAT_DECL);
-#define ggc_alloc_typed(s,z) ggc_alloc_typed_stat (s,z MEM_STAT_INFO)
-/* Like ggc_alloc, but allocates cleared memory.  */
-extern void *ggc_alloc_cleared_stat (size_t MEM_STAT_DECL);
-#define ggc_alloc_cleared(s) ggc_alloc_cleared_stat (s MEM_STAT_INFO)
+
+#define ggc_alloc_typed(s, z) ggc_alloc_typed_stat (s, z MEM_STAT_INFO)
+
+/* Allocates cleared memory.  */
+extern void *ggc_internal_cleared_alloc_stat (size_t MEM_STAT_DECL);
+
 /* Resize a block.  */
 extern void *ggc_realloc_stat (void *, size_t MEM_STAT_DECL);
-#define ggc_realloc(s,z) ggc_realloc_stat (s,z MEM_STAT_INFO)
-/* Like ggc_alloc_cleared, but performs a multiplication.  */
-extern void *ggc_calloc (size_t, size_t);
+
 /* Free a block.  To be used when known for certain it's not reachable.  */
 extern void ggc_free (void *);
 
@@ -233,39 +167,67 @@ extern void ggc_prune_overhead_list (void);
 
 extern void dump_ggc_loc_statistics (bool);
 
-/* Type-safe, C++-friendly versions of ggc_alloc() and gcc_calloc().  */
-#define GGC_NEW(T)             ((T *) ggc_alloc (sizeof (T)))
-#define GGC_CNEW(T)            ((T *) ggc_alloc_cleared (sizeof (T)))
-#define GGC_NEWVEC(T, N)       ((T *) ggc_alloc ((N) * sizeof(T)))
-#define GGC_CNEWVEC(T, N)      ((T *) ggc_alloc_cleared ((N) * sizeof(T)))
-#define GGC_RESIZEVEC(T, P, N)  ((T *) ggc_realloc ((P), (N) * sizeof (T)))
-#define GGC_NEWVAR(T, S)       ((T *) ggc_alloc ((S)))
-#define GGC_CNEWVAR(T, S)      ((T *) ggc_alloc_cleared ((S)))
-#define GGC_RESIZEVAR(T, P, N)  ((T *) ggc_realloc ((P), (N)))
+/* Reallocators.  */
+#define GGC_RESIZEVEC(T, P, N) \
+    ((T *) ggc_realloc_stat ((P), (N) * sizeof (T) MEM_STAT_INFO))
+
+#define GGC_RESIZEVAR(T, P, N)                          \
+    ((T *) ggc_realloc_stat ((P), (N) MEM_STAT_INFO))
+
+static inline void *
+ggc_internal_vec_alloc_stat (size_t s, size_t c MEM_STAT_DECL)
+{
+    return ggc_internal_alloc_stat (c * s PASS_MEM_STAT);
+}
+
+static inline void *
+ggc_internal_cleared_vec_alloc_stat (size_t s, size_t c MEM_STAT_DECL)
+{
+    return ggc_internal_cleared_alloc_stat (c * s PASS_MEM_STAT);
+}
+
+#define ggc_internal_cleared_vec_alloc(s, c) \
+    (ggc_internal_cleared_vec_alloc_stat ((s), (c) MEM_STAT_INFO))
+
+static inline void *
+ggc_alloc_atomic_stat (size_t s MEM_STAT_DECL)
+{
+    return ggc_internal_alloc_stat (s PASS_MEM_STAT);
+}
+
+#define ggc_alloc_atomic(S)  (ggc_alloc_atomic_stat ((S) MEM_STAT_INFO))
+
+#define ggc_alloc_cleared_atomic(S)             \
+    (ggc_internal_cleared_alloc_stat ((S) MEM_STAT_INFO))
 
-#define ggc_alloc_rtvec(NELT)                                           \
-  ((rtvec) ggc_alloc_zone (sizeof (struct rtvec_def) + ((NELT) - 1)     \
-                          * sizeof (rtx), &rtl_zone))
+extern void * ggc_cleared_alloc_htab_ignore_args (size_t, size_t);
 
-#define ggc_alloc_tree(LENGTH) ((tree) ggc_alloc_zone (LENGTH, &tree_zone))
+extern void * ggc_cleared_alloc_ptr_array_two_args (size_t, size_t);
 
 #define htab_create_ggc(SIZE, HASH, EQ, DEL) \
-  htab_create_alloc (SIZE, HASH, EQ, DEL, ggc_calloc, ggc_free)
+  htab_create_typed_alloc (SIZE, HASH, EQ, DEL,        \
+                          ggc_cleared_alloc_htab_ignore_args,          \
+                          ggc_cleared_alloc_ptr_array_two_args,        \
+                          ggc_free)
+
+#define splay_tree_new_ggc(COMPARE, ALLOC_TREE, ALLOC_NODE)                 \
+  splay_tree_new_typed_alloc (COMPARE, NULL, NULL, &ALLOC_TREE, &ALLOC_NODE, \
+                             &ggc_splay_dont_free, NULL)
+
+extern void *ggc_splay_alloc (enum gt_types_enum, int, void *);
 
-#define splay_tree_new_ggc(COMPARE)                                     \
-  splay_tree_new_with_allocator (COMPARE, NULL, NULL,                   \
-                                 &ggc_splay_alloc, &ggc_splay_dont_free, \
-                                NULL)
-extern void *ggc_splay_alloc (int, void *);
 extern void ggc_splay_dont_free (void *, void *);
 
 /* Allocate a gc-able string, and fill it with LENGTH bytes from CONTENTS.
    If LENGTH is -1, then CONTENTS is assumed to be a
    null-terminated string and the memory sized accordingly.  */
-extern const char *ggc_alloc_string (const char *contents, int length);
+extern const char *ggc_alloc_string_stat (const char *contents, int length
+                                          MEM_STAT_DECL);
+
+#define ggc_alloc_string(c, l) ggc_alloc_string_stat (c, l MEM_STAT_INFO)
 
 /* Make a copy of S, in GC-able memory.  */
-#define ggc_strdup(S) ggc_alloc_string((S), -1)
+#define ggc_strdup(S) ggc_alloc_string_stat ((S), -1 MEM_STAT_INFO)
 
 /* Invoke the collector.  Garbage collection occurs only when this
    function is called, not during allocations.  */
@@ -279,55 +241,117 @@ extern void ggc_register_root_tab (const struct ggc_root_tab *);
    plugins.  Does nothing if the passed pointer is NULL. */
 extern void ggc_register_cache_tab (const struct ggc_cache_tab *);
 
-/* Return the number of bytes allocated at the indicated address.  */
-extern size_t ggc_get_size (const void *);
-
-/* Write out all GCed objects to F.  */
-extern void gt_pch_save (FILE *f);
-
 /* Read objects previously saved with gt_pch_save from F.  */
 extern void gt_pch_restore (FILE *f);
 \f
 /* Statistics.  */
 
-/* This structure contains the statistics common to all collectors.
-   Particular collectors can extend this structure.  */
-typedef struct ggc_statistics
-{
-  /* At present, we don't really gather any interesting statistics.  */
-  int unused;
-} ggc_statistics;
-
-/* Used by the various collectors to gather and print statistics that
-   do not depend on the collector in use.  */
-extern void ggc_print_common_statistics (FILE *, ggc_statistics *);
-
 /* Print allocation statistics.  */
 extern void ggc_print_statistics (void);
+
 extern void stringpool_statistics (void);
 
 /* Heuristics.  */
 extern void init_ggc_heuristics (void);
 
 /* Zone collection.  */
-#if defined (GGC_ZONE) && !defined (GENERATOR_FILE)
 
 /* For regular rtl allocations.  */
 extern struct alloc_zone rtl_zone;
+
 /* For regular tree allocations.  */
 extern struct alloc_zone tree_zone;
+
 /* For IDENTIFIER_NODE allocations.  */
 extern struct alloc_zone tree_id_zone;
 
+#define ggc_alloc_rtvec_sized(NELT)                                     \
+    (ggc_alloc_zone_vec_rtvec_def (sizeof (rtx),                        \
+                                   sizeof (struct rtvec_def) + ((NELT) - 1), \
+                                   &rtl_zone))
+
+#if defined (GGC_ZONE) && !defined (GENERATOR_FILE)
+
 /* Allocate an object into the specified allocation zone.  */
-extern void *ggc_alloc_zone_stat (size_t, struct alloc_zone * MEM_STAT_DECL);
-# define ggc_alloc_zone(s,z) ggc_alloc_zone_stat (s,z MEM_STAT_INFO)
-# define ggc_alloc_zone_pass_stat(s,z) ggc_alloc_zone_stat (s,z PASS_MEM_STAT)
+extern void *ggc_internal_alloc_zone_stat (size_t,
+                                         struct alloc_zone * MEM_STAT_DECL);
+
+extern void *ggc_internal_cleared_alloc_zone_stat (size_t,
+                                         struct alloc_zone * MEM_STAT_DECL);
+
+static inline void *
+ggc_internal_zone_alloc_stat (struct alloc_zone * z, size_t s MEM_STAT_DECL)
+{
+    return ggc_internal_alloc_zone_stat (s, z PASS_MEM_STAT);
+}
+
+static inline void *
+ggc_internal_zone_cleared_alloc_stat (struct alloc_zone * z, size_t s
+                                      MEM_STAT_DECL)
+{
+    return ggc_internal_cleared_alloc_zone_stat (s, z PASS_MEM_STAT);
+}
+
+static inline void *
+ggc_internal_zone_vec_alloc_stat (struct alloc_zone * z, size_t s, size_t n
+                                  MEM_STAT_DECL)
+{
+    return ggc_internal_alloc_zone_stat (s * n, z PASS_MEM_STAT);
+}
+
+
 #else
 
-# define ggc_alloc_zone(s, z) ggc_alloc (s)
-# define ggc_alloc_zone_pass_stat(s, z) ggc_alloc_stat (s PASS_MEM_STAT)
+static inline void *
+ggc_internal_zone_alloc_stat (struct alloc_zone * z ATTRIBUTE_UNUSED,
+                              size_t s MEM_STAT_DECL)
+{
+    return ggc_internal_alloc_stat (s PASS_MEM_STAT);
+}
+
+static inline void *
+ggc_internal_zone_cleared_alloc_stat (struct alloc_zone * z ATTRIBUTE_UNUSED,
+                                      size_t s MEM_STAT_DECL)
+{
+    return ggc_internal_cleared_alloc_stat (s PASS_MEM_STAT);
+}
+
+static inline void *
+ggc_internal_zone_vec_alloc_stat (struct alloc_zone * z ATTRIBUTE_UNUSED,
+                                  size_t s, size_t n MEM_STAT_DECL)
+{
+    return ggc_internal_vec_alloc_stat (s, n PASS_MEM_STAT);
+}
 
 #endif
 
+/* Memory statistics passing versions of some allocators.  Too few of them to
+   make gengtype produce them, so just define the needed ones here.  */
+static inline struct rtx_def *
+ggc_alloc_zone_rtx_def_stat (struct alloc_zone * z, size_t s MEM_STAT_DECL)
+{
+  return (struct rtx_def *) ggc_internal_zone_alloc_stat (z, s PASS_MEM_STAT);
+}
+
+static inline union tree_node *
+ggc_alloc_zone_tree_node_stat (struct alloc_zone * z, size_t s MEM_STAT_DECL)
+{
+  return (union tree_node *) ggc_internal_zone_alloc_stat (z, s PASS_MEM_STAT);
+}
+
+static inline union tree_node *
+ggc_alloc_zone_cleared_tree_node_stat (struct alloc_zone * z, size_t s
+                                       MEM_STAT_DECL)
+{
+  return (union tree_node *)
+    ggc_internal_zone_cleared_alloc_stat (z, s PASS_MEM_STAT);
+}
+
+static inline union gimple_statement_d *
+ggc_alloc_cleared_gimple_statement_d_stat (size_t s MEM_STAT_DECL)
+{
+  return (union gimple_statement_d *)
+    ggc_internal_cleared_alloc_stat (s PASS_MEM_STAT);
+}
+
 #endif
index be5171bfc28a6f065274dc4591976c20bac0edc9..13b66b6e00780bfb7e82b680cbb37ba08a0cbd2b 100644 (file)
@@ -404,7 +404,7 @@ gsi_insert_before_without_update (gimple_stmt_iterator *i, gimple stmt,
 {
   gimple_seq_node n;
 
-  n = GGC_NEW (struct gimple_seq_node_d);
+  n = ggc_alloc_gimple_seq_node_d ();
   n->prev = n->next = NULL;
   n->stmt = stmt;
   gsi_insert_seq_nodes_before (i, n, n, m);
@@ -439,7 +439,7 @@ gsi_insert_after_without_update (gimple_stmt_iterator *i, gimple stmt,
 {
   gimple_seq_node n;
 
-  n = GGC_NEW (struct gimple_seq_node_d);
+  n = ggc_alloc_gimple_seq_node_d ();
   n->prev = n->next = NULL;
   n->stmt = stmt;
   gsi_insert_seq_nodes_after (i, n, n, m);
index f4c57b2861c542690cfde9cc620d55f4eb420c84..b94998540de647b9126a150fff85ae1b7ef0cf38 100644 (file)
@@ -145,7 +145,7 @@ gimple_alloc_stat (enum gimple_code code, unsigned num_ops MEM_STAT_DECL)
   }
 #endif
 
-  stmt = (gimple) ggc_alloc_cleared_stat (size PASS_MEM_STAT);
+  stmt = ggc_alloc_cleared_gimple_statement_d_stat (size PASS_MEM_STAT);
   gimple_set_code (stmt, code);
   gimple_set_num_ops (stmt, num_ops);
 
@@ -824,7 +824,8 @@ gimple_build_omp_for (gimple_seq body, tree clauses, size_t collapse,
     gimple_omp_set_body (p, body);
   gimple_omp_for_set_clauses (p, clauses);
   p->gimple_omp_for.collapse = collapse;
-  p->gimple_omp_for.iter = GGC_CNEWVEC (struct gimple_omp_for_iter, collapse);
+  p->gimple_omp_for.iter
+      = ggc_alloc_cleared_vec_gimple_omp_for_iter (collapse);
   if (pre_body)
     gimple_omp_for_set_pre_body (p, pre_body);
 
@@ -1074,7 +1075,7 @@ gimple_seq_alloc (void)
     }
   else
     {
-      seq = (gimple_seq) ggc_alloc_cleared (sizeof (*seq));
+      seq = ggc_alloc_cleared_gimple_seq_d ();
 #ifdef GATHER_STATISTICS
       gimple_alloc_counts[(int) gimple_alloc_kind_seq]++;
       gimple_alloc_sizes[(int) gimple_alloc_kind_seq] += sizeof (*seq);
@@ -2122,8 +2123,8 @@ gimple_copy (gimple stmt)
          t = unshare_expr (gimple_omp_for_clauses (stmt));
          gimple_omp_for_set_clauses (copy, t);
          copy->gimple_omp_for.iter
-           = GGC_NEWVEC (struct gimple_omp_for_iter,
-                         gimple_omp_for_collapse (stmt));
+           = ggc_alloc_vec_gimple_omp_for_iter
+           (gimple_omp_for_collapse (stmt));
          for (i = 0; i < gimple_omp_for_collapse (stmt); i++)
            {
              gimple_omp_for_set_cond (copy, i,
index 1a4dacd23319fbc62ec891ae8ef37144b8d68a61..d847e88699737f55733005b846d498849940fe60 100644 (file)
@@ -752,7 +752,7 @@ enum gimple_statement_structure_enum {
 /* Define the overall contents of a gimple tuple.  It may be any of the
    structures declared above for various types of tuples.  */
 
-union GTY ((desc ("gimple_statement_structure (&%h)"))) gimple_statement_d {
+union GTY ((desc ("gimple_statement_structure (&%h)"), variable_size)) gimple_statement_d {
   struct gimple_statement_base GTY ((tag ("GSS_BASE"))) gsbase;
   struct gimple_statement_with_ops GTY ((tag ("GSS_WITH_OPS"))) gsops;
   struct gimple_statement_with_memory_ops_base GTY ((tag ("GSS_WITH_MEM_OPS_BASE"))) gsmembase;
index e3decfbfe19049ea17bef3c515dc64890d1e4478..b4c1362b3a157edd098d272429f27f3d906cefbb 100644 (file)
@@ -246,10 +246,10 @@ get_hard_reg_initial_val (enum machine_mode mode, unsigned int regno)
   ivs = crtl->hard_reg_initial_vals;
   if (ivs == 0)
     {
-      ivs = GGC_NEW (initial_value_struct);
+      ivs = ggc_alloc_initial_value_struct ();
       ivs->num_entries = 0;
       ivs->max_entries = 5;
-      ivs->entries = GGC_NEWVEC (initial_value_pair, 5);
+      ivs->entries = ggc_alloc_vec_initial_value_pair (5);
       crtl->hard_reg_initial_vals = ivs;
     }
 
index f5a6fcbdf1de0a26f594e5027c0dec24dc30eef9..1c1809b61d05222e921f9d5b5fa7f890c0fc512b 100644 (file)
@@ -838,7 +838,7 @@ ipcp_create_replace_map (tree parm_tree, struct ipcp_lattice *lat)
   struct ipa_replace_map *replace_map;
   tree const_val;
 
-  replace_map = GGC_NEW (struct ipa_replace_map);
+  replace_map = ggc_alloc_ipa_replace_map ();
   const_val = build_const_val (lat, TREE_TYPE (parm_tree));
   if (dump_file)
     {
index b3e8cfa61dcb230c48594b501e1aaad6f75d3b42..6aeca33ca804cda20ae106e7a0b34dbf7039771b 100644 (file)
@@ -892,8 +892,8 @@ ipa_compute_jump_functions_for_edge (struct cgraph_edge *cs)
 
   if (ipa_get_cs_argument_count (arguments) == 0 || arguments->jump_functions)
     return;
-  arguments->jump_functions = GGC_CNEWVEC (struct ipa_jump_func,
-                                          ipa_get_cs_argument_count (arguments));
+  arguments->jump_functions = ggc_alloc_cleared_vec_ipa_jump_func
+    (ipa_get_cs_argument_count (arguments));
 
   call = cs->call_stmt;
   gcc_assert (is_gimple_call (call));
@@ -1696,18 +1696,16 @@ duplicate_array (void *src, size_t n)
   return p;
 }
 
-/* Like duplicate_array byt in GGC memory.  */
-
-static void *
-duplicate_ggc_array (void *src, size_t n)
+static struct ipa_jump_func *
+duplicate_ipa_jump_func_array (const struct ipa_jump_func * src, size_t n)
 {
-  void *p;
+  struct ipa_jump_func *p;
 
   if (!src)
     return NULL;
 
-  p = ggc_alloc (n);
-  memcpy (p, src, n);
+  p = ggc_alloc_vec_ipa_jump_func (n);
+  memcpy (p, src, n * sizeof (struct ipa_jump_func));
   return p;
 }
 
@@ -1727,9 +1725,8 @@ ipa_edge_duplication_hook (struct cgraph_edge *src, struct cgraph_edge *dst,
 
   arg_count = ipa_get_cs_argument_count (old_args);
   ipa_set_cs_argument_count (new_args, arg_count);
-  new_args->jump_functions = (struct ipa_jump_func *)
-    duplicate_ggc_array (old_args->jump_functions,
-                        sizeof (struct ipa_jump_func) * arg_count);
+  new_args->jump_functions =
+    duplicate_ipa_jump_func_array (old_args->jump_functions, arg_count);
 
   if (iinlining_processed_edges
       && bitmap_bit_p (iinlining_processed_edges, src->uid))
@@ -2525,8 +2522,8 @@ ipa_read_node_info (struct lto_input_block *ib, struct cgraph_node *node,
       if (!count)
        continue;
 
-      args->jump_functions = GGC_CNEWVEC (struct ipa_jump_func,
-                                         ipa_get_cs_argument_count (args));
+      args->jump_functions = ggc_alloc_cleared_vec_ipa_jump_func
+       (ipa_get_cs_argument_count (args));
       for (k = 0; k < ipa_get_cs_argument_count (args); k++)
        ipa_read_jump_function (ib, ipa_get_ith_jump_func (args, k), data_in);
     }
index ada0b2c290c97d971680770c7f7177f37a60088f..0cf2987427c71b0f42ef97a11ce5a3d6c567ee2c 100644 (file)
--- a/gcc/ipa.c
+++ b/gcc/ipa.c
@@ -887,7 +887,7 @@ cgraph_node_set_new (void)
 {
   cgraph_node_set new_node_set;
 
-  new_node_set = GGC_NEW (struct cgraph_node_set_def);
+  new_node_set = ggc_alloc_cgraph_node_set_def ();
   new_node_set->hashtab = htab_create_ggc (10,
                                           hash_cgraph_node_set_element,
                                           eq_cgraph_node_set_element,
@@ -918,8 +918,7 @@ cgraph_node_set_add (cgraph_node_set set, struct cgraph_node *node)
     }
 
   /* Insert node into hash table.  */
-  element =
-    (cgraph_node_set_element) GGC_NEW (struct cgraph_node_set_element_def);
+  element = ggc_alloc_cgraph_node_set_element_def ();
   element->node = node;
   element->index = VEC_length (cgraph_node_ptr, set->nodes);
   *slot = element;
@@ -1045,7 +1044,7 @@ varpool_node_set_new (void)
 {
   varpool_node_set new_node_set;
 
-  new_node_set = GGC_NEW (struct varpool_node_set_def);
+  new_node_set = ggc_alloc_varpool_node_set_def ();
   new_node_set->hashtab = htab_create_ggc (10,
                                           hash_varpool_node_set_element,
                                           eq_varpool_node_set_element,
@@ -1076,8 +1075,7 @@ varpool_node_set_add (varpool_node_set set, struct varpool_node *node)
     }
 
   /* Insert node into hash table.  */
-  element =
-    (varpool_node_set_element) GGC_NEW (struct varpool_node_set_element_def);
+  element = ggc_alloc_varpool_node_set_element_def ();
   element->node = node;
   element->index = VEC_length (varpool_node_ptr, set->nodes);
   *slot = element;
index 843095dbb935e9fe1490aad5663b8a269c2703be..bd65d5471405cee33f6c035554eda0b80326c3e3 100644 (file)
--- a/gcc/ira.c
+++ b/gcc/ira.c
@@ -1791,8 +1791,7 @@ fix_reg_equiv_init (void)
 
   if (reg_equiv_init_size < max_regno)
     {
-      reg_equiv_init
-       = (rtx *) ggc_realloc (reg_equiv_init, max_regno * sizeof (rtx));
+      reg_equiv_init = GGC_RESIZEVEC (rtx, reg_equiv_init, max_regno);
       while (reg_equiv_init_size < max_regno)
        reg_equiv_init[reg_equiv_init_size++] = NULL_RTX;
       for (i = FIRST_PSEUDO_REGISTER; i < reg_equiv_init_size; i++)
@@ -2371,7 +2370,7 @@ update_equiv_regs (void)
   recorded_label_ref = 0;
 
   reg_equiv = XCNEWVEC (struct equivalence, max_regno);
-  reg_equiv_init = GGC_CNEWVEC (rtx, max_regno);
+  reg_equiv_init = ggc_alloc_cleared_vec_rtx (max_regno);
   reg_equiv_init_size = max_regno;
 
   init_alias_analysis ();
index 4c737883dac7ee126f1f3b773ebf0acf63dfebe4..f06d42006e5b5cc21d69148c4665bd27a7f14f6e 100644 (file)
@@ -1,3 +1,38 @@
+2010-06-08  Laurynas Biveinis  <laurynas.biveinis@gmail.com>
+
+       * jcf-reader.c (jcf_parse_constant_pool): Use typed GC allocation.
+
+       * jcf-parse.c (java_parse_file): Likewise.
+       (process_zip_dir): Likewise.
+
+       * java-tree.h (MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC): Likewise.
+       (MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC): Likewise.
+
+       * expr.c (add_type_assertion): Likewise.
+
+       * decl.c (make_binding_level): Likewise.
+       (java_dup_lang_specific_decl): Likewise.
+
+       * constants.c (set_constant_entry): Likewise.
+       (cpool_for_class): Likewise.
+
+       * class.c (add_method_1): Likewise.
+       (java_treetreehash_new): Likewise.
+
+       * java-tree.h (struct lang_type): Add variable_size GTY option.
+       (struct lang_decl): Likewise.
+
+       * jch.h (struct cpool_entry): Likewise.
+
+       * java-tree.h (java_treetreehash_create): Remove parameter ggc.
+
+       * except.c (prepare_eh_table_type): Update
+       java_treetreehash_create call.
+
+       * class.c (add_method_1): Update java_treetreehash_create call.
+       (java_treetreehash_create): Remove parameter gc.  Use
+       htab_create_ggc.
+
 2010-06-04  Joseph Myers  <joseph@codesourcery.com>
 
        * jvspec.c (lang_specific_driver): Use GCC-specific formats in
index f346ad420f7ec54793d1c90242e54a44aef76252..47b721cd7d07e3edcc46540d0b0c5e41d1ad0776 100644 (file)
@@ -763,13 +763,12 @@ add_method_1 (tree this_class, int access_flags, tree name, tree function_type)
   DECL_CONTEXT (fndecl) = this_class;
 
   DECL_LANG_SPECIFIC (fndecl)
-    = GGC_CNEW (struct lang_decl);
+    = ggc_alloc_cleared_lang_decl(sizeof (struct lang_decl));
   DECL_LANG_SPECIFIC (fndecl)->desc = LANG_DECL_FUNC;
 
   /* Initialize the static initializer test table.  */
-  
-  DECL_FUNCTION_INIT_TEST_TABLE (fndecl) = 
-    java_treetreehash_create (10, 1);
+
+  DECL_FUNCTION_INIT_TEST_TABLE (fndecl) = java_treetreehash_create (10);
 
   /* Initialize the initialized (static) class table. */
   if (access_flags & ACC_STATIC)
@@ -3144,7 +3143,7 @@ java_treetreehash_new (htab_t ht, tree t)
   e = htab_find_slot_with_hash (ht, t, hv, INSERT);
   if (*e == NULL)
     {
-      tthe = (struct treetreehash_entry *) (*ht->alloc_f) (1, sizeof (*tthe));
+      tthe = ggc_alloc_cleared_treetreehash_entry ();
       tthe->key = t;
       *e = tthe;
     }
@@ -3154,14 +3153,10 @@ java_treetreehash_new (htab_t ht, tree t)
 }
 
 htab_t
-java_treetreehash_create (size_t size, int gc)
+java_treetreehash_create (size_t size)
 {
-  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);
+  return htab_create_ggc (size, java_treetreehash_hash,
+                         java_treetreehash_compare, NULL);
 }
 
 /* Break down qualified IDENTIFIER into package and class-name components.
index ca5eb77ce30cc2fba648e5ceb1741100768ec131..f018a707911466c94f36008cd9cce1f1039477f7 100644 (file)
@@ -44,8 +44,11 @@ set_constant_entry (CPool *cpool, int index, int tag, jword value)
   if (cpool->data == NULL)
     {
       cpool->capacity = 100;
-      cpool->tags = GGC_CNEWVEC (uint8, cpool->capacity);
-      cpool->data = GGC_CNEWVEC (union cpool_entry, cpool->capacity);
+      cpool->tags = (uint8 *) ggc_alloc_cleared_atomic (sizeof (uint8)
+                                               * cpool->capacity);
+      cpool->data = ggc_alloc_cleared_vec_cpool_entry (sizeof
+                                                      (union cpool_entry),
+                                                      cpool->capacity);
       cpool->count = 1;
     }
   if (index >= cpool->capacity)
@@ -333,7 +336,7 @@ cpool_for_class (tree klass)
 
   if (cpool == NULL)
     {
-      cpool = GGC_CNEW (struct CPool);
+      cpool = ggc_alloc_cleared_CPool ();
       TYPE_CPOOL (klass) = cpool;
     }
   return cpool;
index f78d68359eba1b7a242e6b680defaf89536b90fb..86ce719213c3b2571f1379f43aaef8269a49b88c 100644 (file)
@@ -1354,7 +1354,7 @@ static struct binding_level *
 make_binding_level (void)
 {
   /* NOSTRICT */
-  return GGC_CNEW (struct binding_level);
+  return ggc_alloc_cleared_binding_level ();
 }
 
 void
@@ -1696,7 +1696,7 @@ java_dup_lang_specific_decl (tree node)
     return;
 
   lang_decl_size = sizeof (struct lang_decl);
-  x = GGC_NEW (struct lang_decl);
+  x = ggc_alloc_lang_decl (lang_decl_size);
   memcpy (x, DECL_LANG_SPECIFIC (node), lang_decl_size);
   DECL_LANG_SPECIFIC (node) = x;
 }
index 03bf4e6853b275312b3e653ccf179ca76332546d..f5a64071204fde0ee8cb9a6d71c6a70607576c29 100644 (file)
@@ -381,7 +381,7 @@ prepare_eh_table_type (tree type)
     return NULL_TREE;
 
   if (TYPE_TO_RUNTIME_MAP (output_class) == NULL)
-    TYPE_TO_RUNTIME_MAP (output_class) = java_treetreehash_create (10, 1);
+    TYPE_TO_RUNTIME_MAP (output_class) = java_treetreehash_create (10);
   
   slot = java_treetreehash_new (TYPE_TO_RUNTIME_MAP (output_class), type);
   if (*slot != NULL)
index 0abcb0d1de7875c60343f0bacb22b0f241630733..042ed1b7297a8b6cf04d0e95b309c3ebbcd99d70 100644 (file)
@@ -463,7 +463,7 @@ add_type_assertion (tree klass, int assertion_code, tree op1, tree op2)
   if (*as_pp)
     return;
 
-  *as_pp = ggc_alloc (sizeof (type_assertion));
+  *as_pp = ggc_alloc_type_assertion ();
   **(type_assertion **)as_pp = as;
 }
 
index f48e4215925146508545730f5a5cb0df364174cb..282b5802ed9244fd5b9a3cc7c3d91fbfdfde417d 100644 (file)
@@ -750,11 +750,12 @@ union GTY((desc ("TREE_CODE (&%h.generic) == IDENTIFIER_NODE"),
     (DECL_LANG_SPECIFIC (NODE)->u.v.vtable)
 
 /* Create a DECL_LANG_SPECIFIC if necessary. */
-#define MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC(T)                 \
-  if (DECL_LANG_SPECIFIC (T) == NULL)                          \
-    {                                                          \
-      DECL_LANG_SPECIFIC ((T)) = GGC_CNEW (struct lang_decl);  \
-      DECL_LANG_SPECIFIC (T)->desc = LANG_DECL_VAR;            \
+#define MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC(T)                       \
+  if (DECL_LANG_SPECIFIC (T) == NULL)                                \
+    {                                                                \
+      DECL_LANG_SPECIFIC ((T))                                       \
+        = ggc_alloc_cleared_lang_decl (sizeof (struct lang_decl));   \
+      DECL_LANG_SPECIFIC (T)->desc = LANG_DECL_VAR;                  \
     }
 
 /* A ConstantExpression, after folding and name resolution. */
@@ -840,7 +841,7 @@ typedef struct GTY(()) type_assertion {
 
 extern tree java_treetreehash_find (htab_t, tree);
 extern tree * java_treetreehash_new (htab_t, tree);
-extern htab_t java_treetreehash_create (size_t size, int ggc);
+extern htab_t java_treetreehash_create (size_t size);
 
 /* DECL_LANG_SPECIFIC for VAR_DECL, PARM_DECL and sometimes FIELD_DECL
    (access methods on outer class fields) and final fields. */
@@ -861,7 +862,7 @@ struct GTY(()) lang_decl_var {
 
 enum lang_decl_desc {LANG_DECL_FUNC, LANG_DECL_VAR};
 
-struct GTY(()) lang_decl {
+struct GTY((variable_size)) lang_decl {
   enum lang_decl_desc desc;
   union lang_decl_u
     {
@@ -879,7 +880,7 @@ struct GTY(()) lang_decl {
 #define MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC(T) \
   if (TYPE_LANG_SPECIFIC ((T)) == NULL)                \
      TYPE_LANG_SPECIFIC ((T))                  \
-     = GGC_CNEW (struct lang_type);
+       = ggc_alloc_cleared_lang_type (sizeof (struct lang_type));
 
 #define TYPE_DUMMY(T)          (TYPE_LANG_SPECIFIC(T)->dummy_class)
 
@@ -924,7 +925,10 @@ typedef struct GTY(()) method_entry_d {
 DEF_VEC_O(method_entry);
 DEF_VEC_ALLOC_O(method_entry,gc);
 
-struct GTY(()) lang_type {
+/* FIXME: the variable_size annotation here is needed because these types are
+   variable-sized in some other frontends.  Due to gengtype deficiency the GTY
+   options of such types have to agree across all frontends. */
+struct GTY((variable_size)) lang_type {
   tree signature;
   struct JCF *jcf;
   struct CPool *cpool;
index eef75aa2516ee86df56eb533036e02293cc58c89..37d27b41b431df5ea45dc73819b91020d464adfd 100644 (file)
@@ -1906,8 +1906,7 @@ java_parse_file (int set_yydebug ATTRIBUTE_UNUSED)
       if (magic == 0xcafebabe)
        {
          CLASS_FILE_P (node) = 1;
-         current_jcf = GGC_NEW (JCF);
-         JCF_ZERO (current_jcf);
+         current_jcf = ggc_alloc_cleared_JCF ();
          current_jcf->read_state = finput;
          current_jcf->filbuf = jcf_filbuf_from_stdio;
          jcf_parse (current_jcf);
@@ -1924,8 +1923,7 @@ java_parse_file (int set_yydebug ATTRIBUTE_UNUSED)
        }
       else if (magic == (JCF_u4)ZIPMAGIC)
        {
-         main_jcf = GGC_NEW (JCF);
-         JCF_ZERO (main_jcf);
+         main_jcf = ggc_alloc_cleared_JCF ();
          main_jcf->read_state = finput;
          main_jcf->filbuf = jcf_filbuf_from_stdio;
          linemap_add (line_table, LC_ENTER, false, filename, 0);
@@ -2181,8 +2179,7 @@ process_zip_dir (FILE *finput)
 
       class_name = compute_class_name (zdir);
       file_name  = XNEWVEC (char, zdir->filename_length+1);
-      jcf = GGC_NEW (JCF);
-      JCF_ZERO (jcf);
+      jcf = ggc_alloc_cleared_JCF ();
 
       strncpy (file_name, class_name_in_zip_dir, zdir->filename_length);
       file_name [zdir->filename_length] = '\0';
index 8970104708bf67f4f482e7ab7e3141466473523e..069b29bf2771f615ec1d084a11047017b765844c 100644 (file)
@@ -331,8 +331,8 @@ jcf_parse_constant_pool (JCF* jcf)
 {
   int i, n;
   JPOOL_SIZE (jcf) = (JCF_FILL (jcf, 2), JCF_readu2 (jcf));
-  jcf->cpool.tags = GGC_NEWVAR (uint8, JPOOL_SIZE (jcf));
-  jcf->cpool.data = GGC_NEWVAR (union cpool_entry, sizeof (jword) * JPOOL_SIZE (jcf));
+  jcf->cpool.tags = (uint8 *) ggc_alloc_atomic (JPOOL_SIZE (jcf));
+  jcf->cpool.data = ggc_alloc_cpool_entry (sizeof (jword) * JPOOL_SIZE (jcf));
   jcf->cpool.tags[0] = 0;
 #ifdef HANDLE_START_CONSTANT_POOL
   HANDLE_START_CONSTANT_POOL (JPOOL_SIZE (jcf));
index 7e8d18d9b3fa76886337a4e8bfb9ebeaf9e99c35..c7a789d6f2b8a6a854f285be5c4aa9a42553fb1a 100644 (file)
@@ -66,7 +66,7 @@ jcf_open_exact_case (const char* filename, int oflag);
 struct JCF;
 typedef int (*jcf_filbuf_t) (struct JCF*, int needed);
 
-union GTY(()) cpool_entry {
+union GTY((variable_size)) cpool_entry {
   jword GTY ((tag ("0"))) w;
   tree GTY ((tag ("1"))) t;
 };
index 2b287a184d783eb9e722ad761c9c999131b3a805..4a291935fbf6ad8c1d04ad82009467321ff40404 100644 (file)
@@ -1703,7 +1703,7 @@ remove_iv (gimple iv_stmt)
    TRANSFORM is the matrix transform that was applied to OLD_LOOPNEST to get
    NEW_LOOPNEST.  */
 
-void
+void 
 lambda_loopnest_to_gcc_loopnest (struct loop *old_loopnest,
                                 VEC(tree,heap) *old_ivs,
                                 VEC(tree,heap) *invariants,
@@ -2131,7 +2131,7 @@ replace_uses_equiv_to_x_with_y (struct loop *loop, gimple stmt, tree x,
       gsi_insert_before (firstbsi, setstmt, GSI_SAME_STMT);
       update_stmt (setstmt);
       SET_USE (use_p, var);
-      h = GGC_NEW (struct tree_map);
+      h = ggc_alloc_tree_map ();
       h->hash = in.hash;
       h->base.from = use;
       h->to = var;
index c819027f5826b34596b8a6911e61cbe3327afeef..8ef11b9dc6caca4f22a798ed98021e2ec4110761 100644 (file)
@@ -238,7 +238,7 @@ static inline void print_lambda_vector (FILE *, lambda_vector, int);
 static inline lambda_vector
 lambda_vector_new (int size)
 {
-  return GGC_CNEWVEC (int, size);
+  return (lambda_vector) ggc_alloc_cleared_atomic (sizeof (int) * size);
 }
 
 
index 854bb9708799967a9b7d66424bc2b1fa0978d3f2..2a2fbc359120a120a3b0581db1c6c6504f0eccfd 100644 (file)
@@ -45,7 +45,7 @@ loop_optimizer_init (unsigned flags)
   struct loops *loops;
 
   gcc_assert (!current_loops);
-  loops = GGC_CNEW (struct loops);
+  loops = ggc_alloc_cleared_loops ();
 
   /* Find the loops.  */
 
index 079593271ed36e9ddf74c61d0fbc5530dab1d441..dd7b954344036dd20647a92b531a6b354d69b97c 100644 (file)
@@ -1570,7 +1570,7 @@ input_node_opt_summary (struct cgraph_node *node,
     {
       int parm_num;
       tree parm;
-      struct ipa_replace_map *map = GGC_NEW (struct ipa_replace_map);
+      struct ipa_replace_map *map = ggc_alloc_ipa_replace_map ();
 
       VEC_safe_push (ipa_replace_map_p, gc, node->clone.tree_map, map);
       for (parm_num = 0, parm = DECL_ARGUMENTS (node->decl); parm_num;
index 9d6d8a360298302248356eeed7dea36b1092c759..7f4065e6df6b82c620284464b5bab2a17201d6da 100644 (file)
@@ -433,11 +433,7 @@ lto_get_decl_name_mapping (struct lto_file_decl_data *decl_data,
 struct lto_in_decl_state *
 lto_new_in_decl_state (void)
 {
-  struct lto_in_decl_state *state;
-
-  state = ((struct lto_in_decl_state *) ggc_alloc (sizeof (*state)));
-  memset (state, 0, sizeof (*state));
-  return state;
+  return ggc_alloc_cleared_lto_in_decl_state ();
 }
 
 /* Delete STATE and its components. */
index 90e6e3937ee544b7185a18ba35bfa8134b155ebb..0c9f90ae5587aa2654b71a80342ede784850dfc2 100644 (file)
@@ -389,7 +389,7 @@ lto_input_eh_catch_list (struct lto_input_block *ib, struct data_in *data_in,
       lto_tag_check_range (tag, LTO_eh_catch, LTO_eh_catch);
 
       /* Read the catch node.  */
-      n = GGC_CNEW (struct eh_catch_d);
+      n = ggc_alloc_cleared_eh_catch_d ();
       n->type_list = lto_input_tree (ib, data_in);
       n->filter_list = lto_input_tree (ib, data_in);
       n->label = lto_input_tree (ib, data_in);
@@ -429,7 +429,7 @@ input_eh_region (struct lto_input_block *ib, struct data_in *data_in, int ix)
   if (tag == LTO_null)
     return NULL;
 
-  r = GGC_CNEW (struct eh_region_d);
+  r = ggc_alloc_cleared_eh_region_d ();
   r->index = lto_input_sleb128 (ib);
 
   gcc_assert (r->index == ix);
@@ -502,7 +502,7 @@ input_eh_lp (struct lto_input_block *ib, struct data_in *data_in, int ix)
 
   lto_tag_check_range (tag, LTO_eh_landing_pad, LTO_eh_landing_pad);
 
-  lp = GGC_CNEW (struct eh_landing_pad_d);
+  lp = ggc_alloc_cleared_eh_landing_pad_d ();
   lp->index = lto_input_sleb128 (ib);
   gcc_assert (lp->index == ix);
   lp->next_lp = (eh_landing_pad) (intptr_t) lto_input_sleb128 (ib);
@@ -707,7 +707,7 @@ make_new_block (struct function *fn, unsigned int index)
   basic_block bb = alloc_block ();
   bb->index = index;
   SET_BASIC_BLOCK_FOR_FUNCTION (fn, index, bb);
-  bb->il.gimple = GGC_CNEW (struct gimple_bb_info);
+  bb->il.gimple = ggc_alloc_cleared_gimple_bb_info ();
   n_basic_blocks_for_function (fn)++;
   bb->flags = 0;
   set_bb_seq (bb, gimple_seq_alloc ());
@@ -1621,7 +1621,7 @@ unpack_ts_real_cst_value_fields (struct bitpack_d *bp, tree expr)
   for (i = 0; i < SIGSZ; i++)
     r.sig[i] = (unsigned long) bp_unpack_value (bp, HOST_BITS_PER_LONG);
 
-  rp = GGC_NEW (REAL_VALUE_TYPE);
+  rp = ggc_alloc_real_value ();
   memcpy (rp, &r, sizeof (REAL_VALUE_TYPE));
   TREE_REAL_CST_PTR (expr) = rp;
 }
index d8978c9ec59e7c94f871355a3c34e8d4d9c0b75c..8ff5bf57c787c928c73b68a53a2e4469bb0f2e20 100644 (file)
@@ -605,6 +605,8 @@ struct GTY(()) lto_file_decl_data
   htab_t GTY((skip)) renaming_hash_table;
 };
 
+typedef struct lto_file_decl_data *lto_file_decl_data_ptr;
+
 struct lto_char_ptr_base
 {
   char *ptr;
index f02824d1f45d2166b48246a40d4a0d7b9e5fb726..6f46a733b427588fc793dc34ab9b863eb885d12f 100644 (file)
@@ -24,7 +24,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "toplev.h"
 #include "tree.h"
 #include "gimple.h"
-#include "ggc.h"       /* lambda.h needs this */
+#include "ggc.h"
 #include "lambda.h"    /* gcd */
 #include "hashtab.h"
 #include "plugin-api.h"
@@ -152,7 +152,7 @@ lto_symtab_register_decl (tree decl,
   if (TREE_CODE (decl) == FUNCTION_DECL)
     gcc_assert (!DECL_ABSTRACT (decl));
 
-  new_entry = GGC_CNEW (struct lto_symtab_entry_def);
+  new_entry = ggc_alloc_cleared_lto_symtab_entry_def ();
   new_entry->id = DECL_ASSEMBLER_NAME (decl);
   new_entry->decl = decl;
   new_entry->resolution = resolution;
index bfa31dcb338ad8268e2c4c8a36504ea4bb6397f0..f021ba8a51ea4608b6fa1d0b751444245214d7f1 100644 (file)
@@ -1,3 +1,10 @@
+2010-06-08  Laurynas Biveinis  <laurynas.biveinis@gmail.com>
+
+       * lto.c (lto_read_in_decl_state): Use typed GC allocation.
+       (lto_file_read): Likewise.
+       (new_partition): Likewise.
+       (read_cgraph_and_symbols): Likewise.
+
 2010-06-07  Joseph Myers  <joseph@codesourcery.com>
 
        * lto-lang.c (flag_no_builtin, flag_no_nonansi_builtin): Remove.
index fd474b68486304c0db41a19df7452f4440c148e8..721d8fbc2ff9bffddd761efb02099ac0555c1bbc 100644 (file)
@@ -158,7 +158,7 @@ lto_read_in_decl_state (struct data_in *data_in, const uint32_t *data,
   for (i = 0; i < LTO_N_DECL_STREAMS; i++)
     {
       uint32_t size = *data++;
-      tree *decls = GGC_NEWVEC (tree, size);
+      tree *decls = ggc_alloc_vec_tree (size);
 
       for (j = 0; j < size; j++)
        {
@@ -364,7 +364,7 @@ lto_file_read (lto_file *file, FILE *resolution_file)
   
   resolutions = lto_resolution_read (resolution_file, file);
 
-  file_data = GGC_NEW (struct lto_file_decl_data);
+  file_data = ggc_alloc_lto_file_decl_data ();
   file_data->file_name = file->filename;
   file_data->section_hash_table = lto_obj_build_section_table (file);
   file_data->renaming_hash_table = lto_create_renaming_table ();
@@ -529,7 +529,7 @@ static GTY (()) VEC(ltrans_partition, gc) *ltrans_partitions;
 static ltrans_partition
 new_partition (const char *name)
 {
-  ltrans_partition part = GGC_NEW (struct ltrans_partition_def);
+  ltrans_partition part = ggc_alloc_ltrans_partition_def ();
   part->cgraph_set = cgraph_node_set_new ();
   part->varpool_set = varpool_node_set_new ();
   part->name = name;
@@ -1435,7 +1435,8 @@ read_cgraph_and_symbols (unsigned nfiles, const char **fnames)
   timevar_push (TV_IPA_LTO_DECL_IO);
 
   /* Set the hooks so that all of the ipa passes can read in their data.  */
-  all_file_decl_data = GGC_CNEWVEC (struct lto_file_decl_data *, nfiles + 1);
+  all_file_decl_data
+    = ggc_alloc_cleared_vec_lto_file_decl_data_ptr (nfiles + 1);
   lto_set_in_hooks (all_file_decl_data, get_section_data, free_section_data);
 
   /* Read the resolution file.  */
index 9934f24d126fa25a03fa8e3911741a57f1a646f9..a05a140c7cbebfd8a69cc0512c542123279ac73d 100644 (file)
@@ -1,3 +1,16 @@
+2010-06-08  Laurynas Biveinis  <laurynas.biveinis@gmail.com>
+
+       * objc-act.h (ALLOC_OBJC_TYPE_LANG_SPECIFIC): Use typed GC
+       allocation.
+
+       * objc-act.c (objc_volatilize_decl): Likewise.
+       (objc_build_string_object): Likewise.
+       (hash_init): Likewise.
+       (hash_enter): Likewise.
+       (hash_add_attr): Likewise.
+       (add_class): Likewise.
+       (start_class): Likewise.
+
 2010-06-05  Steven Bosscher  <steven@gcc.gnu.org>
 
        * objc-act.c: Update include path for moved files.
index f10592fed1e0d22d8f218325c18d59fa4ed0e1a8..2ec9ca04009caf4a8dd0a94f874c80619c638937 100644 (file)
@@ -976,7 +976,7 @@ objc_volatilize_decl (tree decl)
 
       if (!*loc)
        {
-         *loc = ggc_alloc (sizeof (key));
+         *loc = ggc_alloc_volatilized_type ();
          ((struct volatilized_type *) *loc)->type = t;
        }
 
@@ -1986,7 +1986,7 @@ objc_build_string_object (tree string)
     {
       tree var;
       VEC(constructor_elt,gc) *v = NULL;
-      *loc = desc = GGC_NEW (struct string_descriptor);
+      *loc = desc = ggc_alloc_string_descriptor ();
       desc->literal = string;
 
       /* GNU:    (NXConstantString *) & ((__builtin_ObjCString) { NULL, string, length })  */
@@ -6843,10 +6843,8 @@ hash_func (tree sel_name)
 static void
 hash_init (void)
 {
-  nst_method_hash_list
-    = (hash *) ggc_alloc_cleared (SIZEHASHTABLE * sizeof (hash));
-  cls_method_hash_list
-    = (hash *) ggc_alloc_cleared (SIZEHASHTABLE * sizeof (hash));
+  nst_method_hash_list = ggc_alloc_cleared_vec_hash (SIZEHASHTABLE);
+  cls_method_hash_list = ggc_alloc_cleared_vec_hash (SIZEHASHTABLE);
 
   /* Initialize the hash table used to hold the constant string objects.  */
   string_htab = htab_create_ggc (31, string_hash,
@@ -6868,7 +6866,7 @@ hash_enter (hash *hashlist, tree method)
   hash obj;
   int slot = hash_func (METHOD_SEL_NAME (method)) % SIZEHASHTABLE;
 
-  obj = (hash) ggc_alloc (sizeof (struct hashed_entry));
+  obj = ggc_alloc_hashed_entry ();
   obj->list = 0;
   obj->next = hashlist[slot];
   obj->key = method;
@@ -6898,7 +6896,7 @@ hash_add_attr (hash entry, tree value)
 {
   attr obj;
 
-  obj = (attr) ggc_alloc (sizeof (struct hashed_attribute));
+  obj = ggc_alloc_hashed_attribute ();
   obj->next = entry->list;
   obj->value = value;
 
@@ -7096,7 +7094,7 @@ add_class (tree class_name, tree name)
                              INSERT);
   if (!*slot)
     {
-      *slot = (struct interface_tuple *) ggc_alloc_cleared (sizeof (struct interface_tuple));
+      *slot = ggc_alloc_cleared_interface_tuple ();
       (*slot)->id = name;
     }
   (*slot)->class_name = class_name;
@@ -7735,7 +7733,7 @@ continue_class (tree klass)
       uprivate_record = CLASS_STATIC_TEMPLATE (implementation_template);
       objc_instance_type = build_pointer_type (uprivate_record);
 
-      imp_entry = (struct imp_entry *) ggc_alloc (sizeof (struct imp_entry));
+      imp_entry = ggc_alloc_imp_entry ();
 
       imp_entry->next = imp_list;
       imp_entry->imp_context = klass;
index d8bf0f62f931ac103c4120191a0c92eafde3fb82..c8edd64bcf22140496f0a23f75e1c6210a30a48a 100644 (file)
@@ -81,7 +81,8 @@ tree objc_eh_personality (void);
 #define SIZEOF_OBJC_TYPE_LANG_SPECIFIC sizeof (struct lang_type)
 #define ALLOC_OBJC_TYPE_LANG_SPECIFIC(NODE)                            \
   do {                                                                 \
-    TYPE_LANG_SPECIFIC (NODE) = GGC_CNEW (struct lang_type);           \
+    TYPE_LANG_SPECIFIC (NODE)                                          \
+      = ggc_alloc_cleared_lang_type (sizeof (struct lang_type));       \
   } while (0)
 
 #define TYPE_HAS_OBJC_INFO(TYPE)                               \
index e6fbad5984117a24b1b5e12b8c9ca532987adcdf..70731e13c213c3cf975d38a0f5887d9de249a433 100644 (file)
@@ -1,3 +1,8 @@
+2010-06-08  Laurynas Biveinis  <laurynas.biveinis@gmail.com>
+
+       * objcp-decl.h (ALLOC_OBJC_TYPE_LANG_SPECIFIC): Use typed GC
+       allocation.
+
 2010-06-05  Steven Bosscher  <steven@gcc.gnu.org>
 
        * objcp-lang.c: Update include path for moved files.
index 50d98287662b12a89fd4b4ae440d9a1a5495fc9e..1f9f36c6a3f7634e2613010e2cfadb376545f086 100644 (file)
@@ -73,8 +73,8 @@ extern tree objcp_end_compound_stmt (tree, int);
 #undef ALLOC_OBJC_TYPE_LANG_SPECIFIC
 #define ALLOC_OBJC_TYPE_LANG_SPECIFIC(NODE)                            \
   do {                                                                 \
-    TYPE_LANG_SPECIFIC (NODE) = GGC_CNEWVAR                            \
-      (struct lang_type, sizeof (struct lang_type_class));             \
+    TYPE_LANG_SPECIFIC (NODE) = ggc_alloc_cleared_lang_type            \
+      (sizeof (struct lang_type_class));               \
     TYPE_LANG_SPECIFIC (NODE)->u.c.h.is_lang_type_class = 1;           \
   } while (0)
 
index 3a93cdeb7984ee1684eaf10125d05bdbb92823e5..52ecd0fbe48ed100ea017b0c496f4e2cf76de688 100644 (file)
@@ -5887,7 +5887,9 @@ lower_omp_critical (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 
       if (!critical_name_mutexes)
        critical_name_mutexes
-         = splay_tree_new_ggc (splay_tree_compare_pointers);
+         = splay_tree_new_ggc (splay_tree_compare_pointers,
+                               ggc_alloc_splay_tree_tree_node_tree_node_splay_tree_s,
+                               ggc_alloc_splay_tree_tree_node_tree_node_splay_tree_node_s);
 
       n = splay_tree_lookup (critical_name_mutexes, (splay_tree_key) name);
       if (n == NULL)
index e022114a0e3b152acf3a163e059899ac11d4bb23..f6642fbdafd4d3d51830f3a039dd787f8876885d 100644 (file)
@@ -6132,7 +6132,7 @@ set_optab_libfunc (optab optable, enum machine_mode mode, const char *name)
     val = 0;
   slot = (struct libfunc_entry **) htab_find_slot (libfunc_hash, &e, INSERT);
   if (*slot == NULL)
-    *slot = GGC_NEW (struct libfunc_entry);
+    *slot = ggc_alloc_libfunc_entry ();
   (*slot)->optab = (size_t) (optable - &optab_table[0]);
   (*slot)->mode1 = mode;
   (*slot)->mode2 = VOIDmode;
@@ -6159,7 +6159,7 @@ set_conv_libfunc (convert_optab optable, enum machine_mode tmode,
     val = 0;
   slot = (struct libfunc_entry **) htab_find_slot (libfunc_hash, &e, INSERT);
   if (*slot == NULL)
-    *slot = GGC_NEW (struct libfunc_entry);
+    *slot = ggc_alloc_libfunc_entry ();
   (*slot)->optab = (size_t) (optable - &convert_optab_table[0]);
   (*slot)->mode1 = tmode;
   (*slot)->mode2 = fmode;
index ad444fda27a2954518269472188c45e60f4f27db..3c295a033da6116d298e6c903fb6f1c08abf8ec0 100644 (file)
@@ -1120,7 +1120,7 @@ do_per_function (void (*callback) (void *data), void *data)
    keep the array visible to garbage collector to avoid reading collected
    out nodes.  */
 static int nnodes;
-static GTY ((length ("nnodes"))) struct cgraph_node **order;
+static GTY ((length ("nnodes"))) cgraph_node_ptr *order;
 
 /* If we are in IPA mode (i.e., current_function_decl is NULL), call
    function CALLBACK for every function in the call graph.  Otherwise,
@@ -1136,7 +1136,7 @@ do_per_function_toporder (void (*callback) (void *data), void *data)
   else
     {
       gcc_assert (!order);
-      order = GGC_NEWVEC (struct cgraph_node *, cgraph_n_nodes);
+      order = ggc_alloc_vec_cgraph_node_ptr (cgraph_n_nodes);
       nnodes = cgraph_postorder (order);
       for (i = nnodes - 1; i >= 0; i--)
         order[i]->process = 1;
index dda701e8aeda149dfbd66f0a5b6878a46f716db9..d886e9381d2f1cb68ab23027882b9e676d12d2ec 100644 (file)
--- a/gcc/rtl.c
+++ b/gcc/rtl.c
@@ -149,7 +149,7 @@ rtvec_alloc (int n)
 {
   rtvec rt;
 
-  rt = ggc_alloc_rtvec (n);
+  rt = ggc_alloc_rtvec_sized (n);
   /* Clear out the vector.  */
   memset (&rt->elem[0], 0, n * sizeof (rtx));
 
@@ -193,9 +193,8 @@ rtx_size (const_rtx x)
 rtx
 rtx_alloc_stat (RTX_CODE code MEM_STAT_DECL)
 {
-  rtx rt;
-
-  rt = (rtx) ggc_alloc_zone_pass_stat (RTX_CODE_SIZE (code), &rtl_zone);
+  rtx rt = ggc_alloc_zone_rtx_def_stat (&rtl_zone, RTX_CODE_SIZE (code)
+                                        PASS_MEM_STAT);
 
   /* We want to clear everything up to the FLD array.  Normally, this
      is one int, but we don't want to assume that and it isn't very
@@ -337,7 +336,7 @@ rtx
 shallow_copy_rtx_stat (const_rtx orig MEM_STAT_DECL)
 {
   const unsigned int size = rtx_size (orig);
-  rtx const copy = (rtx) ggc_alloc_zone_pass_stat (size, &rtl_zone);
+  rtx const copy = ggc_alloc_zone_rtx_def_stat (&rtl_zone, size PASS_MEM_STAT);
   return (rtx) memcpy (copy, orig, size);
 }
 \f
index 107bb9c05a086cec27ad4ca9d2c14f1833e542b2..5d67d27a382dc44b5efc6b69a9b11a7fdd9393c8 100644 (file)
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -233,7 +233,7 @@ struct GTY(()) object_block {
 /* RTL expression ("rtx").  */
 
 struct GTY((chain_next ("RTX_NEXT (&%h)"),
-                   chain_prev ("RTX_PREV (&%h)"))) rtx_def {
+           chain_prev ("RTX_PREV (&%h)"), variable_size)) rtx_def {
   /* The kind of expression this is.  */
   ENUM_BITFIELD(rtx_code) code: 16;
 
@@ -352,7 +352,7 @@ struct GTY((chain_next ("RTX_NEXT (&%h)"),
    for a variable number of things.  The principle use is inside
    PARALLEL expressions.  */
 
-struct GTY(()) rtvec_def {
+struct GTY((variable_size)) rtvec_def {
   int num_elem;                /* number of elements */
   rtx GTY ((length ("%h.num_elem"))) elem[1];
 };
index 7e9bd91f2d793c80e68597248744f64952bf6014..2ed6485beed557744d231704f20771b7ee422bb3 100644 (file)
@@ -1493,7 +1493,7 @@ if_region_set_false_region (ifsese if_region, sese region)
 
   if (slot)
     {
-      struct loop_exit *loop_exit = GGC_CNEW (struct loop_exit);
+      struct loop_exit *loop_exit = ggc_alloc_cleared_loop_exit ();
 
       memcpy (loop_exit, *((struct loop_exit **) slot), sizeof (struct loop_exit));
       htab_clear_slot (current_loops->exits, slot);
index 79f8cb2c8d1a748e76b852e5f8031dec4ba63bc8..8d45a26befcfd8b3ea2245974ca80d5e9fe8ef33 100644 (file)
@@ -1,5 +1,5 @@
 /* String pool for GCC.
-   Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008
+   Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010
    Free Software Foundation, Inc.
 
 This file is part of GCC.
@@ -31,6 +31,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "coretypes.h"
 #include "tm.h"
 #include "ggc.h"
+#include "ggc-internal.h"
 #include "tree.h"
 #include "symtab.h"
 #include "cpplib.h"
@@ -40,11 +41,13 @@ const char empty_string[] = "";
 
 /* Character strings, each containing a single decimal digit.
    Written this way to save space.  */
-const char digit_vector[] = {
+static const char digit_vector[] = {
   '0', 0, '1', 0, '2', 0, '3', 0, '4', 0,
   '5', 0, '6', 0, '7', 0, '8', 0, '9', 0
 };
 
+#define digit_string(d) (digit_vector + ((d) * 2))
+
 struct ht *ident_hash;
 
 static hashnode alloc_node (hash_table *);
@@ -53,7 +56,7 @@ static int mark_ident (struct cpp_reader *, hashnode, const void *);
 static void *
 stringpool_ggc_alloc (size_t x)
 {
-  return ggc_alloc (x);
+  return ggc_alloc_atomic (x);
 }
 
 /* Initialize the string pool.  */
@@ -78,7 +81,7 @@ alloc_node (hash_table *table ATTRIBUTE_UNUSED)
    nul-terminated string, and the length is calculated using strlen.  */
 
 const char *
-ggc_alloc_string (const char *contents, int length)
+ggc_alloc_string_stat (const char *contents, int length MEM_STAT_DECL)
 {
   char *result;
 
@@ -90,7 +93,7 @@ ggc_alloc_string (const char *contents, int length)
   if (length == 1 && ISDIGIT (contents[0]))
     return digit_string (contents[0] - '0');
 
-  result = GGC_NEWVAR (char, length + 1);
+  result = (char *) ggc_alloc_atomic_stat (length + 1 PASS_MEM_STAT);
   memcpy (result, contents, length);
   result[length] = '\0';
   return (const char *) result;
@@ -215,7 +218,7 @@ gt_pch_n_S (const void *x)
    to restore the string pool.  */
 
 struct GTY(()) string_pool_data {
-  struct ht_identifier * *
+  ht_identifier_ptr *
     GTY((length ("%h.nslots"),
         nested_ptr (union tree_node, "%h ? GCC_IDENT_TO_HT_IDENT (%h) : NULL",
                     "%h ? HT_IDENT_TO_GCC_IDENT (%h) : NULL")))
@@ -231,10 +234,10 @@ static GTY(()) struct string_pool_data * spd;
 void
 gt_pch_save_stringpool (void)
 {
-  spd = GGC_NEW (struct string_pool_data);
+  spd = ggc_alloc_string_pool_data ();
   spd->nslots = ident_hash->nslots;
   spd->nelements = ident_hash->nelements;
-  spd->entries = GGC_NEWVEC (struct ht_identifier *, spd->nslots);
+  spd->entries = ggc_alloc_vec_ht_identifier_ptr (spd->nslots);
   memcpy (spd->entries, ident_hash->entries,
          spd->nslots * sizeof (spd->entries[0]));
 }
index e25bad0c2f74e7343312c4c5c9ec7dabdf6e3479..20da382b1dde7107d8220c64d24aebffa5361a6d 100644 (file)
@@ -1627,7 +1627,7 @@ default_tree_printer (pretty_printer *pp, text_info *text, const char *spec,
 static void *
 realloc_for_line_map (void *ptr, size_t len)
 {
-  return ggc_realloc (ptr, len);
+  return GGC_RESIZEVAR (void, ptr, len);
 }
 
 /* A helper function: used as the allocator function for
@@ -1635,7 +1635,7 @@ realloc_for_line_map (void *ptr, size_t len)
 static void *
 alloc_for_identifier_to_locale (size_t len)
 {
-  return ggc_alloc (len);
+  return ggc_alloc_atomic (len);
 }
 
 /* Initialization of the front end environment, before command line
@@ -1703,7 +1703,7 @@ general_init (const char *argv0)
      table.  */
   init_ggc ();
   init_stringpool ();
-  line_table = GGC_NEW (struct line_maps);
+  line_table = ggc_alloc_line_maps ();
   linemap_init (line_table);
   line_table->reallocator = realloc_for_line_map;
   init_ttree ();
index eca3ed018ce7909dfa40fe89248f66b8a8ba4abe..f46556fe59a902a0b82844c2182c3c823faeb93a 100644 (file)
@@ -436,13 +436,13 @@ create_bb (void *h, void *e, basic_block after)
   gcc_assert (!e);
 
   /* Create and initialize a new basic block.  Since alloc_block uses
-     ggc_alloc_cleared to allocate a basic block, we do not have to
-     clear the newly allocated basic block here.  */
+     GC allocation that clears memory to allocate a basic block, we do
+     not have to clear the newly allocated basic block here.  */
   bb = alloc_block ();
 
   bb->index = last_basic_block;
   bb->flags = BB_NEW;
-  bb->il.gimple = GGC_CNEW (struct gimple_bb_info);
+  bb->il.gimple = ggc_alloc_cleared_gimple_bb_info ();
   set_bb_seq (bb, h ? (gimple_seq) h : gimple_seq_alloc ());
 
   /* Add the new block to the linked list of blocks.  */
index ad03cd235c6668f3deb0fb7b27be4af14e1f1832..485ebcf10fb77050685ac591342a3686cba033ca 100644 (file)
@@ -134,7 +134,7 @@ create_var_ann (tree t)
              || TREE_CODE (t) == PARM_DECL
              || TREE_CODE (t) == RESULT_DECL);
 
-  ann = GGC_CNEW (struct var_ann_d);
+  ann = ggc_alloc_cleared_var_ann_d ();
   *DECL_VAR_ANN_PTR (t) = ann;
 
   return ann;
index 9c17c1e092e461dc7a29d08dcf66921b407e9af6..872d4241dc81b4a40a4033cb49724cace17b8c5a 100644 (file)
@@ -96,7 +96,7 @@ add_stmt_to_eh_lp_fn (struct function *ifun, gimple t, int num)
 
   gcc_assert (num != 0);
 
-  n = GGC_NEW (struct throw_stmt_node);
+  n = ggc_alloc_throw_stmt_node ();
   n->stmt = t;
   n->lp_nr = num;
 
index d5343b447604c9100a0e734f966347f9e11a91ef..1d0a40a30abc146559103c48605abbc2c6ff5ed6 100644 (file)
@@ -1,5 +1,5 @@
 /* Iterator routines for manipulating GENERIC and GIMPLE tree statements.
-   Copyright (C) 2003, 2004, 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2004, 2007, 2008, 2009 Free Software Foundation, Inc.
    Contributed by Andrew MacLeod  <amacleod@redhat.com>
 
 This file is part of GCC.
@@ -130,7 +130,7 @@ tsi_link_before (tree_stmt_iterator *i, tree t, enum tsi_iterator_update mode)
     }
   else
     {
-      head = GGC_NEW (struct tree_statement_list_node);
+      head = ggc_alloc_tree_statement_list_node ();
       head->prev = NULL;
       head->next = NULL;
       head->stmt = t;
@@ -206,7 +206,7 @@ tsi_link_after (tree_stmt_iterator *i, tree t, enum tsi_iterator_update mode)
     }
   else
     {
-      head = GGC_NEW (struct tree_statement_list_node);
+      head = ggc_alloc_tree_statement_list_node ();
       head->prev = NULL;
       head->next = NULL;
       head->stmt = t;
index c97ace88c8b4157eb890ba1bdde3bc639205d9a4..05b63fbea88708948b965175abfa1e16621416c2 100644 (file)
@@ -153,7 +153,7 @@ allocate_phi_node (size_t len)
     }
   else
     {
-      phi = (gimple) ggc_alloc (size);
+      phi = ggc_alloc_gimple_statement_d (size);
 #ifdef GATHER_STATISTICS
       phi_nodes_created++;
        {
index bf564d8dab537f59479481df3e7c0964e2d0ede7..5eb61740bee8bbfd28a906bfa53b43c7efcd6318 100644 (file)
@@ -314,7 +314,7 @@ new_scev_info_str (basic_block instantiated_below, tree var)
 {
   struct scev_info_str *res;
 
-  res = GGC_NEW (struct scev_info_str);
+  res = ggc_alloc_scev_info_str ();
   res->var = var;
   res->chrec = chrec_not_analyzed_yet;
   res->instantiated_below = instantiated_below;
@@ -3017,12 +3017,9 @@ scev_initialize (void)
   loop_iterator li;
   struct loop *loop;
 
-  scalar_evolution_info = htab_create_alloc (100,
-                                            hash_scev_info,
-                                            eq_scev_info,
-                                            del_scev_info,
-                                            ggc_calloc,
-                                            ggc_free);
+
+  scalar_evolution_info = htab_create_ggc (100, hash_scev_info, eq_scev_info,
+                                          del_scev_info);
 
   initialize_scalar_evolutions_analyzer ();
 
index d3890c5b57c5afeffb449c895ac56301e8d1fe65..e6836d77409ba19f24272b43ae47b233fff736a2 100644 (file)
@@ -376,7 +376,7 @@ get_ptr_info (tree t)
   pi = SSA_NAME_PTR_INFO (t);
   if (pi == NULL)
     {
-      pi = GGC_CNEW (struct ptr_info_def);
+      pi = ggc_alloc_cleared_ptr_info_def ();
       pt_solution_reset (&pi->pt);
       SSA_NAME_PTR_INFO (t) = pi;
     }
index 279718ee5e4aca853abc716b7994c3b603b45c78..accf17a4c237574a1abdca2aa9b2b70d209368fb 100644 (file)
@@ -2521,7 +2521,7 @@ record_estimate (struct loop *loop, tree bound, double_int i_bound,
      list.  */
   if (upper)
     {
-      struct nb_iter_bound *elt = GGC_NEW (struct nb_iter_bound);
+      struct nb_iter_bound *elt = ggc_alloc_nb_iter_bound ();
 
       elt->bound = i_bound;
       elt->stmt = at_stmt;
index 68be8fae8f484b522ab1eecf93e16658a92e3ebb..05e0f6ba2491f4c6766e43c45021654cdbaba978 100644 (file)
@@ -320,9 +320,10 @@ ssa_operand_alloc (unsigned size)
          gcc_unreachable ();
        }
 
-      ptr = (struct ssa_operand_memory_d *)
-             ggc_alloc (sizeof (void *)
-                        + gimple_ssa_operands (cfun)->ssa_operand_mem_size);
+
+      ptr = ggc_alloc_ssa_operand_memory_d (sizeof (void *)
+                        + gimple_ssa_operands (cfun)->ssa_operand_mem_size);
+
       ptr->next = gimple_ssa_operands (cfun)->operand_memory;
       gimple_ssa_operands (cfun)->operand_memory = ptr;
       gimple_ssa_operands (cfun)->operand_memory_index = 0;
index 13d29c3ab013e94177794486234d8e5b4f54770c..4c586f7fb27da1462fcc6dd1e6c5b0784bf8b98e 100644 (file)
@@ -54,7 +54,7 @@ typedef struct use_optype_d *use_optype_p;
    operand memory manager.  Operands are suballocated out of this block.  The
    MEM array varies in size.  */
 
-struct GTY((chain_next("%h.next"))) ssa_operand_memory_d {
+struct GTY((chain_next("%h.next"), variable_size)) ssa_operand_memory_d {
   struct ssa_operand_memory_d *next;
   char mem[1];
 };
index f22605626d367127c8d7adb15cdb018cebcb73c2..05fd6d971f2456e303a866d1d016863622d8dea5 100644 (file)
    keep the set of called functions for indirect calls.
 
    And probably more.  */
-
-static GTY ((if_marked ("tree_map_marked_p"), param_is (struct tree_map)))
+static GTY ((if_marked ("tree_map_marked_p"), param_is (struct heapvar_map)))
 htab_t heapvar_for_stmt;
 
 static bool use_field_sensitive = true;
@@ -379,7 +378,7 @@ heapvar_insert (tree from, unsigned HOST_WIDE_INT offset, tree to)
   struct heapvar_map *h;
   void **loc;
 
-  h = GGC_NEW (struct heapvar_map);
+  h = ggc_alloc_heapvar_map ();
   h->map.base.from = from;
   h->offset = offset;
   h->map.hash = heapvar_map_hash (h);
index ec9c50ceb7743de91c04e408e8902007df4bb4f0..866ce6eb2b7656d09e430a625daee54c017a9131 100644 (file)
@@ -1114,7 +1114,7 @@ uid_ssaname_map_hash (const void *item)
 void
 init_tree_ssa (struct function *fn)
 {
-  fn->gimple_df = GGC_CNEW (struct gimple_df);
+  fn->gimple_df = ggc_alloc_cleared_gimple_df ();
   fn->gimple_df->referenced_vars = htab_create_ggc (20, uid_decl_map_hash,
                                                    uid_decl_map_eq, NULL);
   fn->gimple_df->default_defs = htab_create_ggc (20, uid_ssaname_map_hash,
index cc7683dfabe6604ae6b69630ac6486df761e749a..79b844ffe7c477597339db00c3593272bd90133f 100644 (file)
@@ -269,7 +269,7 @@ duplicate_ssa_name_ptr_info (tree name, struct ptr_info_def *ptr_info)
   if (!ptr_info)
     return;
 
-  new_ptr_info = GGC_NEW (struct ptr_info_def);
+  new_ptr_info = ggc_alloc_ptr_info_def ();
   *new_ptr_info = *ptr_info;
 
   SSA_NAME_PTR_INFO (name) = new_ptr_info;
index 7b1a489a03f43ad58768ede74b12b70b8039d662..3c1a8782cbbdd6dc4841726aec7a9928897c8e6f 100644 (file)
@@ -853,13 +853,9 @@ make_node_stat (enum tree_code code MEM_STAT_DECL)
   tree_node_sizes[(int) kind] += length;
 #endif
 
-  if (code == IDENTIFIER_NODE)
-    t = (tree) ggc_alloc_zone_pass_stat (length, &tree_id_zone);
-  else
-    t = (tree) ggc_alloc_zone_pass_stat (length, &tree_zone);
-
-  memset (t, 0, length);
-
+  t = ggc_alloc_zone_cleared_tree_node_stat (
+               (code == IDENTIFIER_NODE) ? &tree_id_zone : &tree_zone,
+               length PASS_MEM_STAT);
   TREE_SET_CODE (t, code);
 
   switch (type)
@@ -952,7 +948,7 @@ copy_node_stat (tree node MEM_STAT_DECL)
   gcc_assert (code != STATEMENT_LIST);
 
   length = tree_size (node);
-  t = (tree) ggc_alloc_zone_pass_stat (length, &tree_zone);
+  t = ggc_alloc_zone_tree_node_stat (&tree_zone, length PASS_MEM_STAT);
   memcpy (t, node, length);
 
   TREE_CHAIN (t) = 0;
@@ -1385,7 +1381,7 @@ build_fixed (tree type, FIXED_VALUE_TYPE f)
   FIXED_VALUE_TYPE *fp;
 
   v = make_node (FIXED_CST);
-  fp = GGC_NEW (FIXED_VALUE_TYPE);
+  fp = ggc_alloc_fixed_value ();
   memcpy (fp, &f, sizeof (FIXED_VALUE_TYPE));
 
   TREE_TYPE (v) = type;
@@ -1406,7 +1402,7 @@ build_real (tree type, REAL_VALUE_TYPE d)
      Consider doing it via real_convert now.  */
 
   v = make_node (REAL_CST);
-  dp = GGC_NEW (REAL_VALUE_TYPE);
+  dp = ggc_alloc_real_value ();
   memcpy (dp, &d, sizeof (REAL_VALUE_TYPE));
 
   TREE_TYPE (v) = type;
@@ -1466,7 +1462,7 @@ build_string (int len, const char *str)
   tree_node_sizes[(int) c_kind] += length;
 #endif
 
-  s = ggc_alloc_tree (length);
+  s = ggc_alloc_tree_node (length);
 
   memset (s, 0, sizeof (struct tree_common));
   TREE_SET_CODE (s, STRING_CST);
@@ -1555,7 +1551,7 @@ make_tree_binfo_stat (unsigned base_binfos MEM_STAT_DECL)
   tree_node_sizes[(int) binfo_kind] += length;
 #endif
 
-  t = (tree) ggc_alloc_zone_pass_stat (length, &tree_zone);
+  t = ggc_alloc_zone_tree_node_stat (&tree_zone, length PASS_MEM_STAT);
 
   memset (t, 0, offsetof (struct tree_binfo, base_binfos));
 
@@ -1580,9 +1576,7 @@ make_tree_vec_stat (int len MEM_STAT_DECL)
   tree_node_sizes[(int) vec_kind] += length;
 #endif
 
-  t = (tree) ggc_alloc_zone_pass_stat (length, &tree_zone);
-
-  memset (t, 0, length);
+  t = ggc_alloc_zone_cleared_tree_node_stat (&tree_zone, length PASS_MEM_STAT);
 
   TREE_SET_CODE (t, TREE_VEC);
   TREE_VEC_LENGTH (t) = len;
@@ -2093,13 +2087,13 @@ build_tree_list_vec_stat (const VEC(tree,gc) *vec MEM_STAT_DECL)
    purpose and value fields are PURPOSE and VALUE
    and whose TREE_CHAIN is CHAIN.  */
 
-tree
+tree 
 tree_cons_stat (tree purpose, tree value, tree chain MEM_STAT_DECL)
 {
   tree node;
 
-  node = (tree) ggc_alloc_zone_pass_stat (sizeof (struct tree_list), &tree_zone);
-
+  node = ggc_alloc_zone_tree_node_stat (&tree_zone, sizeof (struct tree_list)
+                                        PASS_MEM_STAT);
   memset (node, 0, sizeof (struct tree_common));
 
 #ifdef GATHER_STATISTICS
@@ -3578,7 +3572,7 @@ build1_stat (enum tree_code code, tree type, tree node MEM_STAT_DECL)
 
   gcc_assert (TREE_CODE_LENGTH (code) == 1);
 
-  t = (tree) ggc_alloc_zone_pass_stat (length, &tree_zone);
+  t = ggc_alloc_zone_tree_node_stat (&tree_zone, length PASS_MEM_STAT);
 
   memset (t, 0, sizeof (struct tree_common));
 
@@ -5638,7 +5632,7 @@ decl_priority_info (tree decl)
   h = (struct tree_priority_map *) *loc;
   if (!h)
     {
-      h = GGC_CNEW (struct tree_priority_map);
+      h = ggc_alloc_cleared_tree_priority_map ();
       *loc = h;
       h->base.from = decl;
       h->init = DEFAULT_INIT_PRIORITY;
@@ -5717,7 +5711,7 @@ decl_debug_expr_insert (tree from, tree to)
   struct tree_decl_map *h;
   void **loc;
 
-  h = GGC_NEW (struct tree_decl_map);
+  h = ggc_alloc_tree_decl_map ();
   h->base.from = from;
   h->to = to;
   loc = htab_find_slot_with_hash (debug_expr_for_decl, h, DECL_UID (from),
@@ -5748,7 +5742,7 @@ decl_value_expr_insert (tree from, tree to)
   struct tree_decl_map *h;
   void **loc;
 
-  h = GGC_NEW (struct tree_decl_map);
+  h = ggc_alloc_tree_decl_map ();
   h->base.from = from;
   h->to = to;
   loc = htab_find_slot_with_hash (value_expr_for_decl, h, DECL_UID (from),
@@ -5921,7 +5915,7 @@ type_hash_add (hashval_t hashcode, tree type)
   struct type_hash *h;
   void **loc;
 
-  h = GGC_NEW (struct type_hash);
+  h = ggc_alloc_type_hash ();
   h->hash = hashcode;
   h->type = type;
   loc = htab_find_slot_with_hash (type_hash_table, h, hashcode, INSERT);
@@ -9422,7 +9416,7 @@ build_omp_clause (location_t loc, enum omp_clause_code code)
   length = omp_clause_num_ops[code];
   size = (sizeof (struct tree_omp_clause) + (length - 1) * sizeof (tree));
 
-  t = GGC_NEWVAR (union tree_node, size);
+  t = ggc_alloc_tree_node (size);
   memset (t, 0, size);
   TREE_SET_CODE (t, OMP_CLAUSE);
   OMP_CLAUSE_SET_CODE (t, code);
@@ -9455,9 +9449,7 @@ build_vl_exp_stat (enum tree_code code, int len MEM_STAT_DECL)
   tree_node_sizes[(int) e_kind] += length;
 #endif
 
-  t = (tree) ggc_alloc_zone_pass_stat (length, &tree_zone);
-
-  memset (t, 0, length);
+  t = ggc_alloc_zone_cleared_tree_node_stat (&tree_zone, length PASS_MEM_STAT);
 
   TREE_SET_CODE (t, code);
 
index 31d80dfa7e26d5635fd2723695f2635382300282..683eaea4da917f5fdd0fa3a7b9054d473ad4528c 100644 (file)
@@ -3458,7 +3458,7 @@ extern tree build_target_option_node (void);
    for various types of node.  */
 
 union GTY ((ptr_alias (union lang_tree_node),
-                     desc ("tree_node_structure (&%h)"))) tree_node {
+           desc ("tree_node_structure (&%h)"), variable_size)) tree_node {
   struct tree_base GTY ((tag ("TS_BASE"))) base;
   struct tree_common GTY ((tag ("TS_COMMON"))) common;
   struct tree_int_cst GTY ((tag ("TS_INT_CST"))) int_cst;
index 3f8fd02aa8f92f92d065dac0268e7112df564b8e..e02126b07d7c158a3ffaa9dd7f869806f8a5804f 100644 (file)
@@ -378,7 +378,7 @@ emutls_decl (tree decl)
                       VAR_DECL, get_emutls_object_name (name),
                       get_emutls_object_type ());
 
-      h = GGC_NEW (struct tree_map);
+      h = ggc_alloc_tree_map ();
       h->hash = in.hash;
       h->base.from = decl;
       h->to = to;
@@ -553,7 +553,7 @@ get_unnamed_section (unsigned int flags, void (*callback) (const void *),
 {
   section *sect;
 
-  sect = GGC_NEW (section);
+  sect = ggc_alloc_section ();
   sect->unnamed.common.flags = flags | SECTION_UNNAMED;
   sect->unnamed.callback = callback;
   sect->unnamed.data = data;
@@ -570,7 +570,7 @@ get_noswitch_section (unsigned int flags, noswitch_section_callback callback)
 {
   section *sect;
 
-  sect = GGC_NEW (section);
+  sect = ggc_alloc_section ();
   sect->noswitch.common.flags = flags | SECTION_NOSWITCH;
   sect->noswitch.callback = callback;
 
@@ -591,7 +591,7 @@ get_section (const char *name, unsigned int flags, tree decl)
   flags |= SECTION_NAMED;
   if (*slot == NULL)
     {
-      sect = GGC_NEW (section);
+      sect = ggc_alloc_section ();
       sect->named.common.flags = flags;
       sect->named.name = ggc_strdup (name);
       sect->named.decl = decl;
@@ -640,8 +640,7 @@ get_block_for_section (section *sect)
   block = (struct object_block *) *slot;
   if (block == NULL)
     {
-      block = (struct object_block *)
-       ggc_alloc_cleared (sizeof (struct object_block));
+      block = ggc_alloc_cleared_object_block ();
       block->sect = sect;
       *slot = block;
     }
@@ -661,7 +660,7 @@ create_block_symbol (const char *label, struct object_block *block,
 
   /* Create the extended SYMBOL_REF.  */
   size = RTX_HDR_SIZE + sizeof (struct block_symbol);
-  symbol = (rtx) ggc_alloc_zone (size, &rtl_zone);
+  symbol = ggc_alloc_zone_rtx_def (size, &rtl_zone);
 
   /* Initialize the normal SYMBOL_REF fields.  */
   memset (symbol, 0, size);
@@ -3324,7 +3323,7 @@ build_constant_desc (tree exp)
   int labelno;
   tree decl;
 
-  desc = GGC_NEW (struct constant_descriptor_tree);
+  desc = ggc_alloc_constant_descriptor_tree ();
   desc->value = copy_constant (exp);
 
   /* Propagate marked-ness to copied constant.  */
@@ -3724,7 +3723,7 @@ create_constant_pool (void)
 {
   struct rtx_constant_pool *pool;
 
-  pool = GGC_NEW (struct rtx_constant_pool);
+  pool = ggc_alloc_rtx_constant_pool ();
   pool->const_rtx_htab = htab_create_ggc (31, const_desc_rtx_hash,
                                          const_desc_rtx_eq, NULL);
   pool->first = NULL;
@@ -3790,7 +3789,7 @@ force_const_mem (enum machine_mode mode, rtx x)
     return copy_rtx (desc->mem);
 
   /* Otherwise, create a new descriptor.  */
-  desc = GGC_NEW (struct constant_descriptor_rtx);
+  desc = ggc_alloc_constant_descriptor_rtx ();
   *slot = desc;
 
   /* Align the location counter as required by EXP's data type.  */
index a3be2629ce12587eb574aa82775bd95dfa5ddc1a..94c949e35508eb9cc4e287cbaadbe6b1c6b61042 100644 (file)
@@ -139,7 +139,7 @@ varpool_node (tree decl)
     htab_find_slot (varpool_hash, &key, INSERT);
   if (*slot)
     return *slot;
-  node = GGC_CNEW (struct varpool_node);
+  node = ggc_alloc_cleared_varpool_node ();
   node->decl = decl;
   node->order = cgraph_order++;
   node->next = varpool_nodes;
@@ -651,7 +651,7 @@ varpool_extra_name_alias (tree alias, tree decl)
   if (*slot)
     return false;
 
-  alias_node = GGC_CNEW (struct varpool_node);
+  alias_node = ggc_alloc_cleared_varpool_node ();
   alias_node->decl = alias;
   alias_node->alias = 1;
   alias_node->extra_name = decl_node;
index e65a8f2b9acf8202fbee1459852a3c99c2d7ee59..0c6f91c9599c5a9350a4b0d4d166a70cc45ab51f 100644 (file)
@@ -1,3 +1,12 @@
+2010-06-08  Laurynas Biveinis  <laurynas.biveinis@gmail.com>
+
+       * splay-tree.h: Update copyright years.
+       (splay_tree_s): Document fields.
+       (splay_tree_new_typed_alloc): New.
+
+       * hashtab.h: Update copyright years.
+       (htab_create_typed_alloc): New.
+
 2010-06-01  Rafael Espindola  <espindola@google.com>
 
        * plugin-api.h (ld_plugin_tag): Add LDPT_OUTPUT_NAME.
index 1cd406daf31148c720e9ed118559508e6a165d47..4bb65d6c7a2b4135b8526ca5ec4255987934ed6d 100644 (file)
@@ -1,5 +1,5 @@
 /* An expandable hash tables datatype.  
-   Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005, 2009
+   Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005, 2009, 2010
    Free Software Foundation, Inc.
    Contributed by Vladimir Makarov (vmakarov@cygnus.com).
 
@@ -157,6 +157,9 @@ extern htab_t       htab_create_alloc_ex (size_t, htab_hash,
                                       void *, htab_alloc_with_arg,
                                       htab_free_with_arg);
 
+extern htab_t  htab_create_typed_alloc (size_t, htab_hash, htab_eq, htab_del,
+                                       htab_alloc, htab_alloc, htab_free);
+
 /* Backward-compatibility functions.  */
 extern htab_t htab_create (size_t, htab_hash, htab_eq, htab_del);
 extern htab_t htab_try_create (size_t, htab_hash, htab_eq, htab_del);
index 57a96c4a3de58a5504a931d4e19bc4eb0386a9da..480b2c43e7d4d654e971ce77a6ac67dc860ebfcc 100644 (file)
@@ -1,5 +1,5 @@
 /* A splay-tree datatype.  
-   Copyright 1998, 1999, 2000, 2002, 2005, 2007, 2009
+   Copyright 1998, 1999, 2000, 2002, 2005, 2007, 2009, 2010
    Free Software Foundation, Inc.
    Contributed by Mark Mitchell (mark@markmitchell.com).
 
@@ -119,9 +119,13 @@ struct GTY(()) splay_tree_s {
   /* The deallocate-value function.  NULL if no cleanup is necessary.  */
   splay_tree_delete_value_fn delete_value;
 
-  /* Allocate/free functions, and a data pointer to pass to them.  */
+  /* Node allocate function.  Takes allocate_data as a parameter. */
   splay_tree_allocate_fn allocate;
+
+  /* Free function for nodes and trees.  Takes allocate_data as a parameter.  */
   splay_tree_deallocate_fn deallocate;
+
+  /* Parameter for allocate/free functions.  */
   void * GTY((skip)) allocate_data;
 };
 
@@ -136,6 +140,13 @@ extern splay_tree splay_tree_new_with_allocator (splay_tree_compare_fn,
                                                 splay_tree_allocate_fn,
                                                 splay_tree_deallocate_fn,
                                                 void *);
+extern splay_tree splay_tree_new_typed_alloc (splay_tree_compare_fn,
+                                             splay_tree_delete_key_fn,
+                                             splay_tree_delete_value_fn,
+                                             splay_tree_allocate_fn,
+                                             splay_tree_allocate_fn,
+                                             splay_tree_deallocate_fn,
+                                             void *);
 extern void splay_tree_delete (splay_tree);
 extern splay_tree_node splay_tree_insert (splay_tree,
                                          splay_tree_key,
index 042d6fed4cfcceb713016880c77ee48491d39847..84201a4a5108f1b5605efc97ae6f1e00aab8b86c 100644 (file)
@@ -1,3 +1,7 @@
+2010-06-08  Laurynas Biveinis  <laurynas.biveinis@gmail.com>
+
+       * include/symtab.h (ht_identifier_ptr): New.
+
 2010-06-03  Joern Rennecke <joern.rennecke@embecosm.com>
            Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
index ebb56007a03c598b191ef5364eb612a76680b2dc..b0a2f2697aa0738943eae1ccbd090181fbec6093 100644 (file)
@@ -28,6 +28,7 @@ along with this program; see the file COPYING3.  If not see
 /* This is what each hash table entry points to.  It may be embedded
    deeply within another object.  */
 typedef struct ht_identifier ht_identifier;
+typedef struct ht_identifier *ht_identifier_ptr;
 struct GTY(()) ht_identifier {
   const unsigned char *str;
   unsigned int len;
index 744f6ae1aefcc0b4e3d4e591089e6ce31611f3d4..3b9fdc9871f56a5f1b2437974c4df93b6038e780 100644 (file)
@@ -1,3 +1,15 @@
+2010-06-08  Laurynas Biveinis  <laurynas.biveinis@gmail.com>
+
+       * splay-tree.c: Update copyright years.
+       (splay_tree_new_typed_alloc): New.
+       (splay_tree_new_with_allocator): Use it.
+
+       * hashtab.c: Update copyright years.
+       (htab_create_typed_alloc): New.
+       (htab_create_alloc): Use it.
+
+       * functions.texi: Regenerate.
+
 2010-06-03  Joern Rennecke <joern.rennecke@embecosm.com>
            Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
index 72ca56cbd44dcd192ff59afdb14116fcf99a668f..d9fef8cb7b348efe2c8d065747a823beb3ad6475 100644 (file)
@@ -3,7 +3,7 @@
 @c Edit the *.c files, configure with --enable-maintainer-mode,
 @c run 'make stamp-functions' and gather-docs will build a new copy.
 
-@c safe-ctype.c:25
+@c splay-tree.c:277
 @defvr Extension HOST_CHARSET
 This macro indicates the basic character set and encoding used by the
 host: more precisely, the encoding used for character constants in
@@ -24,6 +24,25 @@ The host character set is some variant of EBCDIC.  (Only one of the
 nineteen EBCDIC varying characters is tested; exercise caution.)
 @end ftable
 @end defvr
+@deftypefn Supplemental splay_tree splay_tree_new_with_typed_alloc
+(splay_tree_compare_fn @var{compare_fn},
+splay_tree_delete_key_fn @var{delete_key_fn},
+splay_tree_delete_value_fn @var{delete_value_fn},
+splay_tree_allocate_fn @var{tree_allocate_fn},
+splay_tree_allocate_fn @var{node_allocate_fn},
+splay_tree_deallocate_fn @var{deallocate_fn},
+void * @var{allocate_data})
+
+This function creates a splay tree that uses two different allocators
+@var{tree_allocate_fn} and @var{node_allocate_fn} to use for allocating the
+tree itself and its nodes respectively.  This is useful when variables of
+different types need to be allocated with different allocators.
+
+The splay tree will use @var{compare_fn} to compare nodes,
+@var{delete_key_fn} to deallocate keys, and @var{delete_value_fn} to
+deallocate values.
+
+@end deftypefn
 
 @c alloca.c:26
 @deftypefn Replacement void* alloca (size_t @var{size})
@@ -477,6 +496,24 @@ systems.
 
 @end deftypefn
 
+@c hashtab.c:336
+@deftypefn Supplemental htab_t htab_create_typed_alloc (size_t @var{size},
+htab_hash @var{hash_f}, htab_eq @var{eq_f}, htab_del @var{del_f},
+htab_alloc @var{alloc_tab_f}, htab_alloc @var{alloc_f},
+htab_free @var{free_f})
+
+This function creates a hash table that uses two different allocators
+@var{alloc_tab_f} and @var{alloc_f} to use for allocating the table itself
+and its entries respectively.  This is useful when variables of different
+types need to be allocated with different allocators.
+
+The created hash table is slightly larger than @var{size} and it is
+initially empty (all the hash table entries are @code{HTAB_EMPTY_ENTRY}).
+The function returns the created hash table, or @code{NULL} if memory
+allocation fails.
+
+@end deftypefn
+
 @c index.c:5
 @deftypefn Supplemental char* index (char *@var{s}, int @var{c})
 
index 8c89bfcd8393e8fde1e6b38847bd85f618c5ae25..359e3ea569ec084fb58fda182cb0a3526ad20420 100644 (file)
@@ -1,5 +1,5 @@
 /* An expandable hash tables datatype.  
-   Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2009
+   Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2009, 2010
    Free Software Foundation, Inc.
    Contributed by Vladimir Makarov (vmakarov@cygnus.com).
 
@@ -290,6 +290,19 @@ htab_mod_m2 (hashval_t hash, htab_t htab)
 htab_t
 htab_create_alloc (size_t size, htab_hash hash_f, htab_eq eq_f,
                    htab_del del_f, htab_alloc alloc_f, htab_free free_f)
+{
+  return htab_create_typed_alloc (size, hash_f, eq_f, del_f, alloc_f, alloc_f,
+                                 free_f);
+}
+
+/* As above, but uses the variants of ALLOC_F and FREE_F which accept
+   an extra argument.  */
+
+htab_t
+htab_create_alloc_ex (size_t size, htab_hash hash_f, htab_eq eq_f,
+                     htab_del del_f, void *alloc_arg,
+                     htab_alloc_with_arg alloc_f,
+                     htab_free_with_arg free_f)
 {
   htab_t result;
   unsigned int size_prime_index;
@@ -297,14 +310,14 @@ htab_create_alloc (size_t size, htab_hash hash_f, htab_eq eq_f,
   size_prime_index = higher_prime_index (size);
   size = prime_tab[size_prime_index].prime;
 
-  result = (htab_t) (*alloc_f) (1, sizeof (struct htab));
+  result = (htab_t) (*alloc_f) (alloc_arg, 1, sizeof (struct htab));
   if (result == NULL)
     return NULL;
-  result->entries = (PTR *) (*alloc_f) (size, sizeof (PTR));
+  result->entries = (PTR *) (*alloc_f) (alloc_arg, size, sizeof (PTR));
   if (result->entries == NULL)
     {
       if (free_f != NULL)
-       (*free_f) (result);
+       (*free_f) (alloc_arg, result);
       return NULL;
     }
   result->size = size;
@@ -312,19 +325,37 @@ htab_create_alloc (size_t size, htab_hash hash_f, htab_eq eq_f,
   result->hash_f = hash_f;
   result->eq_f = eq_f;
   result->del_f = del_f;
-  result->alloc_f = alloc_f;
-  result->free_f = free_f;
+  result->alloc_arg = alloc_arg;
+  result->alloc_with_arg_f = alloc_f;
+  result->free_with_arg_f = free_f;
   return result;
 }
 
-/* As above, but use the variants of alloc_f and free_f which accept
-   an extra argument.  */
+/*
+
+@deftypefn Supplemental htab_t htab_create_typed_alloc (size_t @var{size},
+htab_hash @var{hash_f}, htab_eq @var{eq_f}, htab_del @var{del_f},
+htab_alloc @var{alloc_tab_f}, htab_alloc @var{alloc_f},
+htab_free @var{free_f})
+
+This function creates a hash table that uses two different allocators
+@var{alloc_tab_f} and @var{alloc_f} to use for allocating the table itself
+and its entries respectively.  This is useful when variables of different
+types need to be allocated with different allocators.
+
+The created hash table is slightly larger than @var{size} and it is
+initially empty (all the hash table entries are @code{HTAB_EMPTY_ENTRY}).
+The function returns the created hash table, or @code{NULL} if memory
+allocation fails.
+
+@end deftypefn
+
+*/
 
 htab_t
-htab_create_alloc_ex (size_t size, htab_hash hash_f, htab_eq eq_f,
-                      htab_del del_f, void *alloc_arg,
-                      htab_alloc_with_arg alloc_f,
-                     htab_free_with_arg free_f)
+htab_create_typed_alloc (size_t size, htab_hash hash_f, htab_eq eq_f,
+                        htab_del del_f, htab_alloc alloc_tab_f,
+                        htab_alloc alloc_f, htab_free free_f)
 {
   htab_t result;
   unsigned int size_prime_index;
@@ -332,14 +363,14 @@ htab_create_alloc_ex (size_t size, htab_hash hash_f, htab_eq eq_f,
   size_prime_index = higher_prime_index (size);
   size = prime_tab[size_prime_index].prime;
 
-  result = (htab_t) (*alloc_f) (alloc_arg, 1, sizeof (struct htab));
+  result = (htab_t) (*alloc_tab_f) (1, sizeof (struct htab));
   if (result == NULL)
     return NULL;
-  result->entries = (PTR *) (*alloc_f) (alloc_arg, size, sizeof (PTR));
+  result->entries = (PTR *) (*alloc_f) (size, sizeof (PTR));
   if (result->entries == NULL)
     {
       if (free_f != NULL)
-       (*free_f) (alloc_arg, result);
+       (*free_f) (result);
       return NULL;
     }
   result->size = size;
@@ -347,12 +378,12 @@ htab_create_alloc_ex (size_t size, htab_hash hash_f, htab_eq eq_f,
   result->hash_f = hash_f;
   result->eq_f = eq_f;
   result->del_f = del_f;
-  result->alloc_arg = alloc_arg;
-  result->alloc_with_arg_f = alloc_f;
-  result->free_with_arg_f = free_f;
+  result->alloc_f = alloc_f;
+  result->free_f = free_f;
   return result;
 }
 
+
 /* Update the function pointers and allocation parameter in the htab_t.  */
 
 void
index d7ed86813dc553007827b3208590e8e9ffff9b0a..bf1a0f3f151f36d641510c86de9c592b9b055686 100644 (file)
@@ -1,5 +1,6 @@
 /* A splay-tree datatype.  
-   Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2000, 2001, 2009,
+   2010 Free Software Foundation, Inc.
    Contributed by Mark Mitchell (mark@markmitchell.com).
 
 This file is part of GNU CC.
@@ -265,13 +266,53 @@ splay_tree_new_with_allocator (splay_tree_compare_fn compare_fn,
                                splay_tree_deallocate_fn deallocate_fn,
                                void *allocate_data)
 {
-  splay_tree sp = (splay_tree) (*allocate_fn) (sizeof (struct splay_tree_s),
-                                               allocate_data);
+  return
+    splay_tree_new_typed_alloc (compare_fn, delete_key_fn, delete_value_fn,
+                               allocate_fn, allocate_fn, deallocate_fn,
+                               allocate_data);
+}
+
+/*
+
+@deftypefn Supplemental splay_tree splay_tree_new_with_typed_alloc
+(splay_tree_compare_fn @var{compare_fn},
+splay_tree_delete_key_fn @var{delete_key_fn},
+splay_tree_delete_value_fn @var{delete_value_fn},
+splay_tree_allocate_fn @var{tree_allocate_fn},
+splay_tree_allocate_fn @var{node_allocate_fn},
+splay_tree_deallocate_fn @var{deallocate_fn},
+void * @var{allocate_data})
+
+This function creates a splay tree that uses two different allocators
+@var{tree_allocate_fn} and @var{node_allocate_fn} to use for allocating the
+tree itself and its nodes respectively.  This is useful when variables of
+different types need to be allocated with different allocators.
+
+The splay tree will use @var{compare_fn} to compare nodes,
+@var{delete_key_fn} to deallocate keys, and @var{delete_value_fn} to
+deallocate values.
+
+@end deftypefn
+
+*/
+
+splay_tree
+splay_tree_new_typed_alloc (splay_tree_compare_fn compare_fn,
+                           splay_tree_delete_key_fn delete_key_fn,
+                           splay_tree_delete_value_fn delete_value_fn,
+                           splay_tree_allocate_fn tree_allocate_fn,
+                           splay_tree_allocate_fn node_allocate_fn,
+                           splay_tree_deallocate_fn deallocate_fn,
+                           void * allocate_data)
+{
+  splay_tree sp = (splay_tree) (*tree_allocate_fn)
+    (sizeof (struct splay_tree_s), allocate_data);
+
   sp->root = 0;
   sp->comp = compare_fn;
   sp->delete_key = delete_key_fn;
   sp->delete_value = delete_value_fn;
-  sp->allocate = allocate_fn;
+  sp->allocate = node_allocate_fn;
   sp->deallocate = deallocate_fn;
   sp->allocate_data = allocate_data;
 
@@ -313,10 +354,10 @@ splay_tree_insert (splay_tree sp, splay_tree_key key, splay_tree_value value)
     {
       /* Create a new node, and insert it at the root.  */
       splay_tree_node node;
-      
+
       node = ((splay_tree_node)
-              (*sp->allocate) (sizeof (struct splay_tree_node_s),
-                               sp->allocate_data));
+             (*sp->allocate) (sizeof (struct splay_tree_node_s),
+                              sp->allocate_data));
       node->key = key;
       node->value = value;