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 * 23 */ 24 25 #ifndef SHARE_VM_CLASSFILE_COMPACTHASHTABLE_INLINE_HPP 26 #define SHARE_VM_CLASSFILE_COMPACTHASHTABLE_INLINE_HPP 27 28 #include "classfile/compactHashtable.hpp" 29 #include "memory/allocation.inline.hpp" 30 #include "oops/oop.inline.hpp" 31 32 template <class T, class N> 33 inline Symbol* CompactHashtable<T, N>::decode_entry(CompactHashtable<Symbol*, char>* const t, 34 u4 offset, const char* name, int len) { 35 Symbol* sym = (Symbol*)(_base_address + offset); 36 if (sym->equals(name, len)) { 37 assert(sym->refcount() == -1, "must be shared"); 38 return sym; 39 } 40 41 return NULL; 42 } 43 44 template <class T, class N> 45 inline oop CompactHashtable<T, N>::decode_entry(CompactHashtable<oop, char>* const t, 46 u4 offset, const char* name, int len) { 47 narrowOop obj = (narrowOop)offset; 48 oop string = oopDesc::decode_heap_oop(obj); 49 if (java_lang_String::equals(string, (jchar*)name, len)) { 50 return string; 51 } 52 53 return NULL; 54 } 55 56 template <class T, class N> 57 inline T CompactHashtable<T,N>::lookup(const N* name, unsigned int hash, int len) { 58 if (_entry_count > 0) { 59 int index = hash % _bucket_count; 60 u4 bucket_info = _buckets[index]; 61 u4 bucket_offset = BUCKET_OFFSET(bucket_info); 62 int bucket_type = BUCKET_TYPE(bucket_info); 63 u4* entry = _entries + bucket_offset; 64 65 if (bucket_type == VALUE_ONLY_BUCKET_TYPE) { 66 T res = decode_entry(this, entry[0], name, len); 67 if (res != NULL) { 68 return res; | 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 * 23 */ 24 25 #ifndef SHARE_VM_CLASSFILE_COMPACTHASHTABLE_INLINE_HPP 26 #define SHARE_VM_CLASSFILE_COMPACTHASHTABLE_INLINE_HPP 27 28 #include "classfile/compactHashtable.hpp" 29 #include "classfile/javaClasses.hpp" 30 #include "memory/allocation.inline.hpp" 31 #include "oops/compressedOops.inline.hpp" 32 #include "oops/oop.hpp" 33 34 template <class T, class N> 35 inline Symbol* CompactHashtable<T, N>::decode_entry(CompactHashtable<Symbol*, char>* const t, 36 u4 offset, const char* name, int len) { 37 Symbol* sym = (Symbol*)(_base_address + offset); 38 if (sym->equals(name, len)) { 39 assert(sym->refcount() == -1, "must be shared"); 40 return sym; 41 } 42 43 return NULL; 44 } 45 46 template <class T, class N> 47 inline oop CompactHashtable<T, N>::decode_entry(CompactHashtable<oop, char>* const t, 48 u4 offset, const char* name, int len) { 49 narrowOop obj = (narrowOop)offset; 50 oop string = CompressedOops::decode(obj); 51 if (java_lang_String::equals(string, (jchar*)name, len)) { 52 return string; 53 } 54 55 return NULL; 56 } 57 58 template <class T, class N> 59 inline T CompactHashtable<T,N>::lookup(const N* name, unsigned int hash, int len) { 60 if (_entry_count > 0) { 61 int index = hash % _bucket_count; 62 u4 bucket_info = _buckets[index]; 63 u4 bucket_offset = BUCKET_OFFSET(bucket_info); 64 int bucket_type = BUCKET_TYPE(bucket_info); 65 u4* entry = _entries + bucket_offset; 66 67 if (bucket_type == VALUE_ONLY_BUCKET_TYPE) { 68 T res = decode_entry(this, entry[0], name, len); 69 if (res != NULL) { 70 return res; |