comparison src/share/vm/utilities/hashtable.inline.hpp @ 6162:e9140bf80b4a

7158800: Improve storage of symbol tables Summary: Use an alternate version of hashing algorithm for symbol string tables and after a certain bucket size to improve performance Reviewed-by: pbk, kamg, dlong, kvn, fparain
author coleenp
date Wed, 13 Jun 2012 19:52:59 -0400
parents 1d1603768966
children d2a62e0f25eb
comparison
equal deleted inserted replaced
6129:4d399f013e5a 6162:e9140bf80b4a
1 /* 1 /*
2 * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
27 27
28 #include "memory/allocation.inline.hpp" 28 #include "memory/allocation.inline.hpp"
29 #include "utilities/hashtable.hpp" 29 #include "utilities/hashtable.hpp"
30 30
31 // Inline function definitions for hashtable.hpp. 31 // Inline function definitions for hashtable.hpp.
32
33
34 // --------------------------------------------------------------------------
35 // Hash function
36
37 // We originally used hashpjw, but hash P(31) gives just as good results
38 // and is slighly faster. We would like a hash function that looks at every
39 // character, since package names have large common prefixes, and also because
40 // hash_or_fail does error checking while iterating.
41
42 // hash P(31) from Kernighan & Ritchie
43
44 inline unsigned int BasicHashtable::hash_symbol(const char* s, int len) {
45 unsigned int h = 0;
46 while (len-- > 0) {
47 h = 31*h + (unsigned) *s;
48 s++;
49 }
50 return h;
51 }
52
53 32
54 // -------------------------------------------------------------------------- 33 // --------------------------------------------------------------------------
55 34
56 // Initialize a table. 35 // Initialize a table.
57 36