src/share/vm/utilities/hashtable.inline.hpp

Thu, 19 Mar 2015 19:53:34 +0100

author
zmajo
date
Thu, 19 Mar 2015 19:53:34 +0100
changeset 7638
aefa2e84b424
parent 6911
ce8f6bb717c9
child 7535
7ae4e26cb1e0
permissions
-rw-r--r--

8074869: C2 code generator can replace -0.0f with +0.0f on Linux
Summary: Instead of 'fpclass', use cast float->int and double->long to check if value is +0.0f and +0.0d, respectively.
Reviewed-by: kvn, simonis, dlong

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

mercurial