Sat, 18 May 2013 20:41:01 -0700
8014262: PrintStringTableStatistics should include more footprint info
Summary: Added info for the string/symbol objects and the hash entries
Reviewed-by: coleenp, rbackman
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" |
stefank@2314 | 29 | #include "utilities/hashtable.hpp" |
zgu@3900 | 30 | #include "utilities/dtrace.hpp" |
stefank@2314 | 31 | |
duke@435 | 32 | // Inline function definitions for hashtable.hpp. |
duke@435 | 33 | |
duke@435 | 34 | // -------------------------------------------------------------------------- |
duke@435 | 35 | |
duke@435 | 36 | // Initialize a table. |
duke@435 | 37 | |
zgu@3900 | 38 | template <MEMFLAGS F> inline BasicHashtable<F>::BasicHashtable(int table_size, int entry_size) { |
duke@435 | 39 | // Called on startup, no locking needed |
duke@435 | 40 | initialize(table_size, entry_size, 0); |
zgu@3900 | 41 | _buckets = NEW_C_HEAP_ARRAY2(HashtableBucket<F>, table_size, F, CURRENT_PC); |
duke@435 | 42 | for (int index = 0; index < _table_size; index++) { |
duke@435 | 43 | _buckets[index].clear(); |
duke@435 | 44 | } |
duke@435 | 45 | } |
duke@435 | 46 | |
duke@435 | 47 | |
zgu@3900 | 48 | template <MEMFLAGS F> inline BasicHashtable<F>::BasicHashtable(int table_size, int entry_size, |
zgu@3900 | 49 | HashtableBucket<F>* buckets, |
duke@435 | 50 | int number_of_entries) { |
duke@435 | 51 | // Called on startup, no locking needed |
duke@435 | 52 | initialize(table_size, entry_size, number_of_entries); |
duke@435 | 53 | _buckets = buckets; |
duke@435 | 54 | } |
duke@435 | 55 | |
duke@435 | 56 | |
zgu@3900 | 57 | template <MEMFLAGS F> inline void BasicHashtable<F>::initialize(int table_size, int entry_size, |
duke@435 | 58 | int number_of_entries) { |
duke@435 | 59 | // Called on startup, no locking needed |
duke@435 | 60 | _table_size = table_size; |
duke@435 | 61 | _entry_size = entry_size; |
duke@435 | 62 | _free_list = NULL; |
duke@435 | 63 | _first_free_entry = NULL; |
duke@435 | 64 | _end_block = NULL; |
duke@435 | 65 | _number_of_entries = number_of_entries; |
duke@435 | 66 | #ifdef ASSERT |
duke@435 | 67 | _lookup_count = 0; |
duke@435 | 68 | _lookup_length = 0; |
duke@435 | 69 | #endif |
duke@435 | 70 | } |
duke@435 | 71 | |
duke@435 | 72 | |
duke@435 | 73 | // The following method is MT-safe and may be used with caution. |
zgu@3900 | 74 | template <MEMFLAGS F> inline BasicHashtableEntry<F>* BasicHashtable<F>::bucket(int i) { |
duke@435 | 75 | return _buckets[i].get_entry(); |
duke@435 | 76 | } |
duke@435 | 77 | |
duke@435 | 78 | |
zgu@3900 | 79 | template <MEMFLAGS F> inline void HashtableBucket<F>::set_entry(BasicHashtableEntry<F>* l) { |
duke@435 | 80 | // Warning: Preserve store ordering. The SystemDictionary is read |
duke@435 | 81 | // without locks. The new SystemDictionaryEntry must be |
duke@435 | 82 | // complete before other threads can be allowed to see it |
duke@435 | 83 | // via a store to _buckets[index]. |
duke@435 | 84 | OrderAccess::release_store_ptr(&_entry, l); |
duke@435 | 85 | } |
duke@435 | 86 | |
duke@435 | 87 | |
zgu@3900 | 88 | template <MEMFLAGS F> inline BasicHashtableEntry<F>* HashtableBucket<F>::get_entry() const { |
duke@435 | 89 | // Warning: Preserve load ordering. The SystemDictionary is read |
duke@435 | 90 | // without locks. The new SystemDictionaryEntry must be |
duke@435 | 91 | // complete before other threads can be allowed to see it |
duke@435 | 92 | // via a store to _buckets[index]. |
zgu@3900 | 93 | return (BasicHashtableEntry<F>*) OrderAccess::load_ptr_acquire(&_entry); |
duke@435 | 94 | } |
duke@435 | 95 | |
duke@435 | 96 | |
zgu@3900 | 97 | template <MEMFLAGS F> inline void BasicHashtable<F>::set_entry(int index, BasicHashtableEntry<F>* entry) { |
duke@435 | 98 | _buckets[index].set_entry(entry); |
duke@435 | 99 | } |
duke@435 | 100 | |
duke@435 | 101 | |
zgu@3900 | 102 | template <MEMFLAGS F> inline void BasicHashtable<F>::add_entry(int index, BasicHashtableEntry<F>* entry) { |
duke@435 | 103 | entry->set_next(bucket(index)); |
duke@435 | 104 | _buckets[index].set_entry(entry); |
duke@435 | 105 | ++_number_of_entries; |
duke@435 | 106 | } |
duke@435 | 107 | |
zgu@3900 | 108 | template <MEMFLAGS F> inline void BasicHashtable<F>::free_entry(BasicHashtableEntry<F>* entry) { |
duke@435 | 109 | entry->set_next(_free_list); |
duke@435 | 110 | _free_list = entry; |
duke@435 | 111 | --_number_of_entries; |
duke@435 | 112 | } |
stefank@2314 | 113 | |
stefank@2314 | 114 | #endif // SHARE_VM_UTILITIES_HASHTABLE_INLINE_HPP |