summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog398
-rw-r--r--gcc/Makefile.in10
-rw-r--r--gcc/ada/ChangeLog24
-rw-r--r--gcc/ada/gcc-interface/ada-tree.h35
-rw-r--r--gcc/ada/gcc-interface/decl.c2
-rw-r--r--gcc/ada/gcc-interface/misc.c2
-rw-r--r--gcc/ada/gcc-interface/trans.c12
-rw-r--r--gcc/ada/gcc-interface/utils.c10
-rw-r--r--gcc/alias.c8
-rw-r--r--gcc/bitmap.c4
-rw-r--r--gcc/bitmap.h2
-rw-r--r--gcc/c-decl.c20
-rw-r--r--gcc/c-family/ChangeLog10
-rw-r--r--gcc/c-family/c-common.c2
-rw-r--r--gcc/c-family/c-common.h2
-rw-r--r--gcc/c-family/c-pragma.c4
-rw-r--r--gcc/c-parser.c4
-rw-r--r--gcc/cfg.c10
-rw-r--r--gcc/cfgloop.c14
-rw-r--r--gcc/cfgrtl.c2
-rw-r--r--gcc/cgraph.c8
-rw-r--r--gcc/config/alpha/alpha.c9
-rw-r--r--gcc/config/arm/arm.c2
-rw-r--r--gcc/config/avr/avr.c3
-rw-r--r--gcc/config/bfin/bfin.c6
-rw-r--r--gcc/config/cris/cris.c2
-rw-r--r--gcc/config/darwin.c2
-rw-r--r--gcc/config/frv/frv.c2
-rw-r--r--gcc/config/i386/i386.c7
-rw-r--r--gcc/config/i386/winnt.c4
-rw-r--r--gcc/config/ia64/ia64.c2
-rw-r--r--gcc/config/iq2000/iq2000.c6
-rw-r--r--gcc/config/m32c/m32c.c6
-rw-r--r--gcc/config/mep/mep.c8
-rw-r--r--gcc/config/mips/mips.c7
-rw-r--r--gcc/config/mmix/mmix.c2
-rw-r--r--gcc/config/moxie/moxie.c2
-rw-r--r--gcc/config/pa/pa.c12
-rw-r--r--gcc/config/rs6000/rs6000.c6
-rw-r--r--gcc/config/s390/s390.c2
-rw-r--r--gcc/config/score/score3.c2
-rw-r--r--gcc/config/score/score7.c2
-rw-r--r--gcc/config/sparc/sparc.c2
-rw-r--r--gcc/config/xtensa/xtensa.c2
-rw-r--r--gcc/cp/ChangeLog49
-rw-r--r--gcc/cp/class.c5
-rw-r--r--gcc/cp/cp-objcp-common.c2
-rw-r--r--gcc/cp/cp-tree.h8
-rw-r--r--gcc/cp/decl.c8
-rw-r--r--gcc/cp/lex.c11
-rw-r--r--gcc/cp/name-lookup.c14
-rw-r--r--gcc/cp/parser.c18
-rw-r--r--gcc/cp/pt.c10
-rw-r--r--gcc/cp/typeck2.c2
-rw-r--r--gcc/dbxout.c2
-rw-r--r--gcc/doc/gty.texi37
-rw-r--r--gcc/doc/tm.texi2
-rw-r--r--gcc/dwarf2asm.c4
-rw-r--r--gcc/dwarf2out.c61
-rw-r--r--gcc/emit-rtl.c9
-rw-r--r--gcc/except.c10
-rw-r--r--gcc/fortran/ChangeLog14
-rw-r--r--gcc/fortran/f95-lang.c3
-rw-r--r--gcc/fortran/trans-decl.c6
-rw-r--r--gcc/fortran/trans-types.c8
-rw-r--r--gcc/fortran/trans.h7
-rw-r--r--gcc/function.c13
-rw-r--r--gcc/gengtype.c241
-rw-r--r--gcc/ggc-common.c38
-rw-r--r--gcc/ggc-internal.h121
-rw-r--r--gcc/ggc-none.c15
-rw-r--r--gcc/ggc-page.c38
-rw-r--r--gcc/ggc-zone.c69
-rw-r--r--gcc/ggc.h292
-rw-r--r--gcc/gimple-iterator.c4
-rw-r--r--gcc/gimple.c11
-rw-r--r--gcc/gimple.h2
-rw-r--r--gcc/integrate.c4
-rw-r--r--gcc/ipa-cp.c2
-rw-r--r--gcc/ipa-prop.c25
-rw-r--r--gcc/ipa.c10
-rw-r--r--gcc/ira.c5
-rw-r--r--gcc/java/ChangeLog35
-rw-r--r--gcc/java/class.c19
-rw-r--r--gcc/java/constants.c9
-rw-r--r--gcc/java/decl.c4
-rw-r--r--gcc/java/except.c2
-rw-r--r--gcc/java/expr.c2
-rw-r--r--gcc/java/java-tree.h22
-rw-r--r--gcc/java/jcf-parse.c9
-rw-r--r--gcc/java/jcf-reader.c4
-rw-r--r--gcc/java/jcf.h2
-rw-r--r--gcc/lambda-code.c4
-rw-r--r--gcc/lambda.h2
-rw-r--r--gcc/loop-init.c2
-rw-r--r--gcc/lto-cgraph.c2
-rw-r--r--gcc/lto-section-in.c6
-rw-r--r--gcc/lto-streamer-in.c10
-rw-r--r--gcc/lto-streamer.h2
-rw-r--r--gcc/lto-symtab.c4
-rw-r--r--gcc/lto/ChangeLog7
-rw-r--r--gcc/lto/lto.c9
-rw-r--r--gcc/objc/ChangeLog13
-rw-r--r--gcc/objc/objc-act.c18
-rw-r--r--gcc/objc/objc-act.h3
-rw-r--r--gcc/objcp/ChangeLog5
-rw-r--r--gcc/objcp/objcp-decl.h4
-rw-r--r--gcc/omp-low.c4
-rw-r--r--gcc/optabs.c4
-rw-r--r--gcc/passes.c4
-rw-r--r--gcc/rtl.c9
-rw-r--r--gcc/rtl.h4
-rw-r--r--gcc/sese.c2
-rw-r--r--gcc/stringpool.c19
-rw-r--r--gcc/toplev.c6
-rw-r--r--gcc/tree-cfg.c6
-rw-r--r--gcc/tree-dfa.c2
-rw-r--r--gcc/tree-eh.c2
-rw-r--r--gcc/tree-iterator.c6
-rw-r--r--gcc/tree-phinodes.c2
-rw-r--r--gcc/tree-scalar-evolution.c11
-rw-r--r--gcc/tree-ssa-alias.c2
-rw-r--r--gcc/tree-ssa-loop-niter.c2
-rw-r--r--gcc/tree-ssa-operands.c7
-rw-r--r--gcc/tree-ssa-operands.h2
-rw-r--r--gcc/tree-ssa-structalias.c5
-rw-r--r--gcc/tree-ssa.c2
-rw-r--r--gcc/tree-ssanames.c2
-rw-r--r--gcc/tree.c46
-rw-r--r--gcc/tree.h2
-rw-r--r--gcc/varasm.c19
-rw-r--r--gcc/varpool.c4
-rw-r--r--include/ChangeLog9
-rw-r--r--include/hashtab.h5
-rw-r--r--include/splay-tree.h15
-rw-r--r--libcpp/ChangeLog4
-rw-r--r--libcpp/include/symtab.h1
-rw-r--r--libiberty/ChangeLog12
-rw-r--r--libiberty/functions.texi39
-rw-r--r--libiberty/hashtab.c67
-rw-r--r--libiberty/splay-tree.c55
141 files changed, 1757 insertions, 684 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 1711151e2f6..46703abeece 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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.
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index fed7fe8d498..a19022564b3 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -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
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 2c2b307062e..accf5bbda62 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -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.
diff --git a/gcc/ada/gcc-interface/ada-tree.h b/gcc/ada/gcc-interface/ada-tree.h
index 60a5595fe22..220ed57c215 100644
--- a/gcc/ada/gcc-interface/ada-tree.h
+++ b/gcc/ada/gcc-interface/ada-tree.h
@@ -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)
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c
index cf9f025ba2c..fb4769b7bb2 100644
--- a/gcc/ada/gcc-interface/decl.c
+++ b/gcc/ada/gcc-interface/decl.c
@@ -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;
}
diff --git a/gcc/ada/gcc-interface/misc.c b/gcc/ada/gcc-interface/misc.c
index a80afbdc80e..229663b7ce2 100644
--- a/gcc/ada/gcc-interface/misc.c
+++ b/gcc/ada/gcc-interface/misc.c
@@ -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);
diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c
index 1732069b699..7a94393b0e0 100644
--- a/gcc/ada/gcc-interface/trans.c
+++ b/gcc/ada/gcc-interface/trans.c
@@ -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;
}
diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c
index f10b788fe1a..ebb70259c45 100644
--- a/gcc/ada/gcc-interface/utils.c
+++ b/gcc/ada/gcc-interface/utils.c
@@ -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)
diff --git a/gcc/alias.c b/gcc/alias.c
index a4083a1a13b..38209316118 100644
--- a/gcc/alias.c
+++ b/gcc/alias.c
@@ -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. */
diff --git a/gcc/bitmap.c b/gcc/bitmap.c
index 8f4a56606bd..21a05fc4fa1 100644
--- a/gcc/bitmap.c
+++ b/gcc/bitmap.c
@@ -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));
diff --git a/gcc/bitmap.h b/gcc/bitmap.h
index bbc0e20cfef..1163b2f53d1 100644
--- a/gcc/bitmap.h
+++ b/gcc/bitmap.h
@@ -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
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index 96ef2999844..740ca3588f0 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -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;
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index d0b51567eae..5370a8e8b32 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -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,
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index c3fa8e654dc..7c841b1d076 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -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. */
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index c6701b8bb07..6948b8231e8 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -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];
};
diff --git a/gcc/c-family/c-pragma.c b/gcc/c-family/c-pragma.c
index a48bf4fc50e..ab922696ddd 100644
--- a/gcc/c-family/c-pragma.c
+++ b/gcc/c-family/c-pragma.c
@@ -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;
diff --git a/gcc/c-parser.c b/gcc/c-parser.c
index 56d5d83eccd..04506df176e 100644
--- a/gcc/c-parser.c
+++ b/gcc/c-parser.c
@@ -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. */
diff --git a/gcc/cfg.c b/gcc/cfg.c
index ee6af697468..563582ff296 100644
--- 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;
diff --git a/gcc/cfgloop.c b/gcc/cfgloop.c
index 858e75b3f52..c0d9a4cacc2 100644
--- a/gcc/cfgloop.c
+++ b/gcc/cfgloop.c
@@ -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)
{
diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c
index abdbf9d8598..bf617373762 100644
--- a/gcc/cfgrtl.c
+++ b/gcc/cfgrtl.c
@@ -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 ();
}
diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index 105cdab14a6..557c205e3d1 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -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;
diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c
index 4daf3df4d65..0246d5a5b6d 100644
--- a/gcc/config/alpha/alpha.c
+++ b/gcc/config/alpha/alpha.c
@@ -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);
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 31c13543e90..e44e94946fb 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -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;
diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c
index d8942c5c081..531a4128bf3 100644
--- a/gcc/config/avr/avr.c
+++ b/gcc/config/avr/avr.c
@@ -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. */
diff --git a/gcc/config/bfin/bfin.c b/gcc/config/bfin/bfin.c
index 152e910ee67..c187bf3bbc7 100644
--- a/gcc/config/bfin/bfin.c
+++ b/gcc/config/bfin/bfin.c
@@ -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. */
diff --git a/gcc/config/cris/cris.c b/gcc/config/cris/cris.c
index 62ee7d0c330..9d38d0fee47 100644
--- a/gcc/config/cris/cris.c
+++ b/gcc/config/cris/cris.c
@@ -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.
diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c
index 9a9dde160c5..7eedd95eab3 100644
--- a/gcc/config/darwin.c
+++ b/gcc/config/darwin.c
@@ -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;
diff --git a/gcc/config/frv/frv.c b/gcc/config/frv/frv.c
index d4009693cd8..e72dd2af1f9 100644
--- a/gcc/config/frv/frv.c
+++ b/gcc/config/frv/frv.c
@@ -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 ();
}
/* Implement TARGET_SCHED_ISSUE_RATE. */
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index df18fdbd7eb..1bdc6891df3 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -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);
diff --git a/gcc/config/i386/winnt.c b/gcc/config/i386/winnt.c
index 3750e0c4b08..c20a2ae89fc 100644
--- a/gcc/config/i386/winnt.c
+++ b/gcc/config/i386/winnt.c
@@ -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;
diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c
index e1e3dff8b59..a568ee4f849 100644
--- a/gcc/config/ia64/ia64.c
+++ b/gcc/config/ia64/ia64.c
@@ -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 ();
}
static enum attr_itanium_class ia64_safe_itanium_class (rtx);
diff --git a/gcc/config/iq2000/iq2000.c b/gcc/config/iq2000/iq2000.c
index 0e51eca7965..fc8c4e56789 100644
--- a/gcc/config/iq2000/iq2000.c
+++ b/gcc/config/iq2000/iq2000.c
@@ -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. */
diff --git a/gcc/config/m32c/m32c.c b/gcc/config/m32c/m32c.c
index cfc4a1593b6..3280d14e78e 100644
--- a/gcc/config/m32c/m32c.c
+++ b/gcc/config/m32c/m32c.c
@@ -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
diff --git a/gcc/config/mep/mep.c b/gcc/config/mep/mep.c
index a4b167da4b7..4d5e68218e8 100644
--- a/gcc/config/mep/mep.c
+++ b/gcc/config/mep/mep.c
@@ -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);
diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
index 33f6047e166..a699238ba1c 100644
--- a/gcc/config/mips/mips.c
+++ b/gcc/config/mips/mips.c
@@ -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
diff --git a/gcc/config/mmix/mmix.c b/gcc/config/mmix/mmix.c
index de66ac4e40d..4b35e06df4f 100644
--- a/gcc/config/mmix/mmix.c
+++ b/gcc/config/mmix/mmix.c
@@ -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.
diff --git a/gcc/config/moxie/moxie.c b/gcc/config/moxie/moxie.c
index 1e692b18d7e..b87b80f4744 100644
--- a/gcc/config/moxie/moxie.c
+++ b/gcc/config/moxie/moxie.c
@@ -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 ();
}
diff --git a/gcc/config/pa/pa.c b/gcc/config/pa/pa.c
index 5ef405b4f44..024053e413f 100644
--- a/gcc/config/pa/pa.c
+++ b/gcc/config/pa/pa.c
@@ -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 ();
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 9e31a22e5f8..a4f847d99bd 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -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 ();
}
/* 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;
diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c
index fb6913f2d60..1b742357f26 100644
--- a/gcc/config/s390/s390.c
+++ b/gcc/config/s390/s390.c
@@ -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
diff --git a/gcc/config/score/score3.c b/gcc/config/score/score3.c
index 724cf61bc64..3e20f16dc33 100644
--- a/gcc/config/score/score3.c
+++ b/gcc/config/score/score3.c
@@ -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));
diff --git a/gcc/config/score/score7.c b/gcc/config/score/score7.c
index 547ac00517a..464d97cee22 100644
--- a/gcc/config/score/score7.c
+++ b/gcc/config/score/score7.c
@@ -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));
diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c
index 9e33c740b01..8b44dbeb80d 100644
--- a/gcc/config/sparc/sparc.c
+++ b/gcc/config/sparc/sparc.c
@@ -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
diff --git a/gcc/config/xtensa/xtensa.c b/gcc/config/xtensa/xtensa.c
index 76e872dddb3..fe66711af39 100644
--- a/gcc/config/xtensa/xtensa.c
+++ b/gcc/config/xtensa/xtensa.c
@@ -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 ();
}
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index bf6833664cf..931cbe141eb 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index c6da4cd28bb..14224aa694d 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -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),
diff --git a/gcc/cp/cp-objcp-common.c b/gcc/cp/cp-objcp-common.c
index 63ce56b3c30..9cfe7702aca 100644
--- a/gcc/cp/cp-objcp-common.c
+++ b/gcc/cp/cp-objcp-common.c
@@ -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),
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index f507a21a78d..eaf34591cc9 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -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); \
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 171e160b2af..706eee9b666 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -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;
diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c
index 1bae86fd692..9e3b57b75ef 100644
--- a/gcc/cp/lex.c
+++ b/gcc/cp/lex.c
@@ -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;
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index 0c759c6404a..db4246c5f70 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -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;
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 92f778619eb..0a7006a7d1b 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -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;
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index d66c1bf6e2b..58b746fe16d 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -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;
diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index e7b97c4d5c7..335b1f3499a 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -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))
diff --git a/gcc/dbxout.c b/gcc/dbxout.c
index a314e7b4430..be1e6fdcd0d 100644
--- a/gcc/dbxout.c
+++ b/gcc/dbxout.c
@@ -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. */
diff --git a/gcc/doc/gty.texi b/gcc/doc/gty.texi
index 56da9b55fc9..05a279c7d7c 100644
--- a/gcc/doc/gty.texi
+++ b/gcc/doc/gty.texi
@@ -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}")
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index 34f94c6e29d..12f7d81b68f 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -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
diff --git a/gcc/dwarf2asm.c b/gcc/dwarf2asm.c
index 516a26004f0..8e16a21d031 100644
--- a/gcc/dwarf2asm.c
+++ b/gcc/dwarf2asm.c
@@ -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);
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 0cdd2dc274d..6cbe8dc092c 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -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. */
diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c
index 3f7fb5f895a..eb3ea93c9b3 100644
--- a/gcc/emit-rtl.c
+++ b/gcc/emit-rtl.c
@@ -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,
diff --git a/gcc/except.c b/gcc/except.c
index d166a9a1527..cb4d8058ba5 100644
--- a/gcc/except.c
+++ b/gcc/except.c
@@ -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;
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index edb50382ee1..10fe680f6f4 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -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
diff --git a/gcc/fortran/f95-lang.c b/gcc/fortran/f95-lang.c
index 14525dc2552..f76e75c4b1f 100644
--- a/gcc/fortran/f95-lang.c
+++ b/gcc/fortran/f95-lang.c
@@ -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;
diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index 224474aeff2..7ebdac4d1cf 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -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,
diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c
index d794c2fb668..38bae7d4cea 100644
--- a/gcc/fortran/trans-types.c
+++ b/gcc/fortran/trans-types.c
@@ -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;
diff --git a/gcc/fortran/trans.h b/gcc/fortran/trans.h
index 9ee81480c5b..72f8a436788 100644
--- a/gcc/fortran/trans.h
+++ b/gcc/fortran/trans.h
@@ -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.
diff --git a/gcc/function.c b/gcc/function.c
index 771552913f1..c5b80b0e153 100644
--- a/gcc/function.c
+++ b/gcc/function.c
@@ -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;
diff --git a/gcc/gengtype.c b/gcc/gengtype.c
index 90e64349365..b16a33ac04d 100644
--- a/gcc/gengtype.c
+++ b/gcc/gengtype.c
@@ -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 ();
diff --git a/gcc/ggc-common.c b/gcc/ggc-common.c
index 76bf975c86f..175629b3129 100644
--- a/gcc/ggc-common.c
+++ b/gcc/ggc-common.c
@@ -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
index 00000000000..7b875eec9cb
--- /dev/null
+++ b/gcc/ggc-internal.h
@@ -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
diff --git a/gcc/ggc-none.c b/gcc/ggc-none.c
index 2d45a61ca5f..f9c48cb8cc5 100644
--- a/gcc/ggc-none.c
+++ b/gcc/ggc-none.c
@@ -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;
diff --git a/gcc/ggc-page.c b/gcc/ggc-page.c
index 67483f19349..27862be8ef4 100644
--- a/gcc/ggc-page.c
+++ b/gcc/ggc-page.c
@@ -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;
diff --git a/gcc/ggc-zone.c b/gcc/ggc-zone.c
index a8154cc4de0..12dc8740529 100644
--- a/gcc/ggc-zone.c
+++ b/gcc/ggc-zone.c
@@ -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;
diff --git a/gcc/ggc.h b/gcc/ggc.h
index 33b78f1b03d..7f2144c0f12 100644
--- 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 *);
-
-
-/* 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);
+
+
+/* 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);
/* 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
diff --git a/gcc/gimple-iterator.c b/gcc/gimple-iterator.c
index be5171bfc28..13b66b6e007 100644
--- a/gcc/gimple-iterator.c
+++ b/gcc/gimple-iterator.c
@@ -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);
diff --git a/gcc/gimple.c b/gcc/gimple.c
index f4c57b2861c..b94998540de 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -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,
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 1a4dacd2331..d847e886997 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -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;
diff --git a/gcc/integrate.c b/gcc/integrate.c
index e3decfbfe19..b4c1362b3a1 100644
--- a/gcc/integrate.c
+++ b/gcc/integrate.c
@@ -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;
}
diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
index f5a6fcbdf1d..1c1809b61d0 100644
--- a/gcc/ipa-cp.c
+++ b/gcc/ipa-cp.c
@@ -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)
{
diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c
index b3e8cfa61dc..6aeca33ca80 100644
--- a/gcc/ipa-prop.c
+++ b/gcc/ipa-prop.c
@@ -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);
}
diff --git a/gcc/ipa.c b/gcc/ipa.c
index ada0b2c290c..0cf2987427c 100644
--- 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;
diff --git a/gcc/ira.c b/gcc/ira.c
index 843095dbb93..bd65d547140 100644
--- 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 ();
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog
index 4c737883dac..f06d42006e5 100644
--- a/gcc/java/ChangeLog
+++ b/gcc/java/ChangeLog
@@ -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
diff --git a/gcc/java/class.c b/gcc/java/class.c
index f346ad420f7..47b721cd7d0 100644
--- a/gcc/java/class.c
+++ b/gcc/java/class.c
@@ -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.
diff --git a/gcc/java/constants.c b/gcc/java/constants.c
index ca5eb77ce30..f018a707911 100644
--- a/gcc/java/constants.c
+++ b/gcc/java/constants.c
@@ -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;
diff --git a/gcc/java/decl.c b/gcc/java/decl.c
index f78d68359eb..86ce719213c 100644
--- a/gcc/java/decl.c
+++ b/gcc/java/decl.c
@@ -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;
}
diff --git a/gcc/java/except.c b/gcc/java/except.c
index 03bf4e6853b..f5a64071204 100644
--- a/gcc/java/except.c
+++ b/gcc/java/except.c
@@ -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)
diff --git a/gcc/java/expr.c b/gcc/java/expr.c
index 0abcb0d1de7..042ed1b7297 100644
--- a/gcc/java/expr.c
+++ b/gcc/java/expr.c
@@ -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;
}
diff --git a/gcc/java/java-tree.h b/gcc/java/java-tree.h
index f48e4215925..282b5802ed9 100644
--- a/gcc/java/java-tree.h
+++ b/gcc/java/java-tree.h
@@ -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;
diff --git a/gcc/java/jcf-parse.c b/gcc/java/jcf-parse.c
index eef75aa2516..37d27b41b43 100644
--- a/gcc/java/jcf-parse.c
+++ b/gcc/java/jcf-parse.c
@@ -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';
diff --git a/gcc/java/jcf-reader.c b/gcc/java/jcf-reader.c
index 8970104708b..069b29bf277 100644
--- a/gcc/java/jcf-reader.c
+++ b/gcc/java/jcf-reader.c
@@ -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));
diff --git a/gcc/java/jcf.h b/gcc/java/jcf.h
index 7e8d18d9b3f..c7a789d6f2b 100644
--- a/gcc/java/jcf.h
+++ b/gcc/java/jcf.h
@@ -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;
};
diff --git a/gcc/lambda-code.c b/gcc/lambda-code.c
index 2b287a184d7..4a291935fbf 100644
--- a/gcc/lambda-code.c
+++ b/gcc/lambda-code.c
@@ -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;
diff --git a/gcc/lambda.h b/gcc/lambda.h
index c819027f582..8ef11b9dc6c 100644
--- a/gcc/lambda.h
+++ b/gcc/lambda.h
@@ -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);
}
diff --git a/gcc/loop-init.c b/gcc/loop-init.c
index 854bb970879..2a2fbc35912 100644
--- a/gcc/loop-init.c
+++ b/gcc/loop-init.c
@@ -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. */
diff --git a/gcc/lto-cgraph.c b/gcc/lto-cgraph.c
index 079593271ed..dd7b9543440 100644
--- a/gcc/lto-cgraph.c
+++ b/gcc/lto-cgraph.c
@@ -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;
diff --git a/gcc/lto-section-in.c b/gcc/lto-section-in.c
index 9d6d8a36029..7f4065e6df6 100644
--- a/gcc/lto-section-in.c
+++ b/gcc/lto-section-in.c
@@ -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. */
diff --git a/gcc/lto-streamer-in.c b/gcc/lto-streamer-in.c
index 90e6e3937ee..0c9f90ae558 100644
--- a/gcc/lto-streamer-in.c
+++ b/gcc/lto-streamer-in.c
@@ -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;
}
diff --git a/gcc/lto-streamer.h b/gcc/lto-streamer.h
index d8978c9ec59..8ff5bf57c78 100644
--- a/gcc/lto-streamer.h
+++ b/gcc/lto-streamer.h
@@ -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;
diff --git a/gcc/lto-symtab.c b/gcc/lto-symtab.c
index f02824d1f45..6f46a733b42 100644
--- a/gcc/lto-symtab.c
+++ b/gcc/lto-symtab.c
@@ -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;
diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog
index bfa31dcb338..f021ba8a51e 100644
--- a/gcc/lto/ChangeLog
+++ b/gcc/lto/ChangeLog
@@ -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.
diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c
index fd474b68486..721d8fbc2ff 100644
--- a/gcc/lto/lto.c
+++ b/gcc/lto/lto.c
@@ -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. */
diff --git a/gcc/objc/ChangeLog b/gcc/objc/ChangeLog
index 9934f24d126..a05a140c7cb 100644
--- a/gcc/objc/ChangeLog
+++ b/gcc/objc/ChangeLog
@@ -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.
diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c
index f10592fed1e..2ec9ca04009 100644
--- a/gcc/objc/objc-act.c
+++ b/gcc/objc/objc-act.c
@@ -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;
diff --git a/gcc/objc/objc-act.h b/gcc/objc/objc-act.h
index d8bf0f62f93..c8edd64bcf2 100644
--- a/gcc/objc/objc-act.h
+++ b/gcc/objc/objc-act.h
@@ -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) \
diff --git a/gcc/objcp/ChangeLog b/gcc/objcp/ChangeLog
index e6fbad59841..70731e13c21 100644
--- a/gcc/objcp/ChangeLog
+++ b/gcc/objcp/ChangeLog
@@ -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.
diff --git a/gcc/objcp/objcp-decl.h b/gcc/objcp/objcp-decl.h
index 50d98287662..1f9f36c6a3f 100644
--- a/gcc/objcp/objcp-decl.h
+++ b/gcc/objcp/objcp-decl.h
@@ -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)
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 3a93cdeb798..52ecd0fbe48 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -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)
diff --git a/gcc/optabs.c b/gcc/optabs.c
index e022114a0e3..f6642fbdafd 100644
--- a/gcc/optabs.c
+++ b/gcc/optabs.c
@@ -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;
diff --git a/gcc/passes.c b/gcc/passes.c
index ad444fda27a..3c295a033da 100644
--- a/gcc/passes.c
+++ b/gcc/passes.c
@@ -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;
diff --git a/gcc/rtl.c b/gcc/rtl.c
index dda701e8aed..d886e9381d2 100644
--- 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);
}
diff --git a/gcc/rtl.h b/gcc/rtl.h
index 107bb9c05a0..5d67d27a382 100644
--- 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];
};
diff --git a/gcc/sese.c b/gcc/sese.c
index 7e9bd91f2d7..2ed6485beed 100644
--- a/gcc/sese.c
+++ b/gcc/sese.c
@@ -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);
diff --git a/gcc/stringpool.c b/gcc/stringpool.c
index 79f8cb2c8d1..8d45a26befc 100644
--- a/gcc/stringpool.c
+++ b/gcc/stringpool.c
@@ -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]));
}
diff --git a/gcc/toplev.c b/gcc/toplev.c
index e25bad0c2f7..20da382b1dd 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -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 ();
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index eca3ed018ce..f46556fe59a 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -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. */
diff --git a/gcc/tree-dfa.c b/gcc/tree-dfa.c
index ad03cd235c6..485ebcf10fb 100644
--- a/gcc/tree-dfa.c
+++ b/gcc/tree-dfa.c
@@ -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;
diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index 9c17c1e092e..872d4241dc8 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -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;
diff --git a/gcc/tree-iterator.c b/gcc/tree-iterator.c
index d5343b44760..1d0a40a30ab 100644
--- a/gcc/tree-iterator.c
+++ b/gcc/tree-iterator.c
@@ -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;
diff --git a/gcc/tree-phinodes.c b/gcc/tree-phinodes.c
index c97ace88c8b..05b63fbea88 100644
--- a/gcc/tree-phinodes.c
+++ b/gcc/tree-phinodes.c
@@ -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++;
{
diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c
index bf564d8dab5..5eb61740bee 100644
--- a/gcc/tree-scalar-evolution.c
+++ b/gcc/tree-scalar-evolution.c
@@ -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 ();
diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c
index d3890c5b57c..e6836d77409 100644
--- a/gcc/tree-ssa-alias.c
+++ b/gcc/tree-ssa-alias.c
@@ -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;
}
diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c
index 279718ee5e4..accf17a4c23 100644
--- a/gcc/tree-ssa-loop-niter.c
+++ b/gcc/tree-ssa-loop-niter.c
@@ -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;
diff --git a/gcc/tree-ssa-operands.c b/gcc/tree-ssa-operands.c
index 68be8fae8f4..05e0f6ba249 100644
--- a/gcc/tree-ssa-operands.c
+++ b/gcc/tree-ssa-operands.c
@@ -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;
diff --git a/gcc/tree-ssa-operands.h b/gcc/tree-ssa-operands.h
index 13d29c3ab01..4c586f7fb27 100644
--- a/gcc/tree-ssa-operands.h
+++ b/gcc/tree-ssa-operands.h
@@ -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];
};
diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c
index f22605626d3..05fd6d971f2 100644
--- a/gcc/tree-ssa-structalias.c
+++ b/gcc/tree-ssa-structalias.c
@@ -197,8 +197,7 @@
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);
diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c
index ec9c50ceb77..866ce6eb2b7 100644
--- a/gcc/tree-ssa.c
+++ b/gcc/tree-ssa.c
@@ -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,
diff --git a/gcc/tree-ssanames.c b/gcc/tree-ssanames.c
index cc7683dfabe..79b844ffe7c 100644
--- a/gcc/tree-ssanames.c
+++ b/gcc/tree-ssanames.c
@@ -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;
diff --git a/gcc/tree.c b/gcc/tree.c
index 7b1a489a03f..3c1a8782cbb 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -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);
diff --git a/gcc/tree.h b/gcc/tree.h
index 31d80dfa7e2..683eaea4da9 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -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;
diff --git a/gcc/varasm.c b/gcc/varasm.c
index 3f8fd02aa8f..e02126b07d7 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -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. */
diff --git a/gcc/varpool.c b/gcc/varpool.c
index a3be2629ce1..94c949e3550 100644
--- a/gcc/varpool.c
+++ b/gcc/varpool.c
@@ -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;
diff --git a/include/ChangeLog b/include/ChangeLog
index e65a8f2b9ac..0c6f91c9599 100644
--- a/include/ChangeLog
+++ b/include/ChangeLog
@@ -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.
diff --git a/include/hashtab.h b/include/hashtab.h
index 1cd406daf31..4bb65d6c7a2 100644
--- a/include/hashtab.h
+++ b/include/hashtab.h
@@ -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);
diff --git a/include/splay-tree.h b/include/splay-tree.h
index 57a96c4a3de..480b2c43e7d 100644
--- a/include/splay-tree.h
+++ b/include/splay-tree.h
@@ -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,
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index 042d6fed4cf..84201a4a510 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -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>
diff --git a/libcpp/include/symtab.h b/libcpp/include/symtab.h
index ebb56007a03..b0a2f2697aa 100644
--- a/libcpp/include/symtab.h
+++ b/libcpp/include/symtab.h
@@ -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;
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index 744f6ae1aef..3b9fdc9871f 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -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>
diff --git a/libiberty/functions.texi b/libiberty/functions.texi
index 72ca56cbd44..d9fef8cb7b3 100644
--- a/libiberty/functions.texi
+++ b/libiberty/functions.texi
@@ -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})
diff --git a/libiberty/hashtab.c b/libiberty/hashtab.c
index 8c89bfcd839..359e3ea569e 100644
--- a/libiberty/hashtab.c
+++ b/libiberty/hashtab.c
@@ -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).
@@ -291,20 +291,33 @@ 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;
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
diff --git a/libiberty/splay-tree.c b/libiberty/splay-tree.c
index d7ed86813dc..bf1a0f3f151 100644
--- a/libiberty/splay-tree.c
+++ b/libiberty/splay-tree.c
@@ -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;