# HG changeset patch # User iklam # Date 1449108894 28800 # Wed Dec 02 18:14:54 2015 -0800 # Node ID 5a193afb1ded7043e6bf2ecda34d43486bc6ce0d # Parent 96cc87bb08f8176084c81be5a65f5327743d28a8 8143615: compactHashtable.hpp includes .inline.hpp file Reviewed-by: xxx, yyy diff --git a/src/share/vm/classfile/compactHashtable.cpp b/src/share/vm/classfile/compactHashtable.cpp --- a/src/share/vm/classfile/compactHashtable.cpp +++ b/src/share/vm/classfile/compactHashtable.cpp @@ -23,6 +23,7 @@ */ #include "precompiled.hpp" +#include "classfile/compactHashtable.inline.hpp" #include "classfile/javaClasses.hpp" #include "memory/metaspaceShared.hpp" #include "prims/jvm.h" diff --git a/src/share/vm/classfile/compactHashtable.hpp b/src/share/vm/classfile/compactHashtable.hpp --- a/src/share/vm/classfile/compactHashtable.hpp +++ b/src/share/vm/classfile/compactHashtable.hpp @@ -27,8 +27,6 @@ #include "classfile/stringTable.hpp" #include "classfile/symbolTable.hpp" -#include "memory/allocation.inline.hpp" -#include "oops/oop.inline.hpp" #include "oops/symbol.hpp" #include "services/diagnosticCommand.hpp" #include "utilities/hashtable.hpp" @@ -117,13 +115,8 @@ return _required_bytes; } - void add(unsigned int hash, Symbol* symbol) { - add(hash, new Entry(hash, symbol)); - } - - void add(unsigned int hash, oop string) { - add(hash, new Entry(hash, string)); - } + inline void add(unsigned int hash, Symbol* symbol); + inline void add(unsigned int hash, oop string); private: void add(unsigned int hash, Entry* entry); @@ -219,27 +212,10 @@ juint* _buckets; inline Symbol* lookup_entry(CompactHashtable* const t, - juint* addr, const char* name, int len) { - Symbol* sym = (Symbol*)((void*)(_base_address + *addr)); - if (sym->equals(name, len)) { - assert(sym->refcount() == -1, "must be shared"); - return sym; - } - - return NULL; - } + juint* addr, const char* name, int len); inline oop lookup_entry(CompactHashtable* const t, - juint* addr, const char* name, int len) { - narrowOop obj = (narrowOop)(*addr); - oop string = oopDesc::decode_heap_oop(obj); - if (java_lang_String::equals(string, (jchar*)name, len)) { - return string; - } - - return NULL; - } - + juint* addr, const char* name, int len); public: CompactHashtable() { _entry_count = 0; @@ -257,41 +233,7 @@ } // Lookup an entry from the compact table - inline T lookup(const N* name, unsigned int hash, int len) { - if (_entry_count > 0) { - assert(!DumpSharedSpaces, "run-time only"); - int index = hash % _bucket_count; - juint bucket_info = _buckets[index]; - juint bucket_offset = BUCKET_OFFSET(bucket_info); - int bucket_type = BUCKET_TYPE(bucket_info); - juint* bucket = _buckets + bucket_offset; - juint* bucket_end = _buckets; - - if (bucket_type == COMPACT_BUCKET_TYPE) { - // the compact bucket has one entry with entry offset only - T res = lookup_entry(this, &bucket[0], name, len); - if (res != NULL) { - return res; - } - } else { - // This is a regular bucket, which has more than one - // entries. Each entry is a pair of entry (hash, offset). - // Seek until the end of the bucket. - bucket_end += BUCKET_OFFSET(_buckets[index + 1]); - while (bucket < bucket_end) { - unsigned int h = (unsigned int)(bucket[0]); - if (h == hash) { - T res = lookup_entry(this, &bucket[1], name, len); - if (res != NULL) { - return res; - } - } - bucket += 2; - } - } - } - return NULL; - } + inline T lookup(const N* name, unsigned int hash, int len); // iterate over symbols void symbols_do(SymbolClosure *cl); diff --git a/src/share/vm/classfile/compactHashtable.inline.hpp b/src/share/vm/classfile/compactHashtable.inline.hpp new file mode 100644 --- /dev/null +++ b/src/share/vm/classfile/compactHashtable.inline.hpp @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_CLASSFILE_COMPACTHASHTABLE_INLINE_HPP +#define SHARE_VM_CLASSFILE_COMPACTHASHTABLE_INLINE_HPP + +#include "classfile/compactHashtable.hpp" +#include "memory/allocation.inline.hpp" +#include "oops/oop.inline.hpp" + +template +inline Symbol* CompactHashtable::lookup_entry(CompactHashtable* const t, + juint* addr, const char* name, int len) { + Symbol* sym = (Symbol*)((void*)(_base_address + *addr)); + if (sym->equals(name, len)) { + assert(sym->refcount() == -1, "must be shared"); + return sym; + } + + return NULL; +} + +template +inline oop CompactHashtable::lookup_entry(CompactHashtable* const t, + juint* addr, const char* name, int len) { + narrowOop obj = (narrowOop)(*addr); + oop string = oopDesc::decode_heap_oop(obj); + if (java_lang_String::equals(string, (jchar*)name, len)) { + return string; + } + + return NULL; +} + +template +inline T CompactHashtable::lookup(const N* name, unsigned int hash, int len) { + if (_entry_count > 0) { + assert(!DumpSharedSpaces, "run-time only"); + int index = hash % _bucket_count; + juint bucket_info = _buckets[index]; + juint bucket_offset = BUCKET_OFFSET(bucket_info); + int bucket_type = BUCKET_TYPE(bucket_info); + juint* bucket = _buckets + bucket_offset; + juint* bucket_end = _buckets; + + if (bucket_type == COMPACT_BUCKET_TYPE) { + // the compact bucket has one entry with entry offset only + T res = lookup_entry(this, &bucket[0], name, len); + if (res != NULL) { + return res; + } + } else { + // This is a regular bucket, which has more than one + // entries. Each entry is a pair of entry (hash, offset). + // Seek until the end of the bucket. + bucket_end += BUCKET_OFFSET(_buckets[index + 1]); + while (bucket < bucket_end) { + unsigned int h = (unsigned int)(bucket[0]); + if (h == hash) { + T res = lookup_entry(this, &bucket[1], name, len); + if (res != NULL) { + return res; + } + } + bucket += 2; + } + } + } + return NULL; +} + +inline void CompactHashtableWriter::add(unsigned int hash, Symbol* symbol) { + add(hash, new Entry(hash, symbol)); +} + +inline void CompactHashtableWriter::add(unsigned int hash, oop string) { + add(hash, new Entry(hash, string)); +} + + +#endif // SHARE_VM_CLASSFILE_COMPACTHASHTABLE_INLINE_HPP diff --git a/src/share/vm/classfile/stringTable.cpp b/src/share/vm/classfile/stringTable.cpp --- a/src/share/vm/classfile/stringTable.cpp +++ b/src/share/vm/classfile/stringTable.cpp @@ -24,7 +24,7 @@ #include "precompiled.hpp" #include "classfile/altHashing.hpp" -#include "classfile/compactHashtable.hpp" +#include "classfile/compactHashtable.inline.hpp" #include "classfile/javaClasses.hpp" #include "classfile/stringTable.hpp" #include "classfile/systemDictionary.hpp" diff --git a/src/share/vm/classfile/symbolTable.cpp b/src/share/vm/classfile/symbolTable.cpp --- a/src/share/vm/classfile/symbolTable.cpp +++ b/src/share/vm/classfile/symbolTable.cpp @@ -24,7 +24,7 @@ #include "precompiled.hpp" #include "classfile/altHashing.hpp" -#include "classfile/compactHashtable.hpp" +#include "classfile/compactHashtable.inline.hpp" #include "classfile/javaClasses.hpp" #include "classfile/symbolTable.hpp" #include "classfile/systemDictionary.hpp" diff --git a/src/share/vm/compiler/compilerDirectives.hpp b/src/share/vm/compiler/compilerDirectives.hpp --- a/src/share/vm/compiler/compilerDirectives.hpp +++ b/src/share/vm/compiler/compilerDirectives.hpp @@ -30,7 +30,6 @@ #include "ci/ciUtilities.hpp" #include "compiler/methodMatcher.hpp" #include "compiler/compilerOracle.hpp" -#include "oops/oop.inline.hpp" #include "utilities/exceptions.hpp" // Directives flag name, type, default value, compile command name diff --git a/src/share/vm/memory/filemap.cpp b/src/share/vm/memory/filemap.cpp --- a/src/share/vm/memory/filemap.cpp +++ b/src/share/vm/memory/filemap.cpp @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "classfile/classLoader.hpp" +#include "classfile/compactHashtable.inline.hpp" #include "classfile/sharedClassUtil.hpp" #include "classfile/symbolTable.hpp" #include "classfile/systemDictionaryShared.hpp"