mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8143615: compactHashtable.hpp includes .inline.hpp file
Reviewed-by: dholmes, stefank
This commit is contained in:
parent
974f9e0483
commit
e708f69e1f
7 changed files with 112 additions and 67 deletions
|
@ -23,6 +23,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "precompiled.hpp"
|
#include "precompiled.hpp"
|
||||||
|
#include "classfile/compactHashtable.inline.hpp"
|
||||||
#include "classfile/javaClasses.hpp"
|
#include "classfile/javaClasses.hpp"
|
||||||
#include "memory/metaspaceShared.hpp"
|
#include "memory/metaspaceShared.hpp"
|
||||||
#include "prims/jvm.h"
|
#include "prims/jvm.h"
|
||||||
|
|
|
@ -27,8 +27,6 @@
|
||||||
|
|
||||||
#include "classfile/stringTable.hpp"
|
#include "classfile/stringTable.hpp"
|
||||||
#include "classfile/symbolTable.hpp"
|
#include "classfile/symbolTable.hpp"
|
||||||
#include "memory/allocation.inline.hpp"
|
|
||||||
#include "oops/oop.inline.hpp"
|
|
||||||
#include "oops/symbol.hpp"
|
#include "oops/symbol.hpp"
|
||||||
#include "services/diagnosticCommand.hpp"
|
#include "services/diagnosticCommand.hpp"
|
||||||
#include "utilities/hashtable.hpp"
|
#include "utilities/hashtable.hpp"
|
||||||
|
@ -117,13 +115,8 @@ public:
|
||||||
return _required_bytes;
|
return _required_bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
void add(unsigned int hash, Symbol* symbol) {
|
inline void add(unsigned int hash, Symbol* symbol);
|
||||||
add(hash, new Entry(hash, symbol));
|
inline void add(unsigned int hash, oop string);
|
||||||
}
|
|
||||||
|
|
||||||
void add(unsigned int hash, oop string) {
|
|
||||||
add(hash, new Entry(hash, string));
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void add(unsigned int hash, Entry* entry);
|
void add(unsigned int hash, Entry* entry);
|
||||||
|
@ -219,27 +212,10 @@ private:
|
||||||
juint* _buckets;
|
juint* _buckets;
|
||||||
|
|
||||||
inline Symbol* lookup_entry(CompactHashtable<Symbol*, char>* const t,
|
inline Symbol* lookup_entry(CompactHashtable<Symbol*, char>* const t,
|
||||||
juint* addr, const char* name, int len) {
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline oop lookup_entry(CompactHashtable<oop, char>* const t,
|
inline oop lookup_entry(CompactHashtable<oop, char>* const t,
|
||||||
juint* addr, const char* name, int len) {
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CompactHashtable() {
|
CompactHashtable() {
|
||||||
_entry_count = 0;
|
_entry_count = 0;
|
||||||
|
@ -257,41 +233,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lookup an entry from the compact table
|
// Lookup an entry from the compact table
|
||||||
inline T lookup(const N* name, unsigned int hash, int len) {
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
// iterate over symbols
|
// iterate over symbols
|
||||||
void symbols_do(SymbolClosure *cl);
|
void symbols_do(SymbolClosure *cl);
|
||||||
|
|
102
hotspot/src/share/vm/classfile/compactHashtable.inline.hpp
Normal file
102
hotspot/src/share/vm/classfile/compactHashtable.inline.hpp
Normal file
|
@ -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 <class T, class N>
|
||||||
|
inline Symbol* CompactHashtable<T, N>::lookup_entry(CompactHashtable<Symbol*, char>* 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 <class T, class N>
|
||||||
|
inline oop CompactHashtable<T, N>::lookup_entry(CompactHashtable<oop, char>* 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 <class T, class N>
|
||||||
|
inline T CompactHashtable<T,N>::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
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
#include "precompiled.hpp"
|
#include "precompiled.hpp"
|
||||||
#include "classfile/altHashing.hpp"
|
#include "classfile/altHashing.hpp"
|
||||||
#include "classfile/compactHashtable.hpp"
|
#include "classfile/compactHashtable.inline.hpp"
|
||||||
#include "classfile/javaClasses.hpp"
|
#include "classfile/javaClasses.hpp"
|
||||||
#include "classfile/stringTable.hpp"
|
#include "classfile/stringTable.hpp"
|
||||||
#include "classfile/systemDictionary.hpp"
|
#include "classfile/systemDictionary.hpp"
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
#include "precompiled.hpp"
|
#include "precompiled.hpp"
|
||||||
#include "classfile/altHashing.hpp"
|
#include "classfile/altHashing.hpp"
|
||||||
#include "classfile/compactHashtable.hpp"
|
#include "classfile/compactHashtable.inline.hpp"
|
||||||
#include "classfile/javaClasses.hpp"
|
#include "classfile/javaClasses.hpp"
|
||||||
#include "classfile/symbolTable.hpp"
|
#include "classfile/symbolTable.hpp"
|
||||||
#include "classfile/systemDictionary.hpp"
|
#include "classfile/systemDictionary.hpp"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -30,7 +30,6 @@
|
||||||
#include "ci/ciUtilities.hpp"
|
#include "ci/ciUtilities.hpp"
|
||||||
#include "compiler/methodMatcher.hpp"
|
#include "compiler/methodMatcher.hpp"
|
||||||
#include "compiler/compilerOracle.hpp"
|
#include "compiler/compilerOracle.hpp"
|
||||||
#include "oops/oop.inline.hpp"
|
|
||||||
#include "utilities/exceptions.hpp"
|
#include "utilities/exceptions.hpp"
|
||||||
|
|
||||||
// Directives flag name, type, default value, compile command name
|
// Directives flag name, type, default value, compile command name
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
#include "precompiled.hpp"
|
#include "precompiled.hpp"
|
||||||
#include "classfile/classLoader.hpp"
|
#include "classfile/classLoader.hpp"
|
||||||
|
#include "classfile/compactHashtable.inline.hpp"
|
||||||
#include "classfile/sharedClassUtil.hpp"
|
#include "classfile/sharedClassUtil.hpp"
|
||||||
#include "classfile/symbolTable.hpp"
|
#include "classfile/symbolTable.hpp"
|
||||||
#include "classfile/systemDictionaryShared.hpp"
|
#include "classfile/systemDictionaryShared.hpp"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue