Skip to content

Commit

Permalink
7903366: JOL: Clean up VM configuration messages
Browse files Browse the repository at this point in the history
  • Loading branch information
shipilev authored Oct 19, 2022
1 parent 2d958ff commit 482c0ee
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions jol-core/src/main/java/org/openjdk/jol/vm/HotspotUnsafe.java
Original file line number Diff line number Diff line change
Expand Up @@ -294,37 +294,45 @@ public String details() {
StringWriter sw = new StringWriter();
PrintWriter out = new PrintWriter(sw);

out.println("# Running " + (addressSize * 8) + "-bit HotSpot VM.");
out.println("# VM mode: " + (addressSize * 8) + " bits");

if (lilliputVM) {
out.println("# Lilliput VM detected (experimental).");
out.println("# Lilliput VM detected (experimental)");
}

out.print("# Compressed references (oops): ");
if (compressedOopsEnabled) {
out.print(narrowOopShift + "-bit shift");
if (narrowOopBase != 0) {
out.println("# Using compressed oop with " +
formatAddressAsHexByAddressSize(narrowOopBase) + " base address and " +
narrowOopShift + "-bit shift.");
} else {
out.println("# Using compressed oop with " + narrowOopShift + "-bit shift.");
out.print(" and " + formatAddressAsHexByAddressSize(narrowOopBase) + " base");
}
} else if (addressSize == 4){
out.print("not needed");
} else {
out.print("disabled");
}
out.println();

out.print("# Compressed class pointers: ");
if (compressedKlassOopsEnabled) {
out.print(narrowKlassShift + "-bit shift");
if (narrowKlassBase != 0) {
out.println("# Using compressed klass with " +
formatAddressAsHexByAddressSize(narrowKlassBase) + " base address and " +
narrowKlassShift + "-bit shift.");
} else {
out.println("# Using compressed klass with " + narrowKlassShift + "-bit shift.");
out.print(" and " + formatAddressAsHexByAddressSize(narrowKlassBase) + " base");
}
} else if (addressSize == 4) {
out.print("not needed");
} else {
out.print("disabled");
}
if (!isAccurate && (compressedOopsEnabled || compressedKlassOopsEnabled)) {
out.println();

if (addressSize != 4 && !isAccurate && (compressedOopsEnabled || compressedKlassOopsEnabled)) {
out.println("# WARNING | Compressed references base/shifts are guessed by the experiment!");
out.println("# WARNING | Therefore, computed addresses are just guesses, and ARE NOT RELIABLE.");
out.println("# WARNING | Make sure to attach Serviceability Agent to get the reliable addresses.");
}

out.println("# Objects are " + objectAlignment + " bytes aligned.");
out.println("# Object alignment: " + objectAlignment + " bytes");

out.printf("# %-20s %4s, %4s, %4s, %4s, %4s, %4s, %4s, %4s, %4s%n",
"",
Expand Down Expand Up @@ -682,7 +690,7 @@ private long toJvmKlassAddress(long address) {
}

private String formatAddressAsHexByAddressSize(long address) {
return "0x" + String.format("%" + (addressSize * 2) + "s",
return "0x" + String.format("%s",
Long.toHexString(address).toUpperCase()).replace(' ', '0');
}

Expand Down

0 comments on commit 482c0ee

Please sign in to comment.