diff options
author | Lawrence Crowl <crowl@google.com> | 2012-10-09 21:21:36 +0000 |
---|---|---|
committer | Lawrence Crowl <crowl@gcc.gnu.org> | 2012-10-09 21:21:36 +0000 |
commit | 703c8606fa58f4c827deda50f641da57294cc78e (patch) | |
tree | 6b83efb5a5d730e31c6760ce9e20be32071b13a4 /gcc/java/jcf-io.c | |
parent | aa4723d7f56dd0c690c514b50c917c827a3d56dd (diff) | |
download | gcc-703c8606fa58f4c827deda50f641da57294cc78e.zip gcc-703c8606fa58f4c827deda50f641da57294cc78e.tar.gz gcc-703c8606fa58f4c827deda50f641da57294cc78e.tar.bz2 |
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 <crowl@google.com>
* 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 <crowl@google.com>
* 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 <crowl@google.com>
* 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 <crowl@google.com>
* 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 <crowl@google.com>
* 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
Diffstat (limited to 'gcc/java/jcf-io.c')
-rw-r--r-- | gcc/java/jcf-io.c | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/gcc/java/jcf-io.c b/gcc/java/jcf-io.c index 0fe30b3..97a3c0f 100644 --- a/gcc/java/jcf-io.c +++ b/gcc/java/jcf-io.c @@ -31,7 +31,7 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */ #include "jcf.h" #include "tree.h" #include "java-tree.h" -#include "hashtab.h" +#include "hash-table.h" #include <dirent.h> #include "zlib.h" @@ -271,20 +271,34 @@ find_classfile (char *filename, JCF *jcf, const char *dep_name) return open_class (filename, jcf, fd, dep_name); } -/* Returns 1 if the CLASSNAME (really a char *) matches the name - stored in TABLE_ENTRY (also a char *). */ -static int -memoized_class_lookup_eq (const void *table_entry, const void *classname) +/* Hash table helper. */ + +struct charstar_hash : typed_noop_remove <char> +{ + typedef const char T; + static inline hashval_t hash (const T *candidate); + static inline bool equal (const T *existing, const T *candidate); +}; + +inline hashval_t +charstar_hash::hash (const T *candidate) { - return strcmp ((const char *)classname, (const char *)table_entry) == 0; + return htab_hash_string (candidate); } +inline bool +charstar_hash::equal (const T *existing, const T *candidate) +{ + return strcmp (existing, candidate) == 0; +} + + /* A hash table keeping track of class names that were not found during class lookup. (There is no need to cache the values associated with names that were found; they are saved in IDENTIFIER_CLASS_VALUE.) */ -static htab_t memoized_class_lookups; +static hash_table <charstar_hash> memoized_class_lookups; /* Returns a freshly malloc'd string with the fully qualified pathname of the .class file for the class CLASSNAME. CLASSNAME must be @@ -306,16 +320,13 @@ find_class (const char *classname, int classname_length, JCF *jcf) hashval_t hash; /* Create the hash table, if it does not already exist. */ - if (!memoized_class_lookups) - memoized_class_lookups = htab_create (37, - htab_hash_string, - memoized_class_lookup_eq, - NULL); + if (!memoized_class_lookups.is_created ()) + memoized_class_lookups.create (37); /* Loop for this class in the hashtable. If it is present, we've already looked for this class and failed to find it. */ - hash = htab_hash_string (classname); - if (htab_find_with_hash (memoized_class_lookups, classname, hash)) + hash = charstar_hash::hash (classname); + if (memoized_class_lookups.find_with_hash (classname, hash)) return NULL; /* Allocate and zero out the buffer, since we don't explicitly put a @@ -390,8 +401,8 @@ find_class (const char *classname, int classname_length, JCF *jcf) /* Remember that this class could not be found so that we do not have to look again. */ - *htab_find_slot_with_hash (memoized_class_lookups, classname, hash, INSERT) - = (void *) CONST_CAST (char *, classname); + *memoized_class_lookups.find_slot_with_hash (classname, hash, INSERT) + = classname; return NULL; found: |