Mercurial > hg > graal-compiler
annotate 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 |
rev | line source |
---|---|
0 | 1 /* |
6162 | 2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
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 | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #ifndef SHARE_VM_UTILITIES_HASHTABLE_INLINE_HPP |
26 #define SHARE_VM_UTILITIES_HASHTABLE_INLINE_HPP | |
27 | |
28 #include "memory/allocation.inline.hpp" | |
29 #include "utilities/hashtable.hpp" | |
30 | |
0 | 31 // Inline function definitions for hashtable.hpp. |
32 | |
33 // -------------------------------------------------------------------------- | |
34 | |
35 // Initialize a table. | |
36 | |
37 inline BasicHashtable::BasicHashtable(int table_size, int entry_size) { | |
38 // Called on startup, no locking needed | |
39 initialize(table_size, entry_size, 0); | |
40 _buckets = NEW_C_HEAP_ARRAY(HashtableBucket, table_size); | |
41 for (int index = 0; index < _table_size; index++) { | |
42 _buckets[index].clear(); | |
43 } | |
44 } | |
45 | |
46 | |
47 inline BasicHashtable::BasicHashtable(int table_size, int entry_size, | |
48 HashtableBucket* buckets, | |
49 int number_of_entries) { | |
50 // Called on startup, no locking needed | |
51 initialize(table_size, entry_size, number_of_entries); | |
52 _buckets = buckets; | |
53 } | |
54 | |
55 | |
56 inline void BasicHashtable::initialize(int table_size, int entry_size, | |
57 int number_of_entries) { | |
58 // Called on startup, no locking needed | |
59 _table_size = table_size; | |
60 _entry_size = entry_size; | |
61 _free_list = NULL; | |
62 _first_free_entry = NULL; | |
63 _end_block = NULL; | |
64 _number_of_entries = number_of_entries; | |
65 #ifdef ASSERT | |
66 _lookup_count = 0; | |
67 _lookup_length = 0; | |
68 #endif | |
69 } | |
70 | |
71 | |
72 // The following method is MT-safe and may be used with caution. | |
73 inline BasicHashtableEntry* BasicHashtable::bucket(int i) { | |
74 return _buckets[i].get_entry(); | |
75 } | |
76 | |
77 | |
78 inline void HashtableBucket::set_entry(BasicHashtableEntry* l) { | |
79 // Warning: Preserve store ordering. The SystemDictionary is read | |
80 // without locks. The new SystemDictionaryEntry must be | |
81 // complete before other threads can be allowed to see it | |
82 // via a store to _buckets[index]. | |
83 OrderAccess::release_store_ptr(&_entry, l); | |
84 } | |
85 | |
86 | |
87 inline BasicHashtableEntry* HashtableBucket::get_entry() const { | |
88 // Warning: Preserve load ordering. The SystemDictionary is read | |
89 // without locks. The new SystemDictionaryEntry must be | |
90 // complete before other threads can be allowed to see it | |
91 // via a store to _buckets[index]. | |
92 return (BasicHashtableEntry*) OrderAccess::load_ptr_acquire(&_entry); | |
93 } | |
94 | |
95 | |
96 inline void BasicHashtable::set_entry(int index, BasicHashtableEntry* entry) { | |
97 _buckets[index].set_entry(entry); | |
98 } | |
99 | |
100 | |
101 inline void BasicHashtable::add_entry(int index, BasicHashtableEntry* entry) { | |
102 entry->set_next(bucket(index)); | |
103 _buckets[index].set_entry(entry); | |
104 ++_number_of_entries; | |
105 } | |
106 | |
107 inline void BasicHashtable::free_entry(BasicHashtableEntry* entry) { | |
108 entry->set_next(_free_list); | |
109 _free_list = entry; | |
110 --_number_of_entries; | |
111 } | |
1972 | 112 |
113 #endif // SHARE_VM_UTILITIES_HASHTABLE_INLINE_HPP |