Skip to content

Commit

Permalink
8323680: SA PointerFinder code can do a better job of leveraging exis…
Browse files Browse the repository at this point in the history
…ting code to determine if an address is in the TLAB

Reviewed-by: kevinw, sspitsyn
  • Loading branch information
plummercj committed Feb 2, 2024
1 parent 63cb1f8 commit 7476e29
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,26 @@ public static PointerLocation find(Address a) {

// 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);
Expand All @@ -98,30 +115,11 @@ public static PointerLocation find(Address a) {
}

if (Assert.ASSERTS_ENABLED) {
Assert.that(loc.gen != null, "Should have found this 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;
}
}
Assert.that(loc.gen != null, "Should have found this address in a generation");
}

return loc;
}
} else {
if (heap.isIn(a)) {
loc.heap = heap;
return loc;
}

return loc;
}

// Check if address is in the interpreter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -129,7 +128,7 @@ public Generation getGeneration() {

/** This may be true if isInNewGen is also true */
public boolean isInTLAB() {
return inTLAB;
return (tlab != null);
}

/** Only valid if isInTLAB() returns true */
Expand Down Expand Up @@ -269,10 +268,16 @@ public void printOn(PrintStream tty, boolean printAddress, boolean verbose) {
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 ");
Expand Down

0 comments on commit 7476e29

Please sign in to comment.