Wed, 04 Dec 2013 14:43:50 +0100
8029395: SA: jstack throws WrongTypeException
Summary: SA missed some TLABs
Reviewed-by: dsamersoff, mgerdin, brutisso
1.1 --- a/agent/src/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java Wed Dec 04 08:10:31 2013 -0500 1.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java Wed Dec 04 14:43:50 2013 +0100 1.3 @@ -364,7 +364,7 @@ 1.4 } 1.5 catch (AddressException e) { 1.6 // This is okay at the top of these regions 1.7 - } 1.8 + } 1.9 catch (UnknownOopException e) { 1.10 // This is okay at the top of these regions 1.11 } 1.12 @@ -373,7 +373,7 @@ 1.13 visitor.epilogue(); 1.14 } 1.15 1.16 - private void addLiveRegions(List input, List output) { 1.17 + private void addLiveRegions(String name, List input, List output) { 1.18 for (Iterator itr = input.iterator(); itr.hasNext();) { 1.19 MemRegion reg = (MemRegion) itr.next(); 1.20 Address top = reg.end(); 1.21 @@ -386,6 +386,9 @@ 1.22 } 1.23 output.add(top); 1.24 output.add(bottom); 1.25 + if (DEBUG) { 1.26 + System.err.println("Live region: " + name + ": " + bottom + ", " + top); 1.27 + } 1.28 } 1.29 } 1.30 1.31 @@ -395,7 +398,7 @@ 1.32 } 1.33 1.34 public void doSpace(Space s) { 1.35 - addLiveRegions(s.getLiveRegions(), liveRegions); 1.36 + addLiveRegions(s.toString(), s.getLiveRegions(), liveRegions); 1.37 } 1.38 private List liveRegions; 1.39 } 1.40 @@ -426,11 +429,11 @@ 1.41 ParallelScavengeHeap psh = (ParallelScavengeHeap) heap; 1.42 PSYoungGen youngGen = psh.youngGen(); 1.43 // Add eden space 1.44 - addLiveRegions(youngGen.edenSpace().getLiveRegions(), liveRegions); 1.45 + addLiveRegions("eden", youngGen.edenSpace().getLiveRegions(), liveRegions); 1.46 // Add from-space but not to-space 1.47 - addLiveRegions(youngGen.fromSpace().getLiveRegions(), liveRegions); 1.48 + addLiveRegions("from", youngGen.fromSpace().getLiveRegions(), liveRegions); 1.49 PSOldGen oldGen = psh.oldGen(); 1.50 - addLiveRegions(oldGen.objectSpace().getLiveRegions(), liveRegions); 1.51 + addLiveRegions("old ", oldGen.objectSpace().getLiveRegions(), liveRegions); 1.52 } else if (heap instanceof G1CollectedHeap) { 1.53 G1CollectedHeap g1h = (G1CollectedHeap) heap; 1.54 g1h.heapRegionIterate(lrc); 1.55 @@ -451,23 +454,27 @@ 1.56 1.57 if (VM.getVM().getUseTLAB()) { 1.58 for (JavaThread thread = VM.getVM().getThreads().first(); thread != null; thread = thread.next()) { 1.59 - if (thread.isJavaThread()) { 1.60 - ThreadLocalAllocBuffer tlab = thread.tlab(); 1.61 - if (tlab.start() != null) { 1.62 - if ((tlab.top() == null) || (tlab.end() == null)) { 1.63 - System.err.print("Warning: skipping invalid TLAB for thread "); 1.64 + ThreadLocalAllocBuffer tlab = thread.tlab(); 1.65 + if (tlab.start() != null) { 1.66 + if ((tlab.top() == null) || (tlab.end() == null)) { 1.67 + System.err.print("Warning: skipping invalid TLAB for thread "); 1.68 + thread.printThreadIDOn(System.err); 1.69 + System.err.println(); 1.70 + } else { 1.71 + if (DEBUG) { 1.72 + System.err.print("TLAB for " + thread.getThreadName() + ", #"); 1.73 thread.printThreadIDOn(System.err); 1.74 - System.err.println(); 1.75 - } else { 1.76 - // Go from: 1.77 - // - below start() to start() 1.78 - // - start() to top() 1.79 - // - end() and above 1.80 - liveRegions.add(tlab.start()); 1.81 - liveRegions.add(tlab.start()); 1.82 - liveRegions.add(tlab.top()); 1.83 - liveRegions.add(tlab.hardEnd()); 1.84 + System.err.print(": "); 1.85 + tlab.printOn(System.err); 1.86 } 1.87 + // Go from: 1.88 + // - below start() to start() 1.89 + // - start() to top() 1.90 + // - end() and above 1.91 + liveRegions.add(tlab.start()); 1.92 + liveRegions.add(tlab.start()); 1.93 + liveRegions.add(tlab.top()); 1.94 + liveRegions.add(tlab.hardEnd()); 1.95 } 1.96 } 1.97 } 1.98 @@ -480,6 +487,15 @@ 1.99 Assert.that(liveRegions.size() % 2 == 0, "Must have even number of region boundaries"); 1.100 } 1.101 1.102 + if (DEBUG) { 1.103 + System.err.println("liveRegions:"); 1.104 + for (int i = 0; i < liveRegions.size(); i += 2) { 1.105 + Address bottom = (Address) liveRegions.get(i); 1.106 + Address top = (Address) liveRegions.get(i+1); 1.107 + System.err.println(" " + bottom + " - " + top); 1.108 + } 1.109 + } 1.110 + 1.111 return liveRegions; 1.112 } 1.113
2.1 --- a/agent/src/share/classes/sun/jvm/hotspot/runtime/ThreadLocalAllocBuffer.java Wed Dec 04 08:10:31 2013 -0500 2.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/runtime/ThreadLocalAllocBuffer.java Wed Dec 04 14:43:50 2013 +0100 2.3 @@ -109,6 +109,6 @@ 2.4 2.5 public void printOn(PrintStream tty) { 2.6 tty.println(" [" + start() + "," + 2.7 - top() + "," + end() + ")"); 2.8 + top() + "," + end() + ",{" + hardEnd() + "})"); 2.9 } 2.10 }