diff options
author | rsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-06-25 17:05:47 +0000 |
---|---|---|
committer | rsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-06-25 17:05:47 +0000 |
commit | 9937801191a8686d18a79c105b3c3b419c51f174 (patch) | |
tree | ca64d02be9c4087e4dadaeef0f61260ee7abcc17 | |
parent | 142dd62a9ecab4559e6d7b0be471b9dbbebe8956 (diff) | |
download | gcc-9937801191a8686d18a79c105b3c3b419c51f174.tar.gz |
gcc/ada/
* 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
-rw-r--r-- | gcc/ChangeLog | 22 | ||||
-rw-r--r-- | gcc/ada/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/ada/gcc-interface/decl.c | 12 | ||||
-rw-r--r-- | gcc/ada/gcc-interface/utils.c | 14 | ||||
-rw-r--r-- | gcc/config/i386/i386.c | 12 | ||||
-rw-r--r-- | gcc/hash-table.h | 26 | ||||
-rw-r--r-- | gcc/hash-traits.h | 9 | ||||
-rw-r--r-- | gcc/trans-mem.c | 16 | ||||
-rw-r--r-- | gcc/tree.c | 26 | ||||
-rw-r--r-- | gcc/tree.h | 12 | ||||
-rw-r--r-- | gcc/ubsan.c | 12 | ||||
-rw-r--r-- | gcc/varasm.c | 12 |
12 files changed, 88 insertions, 94 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2045dc778c8..71bb2af4552 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,27 @@ 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... diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 09d1ef9e09d..e4fc1250174 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,12 @@ +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. diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index af2d11ed50a..7511c560814 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -148,16 +148,10 @@ struct value_annotation_hasher : ggc_cache_hasher<tree_int_map *> 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); } }; diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c index fbdf4733833..60446009070 100644 --- a/gcc/ada/gcc-interface/utils.c +++ b/gcc/ada/gcc-interface/utils.c @@ -241,7 +241,7 @@ struct pad_type_hasher : ggc_cache_hasher<pad_type_hash *> { 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)) @@ -1168,16 +1168,10 @@ make_type_from_size (tree type, tree size_tree, bool for_biased) /* 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. */ diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 2df91c48d4d..a05f226ef57 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -14221,16 +14221,10 @@ struct dllimport_hasher : ggc_cache_hasher<tree_map *> 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); } }; diff --git a/gcc/hash-table.h b/gcc/hash-table.h index 71c0f63ec9a..d0d93a353ac 100644 --- a/gcc/hash-table.h +++ b/gcc/hash-table.h @@ -52,6 +52,16 @@ along with GCC; see the file COPYING3. If not see 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. @@ -584,6 +594,8 @@ private: 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 (); @@ -1131,12 +1143,20 @@ template<typename H> 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 */ diff --git a/gcc/hash-traits.h b/gcc/hash-traits.h index 1bac581ee6c..3cc6a6fa9dd 100644 --- a/gcc/hash-traits.h +++ b/gcc/hash-traits.h @@ -146,13 +146,10 @@ struct ggc_cache_hasher 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; } }; diff --git a/gcc/trans-mem.c b/gcc/trans-mem.c index 29e56288510..ded1e513705 100644 --- a/gcc/trans-mem.c +++ b/gcc/trans-mem.c @@ -480,17 +480,11 @@ struct tm_wrapper_hasher : ggc_cache_hasher<tree_map *> 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; diff --git a/gcc/tree.c b/gcc/tree.c index d44bc180f51..25112467bec 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -201,16 +201,10 @@ struct type_cache_hasher : ggc_cache_hasher<type_hash *> 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); } }; @@ -259,7 +253,7 @@ static GTY ((cache)) 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); } @@ -269,16 +263,10 @@ static GTY ((cache)) 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); } }; diff --git a/gcc/tree.h b/gcc/tree.h index e9f0d734a43..51465e25b61 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -4635,16 +4635,10 @@ struct tree_decl_map_cache_hasher : ggc_cache_hasher<tree_decl_map *> 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); } }; diff --git a/gcc/ubsan.c b/gcc/ubsan.c index 3809728ce46..14e54ef5e70 100644 --- a/gcc/ubsan.c +++ b/gcc/ubsan.c @@ -97,16 +97,10 @@ struct tree_type_map_cache_hasher : ggc_cache_hasher<tree_type_map *> 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); } }; diff --git a/gcc/varasm.c b/gcc/varasm.c index 056d8c77219..8b4385b7856 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -5795,16 +5795,10 @@ struct tm_clone_hasher : ggc_cache_hasher<tree_map *> 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); } }; |