diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/PointerFinder.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/PointerFinder.java index 99b45fad1a6..65121c4cca9 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/PointerFinder.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/PointerFinder.java @@ -85,9 +85,26 @@ public class PointerFinder { // Check if address is in the java heap. CollectedHeap heap = VM.getVM().getUniverse().heap(); - if (heap instanceof SerialHeap) { - SerialHeap sh = (SerialHeap) heap; - if (sh.isIn(a)) { + if (heap.isIn(a)) { + loc.heap = heap; + + // See if the address is in a TLAB + if (VM.getVM().getUseTLAB()) { + // Try to find thread containing it + for (int i = 0; i < threads.getNumberOfThreads(); i++) { + JavaThread t = threads.getJavaThreadAt(i); + ThreadLocalAllocBuffer tlab = t.tlab(); + if (tlab.contains(a)) { + loc.tlabThread = t; + loc.tlab = tlab; + break; + } + } + } + + // If we are using the SerialHeap, find out which generation the address is in + if (heap instanceof SerialHeap) { + SerialHeap sh = (SerialHeap) heap; loc.heap = heap; for (int i = 0; i < sh.nGens(); i++) { Generation g = sh.getGen(i); @@ -98,30 +115,11 @@ public class PointerFinder { } if (Assert.ASSERTS_ENABLED) { - Assert.that(loc.gen != null, "Should have found this in a generation"); + Assert.that(loc.gen != null, "Should have found this address in a generation"); } - - if (VM.getVM().getUseTLAB()) { - // Try to find thread containing it - for (int i = 0; i < threads.getNumberOfThreads(); i++) { - JavaThread t = threads.getJavaThreadAt(i); - ThreadLocalAllocBuffer tlab = t.tlab(); - if (tlab.contains(a)) { - loc.inTLAB = true; - loc.tlabThread = t; - loc.tlab = tlab; - break; - } - } - } - - return loc; - } - } else { - if (heap.isIn(a)) { - loc.heap = heap; - return loc; } + + return loc; } // Check if address is in the interpreter diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/PointerLocation.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/PointerLocation.java index 0048b8a8ac4..72bcdf1aba3 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/PointerLocation.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/PointerLocation.java @@ -61,7 +61,6 @@ public class PointerLocation { // If UseTLAB was enabled and the pointer was found in a // currently-active TLAB, these will be set - boolean inTLAB; JavaThread tlabThread; ThreadLocalAllocBuffer tlab; @@ -129,7 +128,7 @@ public class PointerLocation { /** This may be true if isInNewGen is also true */ public boolean isInTLAB() { - return inTLAB; + return (tlab != null); } /** Only valid if isInTLAB() returns true */ @@ -269,10 +268,16 @@ public class PointerLocation { tty.println(); } else if (isInHeap()) { if (isInTLAB()) { - tty.print("In thread-local allocation buffer for thread ("); - getTLABThread().printThreadInfoOn(tty); - tty.print(") "); - getTLAB().printOn(tty); // includes "\n" + tty.print("In TLAB for thread "); + JavaThread thread = getTLABThread(); + if (verbose) { + tty.print("("); + thread.printThreadInfoOn(tty); + tty.print(") "); + getTLAB().printOn(tty); // includes "\n" + } else { + tty.format("\"%s\" %s\n", thread.getThreadName(), thread); + } } else { if (isInNewGen()) { tty.print("In new generation ");