===================================================================
@@ -121,14 +121,11 @@ pointer_hash <Type>::is_empty (Type *e)
return e == NULL;
}
-/* Hasher for entry in gc memory. */
+/* Remover and marker for entries in gc memory. */
template<typename T>
-struct ggc_hasher
+struct ggc_remove
{
- typedef T value_type;
- typedef T compare_type;
-
static void remove (T &) {}
static void
@@ -155,8 +152,11 @@ struct ggc_hasher
/* Hasher for cache entry in gc memory. */
template<typename T>
-struct ggc_cache_hasher : ggc_hasher<T>
+struct ggc_cache_hasher : ggc_remove<T>
{
+ typedef T value_type;
+ typedef T compare_type;
+
/* Entries are weakly held because this is for caches. */
static void ggc_mx (T &) {}
@@ -179,4 +179,10 @@ struct nofree_ptr_hash : pointer_hash <T
template <typename T>
struct free_ptr_hash : pointer_hash <T>, typed_free_remove <T> {};
+/* Traits for elements that point to gc memory. The pointed-to data
+ must be kept across collections. */
+
+template <typename T>
+struct ggc_ptr_hash : pointer_hash <T>, ggc_remove <T *> {};
+
#endif
===================================================================
@@ -91,8 +91,8 @@ Software Foundation; either version 3, o
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 two most common
- policies.
+ hash-traits.h provides class templates for the three most common
+ policies:
* typed_free_remove implements the static 'remove' member function
by calling free().
@@ -100,6 +100,11 @@ Software Foundation; either version 3, o
* typed_noop_remove implements the static 'remove' member function
by doing nothing.
+ * ggc_remove implements the static 'remove' member by doing nothing,
+ but instead provides routines for gc marking and for PCH streaming.
+ Use this for garbage-collected data that needs to be preserved across
+ collections.
+
You can use these policies by simply deriving the descriptor type
from one of those class template, with the appropriate argument.
===================================================================
@@ -88,7 +88,7 @@ struct GTY ((for_user)) loop_exit {
struct loop_exit *next_e;
};
-struct loop_exit_hasher : ggc_hasher<loop_exit *>
+struct loop_exit_hasher : ggc_ptr_hash<loop_exit>
{
typedef edge compare_type;
===================================================================
@@ -44,7 +44,7 @@ struct GTY((for_user)) section_hash_entr
typedef struct section_hash_entry_d section_hash_entry;
-struct section_name_hasher : ggc_hasher<section_hash_entry *>
+struct section_name_hasher : ggc_ptr_hash<section_hash_entry>
{
typedef const char *compare_type;
@@ -783,7 +783,7 @@ enum cgraph_inline_failed_type_t
struct cgraph_edge;
-struct cgraph_edge_hasher : ggc_hasher<cgraph_edge *>
+struct cgraph_edge_hasher : ggc_ptr_hash<cgraph_edge>
{
typedef gimple compare_type;
@@ -2815,7 +2815,7 @@ varpool_node::all_refs_explicit_p ()
&& !force_output);
}
-struct tree_descriptor_hasher : ggc_hasher<constant_descriptor_tree *>
+struct tree_descriptor_hasher : ggc_ptr_hash<constant_descriptor_tree>
{
static hashval_t hash (constant_descriptor_tree *);
static bool equal (constant_descriptor_tree *, constant_descriptor_tree *);
===================================================================
@@ -128,7 +128,7 @@ struct cgraph_2node_hook_list {
/* Hash descriptor for cgraph_function_version_info. */
-struct function_version_hasher : ggc_hasher<cgraph_function_version_info *>
+struct function_version_hasher : ggc_ptr_hash<cgraph_function_version_info>
{
static hashval_t hash (cgraph_function_version_info *);
static bool equal (cgraph_function_version_info *,
===================================================================
@@ -222,7 +222,7 @@ struct GTY((for_user)) indirect_string_n
unsigned int index;
};
-struct indirect_string_hasher : ggc_hasher<indirect_string_node *>
+struct indirect_string_hasher : ggc_ptr_hash<indirect_string_node>
{
typedef const char *compare_type;
@@ -2798,7 +2798,7 @@ static GTY(()) limbo_die_node *limbo_die
DW_AT_{,MIPS_}linkage_name once their DECL_ASSEMBLER_NAMEs are set. */
static GTY(()) limbo_die_node *deferred_asm_name;
-struct dwarf_file_hasher : ggc_hasher<dwarf_file_data *>
+struct dwarf_file_hasher : ggc_ptr_hash<dwarf_file_data>
{
typedef const char *compare_type;
@@ -2809,7 +2809,7 @@ struct dwarf_file_hasher : ggc_hasher<dw
/* Filenames referenced by this compilation unit. */
static GTY(()) hash_table<dwarf_file_hasher> *file_table;
-struct decl_die_hasher : ggc_hasher<die_node *>
+struct decl_die_hasher : ggc_ptr_hash<die_node>
{
typedef tree compare_type;
@@ -2820,7 +2820,7 @@ struct decl_die_hasher : ggc_hasher<die_
The key is a DECL_UID() which is a unique number identifying each decl. */
static GTY (()) hash_table<decl_die_hasher> *decl_die_table;
-struct block_die_hasher : ggc_hasher<die_struct *>
+struct block_die_hasher : ggc_ptr_hash<die_struct>
{
static hashval_t hash (die_struct *);
static bool equal (die_struct *, die_struct *);
@@ -2884,7 +2884,7 @@ struct GTY ((chain_next ("%h.next"))) ca
};
-struct decl_loc_hasher : ggc_hasher<var_loc_list *>
+struct decl_loc_hasher : ggc_ptr_hash<var_loc_list>
{
typedef const_tree compare_type;
@@ -2914,7 +2914,7 @@ struct GTY ((for_user)) cached_dw_loc_li
};
typedef struct cached_dw_loc_list_def cached_dw_loc_list;
-struct dw_loc_list_hasher : ggc_hasher<cached_dw_loc_list *>
+struct dw_loc_list_hasher : ggc_ptr_hash<cached_dw_loc_list>
{
typedef const_tree compare_type;
@@ -4240,7 +4240,7 @@ AT_loc_list_ptr (dw_attr_ref a)
return &a->dw_attr_val.v.val_loc_list;
}
-struct addr_hasher : ggc_hasher<addr_table_entry *>
+struct addr_hasher : ggc_ptr_hash<addr_table_entry>
{
static hashval_t hash (addr_table_entry *);
static bool equal (addr_table_entry *, addr_table_entry *);
===================================================================
@@ -700,7 +700,7 @@ struct GTY((for_user)) types_used_by_var
tree var_decl;
};
-struct used_type_hasher : ggc_hasher<types_used_by_vars_entry *>
+struct used_type_hasher : ggc_ptr_hash<types_used_by_vars_entry>
{
static hashval_t hash (types_used_by_vars_entry *);
static bool equal (types_used_by_vars_entry *, types_used_by_vars_entry *);
===================================================================
@@ -575,7 +575,7 @@ struct GTY((for_user)) temp_slot_address
struct temp_slot *temp_slot;
};
-struct temp_address_hasher : ggc_hasher<temp_slot_address_entry *>
+struct temp_address_hasher : ggc_ptr_hash<temp_slot_address_entry>
{
static hashval_t hash (temp_slot_address_entry *);
static bool equal (temp_slot_address_entry *, temp_slot_address_entry *);
===================================================================
@@ -34,7 +34,7 @@ struct GTY((for_user)) tm_restart_node {
/* Hasher for tm_restart_node. */
-struct tm_restart_hasher : ggc_hasher<tm_restart_node *>
+struct tm_restart_hasher : ggc_ptr_hash<tm_restart_node>
{
static hashval_t hash (tm_restart_node *n) { return htab_hash_pointer (n); }
@@ -45,7 +45,7 @@ struct tm_restart_hasher : ggc_hasher<tm
}
};
-struct ssa_name_hasher : ggc_hasher<tree>
+struct ssa_name_hasher : ggc_ptr_hash<tree_node>
{
/* Hash a tree in a uid_decl_map. */
===================================================================
@@ -61,7 +61,7 @@ struct GTY((for_user)) libfunc_entry {
/* Descriptor for libfunc_entry. */
-struct libfunc_hasher : ggc_hasher<libfunc_entry *>
+struct libfunc_hasher : ggc_ptr_hash<libfunc_entry>
{
static hashval_t hash (libfunc_entry *);
static bool equal (libfunc_entry *, libfunc_entry *);
===================================================================
@@ -508,7 +508,7 @@ struct GTY((for_user)) lto_in_decl_state
typedef struct lto_in_decl_state *lto_in_decl_state_ptr;
-struct decl_state_hasher : ggc_hasher<lto_in_decl_state *>
+struct decl_state_hasher : ggc_ptr_hash<lto_in_decl_state>
{
static hashval_t
hash (lto_in_decl_state *s)
===================================================================
@@ -6053,7 +6053,7 @@ gen_satfractuns_conv_libfunc (convert_op
/* Hashtable callbacks for libfunc_decls. */
-struct libfunc_decl_hasher : ggc_hasher<tree>
+struct libfunc_decl_hasher : ggc_ptr_hash<tree_node>
{
static hashval_t
hash (tree entry)
===================================================================
@@ -341,7 +341,7 @@ static unsigned nb_get_scev = 0;
happen, then it qualifies it with chrec_known. */
tree chrec_known;
-struct scev_info_hasher : ggc_hasher<scev_info_str *>
+struct scev_info_hasher : ggc_ptr_hash<scev_info_str>
{
static hashval_t hash (scev_info_str *i);
static bool equal (const scev_info_str *a, const scev_info_str *b);
===================================================================
@@ -190,7 +190,7 @@ #define IN_NAMED_SECTION(DECL) \
((TREE_CODE (DECL) == FUNCTION_DECL || TREE_CODE (DECL) == VAR_DECL) \
&& DECL_SECTION_NAME (DECL) != NULL)
-struct section_hasher : ggc_hasher<section *>
+struct section_hasher : ggc_ptr_hash<section>
{
typedef const char *compare_type;
@@ -201,7 +201,7 @@ struct section_hasher : ggc_hasher<secti
/* Hash table of named sections. */
static GTY(()) hash_table<section_hasher> *section_htab;
-struct object_block_hasher : ggc_hasher<object_block *>
+struct object_block_hasher : ggc_ptr_hash<object_block>
{
typedef const section *compare_type;
@@ -3541,7 +3541,7 @@ struct GTY((chain_next ("%h.next"), for_
int mark;
};
-struct const_rtx_desc_hasher : ggc_hasher<constant_descriptor_rtx *>
+struct const_rtx_desc_hasher : ggc_ptr_hash<constant_descriptor_rtx>
{
static hashval_t hash (constant_descriptor_rtx *);
static bool equal (constant_descriptor_rtx *, constant_descriptor_rtx *);
===================================================================
@@ -479,7 +479,7 @@ typedef struct GTY ((for_user)) machopic
bool used;
} machopic_indirection;
-struct indirection_hasher : ggc_hasher<machopic_indirection *>
+struct indirection_hasher : ggc_ptr_hash<machopic_indirection>
{
typedef const char *compare_type;
static hashval_t hash (machopic_indirection *);
@@ -3273,7 +3273,7 @@ typedef struct GTY ((for_user)) cfstring
tree constructor;
} cfstring_descriptor;
-struct cfstring_hasher : ggc_hasher<cfstring_descriptor *>
+struct cfstring_hasher : ggc_ptr_hash<cfstring_descriptor>
{
static hashval_t hash (cfstring_descriptor *);
static bool equal (cfstring_descriptor *, cfstring_descriptor *);
===================================================================
@@ -1230,7 +1230,7 @@ struct GTY((for_user)) toc_hash_struct
int labelno;
};
-struct toc_hasher : ggc_hasher<toc_hash_struct *>
+struct toc_hasher : ggc_ptr_hash<toc_hash_struct>
{
static hashval_t hash (toc_hash_struct *);
static bool equal (toc_hash_struct *, toc_hash_struct *);
@@ -1247,7 +1247,7 @@ struct GTY((for_user)) builtin_hash_stru
unsigned char uns_p[4]; /* and whether the types are unsigned. */
};
-struct builtin_hasher : ggc_hasher<builtin_hash_struct *>
+struct builtin_hasher : ggc_ptr_hash<builtin_hash_struct>
{
static hashval_t hash (builtin_hash_struct *);
static bool equal (builtin_hash_struct *, builtin_hash_struct *);
===================================================================
@@ -5092,7 +5092,7 @@ c_apply_type_quals_to_decl (int type_qua
}
}
-struct c_type_hasher : ggc_hasher<tree>
+struct c_type_hasher : ggc_ptr_hash<tree_node>
{
static hashval_t hash (tree);
static bool equal (tree, tree);
===================================================================
@@ -124,7 +124,7 @@ struct GTY((for_user)) constexpr_fundef
tree body;
};
-struct constexpr_fundef_hasher : ggc_hasher<constexpr_fundef *>
+struct constexpr_fundef_hasher : ggc_ptr_hash<constexpr_fundef>
{
static hashval_t hash (constexpr_fundef *);
static bool equal (constexpr_fundef *, constexpr_fundef *);
@@ -873,7 +873,7 @@ struct GTY((for_user)) constexpr_call {
hashval_t hash;
};
-struct constexpr_call_hasher : ggc_hasher<constexpr_call *>
+struct constexpr_call_hasher : ggc_ptr_hash<constexpr_call>
{
static hashval_t hash (constexpr_call *);
static bool equal (constexpr_call *, constexpr_call *);
===================================================================
@@ -1181,7 +1181,7 @@ struct GTY((for_user)) cxx_int_tree_map
tree to;
};
-struct cxx_int_tree_map_hasher : ggc_hasher<cxx_int_tree_map *>
+struct cxx_int_tree_map_hasher : ggc_ptr_hash<cxx_int_tree_map>
{
static hashval_t hash (cxx_int_tree_map *);
static bool equal (cxx_int_tree_map *, cxx_int_tree_map *);
@@ -1189,7 +1189,7 @@ struct cxx_int_tree_map_hasher : ggc_has
struct named_label_entry;
-struct named_label_hasher : ggc_hasher<named_label_entry *>
+struct named_label_hasher : ggc_ptr_hash<named_label_entry>
{
static hashval_t hash (named_label_entry *);
static bool equal (named_label_entry *, named_label_entry *);
===================================================================
@@ -3332,7 +3332,7 @@ struct typename_info {
bool class_p;
};
-struct typename_hasher : ggc_hasher<tree>
+struct typename_hasher : ggc_ptr_hash<tree_node>
{
typedef typename_info *compare_type;
===================================================================
@@ -3844,7 +3844,7 @@ mangle_thunk (tree fn_decl, const int th
return result;
}
-struct conv_type_hasher : ggc_hasher<tree>
+struct conv_type_hasher : ggc_ptr_hash<tree_node>
{
static hashval_t hash (tree);
static bool equal (tree, tree);
===================================================================
@@ -90,7 +90,7 @@ struct GTY((for_user)) spec_entry
tree spec;
};
-struct spec_hasher : ggc_hasher<spec_entry *>
+struct spec_hasher : ggc_ptr_hash<spec_entry>
{
static hashval_t hash (spec_entry *);
static bool equal (spec_entry *, spec_entry *);
===================================================================
@@ -737,7 +737,7 @@ struct cplus_array_info
tree domain;
};
-struct cplus_array_hasher : ggc_hasher<tree>
+struct cplus_array_hasher : ggc_ptr_hash<tree_node>
{
typedef cplus_array_info *compare_type;
@@ -1715,7 +1715,7 @@ struct list_proxy
tree chain;
};
-struct list_hasher : ggc_hasher<tree>
+struct list_hasher : ggc_ptr_hash<tree_node>
{
typedef list_proxy *compare_type;
===================================================================
@@ -157,7 +157,7 @@ struct GTY((chain_next ("%h.next"), for_
struct pending_abstract_type* next;
};
-struct abstract_type_hasher : ggc_hasher<pending_abstract_type *>
+struct abstract_type_hasher : ggc_ptr_hash<pending_abstract_type>
{
typedef tree compare_type;
static hashval_t hash (pending_abstract_type *);
===================================================================
@@ -4363,7 +4363,7 @@ gfc_trans_deferred_vars (gfc_symbol * pr
gfc_add_init_cleanup (block, gfc_finish_block (&tmpblock), NULL_TREE);
}
-struct module_hasher : ggc_hasher<module_htab_entry *>
+struct module_hasher : ggc_ptr_hash<module_htab_entry>
{
typedef const char *compare_type;
===================================================================
@@ -598,7 +598,7 @@ void gfc_generate_module_vars (gfc_names
/* Get the appropriate return statement for a procedure. */
tree gfc_generate_return (void);
-struct module_decl_hasher : ggc_hasher<tree_node *>
+struct module_decl_hasher : ggc_ptr_hash<tree_node>
{
typedef const char *compare_type;
===================================================================
@@ -714,7 +714,7 @@ struct GTY((for_user)) treetreehash_entr
tree value;
};
-struct treetreehasher : ggc_hasher<treetreehash_entry *>
+struct treetreehasher : ggc_ptr_hash<treetreehash_entry>
{
typedef tree compare_type;
@@ -722,7 +722,7 @@ struct treetreehasher : ggc_hasher<treet
static bool equal (treetreehash_entry *, tree);
};
-struct ict_hasher : ggc_hasher<tree_node *>
+struct ict_hasher : ggc_ptr_hash<tree_node>
{
static hashval_t hash (tree t) { return htab_hash_pointer (t); }
static bool equal (tree a, tree b) { return a == b; }
@@ -797,7 +797,7 @@ typedef struct GTY((for_user)) type_asse
tree op2; /* Second operand. */
} type_assertion;
-struct type_assertion_hasher : ggc_hasher<type_assertion *>
+struct type_assertion_hasher : ggc_ptr_hash<type_assertion>
{
static hashval_t hash (type_assertion *);
static bool equal (type_assertion *, type_assertion *);
===================================================================
@@ -268,7 +268,7 @@ struct GTY((for_user)) string_descriptor
tree constructor;
};
-struct objc_string_hasher : ggc_hasher<string_descriptor *>
+struct objc_string_hasher : ggc_ptr_hash<string_descriptor>
{
static hashval_t hash (string_descriptor *);
static bool equal (string_descriptor *, string_descriptor *);