diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/dump/HeapDumpWriter.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/dump/HeapDumpWriter.java index 1e64dcc69013..dcb2e9647555 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/dump/HeapDumpWriter.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/dump/HeapDumpWriter.java @@ -71,6 +71,8 @@ import com.oracle.svm.core.heap.dump.HeapDumpMetadata.FieldNameAccess; import com.oracle.svm.core.hub.DynamicHub; import com.oracle.svm.core.hub.LayoutEncoding; +import com.oracle.svm.core.jdk.UninterruptibleUtils.CharReplacer; +import com.oracle.svm.core.jdk.UninterruptibleUtils.ReplaceDotWithSlash; import com.oracle.svm.core.layeredimagesingleton.MultiLayeredImageSingleton; import com.oracle.svm.core.log.Log; import com.oracle.svm.core.nmt.NmtCategory; @@ -400,6 +402,7 @@ public class HeapDumpWriter { private static final int HEAP_DUMP_SEGMENT_TARGET_SIZE = 1 * 1024 * 1024; private final NoAllocationVerifier noAllocationVerifier = NoAllocationVerifier.factory("HeapDumpWriter", false); + private final ReplaceDotWithSlash dotWithSlashReplacer = new ReplaceDotWithSlash(); private final DumpStackFrameVisitor dumpStackFrameVisitor = new DumpStackFrameVisitor(); private final DumpObjectsVisitor dumpObjectsVisitor = new DumpObjectsVisitor(); private final CodeMetadataVisitor codeMetadataVisitor = new CodeMetadataVisitor(); @@ -547,15 +550,19 @@ private void writeClassNames() { for (int i = 0; i < metadata.getClassInfoCount(); i++) { ClassInfo classInfo = metadata.getClassInfo(i); if (ClassInfoAccess.isValid(classInfo)) { - writeSymbol(classInfo.getHub().getName()); + writeSymbol(classInfo.getHub().getName(), dotWithSlashReplacer); } } } private void writeSymbol(String value) { + writeSymbol(value, null); + } + + private void writeSymbol(String value, CharReplacer replacer) { startTopLevelRecord(HProfTopLevelRecord.UTF8); writeObjectId(value); - writeUTF8(value); + writeUTF8(value, replacer); endTopLevelRecord(); } @@ -1109,7 +1116,11 @@ private void writeId0(long value) { } private void writeUTF8(String value) { - boolean success = file().writeUTF8(f, value); + writeUTF8(value, null); + } + + private void writeUTF8(String value, CharReplacer replacer) { + boolean success = file().writeUTF8(f, value, replacer); handleError(success); } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/UninterruptibleUtils.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/UninterruptibleUtils.java index 6ed9536c7a5f..7ef1d53b76c1 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/UninterruptibleUtils.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/UninterruptibleUtils.java @@ -26,7 +26,6 @@ import static com.oracle.svm.core.Uninterruptible.CALLED_FROM_UNINTERRUPTIBLE_CODE; -import jdk.graal.compiler.word.Word; import org.graalvm.word.Pointer; import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; @@ -37,6 +36,7 @@ import com.oracle.svm.core.util.VMError; import jdk.graal.compiler.core.common.SuppressFBWarnings; +import jdk.graal.compiler.word.Word; import jdk.internal.misc.Unsafe; /** @@ -714,6 +714,17 @@ public interface CharReplacer { char replace(char val); } + public static final class ReplaceDotWithSlash implements CharReplacer { + @Override + @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) + public char replace(char ch) { + if (ch == '.') { + return '/'; + } + return ch; + } + } + public static class CodeUtil { @Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true) public static long signExtend(long value, int inputBits) { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrSymbolRepository.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrSymbolRepository.java index 9502dbd4d652..bba166c80118 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrSymbolRepository.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrSymbolRepository.java @@ -38,6 +38,7 @@ import com.oracle.svm.core.heap.Heap; import com.oracle.svm.core.jdk.UninterruptibleUtils; import com.oracle.svm.core.jdk.UninterruptibleUtils.CharReplacer; +import com.oracle.svm.core.jdk.UninterruptibleUtils.ReplaceDotWithSlash; import com.oracle.svm.core.jfr.traceid.JfrTraceIdEpoch; import com.oracle.svm.core.locks.VMMutex; import com.oracle.svm.core.nmt.NmtCategory; @@ -244,15 +245,4 @@ void teardown() { buffer = Word.nullPointer(); } } - - private static final class ReplaceDotWithSlash implements CharReplacer { - @Override - @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) - public char replace(char ch) { - if (ch == '.') { - return '/'; - } - return ch; - } - } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/os/BufferedFileOperationSupport.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/os/BufferedFileOperationSupport.java index bb82329409cb..1402ed1d63d0 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/os/BufferedFileOperationSupport.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/os/BufferedFileOperationSupport.java @@ -43,6 +43,7 @@ import com.oracle.svm.core.hub.DynamicHub; import com.oracle.svm.core.hub.LayoutEncoding; import com.oracle.svm.core.jdk.UninterruptibleUtils; +import com.oracle.svm.core.jdk.UninterruptibleUtils.CharReplacer; import com.oracle.svm.core.memory.NullableNativeMemory; import com.oracle.svm.core.nmt.NmtCategory; import com.oracle.svm.core.os.BufferedFileOperationSupport.BufferedFileOperationSupportHolder; @@ -343,6 +344,11 @@ public boolean writeDouble(BufferedFile f, double v) { return writeLong(f, Double.doubleToLongBits(v)); } + @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) + public boolean writeUTF8(BufferedFile f, String string) { + return writeUTF8(f, string, null); + } + /** * Writes the String characters encoded as UTF8 to the current file position and advances the * file position. @@ -350,10 +356,14 @@ public boolean writeDouble(BufferedFile f, double v) { * @return true if the data was written, false otherwise. */ @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) - public boolean writeUTF8(BufferedFile f, String string) { + public boolean writeUTF8(BufferedFile f, String string, CharReplacer replacer) { boolean success = true; for (int index = 0; index < string.length() && success; index++) { - success &= writeUTF8(f, UninterruptibleUtils.String.charAt(string, index)); + char ch = UninterruptibleUtils.String.charAt(string, index); + if (replacer != null) { + ch = replacer.replace(ch); + } + success &= writeUTF8(f, ch); } return success; }