From eae1ecb4918474af2840cd4b8b5657eb4fe46df7 Mon Sep 17 00:00:00 2001 From: rsandifo Date: Thu, 25 Jun 2015 17:06:44 +0000 Subject: [PATCH] gcc/ * hash-traits.h (ggc_cache_hasher): Rename to... (ggc_cache_remove): ...this and remove typedefs. (ggc_cache_ptr_hash): New class. * hash-table.h: Update commentary. * emit-rtl.c (const_int_hasher): Inherit from ggc_cache_ptr_hash rather than ggc_cache_hasher. (const_wide_int_hasher, reg_attr_hasher): Likewise. (const_double_hasher, const_fixed_hasher): Likewise. * function.c (insn_cache_hasher): Likewise. * trans-mem.c (tm_wrapper_hasher): Likewise. * tree.h (tree_decl_map_cache_hasher): Likewise. * tree.c (type_cache_hasher, int_cst_hasher): Likewise. (cl_option_hasher, tree_vec_map_cache_hasher): Likewise. * ubsan.c (tree_type_map_cache_hasher): Likewise. * varasm.c (tm_clone_hasher): Likewise. * config/i386/i386.c (dllimport_hasher): Likewise. * config/nvptx/nvptx.c (declared_libfunc_hasher): Likewise. (tree_hasher): Likewise. gcc/ada/ * gcc-interface/decl.c (value_annotation_hasher): Inherit from ggc_cache_ptr_hash rather than ggc_cache_hasher. * gcc-interface/utils.c (pad_type_hasher): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@224960 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 21 +++++++++++++++++++++ gcc/ada/ChangeLog | 6 ++++++ gcc/ada/gcc-interface/decl.c | 2 +- gcc/ada/gcc-interface/utils.c | 2 +- gcc/config/i386/i386.c | 2 +- gcc/config/nvptx/nvptx.c | 4 ++-- gcc/emit-rtl.c | 10 +++++----- gcc/function.c | 2 +- gcc/hash-table.h | 9 ++++++++- gcc/hash-traits.h | 15 ++++++++++----- gcc/trans-mem.c | 2 +- gcc/tree.c | 8 ++++---- gcc/tree.h | 2 +- gcc/ubsan.c | 2 +- gcc/varasm.c | 2 +- 15 files changed, 64 insertions(+), 25 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9737e4ada5c..3f906d8eff6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,26 @@ 2015-06-25 Richard Sandiford + * hash-traits.h (ggc_cache_hasher): Rename to... + (ggc_cache_remove): ...this and remove typedefs. + (ggc_cache_ptr_hash): New class. + * hash-table.h: Update commentary. + * emit-rtl.c (const_int_hasher): Inherit from ggc_cache_ptr_hash + rather than ggc_cache_hasher. + (const_wide_int_hasher, reg_attr_hasher): Likewise. + (const_double_hasher, const_fixed_hasher): Likewise. + * function.c (insn_cache_hasher): Likewise. + * trans-mem.c (tm_wrapper_hasher): Likewise. + * tree.h (tree_decl_map_cache_hasher): Likewise. + * tree.c (type_cache_hasher, int_cst_hasher): Likewise. + (cl_option_hasher, tree_vec_map_cache_hasher): Likewise. + * ubsan.c (tree_type_map_cache_hasher): Likewise. + * varasm.c (tm_clone_hasher): Likewise. + * config/i386/i386.c (dllimport_hasher): Likewise. + * config/nvptx/nvptx.c (declared_libfunc_hasher): Likewise. + (tree_hasher): Likewise. + +2015-06-25 Richard Sandiford + * hash-traits.h (ggc_hasher): Rename to... (ggc_remover): ...this and remove typedefs. (ggc_cache_hasher): Update accordingly. Add typedefs. diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index e4fc1250174..d07340a459c 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,5 +1,11 @@ 2015-06-25 Richard Sandiford + * gcc-interface/decl.c (value_annotation_hasher): Inherit from + ggc_cache_ptr_hash rather than ggc_cache_hasher. + * gcc-interface/utils.c (pad_type_hasher): Likewise. + +2015-06-25 Richard Sandiford + * gcc-interface/decl.c (value_annotation_hasher::handle_cache_entry): Delete. (value_annotation_hasher::keep_cache_entry): New function. diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index 7511c560814..1c82b6eb926 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -134,7 +134,7 @@ typedef struct variant_desc_d { /* A hash table used to cache the result of annotate_value. */ -struct value_annotation_hasher : ggc_cache_hasher +struct value_annotation_hasher : ggc_cache_ptr_hash { static inline hashval_t hash (tree_int_map *m) diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c index 60446009070..f09db594614 100644 --- a/gcc/ada/gcc-interface/utils.c +++ b/gcc/ada/gcc-interface/utils.c @@ -237,7 +237,7 @@ struct GTY((for_user)) pad_type_hash { tree type; }; -struct pad_type_hasher : ggc_cache_hasher +struct pad_type_hasher : ggc_cache_ptr_hash { static inline hashval_t hash (pad_type_hash *t) { return t->hash; } static bool equal (pad_type_hash *a, pad_type_hash *b); diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index a05f226ef57..5c904409bba 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -14212,7 +14212,7 @@ legitimize_tls_address (rtx x, enum tls_model model, bool for_mov) to symbol DECL if BEIMPORT is true. Otherwise create or return the unique refptr-DECL symbol corresponding to symbol DECL. */ -struct dllimport_hasher : ggc_cache_hasher +struct dllimport_hasher : ggc_cache_ptr_hash { static inline hashval_t hash (tree_map *m) { return m->hash; } static inline bool diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c index 98e7422520f..af08abefa5e 100644 --- a/gcc/config/nvptx/nvptx.c +++ b/gcc/config/nvptx/nvptx.c @@ -66,7 +66,7 @@ decls corresponding to them. */ static std::stringstream func_decls; -struct declared_libfunc_hasher : ggc_cache_hasher +struct declared_libfunc_hasher : ggc_cache_ptr_hash { static hashval_t hash (rtx x) { return htab_hash_pointer (x); } static bool equal (rtx a, rtx b) { return a == b; } @@ -75,7 +75,7 @@ struct declared_libfunc_hasher : ggc_cache_hasher static GTY((cache)) hash_table *declared_libfuncs_htab; - struct tree_hasher : ggc_cache_hasher +struct tree_hasher : ggc_cache_ptr_hash { static hashval_t hash (tree t) { return htab_hash_pointer (t); } static bool equal (tree a, tree b) { return a == b; } diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index bab02fe76c5..e7f7eab4fe2 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -140,7 +140,7 @@ rtx_insn *invalid_insn_rtx; /* A hash table storing CONST_INTs whose absolute value is greater than MAX_SAVED_CONST_INT. */ -struct const_int_hasher : ggc_cache_hasher +struct const_int_hasher : ggc_cache_ptr_hash { typedef HOST_WIDE_INT compare_type; @@ -150,7 +150,7 @@ struct const_int_hasher : ggc_cache_hasher static GTY ((cache)) hash_table *const_int_htab; -struct const_wide_int_hasher : ggc_cache_hasher +struct const_wide_int_hasher : ggc_cache_ptr_hash { static hashval_t hash (rtx x); static bool equal (rtx x, rtx y); @@ -159,7 +159,7 @@ struct const_wide_int_hasher : ggc_cache_hasher static GTY ((cache)) hash_table *const_wide_int_htab; /* A hash table storing register attribute structures. */ -struct reg_attr_hasher : ggc_cache_hasher +struct reg_attr_hasher : ggc_cache_ptr_hash { static hashval_t hash (reg_attrs *x); static bool equal (reg_attrs *a, reg_attrs *b); @@ -168,7 +168,7 @@ struct reg_attr_hasher : ggc_cache_hasher static GTY ((cache)) hash_table *reg_attrs_htab; /* A hash table storing all CONST_DOUBLEs. */ -struct const_double_hasher : ggc_cache_hasher +struct const_double_hasher : ggc_cache_ptr_hash { static hashval_t hash (rtx x); static bool equal (rtx x, rtx y); @@ -177,7 +177,7 @@ struct const_double_hasher : ggc_cache_hasher static GTY ((cache)) hash_table *const_double_htab; /* A hash table storing all CONST_FIXEDs. */ -struct const_fixed_hasher : ggc_cache_hasher +struct const_fixed_hasher : ggc_cache_ptr_hash { static hashval_t hash (rtx x); static bool equal (rtx x, rtx y); diff --git a/gcc/function.c b/gcc/function.c index f6b7d30b07b..cb3e9bb4ca0 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -122,7 +122,7 @@ struct function *cfun = 0; /* These hashes record the prologue and epilogue insns. */ -struct insn_cache_hasher : ggc_cache_hasher +struct insn_cache_hasher : ggc_cache_ptr_hash { static hashval_t hash (rtx x) { return htab_hash_pointer (x); } static bool equal (rtx a, rtx b) { return a == b; } diff --git a/gcc/hash-table.h b/gcc/hash-table.h index 3f49345a909..5f3dbede8c1 100644 --- a/gcc/hash-table.h +++ b/gcc/hash-table.h @@ -91,7 +91,7 @@ along with GCC; see the file COPYING3. If not see We compose this into a few steps. 1. Decide on a removal policy for values stored in the table. - hash-traits.h provides class templates for the three most common + hash-traits.h provides class templates for the four most common policies: * typed_free_remove implements the static 'remove' member function @@ -105,6 +105,13 @@ along with GCC; see the file COPYING3. If not see Use this for garbage-collected data that needs to be preserved across collections. + * ggc_cache_remove is like ggc_remove, except that it does not + mark the entries during the normal gc mark phase. Instead it + uses 'keep_cache_entry' (described above) to keep elements that + were not collected and delete those that were. Use this for + garbage-collected caches that should not in themselves stop + the data from being collected. + You can use these policies by simply deriving the descriptor type from one of those class template, with the appropriate argument. diff --git a/gcc/hash-traits.h b/gcc/hash-traits.h index 77f88f30dc6..5fd43f1f54f 100644 --- a/gcc/hash-traits.h +++ b/gcc/hash-traits.h @@ -149,14 +149,12 @@ struct ggc_remove } }; -/* Hasher for cache entry in gc memory. */ +/* Remover and marker for "cache" entries in gc memory. These entries can + be deleted if there are no non-cache references to the data. */ template -struct ggc_cache_hasher : ggc_remove +struct ggc_cache_remove : ggc_remove { - typedef T value_type; - typedef T compare_type; - /* Entries are weakly held because this is for caches. */ static void ggc_mx (T &) {} @@ -185,4 +183,11 @@ struct free_ptr_hash : pointer_hash , typed_free_remove {}; template struct ggc_ptr_hash : pointer_hash , ggc_remove {}; +/* Traits for elements that point to gc memory. The elements don't + in themselves keep the pointed-to data alive and they can be deleted + if the pointed-to data is going to be collected. */ + +template +struct ggc_cache_ptr_hash : pointer_hash , ggc_cache_remove {}; + #endif diff --git a/gcc/trans-mem.c b/gcc/trans-mem.c index b3dbcbd795c..9e860ce7942 100644 --- a/gcc/trans-mem.c +++ b/gcc/trans-mem.c @@ -471,7 +471,7 @@ build_tm_abort_call (location_t loc, bool is_outer) /* Map for aribtrary function replacement under TM, as created by the tm_wrap attribute. */ -struct tm_wrapper_hasher : ggc_cache_hasher +struct tm_wrapper_hasher : ggc_cache_ptr_hash { static inline hashval_t hash (tree_map *m) { return m->hash; } static inline bool diff --git a/gcc/tree.c b/gcc/tree.c index 25112467bec..139544d603e 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -196,7 +196,7 @@ struct GTY((for_user)) type_hash { /* Initial size of the hash table (rounded to next prime). */ #define TYPE_HASH_INITIAL_SIZE 1000 -struct type_cache_hasher : ggc_cache_hasher +struct type_cache_hasher : ggc_cache_ptr_hash { static hashval_t hash (type_hash *t) { return t->hash; } static bool equal (type_hash *a, type_hash *b); @@ -220,7 +220,7 @@ static GTY ((cache)) hash_table *type_hash_table; /* Hash table and temporary node for larger integer const values. */ static GTY (()) tree int_cst_node; -struct int_cst_hasher : ggc_cache_hasher +struct int_cst_hasher : ggc_cache_ptr_hash { static hashval_t hash (tree t); static bool equal (tree x, tree y); @@ -236,7 +236,7 @@ static GTY ((cache)) hash_table *int_cst_hash_table; static GTY (()) tree cl_optimization_node; static GTY (()) tree cl_target_option_node; -struct cl_option_hasher : ggc_cache_hasher +struct cl_option_hasher : ggc_cache_ptr_hash { static hashval_t hash (tree t); static bool equal (tree x, tree y); @@ -253,7 +253,7 @@ static GTY ((cache)) static GTY ((cache)) hash_table *value_expr_for_decl; -struct tree_vec_map_cache_hasher : ggc_cache_hasher +struct tree_vec_map_cache_hasher : ggc_cache_ptr_hash { static hashval_t hash (tree_vec_map *m) { return DECL_UID (m->base.from); } diff --git a/gcc/tree.h b/gcc/tree.h index 51465e25b61..250f99d14b3 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -4626,7 +4626,7 @@ extern unsigned int tree_map_hash (const void *); extern unsigned int tree_decl_map_hash (const void *); #define tree_decl_map_marked_p tree_map_base_marked_p -struct tree_decl_map_cache_hasher : ggc_cache_hasher +struct tree_decl_map_cache_hasher : ggc_cache_ptr_hash { static hashval_t hash (tree_decl_map *m) { return tree_decl_map_hash (m); } static bool diff --git a/gcc/ubsan.c b/gcc/ubsan.c index 14e54ef5e70..ded725a55d0 100644 --- a/gcc/ubsan.c +++ b/gcc/ubsan.c @@ -83,7 +83,7 @@ struct GTY((for_user)) tree_type_map { tree decl; }; -struct tree_type_map_cache_hasher : ggc_cache_hasher +struct tree_type_map_cache_hasher : ggc_cache_ptr_hash { static inline hashval_t hash (tree_type_map *t) diff --git a/gcc/varasm.c b/gcc/varasm.c index 0f87228600b..611b6ca4940 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -5790,7 +5790,7 @@ assemble_alias (tree decl, tree target) to its transaction aware clone. Note that tm_pure functions are considered to be their own clone. */ -struct tm_clone_hasher : ggc_cache_hasher +struct tm_clone_hasher : ggc_cache_ptr_hash { 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); } -- 2.11.4.GIT