diff --git a/src/hotspot/share/runtime/vmStructs.cpp b/src/hotspot/share/runtime/vmStructs.cpp index 86cf44ae5eb..6c6b1de80f2 100644 --- a/src/hotspot/share/runtime/vmStructs.cpp +++ b/src/hotspot/share/runtime/vmStructs.cpp @@ -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) \ diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/DebuggerBase.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/DebuggerBase.java index 42cb3820ace..fb736d64c8f 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/DebuggerBase.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/DebuggerBase.java @@ -24,6 +24,8 @@ package sun.jvm.hotspot.debugger; +import sun.jvm.hotspot.oops.Mark; + /**

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 @@ -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 diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Array.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Array.java index 6ba23c9ea40..04c61c7dea7 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Array.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Array.java @@ -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; } @@ -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; } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Mark.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Mark.java index 31f56fbf0bc..fd4a01fa590 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Mark.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Mark.java @@ -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(); @@ -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; @@ -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); } @@ -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()) { diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Oop.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Oop.java index bf957941a56..a2988306f30 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Oop.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Oop.java @@ -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(); } @@ -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()); } @@ -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); } } @@ -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())); } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/RobustOopDeterminator.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/RobustOopDeterminator.java index 3f701b8d24e..6a8b794a935 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/RobustOopDeterminator.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/RobustOopDeterminator.java @@ -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.*; @@ -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; @@ -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; diff --git a/test/hotspot/jtreg/ProblemList.txt b/test/hotspot/jtreg/ProblemList.txt index fe5a5395fdb..4897c42c86f 100644 --- a/test/hotspot/jtreg/ProblemList.txt +++ b/test/hotspot/jtreg/ProblemList.txt @@ -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