1 /*
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.
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 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
62 _entry_size = entry_size;
63 _free_list = NULL;
64 _first_free_entry = NULL;
65 _end_block = NULL;
66 _number_of_entries = number_of_entries;
67 #ifdef ASSERT
68 _lookup_warning = false;
69 _lookup_count = 0;
70 _lookup_length = 0;
71 #endif
72 }
73
74
75 // The following method is MT-safe and may be used with caution.
76 template <MEMFLAGS F> inline BasicHashtableEntry<F>* BasicHashtable<F>::bucket(int i) const {
77 return _buckets[i].get_entry();
78 }
79
80
81 template <MEMFLAGS F> inline void HashtableBucket<F>::set_entry(BasicHashtableEntry<F>* l) {
82 // Warning: Preserve store ordering. The SystemDictionary is read
83 // without locks. The new SystemDictionaryEntry must be
84 // complete before other threads can be allowed to see it
85 // via a store to _buckets[index].
86 OrderAccess::release_store_ptr(&_entry, l);
87 }
88
89
90 template <MEMFLAGS F> inline BasicHashtableEntry<F>* HashtableBucket<F>::get_entry() const {
91 // Warning: Preserve load ordering. The SystemDictionary is read
92 // without locks. The new SystemDictionaryEntry must be
93 // complete before other threads can be allowed to see it
94 // via a store to _buckets[index].
95 return (BasicHashtableEntry<F>*) OrderAccess::load_ptr_acquire(&_entry);
96 }
97
98
99 template <MEMFLAGS F> inline void BasicHashtable<F>::set_entry(int index, BasicHashtableEntry<F>* entry) {
100 _buckets[index].set_entry(entry);
101 }
102
103
104 template <MEMFLAGS F> inline void BasicHashtable<F>::add_entry(int index, BasicHashtableEntry<F>* entry) {
105 entry->set_next(bucket(index));
106 _buckets[index].set_entry(entry);
107 ++_number_of_entries;
108 }
109
110 template <MEMFLAGS F> inline void BasicHashtable<F>::free_entry(BasicHashtableEntry<F>* entry) {
111 entry->set_next(_free_list);
112 _free_list = entry;
|
1 /*
2 * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
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 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
62 _entry_size = entry_size;
63 _free_list = NULL;
64 _first_free_entry = NULL;
65 _end_block = NULL;
66 _number_of_entries = number_of_entries;
67 #ifdef ASSERT
68 _lookup_warning = false;
69 _lookup_count = 0;
70 _lookup_length = 0;
71 #endif
72 }
73
74
75 // The following method is MT-safe and may be used with caution.
76 template <MEMFLAGS F> inline BasicHashtableEntry<F>* BasicHashtable<F>::bucket(int i) const {
77 return _buckets[i].get_entry();
78 }
79
80
81 template <MEMFLAGS F> inline void HashtableBucket<F>::set_entry(BasicHashtableEntry<F>* l) {
82 // Warning: Preserve store ordering. The PackageEntryTable, ModuleEntryTable and
83 // SystemDictionary are read without locks. The new entry must be
84 // complete before other threads can be allowed to see it
85 // via a store to _buckets[index].
86 OrderAccess::release_store_ptr(&_entry, l);
87 }
88
89
90 template <MEMFLAGS F> inline BasicHashtableEntry<F>* HashtableBucket<F>::get_entry() const {
91 // Warning: Preserve load ordering. The PackageEntryTable, ModuleEntryTable and
92 // SystemDictionary are read without locks. The new entry must be
93 // complete before other threads can be allowed to see it
94 // via a store to _buckets[index].
95 return (BasicHashtableEntry<F>*) OrderAccess::load_ptr_acquire(&_entry);
96 }
97
98
99 template <MEMFLAGS F> inline void BasicHashtable<F>::set_entry(int index, BasicHashtableEntry<F>* entry) {
100 _buckets[index].set_entry(entry);
101 }
102
103
104 template <MEMFLAGS F> inline void BasicHashtable<F>::add_entry(int index, BasicHashtableEntry<F>* entry) {
105 entry->set_next(bucket(index));
106 _buckets[index].set_entry(entry);
107 ++_number_of_entries;
108 }
109
110 template <MEMFLAGS F> inline void BasicHashtable<F>::free_entry(BasicHashtableEntry<F>* entry) {
111 entry->set_next(_free_list);
112 _free_list = entry;
|