This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[boehms-gc] Start using typed GC allocation routines
- From: "Laurynas Biveinis" <laurynas dot biveinis at gmail dot com>
- To: "Gcc Patch List" <gcc-patches at gcc dot gnu dot org>
- Cc: "Daniel Berlin" <dberlin at dberlin dot org>
- Date: Tue, 15 Aug 2006 22:47:02 +0300
- Subject: [boehms-gc] Start using typed GC allocation routines
This is a boring patch that changes part of gc_alloc and
gc_alloc_cleared calls to the typed ones. Commited.
Index: gcc/optabs.c
===================================================================
--- gcc/optabs.c (revision 116135)
+++ gcc/optabs.c (working copy)
@@ -4869,7 +4869,7 @@
new_optab (void)
{
int i;
- optab op = ggc_alloc (sizeof (struct optab));
+ optab op = ggc_alloc_optab ();
for (i = 0; i < NUM_MACHINE_MODES; i++)
{
op->handlers[i].insn_code = CODE_FOR_nothing;
@@ -4883,7 +4883,7 @@
new_convert_optab (void)
{
int i, j;
- convert_optab op = ggc_alloc (sizeof (struct convert_optab));
+ convert_optab op = ggc_alloc_convert_optab ();
for (i = 0; i < NUM_MACHINE_MODES; i++)
for (j = 0; j < NUM_MACHINE_MODES; j++)
{
Index: gcc/value-prof.c
===================================================================
--- gcc/value-prof.c (revision 116135)
+++ gcc/value-prof.c (working copy)
@@ -736,7 +736,7 @@
{
/* Check for the case where the divisor is the same value most
of the time. */
- hist = ggc_alloc (sizeof (*hist));
+ hist = ggc_alloc_histogram_value_t ();
hist->hvalue.value = divisor;
hist->hvalue.stmt = stmt;
hist->type = HIST_TYPE_SINGLE_VALUE;
@@ -748,14 +748,14 @@
if (TREE_CODE (rhs) == TRUNC_MOD_EXPR
&& TYPE_UNSIGNED (type))
{
- /* Check for a special case where the divisor is power of 2. */
- hist = ggc_alloc (sizeof (*hist));
+ /* Check for a special case where the divisor is power of 2. */
+ hist = ggc_alloc_histogram_value_t ();
hist->hvalue.value = divisor;
hist->hvalue.stmt = stmt;
hist->type = HIST_TYPE_POW2;
VEC_quick_push (histogram_value, *values, hist);
- hist = ggc_alloc (sizeof (*hist));
+ hist = ggc_alloc_histogram_value_t ();
hist->hvalue.stmt = stmt;
hist->hvalue.value
= build2 (TRUNC_DIV_EXPR, type, op0, divisor);
Index: gcc/value-prof.h
===================================================================
--- gcc/value-prof.h (revision 116135)
+++ gcc/value-prof.h (working copy)
@@ -38,29 +38,28 @@
((enum hist_type) ((COUNTER) - GCOV_FIRST_VALUE_COUNTER))
/* The value to measure. */
-struct histogram_value_t
+typedef struct histogram_value_t *histogram_value;
+struct histogram_value_t GTY(())
{
- struct
+ struct histogram_value_hvalue_t
{
tree value; /* The value to profile. */
tree stmt; /* Insn containing the value. */
gcov_type *counters; /* Pointer to first counter. */
- struct histogram_value_t *next; /* Linked list pointer. */
+ histogram_value GTY((chain_next("%h.next"))) next; /* Linked
list pointer. */
} hvalue;
enum hist_type type; /* Type of information to measure. */
unsigned n_counters; /* Number of required counters. */
- union
+ union histogram_value_hdata_t
{
- struct
+ struct histogram_value_hdata_intvl_t
{
int int_start; /* First value in interval. */
unsigned int steps; /* Number of values in it. */
} intvl; /* Interval histogram data. */
- } hdata; /* Profiled information specific data. */
+ } GTY((default("intvl"))) hdata; /* Profiled information specific data. */
};
-typedef struct histogram_value_t *histogram_value;
-
DEF_VEC_P(histogram_value);
DEF_VEC_ALLOC_P(histogram_value,heap);
Index: gcc/tree.c
===================================================================
--- gcc/tree.c (revision 116135)
+++ gcc/tree.c (working copy)
@@ -3188,7 +3188,7 @@
return;
}
- SET_EXPR_LOCUS (node, ggc_alloc (sizeof (location_t)));
+ SET_EXPR_LOCUS (node, ggc_alloc_location_t ());
EXPR_LINENO (node) = line;
EXPR_FILENAME (node) = file;
last_annotated_node = EXPR_LOCUS (node);
@@ -3852,7 +3852,7 @@
struct tree_int_map *h;
void **loc;
- h = ggc_alloc (sizeof (struct tree_int_map));
+ h = ggc_alloc_tree_int_map();
h->from = from;
h->to = to;
loc = htab_find_slot_with_hash (init_priority_for_decl, h,
@@ -3882,7 +3882,7 @@
struct tree_map *h;
void **loc;
- h = ggc_alloc (sizeof (struct tree_map));
+ h = ggc_alloc_tree_map ();
h->hash = htab_hash_pointer (from);
h->from = from;
h->to = to;
@@ -3948,7 +3948,7 @@
struct tree_map *h;
void **loc;
- h = ggc_alloc (sizeof (struct tree_map));
+ h = ggc_alloc_tree_map ();
h->hash = htab_hash_pointer (from);
h->from = from;
h->to = to;
@@ -3978,7 +3978,7 @@
struct tree_map *h;
void **loc;
- h = ggc_alloc (sizeof (struct tree_map));
+ h = ggc_alloc_tree_map ();
h->hash = htab_hash_pointer (from);
h->from = from;
h->to = to;
@@ -4137,7 +4137,7 @@
struct type_hash *h;
void **loc;
- h = ggc_alloc (sizeof (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);
Index: gcc/bitmap.h
===================================================================
--- gcc/bitmap.h (revision 116135)
+++ gcc/bitmap.h (working copy)
@@ -73,7 +73,7 @@
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 GC allocation. */
} bitmap_head;
Index: gcc/lambda-mat.c
===================================================================
--- gcc/lambda-mat.c (revision 116135)
+++ gcc/lambda-mat.c (working copy)
@@ -38,7 +38,7 @@
int i;
mat = ggc_alloc (m * sizeof (lambda_vector));
-
+
for (i = 0; i < m; i++)
mat[i] = lambda_vector_new (n);
Index: gcc/cfg.c
===================================================================
--- gcc/cfg.c (revision 116135)
+++ gcc/cfg.c (working copy)
@@ -82,7 +82,7 @@
init_flow (void)
{
if (!cfun->cfg)
- cfun->cfg = ggc_alloc_cleared (sizeof (struct control_flow_graph));
+ cfun->cfg = ggc_alloc_cleared_control_flow_graph();
n_edges = 0;
ENTRY_BLOCK_PTR = ggc_alloc_cleared (sizeof (struct basic_block_def));
ENTRY_BLOCK_PTR->index = ENTRY_BLOCK;
Index: gcc/dwarf2out.c
===================================================================
--- gcc/dwarf2out.c (revision 116135)
+++ gcc/dwarf2out.c (working copy)
@@ -575,7 +575,7 @@
static inline dw_cfi_ref
new_cfi (void)
{
- dw_cfi_ref cfi = ggc_alloc (sizeof (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;
@@ -1208,7 +1208,7 @@
if (q == NULL)
{
- q = ggc_alloc (sizeof (*q));
+ q = ggc_alloc_queued_reg_save ();
q->next = queued_reg_saves;
queued_reg_saves = q;
}
@@ -3086,7 +3086,7 @@
new_loc_descr (enum dwarf_location_atom op, unsigned HOST_WIDE_INT oprnd1,
unsigned HOST_WIDE_INT oprnd2)
{
- dw_loc_descr_ref descr = ggc_alloc_cleared (sizeof (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;
@@ -5002,7 +5002,7 @@
slot = htab_find_slot_with_hash (debug_str_hash, str,
htab_hash_string (str), INSERT);
if (*slot == NULL)
- *slot = ggc_alloc_cleared (sizeof (struct indirect_string_node));
+ *slot = ggc_alloc_cleared_indirect_string_node ();
node = (struct indirect_string_node *) *slot;
node->str = ggc_strdup (str);
node->refcount++;
@@ -5527,7 +5527,7 @@
static inline dw_die_ref
new_die (enum dwarf_tag tag_value, dw_die_ref parent_die, tree t)
{
- dw_die_ref die = ggc_alloc_cleared (sizeof (die_node));
+ dw_die_ref die = ggc_alloc_cleared_die_node ();
die->die_tag = tag_value;
@@ -5537,7 +5537,7 @@
{
limbo_die_node *limbo_node;
- limbo_node = ggc_alloc_cleared (sizeof (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;
@@ -5637,7 +5637,7 @@
slot = htab_find_slot_with_hash (decl_loc_table, decl, decl_id, INSERT);
if (*slot == NULL)
{
- temp = ggc_alloc_cleared (sizeof (var_loc_list));
+ temp = ggc_alloc_cleared_var_loc_list ();
temp->decl_id = decl_id;
*slot = temp;
}
@@ -6876,7 +6876,7 @@
new_loc_list (dw_loc_descr_ref expr, const char *begin, const char *end,
const char *section, unsigned int gensym)
{
- dw_loc_list_ref retlist = ggc_alloc_cleared (sizeof (dw_loc_list_node));
+ dw_loc_list_ref retlist = ggc_alloc_cleared_dw_loc_list_node ();
retlist->begin = begin;
retlist->end = end;
@@ -13518,7 +13518,7 @@
return;
prev_insn = PREV_INSN (loc_note);
- newloc = ggc_alloc_cleared (sizeof (struct var_loc_node));
+ newloc = ggc_alloc_cleared_var_loc_node ();
/* If the insn we processed last time is the previous insn
and it is also a var location note, use the label we emitted
last time. */
Index: gcc/expr.c
===================================================================
--- gcc/expr.c (revision 116135)
+++ gcc/expr.c (working copy)
@@ -337,7 +337,7 @@
void
init_expr (void)
{
- cfun->expr = ggc_alloc_cleared (sizeof (struct expr_status));
+ cfun->expr = ggc_alloc_cleared_expr_status();
}
/* Copy data from FROM to TO, where the machine modes are not the same.
Index: gcc/predict.c
===================================================================
--- gcc/predict.c (revision 116135)
+++ gcc/predict.c (working copy)
@@ -235,7 +235,7 @@
if ((e->src != ENTRY_BLOCK_PTR && EDGE_COUNT (e->src->succs) > 1)
&& flag_guess_branch_prob && optimize)
{
- struct edge_prediction *i = ggc_alloc (sizeof (struct edge_prediction));
+ struct edge_prediction *i = ggc_alloc_edge_prediction ();
i->ep_next = e->src->predictions;
e->src->predictions = i;
Index: gcc/lambda-trans.c
===================================================================
--- gcc/lambda-trans.c (revision 116135)
+++ gcc/lambda-trans.c (working copy)
@@ -34,8 +34,8 @@
lambda_trans_matrix_new (int colsize, int rowsize)
{
lambda_trans_matrix ret;
-
- ret = ggc_alloc (sizeof (*ret));
+
+ ret = ggc_alloc (sizeof (struct lambda_trans_matrix_def));
LTM_MATRIX (ret) = lambda_matrix_new (rowsize, colsize);
LTM_ROWSIZE (ret) = rowsize;
LTM_COLSIZE (ret) = colsize;
Index: gcc/function.c
===================================================================
--- gcc/function.c (revision 116135)
+++ gcc/function.c (working copy)
@@ -679,7 +679,7 @@
if (best_p->size - rounded_size >= alignment)
{
- p = ggc_alloc (sizeof (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;
@@ -704,7 +704,7 @@
{
HOST_WIDE_INT frame_offset_old = frame_offset;
- p = ggc_alloc (sizeof (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
@@ -3833,7 +3833,7 @@
tree result;
tree fntype = fndecl ? TREE_TYPE (fndecl) : NULL_TREE;
- cfun = ggc_alloc_cleared (sizeof (struct function));
+ cfun = ggc_alloc_cleared_function ();
cfun->stack_alignment_needed = STACK_BOUNDARY;
cfun->preferred_stack_boundary = STACK_BOUNDARY;
Index: gcc/tree-dfa.c
===================================================================
--- gcc/tree-dfa.c (revision 116135)
+++ gcc/tree-dfa.c (working copy)
@@ -163,7 +163,7 @@
gcc_assert (TREE_CODE (t) == FUNCTION_DECL);
gcc_assert (!t->common.ann || t->common.ann->common.type == FUNCTION_ANN);
- ann = ggc_alloc (sizeof (*ann));
+ ann = ggc_alloc_function_ann_d ();
memset ((void *) ann, 0, sizeof (*ann));
ann->common.type = FUNCTION_ANN;
Index: gcc/except.c
===================================================================
--- gcc/except.c (revision 116135)
+++ gcc/except.c (working copy)
@@ -438,7 +438,7 @@
void
init_eh_for_function (void)
{
- cfun->eh = ggc_alloc_cleared (sizeof (struct eh_status));
+ cfun->eh = ggc_alloc_cleared_eh_status();
}
/* Routines to generate the exception tree somewhat directly.
@@ -455,7 +455,7 @@
#endif
/* Insert a new blank region as a leaf in the tree. */
- new = ggc_alloc_cleared (sizeof (*new));
+ new = ggc_alloc_cleared_eh_region();
new->type = type;
new->outer = outer;
if (outer)
@@ -778,7 +778,7 @@
LABEL_PRESERVE_P (label) = 1;
- entry = ggc_alloc (sizeof (*entry));
+ entry = ggc_alloc_ehl_map_entry();
entry->label = label;
entry->region = region;
@@ -889,7 +889,7 @@
{
eh_region ret, n;
- ret = n = ggc_alloc (sizeof (struct eh_region));
+ ret = n = ggc_alloc_eh_region();
*n = *old;
n->outer = outer;
Index: gcc/emit-rtl.c
===================================================================
--- gcc/emit-rtl.c (revision 116135)
+++ gcc/emit-rtl.c (working copy)
@@ -304,7 +304,7 @@
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));
}
@@ -353,7 +353,7 @@
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));
}
@@ -4679,7 +4679,7 @@
free_sequence_stack = tem->next;
}
else
- tem = ggc_alloc (sizeof (struct sequence_stack));
+ tem = ggc_alloc_sequence_stack();
tem->next = seq_stack;
tem->first = first_insn;
@@ -4966,7 +4966,7 @@
{
struct function *f = cfun;
- f->emit = ggc_alloc (sizeof (struct emit_status));
+ f->emit = ggc_alloc_emit_status();
first_insn = NULL;
last_insn = NULL;
cur_insn_uid = 1;
Index: gcc/varasm.c
===================================================================
--- gcc/varasm.c (revision 116135)
+++ gcc/varasm.c (working copy)
@@ -254,7 +254,7 @@
{
section *sect;
- sect = ggc_alloc (sizeof (struct unnamed_section));
+ sect = ggc_alloc_unnamed_section();
sect->unnamed.common.flags = flags | SECTION_UNNAMED;
sect->unnamed.callback = callback;
sect->unnamed.data = data;
@@ -271,7 +271,7 @@
{
section *sect;
- sect = ggc_alloc (sizeof (struct unnamed_section));
+ sect = ggc_alloc_unnamed_section();
sect->noswitch.common.flags = flags | SECTION_NOSWITCH;
sect->noswitch.callback = callback;
@@ -292,7 +292,7 @@
flags |= SECTION_NAMED;
if (*slot == NULL)
{
- sect = ggc_alloc (sizeof (struct named_section));
+ sect = ggc_alloc_named_section();
sect->named.common.flags = flags;
sect->named.name = ggc_strdup (name);
sect->named.decl = decl;
@@ -341,8 +341,7 @@
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;
}
@@ -2808,7 +2807,7 @@
int labelno;
struct constant_descriptor_tree *desc;
- desc = ggc_alloc (sizeof (*desc));
+ desc = ggc_alloc_constant_descriptor_tree ();
desc->value = copy_constant (exp);
/* Propagate marked-ness to copied constant. */
@@ -3143,7 +3142,7 @@
{
struct rtx_constant_pool *pool;
- pool = ggc_alloc (sizeof (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;
@@ -3159,7 +3158,7 @@
{
struct varasm_status *p;
- p = ggc_alloc (sizeof (struct varasm_status));
+ p = ggc_alloc_varasm_status ();
f->varasm = p;
p->pool = create_constant_pool ();
@@ -3214,7 +3213,7 @@
return copy_rtx (desc->mem);
/* Otherwise, create a new descriptor. */
- desc = ggc_alloc (sizeof (*desc));
+ desc = ggc_alloc_constant_descriptor_rtx ();
*slot = desc;
/* Align the location counter as required by EXP's data type. */
Index: gcc/tree-nested.c
===================================================================
--- gcc/tree-nested.c (revision 116135)
+++ gcc/tree-nested.c (working copy)
@@ -870,7 +870,7 @@
SET_DECL_VALUE_EXPR (new_decl, x);
DECL_HAS_VALUE_EXPR_P (new_decl) = 1;
- elt = ggc_alloc (sizeof (*elt));
+ elt = ggc_alloc_var_map_elt ();
elt->old = decl;
elt->new = new_decl;
*slot = elt;
@@ -1178,7 +1178,7 @@
SET_DECL_VALUE_EXPR (new_decl, x);
DECL_HAS_VALUE_EXPR_P (new_decl) = 1;
- elt = ggc_alloc (sizeof (*elt));
+ elt = ggc_alloc_var_map_elt ();
elt->old = decl;
elt->new = new_decl;
*slot = elt;
Index: gcc/tree-inline.c
===================================================================
--- gcc/tree-inline.c (revision 116135)
+++ gcc/tree-inline.c (working copy)
@@ -864,8 +864,7 @@
struct function *new_cfun;
/* Place to copy from; when a copy of the function was saved off earlier,
use that instead of the main copy. */
- struct function *cfun_to_copy =
- (struct function *) ggc_alloc_cleared (sizeof (struct function));
+ struct function *cfun_to_copy = ggc_alloc_cleared_function ();
basic_block bb;
tree new_fndecl = NULL;
int count_scale, frequency_scale;
@@ -898,8 +897,7 @@
Otherwise, insert our new blocks and labels into the existing cfg. */
if (id->transform_new_cfg)
{
- new_cfun =
- (struct function *) ggc_alloc_cleared (sizeof (struct function));
+ new_cfun = ggc_alloc_cleared_function ();
*new_cfun = *DECL_STRUCT_FUNCTION (callee_fndecl);
new_cfun->cfg = NULL;
new_cfun->decl = new_fndecl = copy_node (callee_fndecl);
Index: gcc/integrate.c
===================================================================
--- gcc/integrate.c (revision 116135)
+++ gcc/integrate.c (working copy)
@@ -237,7 +237,7 @@
ivs = cfun->hard_reg_initial_vals;
if (ivs == 0)
{
- ivs = ggc_alloc (sizeof (initial_value_struct));
+ ivs = ggc_alloc_initial_value_struct();
ivs->num_entries = 0;
ivs->max_entries = 5;
ivs->entries = ggc_alloc (5 * sizeof (initial_value_pair));
Index: gcc/tree-iterator.c
===================================================================
--- gcc/tree-iterator.c (revision 116135)
+++ gcc/tree-iterator.c (working copy)
@@ -90,7 +90,7 @@
}
else
{
- head = ggc_alloc (sizeof (*head));
+ head = ggc_alloc_tree_statement_list_node ();
head->prev = NULL;
head->next = NULL;
head->stmt = t;
@@ -166,7 +166,7 @@
}
else
{
- head = ggc_alloc (sizeof (*head));
+ head = ggc_alloc_tree_statement_list_node ();
head->prev = NULL;
head->next = NULL;
head->stmt = t;
Index: gcc/Makefile.in
===================================================================
--- gcc/Makefile.in (revision 116135)
+++ gcc/Makefile.in (working copy)
@@ -2863,8 +2863,8 @@
$(srcdir)/tree-ssa-operands.h $(srcdir)/tree-ssa-operands.c \
$(srcdir)/tree-profile.c $(srcdir)/tree-nested.c \
$(srcdir)/ipa-reference.c $(srcdir)/tree-ssa-structalias.h \
- $(srcdir)/tree-ssa-structalias.c \
- $(srcdir)/c-pragma.h $(srcdir)/omp-low.c \
+ $(srcdir)/tree-ssa-structalias.c $(srcdir)/value-prof.h \
+ $(srcdir)/c-pragma.h $(srcdir)/omp-low.c $(srcdir)/stmt.c \
$(srcdir)/targhooks.c $(out_file) \
@all_gtfiles@
Index: gcc/tree-ssa-structalias.c
===================================================================
--- gcc/tree-ssa-structalias.c (revision 116135)
+++ gcc/tree-ssa-structalias.c (working copy)
@@ -336,7 +336,7 @@
struct tree_map *h;
void **loc;
- h = ggc_alloc (sizeof (struct tree_map));
+ h = ggc_alloc_tree_map ();
h->hash = htab_hash_pointer (from);
h->from = from;
h->to = to;
Index: gcc/stmt.c
===================================================================
--- gcc/stmt.c (revision 116135)
+++ gcc/stmt.c (working copy)
@@ -2124,7 +2124,7 @@
/* Add this label to the chain. Make sure to drop overflow flags. */
- r = ggc_alloc (sizeof (struct case_node));
+ r = ggc_alloc_case_node ();
r->low = build_int_cst_wide (TREE_TYPE (low), TREE_INT_CST_LOW (low),
TREE_INT_CST_HIGH (low));
r->high = build_int_cst_wide (TREE_TYPE (high), TREE_INT_CST_LOW (high),
Index: gcc/tree-ssanames.c
===================================================================
--- gcc/tree-ssanames.c (revision 116135)
+++ gcc/tree-ssanames.c (working copy)
@@ -268,7 +268,7 @@
if (!ptr_info)
return;
- new_ptr_info = ggc_alloc (sizeof (struct ptr_info_def));
+ new_ptr_info = ggc_alloc_ptr_info_def ();
*new_ptr_info = *ptr_info;
if (ptr_info->pt_vars)
--
Laurynas