mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-16 17:14:41 +02:00
8269962: SA has unused Hashtable, Dictionary classes
Reviewed-by: cjplummer, iklam, dholmes
This commit is contained in:
parent
4a45d95719
commit
bca570c56e
14 changed files with 3 additions and 669 deletions
|
@ -166,11 +166,6 @@
|
|||
#define JVMTI_STRUCTS(static_field)
|
||||
#endif // INCLUDE_JVMTI
|
||||
|
||||
typedef HashtableEntry<intptr_t, mtInternal> IntptrHashtableEntry;
|
||||
typedef Hashtable<intptr_t, mtInternal> IntptrHashtable;
|
||||
typedef Hashtable<InstanceKlass*, mtClass> KlassHashtable;
|
||||
typedef HashtableEntry<InstanceKlass*, mtClass> KlassHashtableEntry;
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// VM_STRUCTS
|
||||
//
|
||||
|
@ -470,34 +465,12 @@ typedef HashtableEntry<InstanceKlass*, mtClass> KlassHashtableEntry;
|
|||
static_field(Symbol, _vm_symbols[0], Symbol*) \
|
||||
\
|
||||
/*******************/ \
|
||||
/* HashtableBucket */ \
|
||||
/*******************/ \
|
||||
\
|
||||
nonstatic_field(HashtableBucket<mtInternal>, _entry, BasicHashtableEntry<mtInternal>*) \
|
||||
\
|
||||
/******************/ \
|
||||
/* HashtableEntry */ \
|
||||
/******************/ \
|
||||
\
|
||||
nonstatic_field(BasicHashtableEntry<mtInternal>, _next, BasicHashtableEntry<mtInternal>*) \
|
||||
nonstatic_field(BasicHashtableEntry<mtInternal>, _hash, unsigned int) \
|
||||
nonstatic_field(IntptrHashtableEntry, _literal, intptr_t) \
|
||||
\
|
||||
/*************/ \
|
||||
/* Hashtable */ \
|
||||
/*************/ \
|
||||
\
|
||||
nonstatic_field(BasicHashtable<mtInternal>, _table_size, int) \
|
||||
nonstatic_field(BasicHashtable<mtInternal>, _buckets, HashtableBucket<mtInternal>*) \
|
||||
\
|
||||
/*******************/ \
|
||||
/* ClassLoaderData */ \
|
||||
/*******************/ \
|
||||
nonstatic_field(ClassLoaderData, _class_loader, OopHandle) \
|
||||
nonstatic_field(ClassLoaderData, _next, ClassLoaderData*) \
|
||||
volatile_nonstatic_field(ClassLoaderData, _klasses, Klass*) \
|
||||
nonstatic_field(ClassLoaderData, _has_class_mirror_holder, bool) \
|
||||
volatile_nonstatic_field(ClassLoaderData, _dictionary, Dictionary*) \
|
||||
\
|
||||
static_ptr_volatile_field(ClassLoaderDataGraph, _head, ClassLoaderData*) \
|
||||
\
|
||||
|
@ -1309,14 +1282,6 @@ typedef HashtableEntry<InstanceKlass*, mtClass> KlassHashtableEntry;
|
|||
/* SystemDictionary */ \
|
||||
/********************/ \
|
||||
\
|
||||
declare_toplevel_type(BasicHashtable<mtInternal>) \
|
||||
declare_type(IntptrHashtable, BasicHashtable<mtInternal>) \
|
||||
declare_toplevel_type(BasicHashtable<mtSymbol>) \
|
||||
declare_type(Dictionary, KlassHashtable) \
|
||||
declare_toplevel_type(BasicHashtableEntry<mtInternal>) \
|
||||
declare_type(IntptrHashtableEntry, BasicHashtableEntry<mtInternal>) \
|
||||
declare_type(DictionaryEntry, KlassHashtableEntry) \
|
||||
declare_toplevel_type(HashtableBucket<mtInternal>) \
|
||||
declare_toplevel_type(SystemDictionary) \
|
||||
declare_toplevel_type(vmClasses) \
|
||||
declare_toplevel_type(vmSymbols) \
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2021, 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
|
||||
|
@ -47,24 +47,17 @@ public class ClassLoaderData extends VMObject {
|
|||
nextField = type.getAddressField("_next");
|
||||
klassesField = new MetadataField(type.getAddressField("_klasses"), 0);
|
||||
hasClassMirrorHolderField = new CIntField(type.getCIntegerField("_has_class_mirror_holder"), 0);
|
||||
dictionaryField = type.getAddressField("_dictionary");
|
||||
}
|
||||
|
||||
private static long classLoaderFieldOffset;
|
||||
private static AddressField nextField;
|
||||
private static MetadataField klassesField;
|
||||
private static CIntField hasClassMirrorHolderField;
|
||||
private static AddressField dictionaryField;
|
||||
|
||||
public ClassLoaderData(Address addr) {
|
||||
super(addr);
|
||||
}
|
||||
|
||||
public Dictionary dictionary() {
|
||||
Address tmp = dictionaryField.getValue();
|
||||
return (Dictionary) VMObjectFactory.newObject(Dictionary.class, tmp);
|
||||
}
|
||||
|
||||
public static ClassLoaderData instantiateWrapperFor(Address addr) {
|
||||
if (addr == null) {
|
||||
return null;
|
||||
|
@ -114,9 +107,4 @@ public class ClassLoaderData extends VMObject {
|
|||
v.visit(l);
|
||||
}
|
||||
}
|
||||
|
||||
/** Iterate over all klasses in the dictionary, including initiating loader. */
|
||||
public void allEntriesDo(ClassLoaderDataGraph.ClassAndLoaderVisitor v) {
|
||||
dictionary().allEntriesDo(v, getClassLoader());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 2021, 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
|
||||
|
@ -84,12 +84,4 @@ public class ClassLoaderDataGraph {
|
|||
cld.classesDo(v);
|
||||
}
|
||||
}
|
||||
|
||||
/** Iterate over all klasses - including object, primitive
|
||||
array klasses, pass initiating loader. */
|
||||
public void allEntriesDo(ClassAndLoaderVisitor v) {
|
||||
for (ClassLoaderData cld = getClassLoaderGraphHead(); cld != null; cld = cld.next()) {
|
||||
cld.allEntriesDo(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,61 +0,0 @@
|
|||
/*
|
||||
* @(#)BinaryTreeDictionary.java
|
||||
* Copyright (c) 2000, 2020, 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.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.memory;
|
||||
|
||||
import java.util.*;
|
||||
import sun.jvm.hotspot.debugger.*;
|
||||
import sun.jvm.hotspot.types.*;
|
||||
import sun.jvm.hotspot.runtime.*;
|
||||
import sun.jvm.hotspot.utilities.Observable;
|
||||
import sun.jvm.hotspot.utilities.Observer;
|
||||
|
||||
public class AFLBinaryTreeDictionary extends VMObject {
|
||||
static {
|
||||
VM.registerVMInitializedObserver(new Observer() {
|
||||
public void update(Observable o, Object data) {
|
||||
initialize(VM.getVM().getTypeDataBase());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static synchronized void initialize(TypeDataBase db) {
|
||||
Type type = db.lookupType("AFLBinaryTreeDictionary");
|
||||
totalSizeField = type.getCIntegerField("_total_size");
|
||||
}
|
||||
|
||||
// Fields
|
||||
private static CIntegerField totalSizeField;
|
||||
|
||||
// Accessors
|
||||
public long size() {
|
||||
return totalSizeField.getValue(addr);
|
||||
}
|
||||
|
||||
// Constructor
|
||||
public AFLBinaryTreeDictionary(Address addr) {
|
||||
super(addr);
|
||||
}
|
||||
}
|
|
@ -1,102 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2020, 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.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.memory;
|
||||
|
||||
import java.util.*;
|
||||
import sun.jvm.hotspot.debugger.*;
|
||||
import sun.jvm.hotspot.classfile.*;
|
||||
import sun.jvm.hotspot.oops.*;
|
||||
import sun.jvm.hotspot.types.*;
|
||||
import sun.jvm.hotspot.runtime.*;
|
||||
import sun.jvm.hotspot.utilities.*;
|
||||
import sun.jvm.hotspot.utilities.Observable;
|
||||
import sun.jvm.hotspot.utilities.Observer;
|
||||
|
||||
public class Dictionary extends sun.jvm.hotspot.utilities.Hashtable {
|
||||
static {
|
||||
VM.registerVMInitializedObserver(new Observer() {
|
||||
public void update(Observable o, Object data) {
|
||||
initialize(VM.getVM().getTypeDataBase());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static synchronized void initialize(TypeDataBase db) {
|
||||
// just checking that the type exists
|
||||
Type type = db.lookupType("Dictionary");
|
||||
}
|
||||
|
||||
public Dictionary(Address addr) {
|
||||
super(addr);
|
||||
}
|
||||
|
||||
// this is overriden here so that Hashtable.bucket will return
|
||||
// object of DictionaryEntry.class
|
||||
protected Class<? extends HashtableEntry> getHashtableEntryClass() {
|
||||
return DictionaryEntry.class;
|
||||
}
|
||||
|
||||
/** All classes, and their initiating class loader, passed in. */
|
||||
public void allEntriesDo(ClassLoaderDataGraph.ClassAndLoaderVisitor v, Oop loader) {
|
||||
int tblSize = tableSize();
|
||||
for (int index = 0; index < tblSize; index++) {
|
||||
for (DictionaryEntry probe = (DictionaryEntry) bucket(index); probe != null;
|
||||
probe = (DictionaryEntry) probe.next()) {
|
||||
Klass k = probe.klass();
|
||||
// Only visit InstanceKlasses that are at least in the "loaded" init_state. Otherwise
|
||||
// the InstanceKlass won't have some required fields initialized, which can cause problems.
|
||||
if (k instanceof InstanceKlass && !((InstanceKlass)k).isLoaded()) {
|
||||
continue;
|
||||
}
|
||||
v.visit(k, loader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// - Internals only below this point
|
||||
|
||||
private DictionaryEntry getEntry(int index, long hash, Symbol className) {
|
||||
for (DictionaryEntry entry = (DictionaryEntry) bucket(index); entry != null;
|
||||
entry = (DictionaryEntry) entry.next()) {
|
||||
if (entry.hash() == hash && entry.equals(className)) {
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean contains(Klass c) {
|
||||
long hash = computeHash(c.getName());
|
||||
int index = hashToIndex(hash);
|
||||
|
||||
for (DictionaryEntry entry = (DictionaryEntry) bucket(index); entry != null;
|
||||
entry = (DictionaryEntry) entry.next()) {
|
||||
if (entry.literalValue().equals(c.getAddress())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,69 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2020, 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.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.memory;
|
||||
|
||||
import java.util.*;
|
||||
import sun.jvm.hotspot.classfile.ClassLoaderData;
|
||||
import sun.jvm.hotspot.debugger.*;
|
||||
import sun.jvm.hotspot.oops.*;
|
||||
import sun.jvm.hotspot.types.*;
|
||||
import sun.jvm.hotspot.runtime.*;
|
||||
import sun.jvm.hotspot.utilities.*;
|
||||
import sun.jvm.hotspot.utilities.Observable;
|
||||
import sun.jvm.hotspot.utilities.Observer;
|
||||
|
||||
public class DictionaryEntry extends sun.jvm.hotspot.utilities.HashtableEntry {
|
||||
static {
|
||||
VM.registerVMInitializedObserver(new Observer() {
|
||||
public void update(Observable o, Object data) {
|
||||
initialize(VM.getVM().getTypeDataBase());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static synchronized void initialize(TypeDataBase db) {
|
||||
Type type = db.lookupType("DictionaryEntry");
|
||||
}
|
||||
|
||||
public Klass klass() {
|
||||
return (Klass)Metadata.instantiateWrapperFor(literalValue());
|
||||
}
|
||||
|
||||
public DictionaryEntry(Address addr) {
|
||||
super(addr);
|
||||
}
|
||||
|
||||
public boolean equals(Symbol className) {
|
||||
InstanceKlass ik = (InstanceKlass) klass();
|
||||
return ik.getName().equals(className);
|
||||
}
|
||||
|
||||
/* covariant return type :-(
|
||||
public DictionaryEntry next() {
|
||||
return (DictionaryEntry) super.next();
|
||||
}
|
||||
For now, let the caller cast it ..
|
||||
*/
|
||||
}
|
|
@ -29,7 +29,6 @@ import java.util.*;
|
|||
import sun.jvm.hotspot.classfile.ClassLoaderData;
|
||||
import sun.jvm.hotspot.debugger.*;
|
||||
import sun.jvm.hotspot.memory.*;
|
||||
import sun.jvm.hotspot.memory.Dictionary;
|
||||
import sun.jvm.hotspot.runtime.*;
|
||||
import sun.jvm.hotspot.types.*;
|
||||
import sun.jvm.hotspot.utilities.*;
|
||||
|
|
|
@ -81,19 +81,6 @@ public class Symbol extends VMObject {
|
|||
return addr.getJByteAt(baseOffset + index);
|
||||
}
|
||||
|
||||
public long identityHash() {
|
||||
long addr_value = getAddress().asLongValue();
|
||||
long addr_bits =
|
||||
(addr_value >> (VM.getVM().getLogBytesPerWord() + 3)) & 0xffffffffL;
|
||||
int length = (int)getLength();
|
||||
int byte0 = getByteAt(0);
|
||||
int byte1 = getByteAt(1);
|
||||
long id_hash = (long)idHashAndRefcount.getValue(this.addr);
|
||||
id_hash = (id_hash >> 16) & 0xffff;
|
||||
return (id_hash |
|
||||
((addr_bits ^ (length << 8) ^ ((byte0 << 8) | byte1)) << 16)) & 0xffffffffL;
|
||||
}
|
||||
|
||||
public boolean equals(byte[] modUTF8Chars) {
|
||||
int l = (int) getLength();
|
||||
if (l != modUTF8Chars.length) return false;
|
||||
|
|
|
@ -1,81 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2020, 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.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.utilities;
|
||||
|
||||
import java.util.*;
|
||||
import sun.jvm.hotspot.debugger.*;
|
||||
import sun.jvm.hotspot.types.*;
|
||||
import sun.jvm.hotspot.runtime.*;
|
||||
import sun.jvm.hotspot.utilities.Observable;
|
||||
import sun.jvm.hotspot.utilities.Observer;
|
||||
|
||||
// Superclass for symbol and string tables.
|
||||
|
||||
public class BasicHashtable extends VMObject {
|
||||
static {
|
||||
VM.registerVMInitializedObserver(new Observer() {
|
||||
public void update(Observable o, Object data) {
|
||||
initialize(VM.getVM().getTypeDataBase());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static synchronized void initialize(TypeDataBase db) {
|
||||
Type type = db.lookupType("BasicHashtable<mtInternal>");
|
||||
tableSizeField = type.getCIntegerField("_table_size");
|
||||
bucketsField = type.getAddressField("_buckets");
|
||||
bucketSize = db.lookupType("HashtableBucket<mtInternal>").getSize();
|
||||
}
|
||||
|
||||
// Fields
|
||||
private static CIntegerField tableSizeField;
|
||||
private static AddressField bucketsField;
|
||||
private static long bucketSize;
|
||||
|
||||
// Accessors
|
||||
protected int tableSize() {
|
||||
return (int) tableSizeField.getValue(addr);
|
||||
}
|
||||
|
||||
protected BasicHashtableEntry bucket(int i) {
|
||||
if (Assert.ASSERTS_ENABLED) {
|
||||
Assert.that(i >= 0 && i < tableSize(), "Invalid bucket id");
|
||||
}
|
||||
Address tmp = bucketsField.getValue(addr);
|
||||
tmp = tmp.addOffsetTo(i * bucketSize);
|
||||
HashtableBucket bucket = VMObjectFactory.newObject(
|
||||
HashtableBucket.class, tmp);
|
||||
return bucket.getEntry(getHashtableEntryClass());
|
||||
}
|
||||
|
||||
// derived class may return Class<? extends BasicHashtableEntry>
|
||||
protected Class<? extends BasicHashtableEntry> getHashtableEntryClass() {
|
||||
return BasicHashtableEntry.class;
|
||||
}
|
||||
|
||||
public BasicHashtable(Address addr) {
|
||||
super(addr);
|
||||
}
|
||||
}
|
|
@ -1,82 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2020, 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.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.utilities;
|
||||
|
||||
import java.util.*;
|
||||
import sun.jvm.hotspot.debugger.*;
|
||||
import sun.jvm.hotspot.oops.Oop;
|
||||
import sun.jvm.hotspot.oops.ObjectHeap;
|
||||
import sun.jvm.hotspot.types.*;
|
||||
import sun.jvm.hotspot.runtime.*;
|
||||
import sun.jvm.hotspot.utilities.Observable;
|
||||
import sun.jvm.hotspot.utilities.Observer;
|
||||
|
||||
public class BasicHashtableEntry extends VMObject {
|
||||
static {
|
||||
VM.registerVMInitializedObserver(new Observer() {
|
||||
public void update(Observable o, Object data) {
|
||||
initialize(VM.getVM().getTypeDataBase());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static synchronized void initialize(TypeDataBase db) {
|
||||
Type type = db.lookupType("BasicHashtableEntry<mtInternal>");
|
||||
hashField = type.getCIntegerField("_hash");
|
||||
nextField = type.getAddressField("_next");
|
||||
}
|
||||
|
||||
// Fields
|
||||
private static CIntegerField hashField;
|
||||
private static AddressField nextField;
|
||||
|
||||
// Accessors
|
||||
public long hash() {
|
||||
return hashField.getValue(addr) & 0xFFFFFFFFL;
|
||||
}
|
||||
|
||||
private long nextAddressValue() {
|
||||
Debugger dbg = VM.getVM().getDebugger();
|
||||
Address nextValue = nextField.getValue(addr);
|
||||
return (nextValue != null) ? dbg.getAddressValue(nextValue) : 0L;
|
||||
}
|
||||
|
||||
public boolean isShared() {
|
||||
return (nextAddressValue() & 1L) != 0;
|
||||
}
|
||||
|
||||
public BasicHashtableEntry next() {
|
||||
Address nextValue = nextField.getValue(addr);
|
||||
Address next = (nextValue != null)? nextValue.andWithMask(-2L) : null;
|
||||
// using this.getClass so that return type will be as expected in
|
||||
// subclass context. But, because we can't use covariant return type
|
||||
// caller has to use this next and cast the result to correct type.
|
||||
return (BasicHashtableEntry) VMObjectFactory.newObject(this.getClass(), next);
|
||||
}
|
||||
|
||||
public BasicHashtableEntry(Address addr) {
|
||||
super(addr);
|
||||
}
|
||||
}
|
|
@ -1,76 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2020, 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.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.utilities;
|
||||
|
||||
import java.util.*;
|
||||
import sun.jvm.hotspot.debugger.*;
|
||||
import sun.jvm.hotspot.types.*;
|
||||
import sun.jvm.hotspot.oops.*;
|
||||
import sun.jvm.hotspot.runtime.*;
|
||||
import sun.jvm.hotspot.utilities.Observable;
|
||||
import sun.jvm.hotspot.utilities.Observer;
|
||||
|
||||
public class Hashtable extends BasicHashtable {
|
||||
static {
|
||||
VM.registerVMInitializedObserver(new Observer() {
|
||||
public void update(Observable o, Object data) {
|
||||
initialize(VM.getVM().getTypeDataBase());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static synchronized void initialize(TypeDataBase db) {
|
||||
// just to confirm that type exists
|
||||
Type type = db.lookupType("IntptrHashtable");
|
||||
}
|
||||
|
||||
protected Class<? extends HashtableEntry> getHashtableEntryClass() {
|
||||
return HashtableEntry.class;
|
||||
}
|
||||
|
||||
public long computeHash(Symbol name) {
|
||||
return name.identityHash();
|
||||
}
|
||||
|
||||
public int hashToIndex(long fullHash) {
|
||||
return (int) (fullHash % tableSize());
|
||||
}
|
||||
|
||||
public Hashtable(Address addr) {
|
||||
super(addr);
|
||||
}
|
||||
|
||||
// VM's Hashtable::hash_symbol
|
||||
protected static long hashSymbol(byte[] buf) {
|
||||
long h = 0;
|
||||
int s = 0;
|
||||
int len = buf.length;
|
||||
while (len-- > 0) {
|
||||
h = 31*h + (0xFFL & buf[s]);
|
||||
s++;
|
||||
}
|
||||
return h & 0xFFFFFFFFL;
|
||||
}
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2020, 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.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.utilities;
|
||||
|
||||
import java.util.*;
|
||||
import sun.jvm.hotspot.debugger.*;
|
||||
import sun.jvm.hotspot.types.*;
|
||||
import sun.jvm.hotspot.runtime.*;
|
||||
import sun.jvm.hotspot.utilities.Observable;
|
||||
import sun.jvm.hotspot.utilities.Observer;
|
||||
|
||||
public class HashtableBucket extends VMObject {
|
||||
static {
|
||||
VM.registerVMInitializedObserver(new Observer() {
|
||||
public void update(Observable o, Object data) {
|
||||
initialize(VM.getVM().getTypeDataBase());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static synchronized void initialize(TypeDataBase db) {
|
||||
Type type = db.lookupType("HashtableBucket<mtInternal>");
|
||||
entryField = type.getAddressField("_entry");
|
||||
}
|
||||
|
||||
// Field
|
||||
private static AddressField entryField;
|
||||
|
||||
// Accessor
|
||||
public BasicHashtableEntry getEntry(Class<? extends BasicHashtableEntry> clazz) {
|
||||
Address tmp = entryField.getValue(addr);
|
||||
return VMObjectFactory.newObject(clazz, tmp);
|
||||
}
|
||||
|
||||
public BasicHashtableEntry entry() {
|
||||
return getEntry(HashtableEntry.class);
|
||||
}
|
||||
|
||||
public HashtableBucket(Address addr) {
|
||||
super(addr);
|
||||
}
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2020, 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.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.utilities;
|
||||
|
||||
import java.util.*;
|
||||
import sun.jvm.hotspot.debugger.*;
|
||||
import sun.jvm.hotspot.oops.Oop;
|
||||
import sun.jvm.hotspot.oops.ObjectHeap;
|
||||
import sun.jvm.hotspot.types.*;
|
||||
import sun.jvm.hotspot.runtime.*;
|
||||
import sun.jvm.hotspot.utilities.Observable;
|
||||
import sun.jvm.hotspot.utilities.Observer;
|
||||
|
||||
public class HashtableEntry extends BasicHashtableEntry {
|
||||
static {
|
||||
VM.registerVMInitializedObserver(new Observer() {
|
||||
public void update(Observable o, Object data) {
|
||||
initialize(VM.getVM().getTypeDataBase());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static synchronized void initialize(TypeDataBase db) {
|
||||
Type type = db.lookupType("IntptrHashtableEntry");
|
||||
literalField = type.getAddressField("_literal");
|
||||
}
|
||||
|
||||
// Fields
|
||||
private static AddressField literalField;
|
||||
|
||||
// Accessors
|
||||
public Address literalValue() {
|
||||
return literalField.getValue(addr);
|
||||
}
|
||||
|
||||
public HashtableEntry(Address addr) {
|
||||
super(addr);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2021, 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
|
||||
|
@ -56,7 +56,6 @@ public class ClhsdbVmStructsDump {
|
|||
"field InstanceKlass _constants ConstantPool*",
|
||||
"field Klass _name Symbol*",
|
||||
"type ClassLoaderData* null",
|
||||
"type DictionaryEntry KlassHashtableEntry",
|
||||
"field JavaThread _osthread OSThread*",
|
||||
"type TenuredGeneration CardGeneration",
|
||||
"field JVMState _bci",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue