8323680: SA PointerFinder code can do a better job of leveraging existing code to determine if an address is in the TLAB

Reviewed-by: kevinw, sspitsyn
This commit is contained in:
Chris Plummer 2024-02-02 20:41:37 +00:00
parent 63cb1f8818
commit 7476e29053
2 changed files with 34 additions and 31 deletions

View File

@ -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

View File

@ -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 ");