+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.
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
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
+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.
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)
/* 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;
}
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);
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);
/* 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);
/* 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 ();
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;
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;
}
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;
}
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
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. */
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)
{
/* 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);
}
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. */
/* 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
{
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));
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
binding_freelist = b->prev;
}
else
- b = GGC_NEW (struct c_binding);
+ b = ggc_alloc_c_binding ();
b->shadowed = 0;
b->decl = decl;
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;
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)
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 ();
{
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);
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;
/* 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;
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;
+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,
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. */
/* 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];
};
{
align_stack * entry;
- entry = GGC_NEW (align_stack);
+ entry = ggc_alloc_align_stack ();
entry->alignment = alignment;
entry->id = id;
return;
}
- p = GGC_NEW (opt_stack);
+ p = ggc_alloc_opt_stack ();
p->prev = options_stack;
options_stack = p;
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
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. */
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);
alloc_block (void)
{
basic_block bb;
- bb = GGC_CNEW (struct basic_block_def);
+ bb = ggc_alloc_cleared_basic_block_def ();
return bb;
}
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;
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;
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;
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)
{
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 ();
}
}
else
{
- node = GGC_CNEW (struct cgraph_node);
+ node = ggc_alloc_cleared_cgraph_node ();
node->uid = cgraph_max_uid++;
}
}
else
{
- edge = GGC_NEW (struct cgraph_edge);
+ edge = ggc_alloc_cgraph_edge ();
edge->uid = cgraph_edge_max_uid++;
}
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;
{
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;
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. */
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;
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. */
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);
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;
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. */
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. */
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.
}
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;
static struct machine_function *
frv_init_machine_status (void)
{
- return GGC_CNEW (struct machine_function);
+ return ggc_alloc_cleared_machine_function ();
}
\f
/* Implement TARGET_SCHED_ISSUE_RATE. */
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),
{
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;
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);
{
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;
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;
static struct machine_function *
ia64_init_machine_status (void)
{
- return GGC_CNEW (struct machine_function);
+ return ggc_alloc_cleared_machine_function ();
}
\f
static enum attr_itanium_class ia64_safe_itanium_class (rtx);
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. */
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
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
if (!*slot)
{
- *slot = GGC_NEW (pragma_entry);
+ *slot = ggc_alloc_pragma_entry ();
(*slot)->flag = 0;
(*slot)->used = 0;
(*slot)->funcname = ggc_strdup (funcname);
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;
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;
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
static struct machine_function *
mmix_init_machine_status (void)
{
- return GGC_CNEW (struct machine_function);
+ return ggc_alloc_cleared_machine_function ();
}
/* DATA_ALIGNMENT.
static struct machine_function *
moxie_init_machine_status (void)
{
- return GGC_CNEW (struct machine_function);
+ return ggc_alloc_cleared_machine_function ();
}
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
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 ();
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;
static struct machine_function *
rs6000_init_machine_status (void)
{
- return GGC_CNEW (machine_function);
+ return ggc_alloc_cleared_machine_function ();
}
\f
/* These macros test for integers and extract the low-order bits. */
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;
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
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));
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));
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
static struct machine_function *
xtensa_init_machine_status (void)
{
- return GGC_CNEW (struct machine_function);
+ return ggc_alloc_cleared_machine_function ();
}
+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
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),
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),
tree record;
};
-struct GTY(()) lang_type {
+struct GTY((variable_size)) lang_type {
union lang_type_u
{
struct lang_type_header GTY((skip (""))) h;
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;
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); \
/* 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);
&& 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;
/* 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;
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;
/* 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)
else
gcc_unreachable ();
- ld = GGC_CNEWVAR (struct lang_decl, size);
+ ld = ggc_alloc_cleared_lang_decl (size);
ld->u.base.selector = sel;
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;
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;
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;
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;
{
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. */
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;
free_bindings = binding->previous;
}
else
- binding = GGC_NEW (cxx_binding);
+ binding = ggc_alloc_cxx_binding ();
cxx_binding_init (binding, value, type);
= 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
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;
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;
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. */
/* 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;
{
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;
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;
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;
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 ();
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);
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 =
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;
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))
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)
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)
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
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;
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))
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. */
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
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}")
@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
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);
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;
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;
}
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;
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;
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;
}
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;
{
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;
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;
}
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
}
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);
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++)
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++)
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;
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;
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;
{
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;
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;
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);
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;
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))
{
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;
{
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;
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;
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);
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. */
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));
}
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));
}
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 ();
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,
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);
#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)
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;
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;
{
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;
+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
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;
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
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,
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;
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;
};
/* 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];
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.
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;
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);
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;
{
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
tree result;
tree fntype = fndecl ? TREE_TYPE (fndecl) : NULL_TREE;
- cfun = GGC_CNEW (struct function);
+ cfun = ggc_alloc_cleared_function ();
init_eh_for_function ();
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;
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,
;
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);
}
}
+/* 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
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");
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);
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)
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 ();
#include "coretypes.h"
#include "hashtab.h"
#include "ggc.h"
+#include "ggc-internal.h"
#include "toplev.h"
#include "params.h"
#include "hosthooks.h"
/* 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;
}
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);
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
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
/* 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);
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);
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
}
--- /dev/null
+/* 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
/* 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.
}
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);
}
{
free (p);
}
+
+struct alloc_zone
+{
+ int dummy;
+};
+
+struct alloc_zone rtl_zone;
+struct alloc_zone tree_zone;
+struct alloc_zone tree_id_zone;
/* "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.
#include "toplev.h"
#include "flags.h"
#include "ggc.h"
+#include "ggc-internal.h"
#include "timevar.h"
#include "params.h"
#include "tree-flow.h"
#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.
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));
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;
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. */
/* 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;
#include "toplev.h"
#include "flags.h"
#include "ggc.h"
+#include "ggc-internal.h"
#include "timevar.h"
#include "params.h"
#include "bitmap.h"
#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.
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));
/* 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;
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. */
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. */
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
/* 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;
/* 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.
/* 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 *);
static objects, stack variables, or memory allocated with malloc. */
extern int ggc_marked_p (const void *);
-/* Mark the entries in the string pool. */
-extern void ggc_mark_stringpool (void);
-
-/* Purge the entries in the string pool. */
-extern void ggc_purge_stringpool (void);
-
-/* Call ggc_set_mark on all the roots. */
-
-extern void ggc_mark_roots (void);
-
-/* Save and restore the string pool entries for PCH. */
-
-extern void gt_pch_save_stringpool (void);
-extern void gt_pch_fixup_stringpool (void);
-extern void gt_pch_restore_stringpool (void);
-
/* PCH and GGC handling for strings, mostly trivial. */
-
-extern void gt_pch_p_S (void *, void *, gt_pointer_operator, void *);
extern void gt_pch_n_S (const void *);
extern void gt_ggc_m_S (const void *);
-/* Initialize the string pool. */
-extern void init_stringpool (void);
+/* End of GTY machinery API. */
-/* A GC implementation must provide these functions. They are internal
- to the GC system. */
-
-/* Forward declare the zone structure. Only ggc_zone implements this. */
struct alloc_zone;
+/* Initialize the string pool. */
+extern void init_stringpool (void);
+
/* Initialize the garbage collector. */
extern void init_ggc (void);
-/* Start a new GGC zone. */
-extern struct alloc_zone *new_ggc_zone (const char *);
-
-/* Free a complete GGC zone, destroying everything in it. */
-extern void destroy_ggc_zone (struct alloc_zone *);
-
-struct ggc_pch_data;
-
-/* Return a new ggc_pch_data structure. */
-extern struct ggc_pch_data *init_ggc_pch (void);
-
-/* The second parameter and third parameters give the address and size
- of an object. Update the ggc_pch_data structure with as much of
- that information as is necessary. The bool argument should be true
- if the object is a string. */
-extern void ggc_pch_count_object (struct ggc_pch_data *, void *, size_t, bool,
- enum gt_types_enum);
-
-/* Return the total size of the data to be written to hold all
- the objects previously passed to ggc_pch_count_object. */
-extern size_t ggc_pch_total_size (struct ggc_pch_data *);
-
-/* The objects, when read, will most likely be at the address
- in the second parameter. */
-extern void ggc_pch_this_base (struct ggc_pch_data *, void *);
-
-/* Assuming that the objects really do end up at the address
- passed to ggc_pch_this_base, return the address of this object.
- The bool argument should be true if the object is a string. */
-extern char *ggc_pch_alloc_object (struct ggc_pch_data *, void *, size_t, bool,
- enum gt_types_enum);
-
-/* Write out any initial information required. */
-extern void ggc_pch_prepare_write (struct ggc_pch_data *, FILE *);
-/* Write out this object, including any padding. The last argument should be
- true if the object is a string. */
-extern void ggc_pch_write_object (struct ggc_pch_data *, FILE *, void *,
- void *, size_t, bool);
-/* All objects have been written, write out any final information
- required. */
-extern void ggc_pch_finish (struct ggc_pch_data *, FILE *);
-
-/* A PCH file has just been read in at the address specified second
- parameter. Set up the GC implementation for the new objects. */
-extern void ggc_pch_read (FILE *, void *);
-
-\f
-/* Allocation. */
-
-/* When set, ggc_collect will do collection. */
-extern bool ggc_force_collect;
-
/* When true, identifier nodes are considered as GC roots. When
false, identifier nodes are treated like any other GC-allocated
object, and the identifier hash table is treated as a weak
hash. */
extern bool ggc_protect_identifiers;
+/* Write out all GCed objects to F. */
+extern void gt_pch_save (FILE *f);
+
+\f
+/* Allocation. */
+
/* The internal primitive. */
-extern void *ggc_alloc_stat (size_t MEM_STAT_DECL);
-#define ggc_alloc(s) ggc_alloc_stat (s MEM_STAT_INFO)
+extern void *ggc_internal_alloc_stat (size_t MEM_STAT_DECL);
+
+#define ggc_internal_alloc(s) ggc_internal_alloc_stat (s MEM_STAT_INFO)
+
/* Allocate an object of the specified type and size. */
extern void *ggc_alloc_typed_stat (enum gt_types_enum, size_t MEM_STAT_DECL);
-#define ggc_alloc_typed(s,z) ggc_alloc_typed_stat (s,z MEM_STAT_INFO)
-/* Like ggc_alloc, but allocates cleared memory. */
-extern void *ggc_alloc_cleared_stat (size_t MEM_STAT_DECL);
-#define ggc_alloc_cleared(s) ggc_alloc_cleared_stat (s MEM_STAT_INFO)
+
+#define ggc_alloc_typed(s, z) ggc_alloc_typed_stat (s, z MEM_STAT_INFO)
+
+/* Allocates cleared memory. */
+extern void *ggc_internal_cleared_alloc_stat (size_t MEM_STAT_DECL);
+
/* Resize a block. */
extern void *ggc_realloc_stat (void *, size_t MEM_STAT_DECL);
-#define ggc_realloc(s,z) ggc_realloc_stat (s,z MEM_STAT_INFO)
-/* Like ggc_alloc_cleared, but performs a multiplication. */
-extern void *ggc_calloc (size_t, size_t);
+
/* Free a block. To be used when known for certain it's not reachable. */
extern void ggc_free (void *);
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. */
plugins. Does nothing if the passed pointer is NULL. */
extern void ggc_register_cache_tab (const struct ggc_cache_tab *);
-/* Return the number of bytes allocated at the indicated address. */
-extern size_t ggc_get_size (const void *);
-
-/* Write out all GCed objects to F. */
-extern void gt_pch_save (FILE *f);
-
/* Read objects previously saved with gt_pch_save from F. */
extern void gt_pch_restore (FILE *f);
\f
/* Statistics. */
-/* This structure contains the statistics common to all collectors.
- Particular collectors can extend this structure. */
-typedef struct ggc_statistics
-{
- /* At present, we don't really gather any interesting statistics. */
- int unused;
-} ggc_statistics;
-
-/* Used by the various collectors to gather and print statistics that
- do not depend on the collector in use. */
-extern void ggc_print_common_statistics (FILE *, ggc_statistics *);
-
/* Print allocation statistics. */
extern void ggc_print_statistics (void);
+
extern void stringpool_statistics (void);
/* Heuristics. */
extern void init_ggc_heuristics (void);
/* Zone collection. */
-#if defined (GGC_ZONE) && !defined (GENERATOR_FILE)
/* For regular rtl allocations. */
extern struct alloc_zone rtl_zone;
+
/* For regular tree allocations. */
extern struct alloc_zone tree_zone;
+
/* For IDENTIFIER_NODE allocations. */
extern struct alloc_zone tree_id_zone;
+#define ggc_alloc_rtvec_sized(NELT) \
+ (ggc_alloc_zone_vec_rtvec_def (sizeof (rtx), \
+ sizeof (struct rtvec_def) + ((NELT) - 1), \
+ &rtl_zone))
+
+#if defined (GGC_ZONE) && !defined (GENERATOR_FILE)
+
/* Allocate an object into the specified allocation zone. */
-extern void *ggc_alloc_zone_stat (size_t, struct alloc_zone * MEM_STAT_DECL);
-# define ggc_alloc_zone(s,z) ggc_alloc_zone_stat (s,z MEM_STAT_INFO)
-# define ggc_alloc_zone_pass_stat(s,z) ggc_alloc_zone_stat (s,z PASS_MEM_STAT)
+extern void *ggc_internal_alloc_zone_stat (size_t,
+ struct alloc_zone * MEM_STAT_DECL);
+
+extern void *ggc_internal_cleared_alloc_zone_stat (size_t,
+ struct alloc_zone * MEM_STAT_DECL);
+
+static inline void *
+ggc_internal_zone_alloc_stat (struct alloc_zone * z, size_t s MEM_STAT_DECL)
+{
+ return ggc_internal_alloc_zone_stat (s, z PASS_MEM_STAT);
+}
+
+static inline void *
+ggc_internal_zone_cleared_alloc_stat (struct alloc_zone * z, size_t s
+ MEM_STAT_DECL)
+{
+ return ggc_internal_cleared_alloc_zone_stat (s, z PASS_MEM_STAT);
+}
+
+static inline void *
+ggc_internal_zone_vec_alloc_stat (struct alloc_zone * z, size_t s, size_t n
+ MEM_STAT_DECL)
+{
+ return ggc_internal_alloc_zone_stat (s * n, z PASS_MEM_STAT);
+}
+
+
#else
-# define ggc_alloc_zone(s, z) ggc_alloc (s)
-# define ggc_alloc_zone_pass_stat(s, z) ggc_alloc_stat (s PASS_MEM_STAT)
+static inline void *
+ggc_internal_zone_alloc_stat (struct alloc_zone * z ATTRIBUTE_UNUSED,
+ size_t s MEM_STAT_DECL)
+{
+ return ggc_internal_alloc_stat (s PASS_MEM_STAT);
+}
+
+static inline void *
+ggc_internal_zone_cleared_alloc_stat (struct alloc_zone * z ATTRIBUTE_UNUSED,
+ size_t s MEM_STAT_DECL)
+{
+ return ggc_internal_cleared_alloc_stat (s PASS_MEM_STAT);
+}
+
+static inline void *
+ggc_internal_zone_vec_alloc_stat (struct alloc_zone * z ATTRIBUTE_UNUSED,
+ size_t s, size_t n MEM_STAT_DECL)
+{
+ return ggc_internal_vec_alloc_stat (s, n PASS_MEM_STAT);
+}
#endif
+/* Memory statistics passing versions of some allocators. Too few of them to
+ make gengtype produce them, so just define the needed ones here. */
+static inline struct rtx_def *
+ggc_alloc_zone_rtx_def_stat (struct alloc_zone * z, size_t s MEM_STAT_DECL)
+{
+ return (struct rtx_def *) ggc_internal_zone_alloc_stat (z, s PASS_MEM_STAT);
+}
+
+static inline union tree_node *
+ggc_alloc_zone_tree_node_stat (struct alloc_zone * z, size_t s MEM_STAT_DECL)
+{
+ return (union tree_node *) ggc_internal_zone_alloc_stat (z, s PASS_MEM_STAT);
+}
+
+static inline union tree_node *
+ggc_alloc_zone_cleared_tree_node_stat (struct alloc_zone * z, size_t s
+ MEM_STAT_DECL)
+{
+ return (union tree_node *)
+ ggc_internal_zone_cleared_alloc_stat (z, s PASS_MEM_STAT);
+}
+
+static inline union gimple_statement_d *
+ggc_alloc_cleared_gimple_statement_d_stat (size_t s MEM_STAT_DECL)
+{
+ return (union gimple_statement_d *)
+ ggc_internal_cleared_alloc_stat (s PASS_MEM_STAT);
+}
+
#endif
{
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);
{
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);
}
#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);
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);
}
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);
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,
/* 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;
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;
}
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)
{
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));
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;
}
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))
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);
}
{
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,
}
/* 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;
{
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,
}
/* 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;
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++)
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 ();
+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
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)
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;
}
}
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.
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)
if (cpool == NULL)
{
- cpool = GGC_CNEW (struct CPool);
+ cpool = ggc_alloc_cleared_CPool ();
TYPE_CPOOL (klass) = cpool;
}
return cpool;
make_binding_level (void)
{
/* NOSTRICT */
- return GGC_CNEW (struct binding_level);
+ return ggc_alloc_cleared_binding_level ();
}
void
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;
}
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)
if (*as_pp)
return;
- *as_pp = ggc_alloc (sizeof (type_assertion));
+ *as_pp = ggc_alloc_type_assertion ();
**(type_assertion **)as_pp = as;
}
(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. */
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. */
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
{
#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)
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;
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);
}
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);
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';
{
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));
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;
};
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,
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;
static inline lambda_vector
lambda_vector_new (int size)
{
- return GGC_CNEWVEC (int, size);
+ return (lambda_vector) ggc_alloc_cleared_atomic (sizeof (int) * size);
}
struct loops *loops;
gcc_assert (!current_loops);
- loops = GGC_CNEW (struct loops);
+ loops = ggc_alloc_cleared_loops ();
/* Find the loops. */
{
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;
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. */
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);
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);
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);
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 ());
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;
}
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;
#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"
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;
+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.
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++)
{
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 ();
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;
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. */
+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.
if (!*loc)
{
- *loc = ggc_alloc (sizeof (key));
+ *loc = ggc_alloc_volatilized_type ();
((struct volatilized_type *) *loc)->type = t;
}
{
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 }) */
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,
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;
{
attr obj;
- obj = (attr) ggc_alloc (sizeof (struct hashed_attribute));
+ obj = ggc_alloc_hashed_attribute ();
obj->next = entry->list;
obj->value = value;
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;
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;
#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) \
+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.
#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)
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)
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;
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;
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,
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;
{
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));
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
shallow_copy_rtx_stat (const_rtx orig MEM_STAT_DECL)
{
const unsigned int size = rtx_size (orig);
- rtx const copy = (rtx) ggc_alloc_zone_pass_stat (size, &rtl_zone);
+ rtx const copy = ggc_alloc_zone_rtx_def_stat (&rtl_zone, size PASS_MEM_STAT);
return (rtx) memcpy (copy, orig, size);
}
\f
/* 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;
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];
};
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);
/* 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.
#include "coretypes.h"
#include "tm.h"
#include "ggc.h"
+#include "ggc-internal.h"
#include "tree.h"
#include "symtab.h"
#include "cpplib.h"
/* 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 *);
static void *
stringpool_ggc_alloc (size_t x)
{
- return ggc_alloc (x);
+ return ggc_alloc_atomic (x);
}
/* Initialize the string pool. */
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;
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;
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")))
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]));
}
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
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
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 ();
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. */
|| 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;
gcc_assert (num != 0);
- n = GGC_NEW (struct throw_stmt_node);
+ n = ggc_alloc_throw_stmt_node ();
n->stmt = t;
n->lp_nr = num;
/* 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.
}
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;
}
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;
}
else
{
- phi = (gimple) ggc_alloc (size);
+ phi = ggc_alloc_gimple_statement_d (size);
#ifdef GATHER_STATISTICS
phi_nodes_created++;
{
{
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;
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 ();
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;
}
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;
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;
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];
};
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;
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);
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,
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;
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)
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;
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;
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;
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);
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));
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;
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
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));
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;
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),
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),
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);
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);
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);
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;
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;
{
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;
{
section *sect;
- sect = GGC_NEW (section);
+ sect = ggc_alloc_section ();
sect->noswitch.common.flags = flags | SECTION_NOSWITCH;
sect->noswitch.callback = callback;
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;
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;
}
/* 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);
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. */
{
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;
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. */
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;
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;
+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.
/* 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).
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);
/* 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).
/* 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;
};
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,
+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>
/* 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;
+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>
@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
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})
@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})
/* 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).
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;
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;
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;
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
/* 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.
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;
{
/* 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;