From 2a22f99cb12d82712dd93cfef808b1cef543601b Mon Sep 17 00:00:00 2001 From: Trevor Saunders Date: Sun, 12 Oct 2014 22:22:53 +0000 Subject: move many gc hashtab to hash_table gcc/ * asan.c, cfgloop.c, cfgloop.h, cgraph.c, cgraph.h, config/darwin.c, config/m32c/m32c.c, config/mep/mep.c, config/mips/mips.c, config/rs6000/rs6000.c, dwarf2out.c, function.c, function.h, gimple-ssa.h, libfuncs.h, optabs.c, output.h, rtl.h, sese.c, symtab.c, tree-cfg.c, tree-dfa.c, tree-ssa.c, varasm.c: Use hash-table instead of hashtab. * doc/gty.texi (for_user): Document new option. * gengtype.c (create_user_defined_type): Don't try to get a struct for char. (walk_type): Don't error out on for_user option. (write_func_for_structure): Emit user marking routines if requested by for_user option. (write_local_func_for_structure): Likewise. (main): Mark types with for_user option as used. * ggc.h (gt_pch_nx): Add overload for unsigned int. * hash-map.h (hash_map::hash_entry::pch_nx_helper): AddOverloads. * hash-table.h (ggc_hasher): New struct. (hash_table::create_ggc): New function. (gt_pch_nx): New overload for hash_table. java/ * class.c, decl.c, except.c, expr.c, java-tree.h, lang.c: Use hash_table instead of hashtab. objc/ * objc-act.c: use hash_table instead of hashtab. cp/ * cp-gimplify.c, cp-tree.h, decl.c, mangle.c, name-lookup.c, pt.c, semantics.c, tree.c, typeck2.c: Use hash_table instead of hashtab. fortran/ * trans-decl.c, trans.c, trans.h: Use hash_table instead of hashtab. c-family/ * c-common.c: Use hash_table instead of hashtab. From-SVN: r216127 --- gcc/objc/ChangeLog | 4 ++++ gcc/objc/objc-act.c | 32 ++++++++++++++++++-------------- 2 files changed, 22 insertions(+), 14 deletions(-) (limited to 'gcc/objc') diff --git a/gcc/objc/ChangeLog b/gcc/objc/ChangeLog index e0fd501..6cfbefa 100644 --- a/gcc/objc/ChangeLog +++ b/gcc/objc/ChangeLog @@ -1,3 +1,7 @@ +2014-10-12 Trevor Saunders + + * objc-act.c: use hash_table instead of hashtab. + 2014-09-15 Jakub Jelinek * Make-lang.in (check_objc_parallelize): Change to just an upper diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index df59981..a703c42 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -253,7 +253,7 @@ vec *local_variables_to_volatilize = NULL; /* Store all constructed constant strings in a hash table so that they get uniqued properly. */ -struct GTY(()) string_descriptor { +struct GTY((for_user)) string_descriptor { /* The literal argument . */ tree literal; @@ -261,7 +261,13 @@ struct GTY(()) string_descriptor { tree constructor; }; -static GTY((param_is (struct string_descriptor))) htab_t string_htab; +struct objc_string_hasher : ggc_hasher +{ + static hashval_t hash (string_descriptor *); + static bool equal (string_descriptor *, string_descriptor *); +}; + +static GTY(()) hash_table *string_htab; FILE *gen_declaration_file; @@ -3107,10 +3113,10 @@ my_build_string_pointer (int len, const char *str) return build1 (ADDR_EXPR, ptrtype, string); } -static hashval_t -string_hash (const void *ptr) +hashval_t +objc_string_hasher::hash (string_descriptor *ptr) { - const_tree const str = ((const struct string_descriptor *)ptr)->literal; + const_tree const str = ptr->literal; const unsigned char *p = (const unsigned char *) TREE_STRING_POINTER (str); int i, len = TREE_STRING_LENGTH (str); hashval_t h = len; @@ -3121,11 +3127,11 @@ string_hash (const void *ptr) return h; } -static int -string_eq (const void *ptr1, const void *ptr2) +bool +objc_string_hasher::equal (string_descriptor *ptr1, string_descriptor *ptr2) { - const_tree const str1 = ((const struct string_descriptor *)ptr1)->literal; - const_tree const str2 = ((const struct string_descriptor *)ptr2)->literal; + const_tree const str1 = ptr1->literal; + const_tree const str2 = ptr2->literal; int len1 = TREE_STRING_LENGTH (str1); return (len1 == TREE_STRING_LENGTH (str2) @@ -3147,7 +3153,6 @@ objc_build_string_object (tree string) int length; tree addr; struct string_descriptor *desc, key; - void **loc; /* We should be passed a STRING_CST. */ gcc_checking_assert (TREE_CODE (string) == STRING_CST); @@ -3198,8 +3203,8 @@ objc_build_string_object (tree string) /* Perhaps we already constructed a constant string just like this one? */ key.literal = string; - loc = htab_find_slot (string_htab, &key, INSERT); - desc = (struct string_descriptor *) *loc; + string_descriptor **loc = string_htab->find_slot (&key, INSERT); + desc = *loc; if (!desc) { @@ -5776,8 +5781,7 @@ hash_init (void) alias_name_map = objc_map_alloc_ggc (200); /* Initialize the hash table used to hold the constant string objects. */ - string_htab = htab_create_ggc (31, string_hash, - string_eq, NULL); + string_htab = hash_table::create_ggc (31); } /* Use the following to add a method to class_method_map or -- cgit v1.1