From 703c8606fa58f4c827deda50f641da57294cc78e Mon Sep 17 00:00:00 2001 From: Lawrence Crowl Date: Tue, 9 Oct 2012 21:21:36 +0000 Subject: Change more non-GTY hash tables to use the new type-safe template hash table. Constify member function parameters that can be const. Correct a couple of expressions in formerly uninstantiated templates. The new code is 0.362% faster in bootstrap, with a 99.5% confidence of being faster. Tested on x86-64. Index: gcc/java/ChangeLog 2012-10-01 Lawrence Crowl * Make-lang.in (JAVA_OBJS): Add dependence on hash-table.o. (JCFDUMP_OBJS): Add dependence on hash-table.o. (jcf-io.o): Add dependence on hash-table.h. * jcf-io.c (memoized_class_lookups): Change to use type-safe hash table. Index: gcc/c/ChangeLog 2012-10-09 Lawrence Crowl * Make-lang.in (c-decl.o): Add dependence on hash-table.h. * c-decl.c (detect_field_duplicates_hash): Change to new type-safe hash table. Index: gcc/objc/ChangeLog 2012-10-01 Lawrence Crowl * Make-lang.in (OBJC_OBJS): Add dependence on hash-table.o. (objc-act.o): Add dependence on hash-table.h. * objc-act.c (objc_detect_field_duplicates): Change to new type-safe hash table. Index: gcc/ChangeLog 2012-10-09 Lawrence Crowl * Makefile.in (fold-const.o): Add depencence on hash-table.h. (dse.o): Likewise. (cfg.o): Likewise. * fold-const.c (fold_checksum_tree): Change to new type-safe hash table. * (print_fold_checksum): Likewise. * cfg.c (var bb_original): Likewise. * (var bb_copy): Likewise. * (var loop_copy): Likewise. * hash-table.h (template hash_table): Constify parameters for find... and remove_elt... member functions. (hash_table::empty) Correct size expression. (hash_table::clear_slot) Correct deleted entry assignment. * dse.c (var rtx_group_table): Change to new type-safe hash table. Index: gcc/cp/ChangeLog 2012-10-09 Lawrence Crowl * Make-lang.in (class.o): Add dependence on hash-table.h. (tree.o): Likewise. (semantics.o): Likewise. * class.c (fixed_type_or_null): Change to new type-safe hash table. * tree.c (verify_stmt_tree): Likewise. (verify_stmt_tree_r): Likewise. * semantics.c (struct nrv_data): Likewise. From-SVN: r192273 --- gcc/objc/ChangeLog | 7 +++++++ gcc/objc/Make-lang.in | 4 ++-- gcc/objc/objc-act.c | 33 +++++++++++++++++++-------------- 3 files changed, 28 insertions(+), 16 deletions(-) (limited to 'gcc/objc') diff --git a/gcc/objc/ChangeLog b/gcc/objc/ChangeLog index e8ef7bb347d..575d4733925 100644 --- a/gcc/objc/ChangeLog +++ b/gcc/objc/ChangeLog @@ -1,3 +1,10 @@ +2012-10-01 Lawrence Crowl + + * Make-lang.in (OBJC_OBJS): Add dependence on hash-table.o. + (objc-act.o): Add dependence on hash-table.h. + * objc-act.c (objc_detect_field_duplicates): Change to new type-safe + hash table. + 2012-06-29 Steven Bosscher * Make-ang.in: Adjust for move of C front-end files. diff --git a/gcc/objc/Make-lang.in b/gcc/objc/Make-lang.in index 05ddec639ff..bdc35e559c2 100644 --- a/gcc/objc/Make-lang.in +++ b/gcc/objc/Make-lang.in @@ -50,7 +50,7 @@ START_HDRS = $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) $(C_TREE_H) \ objc-warn = $(STRICT_WARN) # Language-specific object files for Objective C. -OBJC_OBJS = objc/objc-lang.o objc/objc-act.o \ +OBJC_OBJS = objc/objc-lang.o objc/objc-act.o hash-table.o \ objc/objc-runtime-shared-support.o \ objc/objc-gnu-runtime-abi-01.o \ objc/objc-next-runtime-abi-01.o \ @@ -127,7 +127,7 @@ objc/objc-act.o : objc/objc-act.c \ $(START_HDRS) \ $(GGC_H) $(DIAGNOSTIC_CORE_H) $(FLAGS_H) input.h \ toplev.h $(FUNCTION_H) debug.h $(LANGHOOKS_DEF_H) \ - $(HASHTAB_H) $(GIMPLE_H) \ + $(HASH_TABLE_H) $(GIMPLE_H) \ $(C_PRAGMA_H) $(C_TARGET_H) \ objc/objc-encoding.h \ objc/objc-map.h \ diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index caa16c72b50..cf0cc845369 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -51,7 +51,7 @@ along with GCC; see the file COPYING3. If not see #include "intl.h" #include "cgraph.h" #include "tree-iterator.h" -#include "hashtab.h" +#include "hash-table.h" #include "langhooks-def.h" /* Different initialization, code gen and meta data generation for each runtime. */ @@ -3824,18 +3824,23 @@ objc_get_class_ivars (tree class_name) allows us to store keys in the hashtable, without values (it looks more like a set). So, we store the DECLs, but define equality as DECLs having the same name, and hash as the hash of the name. */ -static hashval_t -hash_instance_variable (const PTR p) + +struct decl_name_hash : typed_noop_remove +{ + typedef tree_node T; + static inline hashval_t hash (const T *); + static inline bool equal (const T *, const T *); +}; + +inline hashval_t +decl_name_hash::hash (const T *q) { - const_tree q = (const_tree)p; return (hashval_t) ((intptr_t)(DECL_NAME (q)) >> 3); } -static int -eq_instance_variable (const PTR p1, const PTR p2) +inline bool +decl_name_hash::equal (const T *a, const T *b) { - const_tree a = (const_tree)p1; - const_tree b = (const_tree)p2; return DECL_NAME (a) == DECL_NAME (b); } @@ -3916,8 +3921,8 @@ objc_detect_field_duplicates (bool check_superclasses_only) { /* First, build the hashtable by putting all the instance variables of superclasses in it. */ - htab_t htab = htab_create (37, hash_instance_variable, - eq_instance_variable, NULL); + hash_table htab; + htab.create (37); tree interface; for (interface = lookup_interface (CLASS_SUPER_NAME (objc_interface_context)); @@ -3930,7 +3935,7 @@ objc_detect_field_duplicates (bool check_superclasses_only) { if (DECL_NAME (ivar) != NULL_TREE) { - void **slot = htab_find_slot (htab, ivar, INSERT); + tree_node **slot = htab.find_slot (ivar, INSERT); /* Do not check for duplicate instance variables in superclasses. Errors have already been generated. */ @@ -3950,7 +3955,7 @@ objc_detect_field_duplicates (bool check_superclasses_only) { if (DECL_NAME (ivar) != NULL_TREE) { - tree duplicate_ivar = (tree)(htab_find (htab, ivar)); + tree duplicate_ivar = htab.find (ivar); if (duplicate_ivar != HTAB_EMPTY_ENTRY) { error_at (DECL_SOURCE_LOCATION (ivar), @@ -3977,7 +3982,7 @@ objc_detect_field_duplicates (bool check_superclasses_only) { if (DECL_NAME (ivar) != NULL_TREE) { - void **slot = htab_find_slot (htab, ivar, INSERT); + tree_node **slot = htab.find_slot (ivar, INSERT); if (*slot) { tree duplicate_ivar = (tree)(*slot); @@ -3994,7 +3999,7 @@ objc_detect_field_duplicates (bool check_superclasses_only) } } } - htab_delete (htab); + htab.dispose (); return true; } } -- cgit v1.2.1