Mercurial > hg > graal-compiler
annotate src/share/vm/utilities/hashtable.inline.hpp @ 7106:4983da9d3fc7
Merge
author | Christian Wimmer <christian.wimmer@oracle.com> |
---|---|
date | Thu, 29 Nov 2012 17:43:48 -0800 |
parents | d2a62e0f25eb |
children | ce8f6bb717c9 |
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" | |
6197 | 30 #include "utilities/dtrace.hpp" |
1972 | 31 |
0 | 32 // Inline function definitions for hashtable.hpp. |
33 | |
34 // -------------------------------------------------------------------------- | |
35 | |
36 // Initialize a table. | |
37 | |
6197 | 38 template <MEMFLAGS F> inline BasicHashtable<F>::BasicHashtable(int table_size, int entry_size) { |
0 | 39 // Called on startup, no locking needed |
40 initialize(table_size, entry_size, 0); | |
6197 | 41 _buckets = NEW_C_HEAP_ARRAY2(HashtableBucket<F>, table_size, F, CURRENT_PC); |
0 | 42 for (int index = 0; index < _table_size; index++) { |
43 _buckets[index].clear(); | |
44 } | |
45 } | |
46 | |
47 | |
6197 | 48 template <MEMFLAGS F> inline BasicHashtable<F>::BasicHashtable(int table_size, int entry_size, |
49 HashtableBucket<F>* buckets, | |
0 | 50 int number_of_entries) { |
51 // Called on startup, no locking needed | |
52 initialize(table_size, entry_size, number_of_entries); | |
53 _buckets = buckets; | |
54 } | |
55 | |
56 | |
6197 | 57 template <MEMFLAGS F> inline void BasicHashtable<F>::initialize(int table_size, int entry_size, |
0 | 58 int number_of_entries) { |
59 // Called on startup, no locking needed | |
60 _table_size = table_size; | |
61 _entry_size = entry_size; | |
62 _free_list = NULL; | |
63 _first_free_entry = NULL; | |
64 _end_block = NULL; | |
65 _number_of_entries = number_of_entries; | |
66 #ifdef ASSERT | |
67 _lookup_count = 0; | |
68 _lookup_length = 0; | |
69 #endif | |
70 } | |
71 | |
72 | |
73 // The following method is MT-safe and may be used with caution. | |
6197 | 74 template <MEMFLAGS F> inline BasicHashtableEntry<F>* BasicHashtable<F>::bucket(int i) { |
0 | 75 return _buckets[i].get_entry(); |
76 } | |
77 | |
78 | |
6197 | 79 template <MEMFLAGS F> inline void HashtableBucket<F>::set_entry(BasicHashtableEntry<F>* l) { |
0 | 80 // Warning: Preserve store ordering. The SystemDictionary is read |
81 // without locks. The new SystemDictionaryEntry must be | |
82 // complete before other threads can be allowed to see it | |
83 // via a store to _buckets[index]. | |
84 OrderAccess::release_store_ptr(&_entry, l); | |
85 } | |
86 | |
87 | |
6197 | 88 template <MEMFLAGS F> inline BasicHashtableEntry<F>* HashtableBucket<F>::get_entry() const { |
0 | 89 // Warning: Preserve load ordering. The SystemDictionary is read |
90 // without locks. The new SystemDictionaryEntry must be | |
91 // complete before other threads can be allowed to see it | |
92 // via a store to _buckets[index]. | |
6197 | 93 return (BasicHashtableEntry<F>*) OrderAccess::load_ptr_acquire(&_entry); |
0 | 94 } |
95 | |
96 | |
6197 | 97 template <MEMFLAGS F> inline void BasicHashtable<F>::set_entry(int index, BasicHashtableEntry<F>* entry) { |
0 | 98 _buckets[index].set_entry(entry); |
99 } | |
100 | |
101 | |
6197 | 102 template <MEMFLAGS F> inline void BasicHashtable<F>::add_entry(int index, BasicHashtableEntry<F>* entry) { |
0 | 103 entry->set_next(bucket(index)); |
104 _buckets[index].set_entry(entry); | |
105 ++_number_of_entries; | |
106 } | |
107 | |
6197 | 108 template <MEMFLAGS F> inline void BasicHashtable<F>::free_entry(BasicHashtableEntry<F>* entry) { |
0 | 109 entry->set_next(_free_list); |
110 _free_list = entry; | |
111 --_number_of_entries; | |
112 } | |
1972 | 113 |
114 #endif // SHARE_VM_UTILITIES_HASHTABLE_INLINE_HPP |