* gcc-interface/decl.c (value_annotation_hasher::handle_cache_entry):
Delete.
(value_annotation_hasher::keep_cache_entry): New function.
* gcc-interface/utils.c (pad_type_hasher::handle_cache_entry):
Delete.
(pad_type_hasher::keep_cache_entry): New function.
gcc/
* hash-table.h (hash_table): Add gt_cleare_cache as a friend.
(gt_cleare_cache): Check here for deleted and empty entries.
Replace handle_cache_entry with a call to keep_cache_entry.
* hash-traits.h (ggc_cache_hasher::handle_cache_entry): Delete.
(ggc_cache_hasher::keep_cache_entry): New function.
* trans-mem.c (tm_wrapper_hasher::handle_cache_entry): Delete.
(tm_wrapper_hasher::keep_cache_entry): New function.
* tree.h (tree_decl_map_cache_hasher::handle_cache_entry): Delete.
(tree_vec_map_cache_hasher::keep_cache_entry): New function.
* tree.c (type_cache_hasher::handle_cache_entry): Delete.
(type_cache_hasher::keep_cache_entry): New function.
(tree_vec_map_cache_hasher::handle_cache_entry): Delete.
(tree_vec_map_cache_hasher::keep_cache_entry): New function.
* ubsan.c (tree_type_map_cache_hasher::handle_cache_entry): Delete.
(tree_type_map_cache_hasher::keep_cache_entry): New function.
* varasm.c (tm_clone_hasher::handle_cache_entry): Delete.
(tm_clone_hasher::keep_cache_entry): New function.
* config/i386/i386.c (dllimport_hasher::handle_cache_entry): Delete.
(dllimport_hasher::keep_cache_entry): New function.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@224954
138bc75d-0d04-0410-961f-
82ee72b054a4
2015-06-25 Richard Sandiford <richard.sandiford@arm.com>
+ * hash-table.h (hash_table): Add gt_cleare_cache as a friend.
+ (gt_cleare_cache): Check here for deleted and empty entries.
+ Replace handle_cache_entry with a call to keep_cache_entry.
+ * hash-traits.h (ggc_cache_hasher::handle_cache_entry): Delete.
+ (ggc_cache_hasher::keep_cache_entry): New function.
+ * trans-mem.c (tm_wrapper_hasher::handle_cache_entry): Delete.
+ (tm_wrapper_hasher::keep_cache_entry): New function.
+ * tree.h (tree_decl_map_cache_hasher::handle_cache_entry): Delete.
+ (tree_vec_map_cache_hasher::keep_cache_entry): New function.
+ * tree.c (type_cache_hasher::handle_cache_entry): Delete.
+ (type_cache_hasher::keep_cache_entry): New function.
+ (tree_vec_map_cache_hasher::handle_cache_entry): Delete.
+ (tree_vec_map_cache_hasher::keep_cache_entry): New function.
+ * ubsan.c (tree_type_map_cache_hasher::handle_cache_entry): Delete.
+ (tree_type_map_cache_hasher::keep_cache_entry): New function.
+ * varasm.c (tm_clone_hasher::handle_cache_entry): Delete.
+ (tm_clone_hasher::keep_cache_entry): New function.
+ * config/i386/i386.c (dllimport_hasher::handle_cache_entry): Delete.
+ (dllimport_hasher::keep_cache_entry): New function.
+
+2015-06-25 Richard Sandiford <richard.sandiford@arm.com>
+
* hash-table.h: Include hash-traits.h.
(typed_free_remove, typed_noop_remove, pointer_hash, ggc_hasher)
(ggc_cache_hasher): Move to...
+2015-06-25 Richard Sandiford <richard.sandiford@arm.com>
+
+ * gcc-interface/decl.c (value_annotation_hasher::handle_cache_entry):
+ Delete.
+ (value_annotation_hasher::keep_cache_entry): New function.
+ * gcc-interface/utils.c (pad_type_hasher::handle_cache_entry):
+ Delete.
+ (pad_type_hasher::keep_cache_entry): New function.
+
2015-06-25 Andrew MacLeod <amacleod@redhat.com>
* gcc-interface/misc.c: Include calls.h not function.h.
return a->base.from == b->base.from;
}
- static void
- handle_cache_entry (tree_int_map *&m)
+ static int
+ keep_cache_entry (tree_int_map *&m)
{
- extern void gt_ggc_mx (tree_int_map *&);
- if (m == HTAB_EMPTY_ENTRY || m == HTAB_DELETED_ENTRY)
- return;
- else if (ggc_marked_p (m->base.from))
- gt_ggc_mx (m);
- else
- m = static_cast<tree_int_map *> (HTAB_DELETED_ENTRY);
+ return ggc_marked_p (m->base.from);
}
};
{
static inline hashval_t hash (pad_type_hash *t) { return t->hash; }
static bool equal (pad_type_hash *a, pad_type_hash *b);
- static void handle_cache_entry (pad_type_hash *&);
+ static int keep_cache_entry (pad_type_hash *&);
};
static GTY ((cache))
/* See if the data pointed to by the hash table slot is marked. */
-void
-pad_type_hasher::handle_cache_entry (pad_type_hash *&t)
+int
+pad_type_hasher::keep_cache_entry (pad_type_hash *&t)
{
- extern void gt_ggc_mx (pad_type_hash *&);
- if (t == HTAB_EMPTY_ENTRY || t == HTAB_DELETED_ENTRY)
- return;
- else if (ggc_marked_p (t->type))
- gt_ggc_mx (t);
- else
- t = static_cast<pad_type_hash *> (HTAB_DELETED_ENTRY);
+ return ggc_marked_p (t->type);
}
/* Return true iff the padded types are equivalent. */
return a->base.from == b->base.from;
}
- static void
- handle_cache_entry (tree_map *&m)
+ static int
+ keep_cache_entry (tree_map *&m)
{
- extern void gt_ggc_mx (tree_map *&);
- if (m == HTAB_EMPTY_ENTRY || m == HTAB_DELETED_ENTRY)
- return;
- else if (ggc_marked_p (m->base.from))
- gt_ggc_mx (m);
- else
- m = static_cast<tree_map *> (HTAB_DELETED_ENTRY);
+ return ggc_marked_p (m->base.from);
}
};
individual elements of the table need to be disposed of (e.g.,
when deleting a hash table, removing elements from the table, etc).
+ - An optional static function named 'keep_cache_entry'. This
+ function is provided only for garbage-collected elements that
+ are not marked by the normal gc mark pass. It describes what
+ what should happen to the element at the end of the gc mark phase.
+ The return value should be:
+ - 0 if the element should be deleted
+ - 1 if the element should be kept and needs to be marked
+ - -1 if the element should be kept and is already marked.
+ Returning -1 rather than 1 is purely an optimization.
+
3. The type of the hash table itself. (More later.)
In very special circumstances, users may need to know about a fourth type.
template<typename T> friend void gt_pch_nx (hash_table<T> *,
gt_pointer_operator, void *);
+ template<typename T> friend void gt_cleare_cache (hash_table<T> *);
+
value_type *alloc_entries (size_t n CXX_MEM_STAT_INFO) const;
value_type *find_empty_slot_for_expand (hashval_t);
void expand ();
inline void
gt_cleare_cache (hash_table<H> *h)
{
+ extern void gt_ggc_mx (typename H::value_type &t);
+ typedef hash_table<H> table;
if (!h)
return;
- for (typename hash_table<H>::iterator iter = h->begin (); iter != h->end ();
- ++iter)
- H::handle_cache_entry (*iter);
+ for (typename table::iterator iter = h->begin (); iter != h->end (); ++iter)
+ if (!table::is_empty (*iter) && !table::is_deleted (*iter))
+ {
+ int res = H::keep_cache_entry (*iter);
+ if (res == 0)
+ h->clear_slot (&*iter);
+ else if (res != -1)
+ gt_ggc_mx (*iter);
+ }
}
#endif /* TYPED_HASHTAB_H */
op (&p, cookie);
}
- /* Clear out entries if they are about to be gc'd. */
-
- static void
- handle_cache_entry (T &e)
+ static int
+ keep_cache_entry (T &e)
{
- if (e != HTAB_EMPTY_ENTRY && e != HTAB_DELETED_ENTRY && !ggc_marked_p (e))
- e = static_cast<T> (HTAB_DELETED_ENTRY);
+ return ggc_marked_p (e) ? -1 : 0;
}
};
return a->base.from == b->base.from;
}
- static void
- handle_cache_entry (tree_map *&m)
- {
- extern void gt_ggc_mx (tree_map *&);
- if (m == HTAB_EMPTY_ENTRY || m == HTAB_DELETED_ENTRY)
- return;
- else if (ggc_marked_p (m->base.from))
- gt_ggc_mx (m);
- else
- m = static_cast<tree_map *> (HTAB_DELETED_ENTRY);
- }
+ static int
+ keep_cache_entry (tree_map *&m)
+ {
+ return ggc_marked_p (m->base.from);
+ }
};
static GTY((cache)) hash_table<tm_wrapper_hasher> *tm_wrap_map;
static hashval_t hash (type_hash *t) { return t->hash; }
static bool equal (type_hash *a, type_hash *b);
- static void
- handle_cache_entry (type_hash *&t)
+ static int
+ keep_cache_entry (type_hash *&t)
{
- extern void gt_ggc_mx (type_hash *&);
- if (t == HTAB_DELETED_ENTRY || t == HTAB_EMPTY_ENTRY)
- return;
- else if (ggc_marked_p (t->type))
- gt_ggc_mx (t);
- else
- t = static_cast<type_hash *> (HTAB_DELETED_ENTRY);
+ return ggc_marked_p (t->type);
}
};
static GTY ((cache))
hash_table<tree_decl_map_cache_hasher> *value_expr_for_decl;
- struct tree_vec_map_cache_hasher : ggc_cache_hasher<tree_vec_map *>
+struct tree_vec_map_cache_hasher : ggc_cache_hasher<tree_vec_map *>
{
static hashval_t hash (tree_vec_map *m) { return DECL_UID (m->base.from); }
return a->base.from == b->base.from;
}
- static void
- handle_cache_entry (tree_vec_map *&m)
+ static int
+ keep_cache_entry (tree_vec_map *&m)
{
- extern void gt_ggc_mx (tree_vec_map *&);
- if (m == HTAB_EMPTY_ENTRY || m == HTAB_DELETED_ENTRY)
- return;
- else if (ggc_marked_p (m->base.from))
- gt_ggc_mx (m);
- else
- m = static_cast<tree_vec_map *> (HTAB_DELETED_ENTRY);
+ return ggc_marked_p (m->base.from);
}
};
return tree_decl_map_eq (a, b);
}
- static void
- handle_cache_entry (tree_decl_map *&m)
+ static int
+ keep_cache_entry (tree_decl_map *&m)
{
- extern void gt_ggc_mx (tree_decl_map *&);
- if (m == HTAB_EMPTY_ENTRY || m == HTAB_DELETED_ENTRY)
- return;
- else if (ggc_marked_p (m->base.from))
- gt_ggc_mx (m);
- else
- m = static_cast<tree_decl_map *> (HTAB_DELETED_ENTRY);
+ return ggc_marked_p (m->base.from);
}
};
return a->type.from == b->type.from;
}
- static void
- handle_cache_entry (tree_type_map *&m)
+ static int
+ keep_cache_entry (tree_type_map *&m)
{
- extern void gt_ggc_mx (tree_type_map *&);
- if (m == HTAB_EMPTY_ENTRY || m == HTAB_DELETED_ENTRY)
- return;
- else if (ggc_marked_p (m->type.from))
- gt_ggc_mx (m);
- else
- m = static_cast<tree_type_map *> (HTAB_DELETED_ENTRY);
+ return ggc_marked_p (m->type.from);
}
};
static hashval_t hash (tree_map *m) { return tree_map_hash (m); }
static bool equal (tree_map *a, tree_map *b) { return tree_map_eq (a, b); }
- static void
- handle_cache_entry (tree_map *&e)
+ static int
+ keep_cache_entry (tree_map *&e)
{
- extern void gt_ggc_mx (tree_map *&);
- if (e == HTAB_EMPTY_ENTRY || e == HTAB_DELETED_ENTRY)
- return;
- else if (ggc_marked_p (e->base.from))
- gt_ggc_mx (e);
- else
- e = static_cast<tree_map *> (HTAB_DELETED_ENTRY);
+ return ggc_marked_p (e->base.from);
}
};