Skip to content

Commit

Permalink
8300888: [Lilliput] Remaining missing parts in the SA
Browse files Browse the repository at this point in the history
Reviewed-by: shade
  • Loading branch information
rkennke committed Jan 27, 2023
1 parent bf6d4f3 commit 10e00d3
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 90 deletions.
1 change: 1 addition & 0 deletions src/hotspot/share/runtime/vmStructs.cpp
Expand Up @@ -2611,6 +2611,7 @@
declare_constant(markWord::lock_shift) \
declare_constant(markWord::age_shift) \
declare_constant(markWord::hash_shift) \
LP64_ONLY(declare_constant(markWord::klass_shift)) \
\
declare_constant(markWord::lock_mask) \
declare_constant(markWord::lock_mask_in_place) \
Expand Down
Expand Up @@ -24,6 +24,8 @@

package sun.jvm.hotspot.debugger;

import sun.jvm.hotspot.oops.Mark;

/** <P> DebuggerBase is a recommended base class for debugger
implementations. It can use a PageCache to cache data from the
target process. Note that this class would not be suitable if the
Expand Down Expand Up @@ -394,7 +396,11 @@ protected long readCompOopAddressValue(long address)

protected long readCompKlassAddressValue(long address)
throws UnmappedAddressException, UnalignedAddressException {
long value = readCInteger(address, getKlassPtrSize(), true);
// On 64 bit systems, the compressed Klass* is currently read from the mark
// word. We need to load the whole mark, and shift the upper parts.
long value = readCInteger(address, machDesc.getAddressSize(), true);
value = value >>> Mark.getKlassShift();

// Todo: Lilliput: this is a hack. The real problem is the assumption that size
// of a narrow Klass pointer can be expressed in number of bytes (getKlassPtrSize).
// That assumption is present in a number of files here. Better would be
Expand Down
31 changes: 10 additions & 21 deletions src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Array.java
Expand Up @@ -61,32 +61,15 @@ private static long headerSizeInBytes() {
if (headerSize != 0) {
return headerSize;
}
if (VM.getVM().isCompressedKlassPointersEnabled()) {
headerSize = typeSize;
} else {
headerSize = VM.getVM().alignUp(typeSize + VM.getVM().getIntSize(),
VM.getVM().getHeapWordSize());
}
headerSize = lengthOffsetInBytes() + VM.getVM().getIntSize();
return headerSize;
}

private static long headerSize(BasicType type) {
if (Universe.elementTypeShouldBeAligned(type)) {
return alignObjectSize(headerSizeInBytes())/VM.getVM().getHeapWordSize();
} else {
return headerSizeInBytes()/VM.getVM().getHeapWordSize();
}
}

private long lengthOffsetInBytes() {
private static long lengthOffsetInBytes() {
if (lengthOffsetInBytes != 0) {
return lengthOffsetInBytes;
}
if (VM.getVM().isCompressedKlassPointersEnabled()) {
lengthOffsetInBytes = typeSize - VM.getVM().getIntSize();
} else {
lengthOffsetInBytes = typeSize;
}
lengthOffsetInBytes = typeSize;
return lengthOffsetInBytes;
}

Expand All @@ -108,7 +91,13 @@ public long getObjectSize() {
}

public static long baseOffsetInBytes(BasicType type) {
return headerSize(type) * VM.getVM().getHeapWordSize();
long typeSizeInBytes = headerSizeInBytes();
if (Universe.elementTypeShouldBeAligned(type)) {
VM vm = VM.getVM();
return vm.alignUp(typeSizeInBytes, vm.getVM().getHeapWordSize());
} else {
return typeSizeInBytes;
}
}

public boolean isArray() { return true; }
Expand Down
13 changes: 13 additions & 0 deletions src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Mark.java
Expand Up @@ -54,6 +54,9 @@ private static synchronized void initialize(TypeDataBase db) throws WrongTypeExc
lockShift = db.lookupLongConstant("markWord::lock_shift").longValue();
ageShift = db.lookupLongConstant("markWord::age_shift").longValue();
hashShift = db.lookupLongConstant("markWord::hash_shift").longValue();
if (VM.getVM().isLP64()) {
klassShift = db.lookupLongConstant("markWord::klass_shift").longValue();
}
lockMask = db.lookupLongConstant("markWord::lock_mask").longValue();
lockMaskInPlace = db.lookupLongConstant("markWord::lock_mask_in_place").longValue();
ageMask = db.lookupLongConstant("markWord::age_mask").longValue();
Expand Down Expand Up @@ -82,6 +85,7 @@ private static synchronized void initialize(TypeDataBase db) throws WrongTypeExc
private static long lockShift;
private static long ageShift;
private static long hashShift;
private static long klassShift;

private static long lockMask;
private static long lockMaskInPlace;
Expand All @@ -107,6 +111,10 @@ private static synchronized void initialize(TypeDataBase db) throws WrongTypeExc
private static long cmsMask;
private static long sizeShift;

public static long getKlassShift() {
return klassShift;
}

public Mark(Address addr) {
super(addr);
}
Expand Down Expand Up @@ -186,6 +194,11 @@ public boolean hasNoHash() {
return hash() == noHash;
}

public Klass getKlass() {
assert(!hasMonitor());
return (Klass)Metadata.instantiateWrapperFor(addr.getCompKlassAddressAt(0));
}

// Debugging
public void printOn(PrintStream tty) {
if (isLocked()) {
Expand Down
28 changes: 19 additions & 9 deletions src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Oop.java
Expand Up @@ -46,8 +46,9 @@ public void update(Observable o, Object data) {
private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
Type type = db.lookupType("oopDesc");
mark = new CIntField(type.getCIntegerField("_mark"), 0);
klass = new MetadataField(type.getAddressField("_metadata._klass"), 0);
compressedKlass = new NarrowKlassField(type.getAddressField("_metadata._compressed_klass"), 0);
if (!VM.getVM().isLP64()) {
klass = new MetadataField(type.getAddressField("_klass"), 0);
}
headerSize = type.getSize();
}

Expand Down Expand Up @@ -75,9 +76,19 @@ private static synchronized void initialize(TypeDataBase db) throws WrongTypeExc

// Accessors for declared fields
public Mark getMark() { return new Mark(getHandle()); }

private static Klass getKlass(Mark mark) {
if (mark.hasMonitor()) {
ObjectMonitor mon = mark.monitor();
mark = mon.header();
}
return mark.getKlass();
}

public Klass getKlass() {
if (VM.getVM().isCompressedKlassPointersEnabled()) {
return (Klass)compressedKlass.getValue(getHandle());
if (VM.getVM().isLP64()) {
assert(VM.getVM().isCompressedKlassPointersEnabled());
return getKlass(getMark());
} else {
return (Klass)klass.getValue(getHandle());
}
Expand Down Expand Up @@ -147,9 +158,7 @@ public void iterate(OopVisitor visitor, boolean doVMFields) {
void iterateFields(OopVisitor visitor, boolean doVMFields) {
if (doVMFields) {
visitor.doCInt(mark, true);
if (VM.getVM().isCompressedKlassPointersEnabled()) {
visitor.doMetadata(compressedKlass, true);
} else {
if (!VM.getVM().isLP64()) {
visitor.doMetadata(klass, true);
}
}
Expand Down Expand Up @@ -206,8 +215,9 @@ public static Klass getKlassForOopHandle(OopHandle handle) {
if (handle == null) {
return null;
}
if (VM.getVM().isCompressedKlassPointersEnabled()) {
return (Klass)Metadata.instantiateWrapperFor(handle.getCompKlassAddressAt(compressedKlass.getOffset()));
if (VM.getVM().isLP64()) {
Mark mark = new Mark(handle);
return getKlass(mark);
} else {
return (Klass)Metadata.instantiateWrapperFor(handle.getAddressAt(klass.getOffset()));
}
Expand Down
Expand Up @@ -26,6 +26,7 @@

import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.oops.Metadata;
import sun.jvm.hotspot.oops.Oop;
import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.types.*;

Expand All @@ -37,26 +38,6 @@
states than the ObjectHeap code. */

