Skip to content

Commit

Permalink
restore and rename 'GenCollectedHeap' to 'SerialHeap'
Browse files Browse the repository at this point in the history
  • Loading branch information
LizBing committed Jan 11, 2024
1 parent 628de1a commit ae2817d
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import sun.jvm.hotspot.code.*;
import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.debugger.cdbg.*;
import sun.jvm.hotspot.gc.serial.*;
import sun.jvm.hotspot.gc.shared.*;
import sun.jvm.hotspot.interpreter.*;
import sun.jvm.hotspot.memory.*;
Expand Down Expand Up @@ -84,9 +85,43 @@ public static PointerLocation find(Address a) {

// Check if address is in the java heap.
CollectedHeap heap = VM.getVM().getUniverse().heap();
if (heap.isIn(a)) {
loc.heap = heap;
return loc;
if (heap instanceof SerialHeap) {
SerialHeap sh = (SerialHeap) heap;
if (sh.isIn(a)) {
loc.heap = heap;
for (int i = 0; i < sh.nGens(); i++) {
Generation g = sh.getGen(i);
if (g.isIn(a)) {
loc.gen = g;
break;
}
}

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;
}
}
}

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

// Check if address is in the interpreter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import sun.jvm.hotspot.code.*;
import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.debugger.cdbg.*;
import sun.jvm.hotspot.gc.serial.*;
import sun.jvm.hotspot.gc.shared.*;
import sun.jvm.hotspot.interpreter.*;
import sun.jvm.hotspot.memory.*;
Expand Down Expand Up @@ -110,10 +111,23 @@ public boolean isInHeap() {
return (heap != null);
}

public boolean isInNewGen() {
return ((gen != null) && (gen.equals(((SerialHeap)heap).getGen(0))));
}

public boolean isInOldGen() {
return ((gen != null) && (gen.equals(((SerialHeap)heap).getGen(1))));
}

public boolean inOtherGen() {
return (!isInNewGen() && !isInOldGen());
}

public Generation getGeneration() {
return gen;
}

/** This may be true if isInNewGen is also true */
public boolean isInTLAB() {
return inTLAB;
}
Expand Down Expand Up @@ -259,6 +273,18 @@ public void printOn(PrintStream tty, boolean printAddress, boolean verbose) {
getTLABThread().printThreadInfoOn(tty);
tty.print(") ");
getTLAB().printOn(tty); // includes "\n"
} else {
if (isInNewGen()) {
tty.print("In new generation ");
} else if (isInOldGen()) {
tty.print("In old generation ");
} else {
tty.print("In unknown section of Java heap");
}
if (getGeneration() != null) {
getGeneration().printOn(tty); // does not include "\n"
}
tty.println();
}
} else if (isInInterpreter()) {
tty.print("In interpreter codelet: ");
Expand Down

0 comments on commit ae2817d

Please sign in to comment.