summaryrefslogtreecommitdiff
path: root/gcc/ggc-common.c
diff options
context:
space:
mode:
authortbsaunde <tbsaunde@138bc75d-0d04-0410-961f-82ee72b054a4>2014-06-24 13:21:35 +0000
committertbsaunde <tbsaunde@138bc75d-0d04-0410-961f-82ee72b054a4>2014-06-24 13:21:35 +0000
commitc1f445d2fbea31314327e0ce37f86184a6ae3de7 (patch)
treeb8d7f5b21a14b16949ddbc5dcaeb5f2b2654d63a /gcc/ggc-common.c
parentd0285fb08b709575f6b35bf46efbae5e1cb3a40a (diff)
downloadgcc-c1f445d2fbea31314327e0ce37f86184a6ae3de7.tar.gz
Remove a layer of indirection from hash_table
gcc/ * hash-table.h: Remove a layer of indirection from hash_table so that it contains the hash table's data instead of a pointer to the data. * alloc-pool.c, asan.c, attribs.c, bitmap.c, cfg.c, config/arm/arm.c, config/i386/winnt.c, config/ia64/ia64.c, config/mips/mips.c, config/sol2.c, coverage.c, cselib.c, data-streamer-out.c, dse.c, dwarf2cfi.c, dwarf2out.c, except.c, fold-const.c, gcse.c, ggc-common.c, gimple-ssa-strength-reduction.c, gimplify.c, graphite-clast-to-gimple.c, graphite-dependences.c, graphite-htab.h, graphite.c, haifa-sched.c, ipa-devirt.c, ipa-profile.c, ira-color.c, ira-costs.c, loop-invariant.c, loop-iv.c, loop-unroll.c, lto-streamer-in.c, lto-streamer-out.c, lto-streamer.c, lto-streamer.h, passes.c, plugin.c, postreload-gcse.c, sese.c, statistics.c, store-motion.c, trans-mem.c, tree-browser.c, tree-cfg.c, tree-complex.c, tree-eh.c, tree-into-ssa.c, tree-parloops.c, tree-sra.c, tree-ssa-ccp.c, tree-ssa-coalesce.c, tree-ssa-dom.c, tree-ssa-live.c, tree-ssa-loop-im.c, tree-ssa-loop-ivopts.c, tree-ssa-phiopt.c, tree-ssa-pre.c, tree-ssa-reassoc.c, tree-ssa-sccvn.c, tree-ssa-strlen.c, tree-ssa-structalias.c, tree-ssa-tail-merge.c, tree-ssa-threadupdate.c, tree-ssa-uncprop.c, tree-vect-data-refs.c, tree-vect-loop.c, tree-vectorizer.c, tree-vectorizer.h, valtrack.c, valtrack.h, var-tracking.c, vtable-verify.c, vtable-verify.h: Adjust. gcc/c/ * c-decl.c: Adjust. gcc/cp/ * class.c, semantics.c, tree.c, vtable-class-hierarchy.c: Adjust. gcc/java/ * jcf-io.c: Adjust. gcc/lto/ * lto.c: Adjust. gcc/objc/ * objc-act.c: Adjust. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@211936 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ggc-common.c')
-rw-r--r--gcc/ggc-common.c49
1 files changed, 25 insertions, 24 deletions
diff --git a/gcc/ggc-common.c b/gcc/ggc-common.c
index b11a10c0072..b88776bb40e 100644
--- a/gcc/ggc-common.c
+++ b/gcc/ggc-common.c
@@ -320,7 +320,7 @@ saving_hasher::equal (const value_type *p1, const compare_type *p2)
return p1->obj == p2;
}
-static hash_table <saving_hasher> saving_htab;
+static hash_table<saving_hasher> *saving_htab;
/* Register an object in the hash table. */
@@ -334,7 +334,7 @@ gt_pch_note_object (void *obj, void *note_ptr_cookie,
return 0;
slot = (struct ptr_data **)
- saving_htab.find_slot_with_hash (obj, POINTER_HASH (obj), INSERT);
+ saving_htab->find_slot_with_hash (obj, POINTER_HASH (obj), INSERT);
if (*slot != NULL)
{
gcc_assert ((*slot)->note_ptr_fn == note_ptr_fn
@@ -365,7 +365,7 @@ gt_pch_note_reorder (void *obj, void *note_ptr_cookie,
return;
data = (struct ptr_data *)
- saving_htab.find_with_hash (obj, POINTER_HASH (obj));
+ saving_htab->find_with_hash (obj, POINTER_HASH (obj));
gcc_assert (data && data->note_ptr_cookie == note_ptr_cookie);
data->reorder_fn = reorder_fn;
@@ -431,7 +431,7 @@ relocate_ptrs (void *ptr_p, void *state_p)
return;
result = (struct ptr_data *)
- saving_htab.find_with_hash (*ptr, POINTER_HASH (*ptr));
+ saving_htab->find_with_hash (*ptr, POINTER_HASH (*ptr));
gcc_assert (result);
*ptr = result->new_addr;
}
@@ -460,7 +460,7 @@ write_pch_globals (const struct ggc_root_tab * const *tab,
else
{
new_ptr = (struct ptr_data *)
- saving_htab.find_with_hash (ptr, POINTER_HASH (ptr));
+ saving_htab->find_with_hash (ptr, POINTER_HASH (ptr));
if (fwrite (&new_ptr->new_addr, sizeof (void *), 1, state->f)
!= 1)
fatal_error ("can%'t write PCH file: %m");
@@ -494,7 +494,7 @@ gt_pch_save (FILE *f)
gt_pch_save_stringpool ();
timevar_push (TV_PCH_PTR_REALLOC);
- saving_htab.create (50000);
+ saving_htab = new hash_table<saving_hasher> (50000);
for (rt = gt_ggc_rtab; *rt; rt++)
for (rti = *rt; rti->base != NULL; rti++)
@@ -510,7 +510,7 @@ gt_pch_save (FILE *f)
state.f = f;
state.d = init_ggc_pch ();
state.count = 0;
- saving_htab.traverse <traversal_state *, ggc_call_count> (&state);
+ saving_htab->traverse <traversal_state *, ggc_call_count> (&state);
mmi.size = ggc_pch_total_size (state.d);
@@ -526,7 +526,7 @@ gt_pch_save (FILE *f)
state.ptrs = XNEWVEC (struct ptr_data *, state.count);
state.ptrs_i = 0;
- saving_htab.traverse <traversal_state *, ggc_call_alloc> (&state);
+ saving_htab->traverse <traversal_state *, ggc_call_alloc> (&state);
timevar_pop (TV_PCH_PTR_REALLOC);
timevar_push (TV_PCH_PTR_SORT);
@@ -655,7 +655,8 @@ gt_pch_save (FILE *f)
XDELETE (state.ptrs);
XDELETE (this_object);
- saving_htab.dispose ();
+ delete saving_htab;
+ saving_htab = NULL;
}
/* Read the state of the compiler back in from F. */
@@ -939,7 +940,7 @@ loc_desc_hasher::equal (const value_type *d, const compare_type *d2)
}
/* Hashtable used for statistics. */
-static hash_table <loc_desc_hasher> loc_hash;
+static hash_table<loc_desc_hasher> *loc_hash;
struct ptr_hash_entry
{
@@ -971,7 +972,7 @@ ptr_hash_hasher::equal (const value_type *p, const compare_type *p2)
}
/* Hashtable converting address of allocated field to loc descriptor. */
-static hash_table <ptr_hash_hasher> ptr_hash;
+static hash_table<ptr_hash_hasher> *ptr_hash;
/* Return descriptor for given call site, create new one if needed. */
static struct loc_descriptor *
@@ -983,10 +984,10 @@ make_loc_descriptor (const char *name, int line, const char *function)
loc.file = name;
loc.line = line;
loc.function = function;
- if (!loc_hash.is_created ())
- loc_hash.create (10);
+ if (!loc_hash)
+ loc_hash = new hash_table<loc_desc_hasher> (10);
- slot = loc_hash.find_slot (&loc, INSERT);
+ slot = loc_hash->find_slot (&loc, INSERT);
if (*slot)
return *slot;
*slot = XCNEW (struct loc_descriptor);
@@ -1008,9 +1009,9 @@ ggc_record_overhead (size_t allocated, size_t overhead, void *ptr,
p->ptr = ptr;
p->loc = loc;
p->size = allocated + overhead;
- if (!ptr_hash.is_created ())
- ptr_hash.create (10);
- slot = ptr_hash.find_slot_with_hash (ptr, htab_hash_pointer (ptr), INSERT);
+ if (!ptr_hash)
+ ptr_hash = new hash_table<ptr_hash_hasher> (10);
+ slot = ptr_hash->find_slot_with_hash (ptr, htab_hash_pointer (ptr), INSERT);
gcc_assert (!*slot);
*slot = p;
@@ -1028,7 +1029,7 @@ ggc_prune_ptr (ptr_hash_entry **slot, void *b ATTRIBUTE_UNUSED)
if (!ggc_marked_p (p->ptr))
{
p->loc->collected += p->size;
- ptr_hash.clear_slot (slot);
+ ptr_hash->clear_slot (slot);
free (p);
}
return 1;
@@ -1039,15 +1040,15 @@ ggc_prune_ptr (ptr_hash_entry **slot, void *b ATTRIBUTE_UNUSED)
void
ggc_prune_overhead_list (void)
{
- ptr_hash.traverse <void *, ggc_prune_ptr> (NULL);
+ ptr_hash->traverse <void *, ggc_prune_ptr> (NULL);
}
/* Notice that the pointer has been freed. */
void
ggc_free_overhead (void *ptr)
{
- ptr_hash_entry **slot;
- slot = ptr_hash.find_slot_with_hash (ptr, htab_hash_pointer (ptr), NO_INSERT);
+ ptr_hash_entry **slot
+ = ptr_hash->find_slot_with_hash (ptr, htab_hash_pointer (ptr), NO_INSERT);
struct ptr_hash_entry *p;
/* The pointer might be not found if a PCH read happened between allocation
and ggc_free () call. FIXME: account memory properly in the presence of
@@ -1056,7 +1057,7 @@ ggc_free_overhead (void *ptr)
return;
p = (struct ptr_hash_entry *) *slot;
p->loc->freed += p->size;
- ptr_hash.clear_slot (slot);
+ ptr_hash->clear_slot (slot);
free (p);
}
@@ -1120,12 +1121,12 @@ dump_ggc_loc_statistics (bool final)
ggc_collect ();
loc_array = XCNEWVEC (struct loc_descriptor *,
- loc_hash.elements_with_deleted ());
+ loc_hash->elements_with_deleted ());
fprintf (stderr, "-------------------------------------------------------\n");
fprintf (stderr, "\n%-48s %10s %10s %10s %10s %10s\n",
"source location", "Garbage", "Freed", "Leak", "Overhead", "Times");
fprintf (stderr, "-------------------------------------------------------\n");
- loc_hash.traverse <int *, ggc_add_statistics> (&nentries);
+ loc_hash->traverse <int *, ggc_add_statistics> (&nentries);
qsort (loc_array, nentries, sizeof (*loc_array),
final ? final_cmp_statistic : cmp_statistic);
for (i = 0; i < nentries; i++)