public class RobustOopDeterminator {
private static AddressField klassField;

static {
VM.registerVMInitializedObserver(new Observer() {
public void update(Observable o, Object data) {
initialize(VM.getVM().getTypeDataBase());
}
});
}

private static void initialize(TypeDataBase db) {
Type type = db.lookupType("oopDesc");

if (VM.getVM().isCompressedKlassPointersEnabled()) {
klassField = type.getAddressField("_metadata._compressed_klass");
} else {
klassField = type.getAddressField("_metadata._klass");
}
}

public static boolean oopLooksValid(OopHandle oop) {
if (oop == null) {
return false;
Expand All @@ -66,11 +47,7 @@ public static boolean oopLooksValid(OopHandle oop) {
}
try {
// Try to instantiate the Klass
if (VM.getVM().isCompressedKlassPointersEnabled()) {
Metadata.instantiateWrapperFor(oop.getCompKlassAddressAt(klassField.getOffset()));
} else {
Metadata.instantiateWrapperFor(klassField.getValue(oop));
}
Oop.getKlassForOopHandle(oop);
return true;
} catch (AddressException | WrongTypeException e) {
return false;
Expand Down
34 changes: 0 additions & 34 deletions test/hotspot/jtreg/ProblemList.txt
Expand Up @@ -123,40 +123,6 @@ serviceability/sa/TestJmapCoreMetaspace.java 8294316,8267433 macosx-x64

serviceability/attach/ConcAttachTest.java 8290043 linux-all

# Missing Lilliput support to load Klass*
serviceability/sa/CDSJMapClstats.java 1234567 generic-all
serviceability/sa/ClhsdbCDSCore.java 1234567 generic-all
serviceability/sa/ClhsdbCDSJstackPrintAll.java 1234567 generic-all
serviceability/sa/ClhsdbDumpheap.java 1234567 generic-all
serviceability/sa/ClhsdbFindPC.java#no-xcomp-core
serviceability/sa/ClhsdbFindPC.java#no-xcomp-process
serviceability/sa/ClhsdbFindPC.java#xcomp-core
serviceability/sa/ClhsdbFindPC.java#xcomp-process
serviceability/sa/ClhsdbInspect.java 1234567 generic-all
serviceability/sa/ClhsdbJdis.java 1234567 generic-all
serviceability/sa/ClhsdbJhisto.java 1234567 generic-all
serviceability/sa/ClhsdbJstack.java#id0 1234567 generic-all
serviceability/sa/ClhsdbJstack.java#id1 1234567 generic-all
serviceability/sa/ClhsdbPrintAs.java 1234567 generic-all
serviceability/sa/ClhsdbPstack.java#core 1234567 generic-all
serviceability/sa/ClhsdbPstack.java#process 1234567 generic-all
serviceability/sa/ClhsdbSource.java 1234567 generic-all
serviceability/sa/ClhsdbThread.java 1234567 generic-all
serviceability/sa/ClhsdbThreadContext.java 1234567 generic-all
serviceability/sa/ClhsdbWhere.java 1234567 generic-all
serviceability/sa/DeadlockDetectionTest.java 1234567 generic-all
serviceability/sa/JhsdbThreadInfoTest.java 1234567 generic-all
serviceability/sa/TestClhsdbJstackLock.java 1234567 generic-all
serviceability/sa/TestHeapDumpForInvokeDynamic.java 1234567 generic-all
serviceability/sa/TestJhsdbJstackLineNumbers.java 1234567 generic-all
serviceability/sa/TestJhsdbJstackLock.java 1234567 generic-all
serviceability/sa/TestJhsdbJstackMixed.java 1234567 generic-all
serviceability/sa/TestObjectMonitorIterate.java 1234567 generic-all
serviceability/sa/TestSysProps.java 1234567 generic-all
serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java 1234567 generic-all
serviceability/sa/sadebugd/DebugdConnectTest.java 1234567 generic-all
serviceability/sa/sadebugd/DisableRegistryTest.java 1234567 generic-all

#############################################################################

# :hotspot_misc
Expand Down

0 comments on commit 10e00d3

Please sign in to comment.