Skip to content

Commit 847d6fb

Browse files
style
1 parent 533da7a commit 847d6fb

File tree

12 files changed

+53
-28
lines changed

12 files changed

+53
-28
lines changed

substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/jfr/PosixJfrEmergencyDumpSupport.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ private void writeEmergencyDumpFile(GrowableWordArray sortedChunkFilenames) {
267267
long bytesWritten = 0;
268268
while (bytesRead < chunkFileSize) {
269269
// Start at beginning
270-
getFileSupport().seek(chunkFd, 0); // seems unneeded. idk why???
270+
getFileSupport().seek(chunkFd, 0);
271271
// Read from chunk file to copy block
272272
long readResult = getFileSupport().read(chunkFd, copyBlock, WordFactory.unsigned(blockSize));
273273
if (readResult < 0) { // -1 if read failed
@@ -341,7 +341,7 @@ private boolean filter(CCharPointer fn) {
341341
}
342342
}
343343

344-
// Verify if you can open it and receive a valid file descriptor
344+
// Verify it can be opened and receive a valid file descriptor
345345
RawFileDescriptor chunkFd = getFileSupport().open(fullyQualified(fn), FileAccessMode.READ_WRITE);
346346
if (!getFileSupport().isValid(chunkFd)) {
347347
return false;
@@ -357,8 +357,7 @@ private boolean filter(CCharPointer fn) {
357357
}
358358

359359
/**
360-
* Given a chunk file name, it returns the fully qualified filename. See
361-
* RepositoryIterator::fully_qualified
360+
* Given a chunk file name, it returns the fully qualified filename.
362361
*/
363362
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+2/src/hotspot/share/jfr/recorder/repository/jfrEmergencyDump.cpp#L263-L273")
364363
private CCharPointer fullyQualified(CCharPointer fn) {

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrChunkFileWriter.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@
2727
import static com.oracle.svm.core.jfr.JfrThreadLocal.getJavaBufferList;
2828
import static com.oracle.svm.core.jfr.JfrThreadLocal.getNativeBufferList;
2929

30-
import com.oracle.svm.core.jfr.oldobject.JfrOldObjectRepository;
31-
import com.oracle.svm.core.nmt.NmtCategory;
32-
import jdk.graal.compiler.word.Word;
33-
3430
import org.graalvm.nativeimage.IsolateThread;
3531
import org.graalvm.nativeimage.Platform;
3632
import org.graalvm.nativeimage.Platforms;
@@ -41,11 +37,13 @@
4137
import com.oracle.svm.core.Uninterruptible;
4238
import com.oracle.svm.core.heap.VMOperationInfos;
4339
import com.oracle.svm.core.jdk.UninterruptibleUtils;
40+
import com.oracle.svm.core.jfr.oldobject.JfrOldObjectRepository;
4441
import com.oracle.svm.core.jfr.sampler.JfrExecutionSampler;
4542
import com.oracle.svm.core.jfr.sampler.JfrRecurringCallbackExecutionSampler;
4643
import com.oracle.svm.core.jfr.traceid.JfrTraceIdEpoch;
4744
import com.oracle.svm.core.locks.VMMutex;
4845
import com.oracle.svm.core.memory.NullableNativeMemory;
46+
import com.oracle.svm.core.nmt.NmtCategory;
4947
import com.oracle.svm.core.os.RawFileOperationSupport;
5048
import com.oracle.svm.core.os.RawFileOperationSupport.FileAccessMode;
5149
import com.oracle.svm.core.os.RawFileOperationSupport.FileCreationMode;
@@ -59,6 +57,7 @@
5957

6058
import jdk.graal.compiler.api.replacements.Fold;
6159
import jdk.graal.compiler.core.common.NumUtil;
60+
import jdk.graal.compiler.word.Word;
6261

6362
/**
6463
* This class is used when writing the in-memory JFR data to a file. For all operations, except

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrChunkWriter.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public interface JfrChunkWriter extends JfrUnlockedChunkWriter {
4747
void markChunkFinal();
4848

4949
void closeFile();
50+
5051
void closeFileForEmergencyDump();
5152

5253
void setMetadata(byte[] bytes);

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrEmergencyDumpFeature.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
import org.graalvm.nativeimage.ImageSingletons;
3535

3636
/**
37-
* The JFR emergency dump mechanism uses platform-specific implementations (see {@link JfrEmergencyDumpSupport}).
37+
* The JFR emergency dump mechanism uses platform-specific implementations (see
38+
* {@link JfrEmergencyDumpSupport}).
3839
*/
3940
@AutomaticallyRegisteredFeature
4041
public class JfrEmergencyDumpFeature implements InternalFeature {

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrEmergencyDumpSupport.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.graalvm.nativeimage.ImageSingletons;
3131

3232
import jdk.graal.compiler.api.replacements.Fold;
33+
3334
public interface JfrEmergencyDumpSupport {
3435
@Fold
3536
static boolean isPresent() {
@@ -42,10 +43,16 @@ static JfrEmergencyDumpSupport singleton() {
4243
}
4344

4445
void initialize();
46+
4547
void setRepositoryLocation(String dirText);
48+
4649
void setDumpPath(String dumpPathText);
50+
4751
String getDumpPath();
52+
4853
RawFileOperationSupport.RawFileDescriptor chunkPath();
54+
4955
void onVmError();
56+
5057
void teardown();
5158
}

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrFeature.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ private static HotSpotDiagnosticMXBean getDiagnosticBean() {
154154

155155
@Override
156156
public List<Class<? extends Feature>> getRequiredFeatures() {
157-
return Arrays.asList(ThreadListenerSupportFeature.class, JfrEmergencyDumpFeature.class);
157+
return Arrays.asList(ThreadListenerSupportFeature.class, JfrEmergencyDumpFeature.class);
158158
}
159159

160160
@Override

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrGCWhenSerializer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
public class JfrGCWhenSerializer implements JfrSerializer {
3131
private JfrGCWhen[] values;
32+
3233
@Platforms(Platform.HOSTED_ONLY.class)
3334
public JfrGCWhenSerializer() {
3435
values = JfrGCWhen.values();

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrNmtCategorySerializer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
public class JfrNmtCategorySerializer implements JfrSerializer {
3535
private NmtCategory[] nmtCategories;
36+
3637
@Platforms(Platform.HOSTED_ONLY.class)
3738
public JfrNmtCategorySerializer() {
3839
nmtCategories = NmtCategory.values();

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrSymbolRepository.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,9 @@ public long getSymbolId(String imageHeapString, boolean previousEpoch, boolean r
9595
return getSymbolId(buffer, WordFactory.unsigned(length), hash, previousEpoch);
9696
}
9797

98-
9998
@Uninterruptible(reason = "Locking without transition and result is only valid until epoch changes.", callerMustBe = true)
10099
public long getSymbolId(PointerBase buffer, UnsignedWord length, int hash, boolean previousEpoch) {
101-
com.oracle.svm.core.util.VMError.guarantee(buffer.isNonNull());
100+
assert buffer.isNonNull();
102101
JfrSymbol symbol = StackValue.get(JfrSymbol.class);
103102
symbol.setModifiedUTF8(buffer); // symbol allocated in native memory
104103
symbol.setLength(length);
@@ -181,10 +180,13 @@ private interface JfrSymbol extends UninterruptibleEntry {
181180

182181
@RawField
183182
void setLength(UnsignedWord value);
183+
184184
@RawField
185185
UnsignedWord getLength();
186+
186187
@RawField
187188
void setModifiedUTF8(PointerBase value);
189+
188190
@RawField
189191
PointerBase getModifiedUTF8();
190192
}

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrTypeRepository.java

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,32 @@
5353
import static com.oracle.svm.core.Uninterruptible.CALLED_FROM_UNINTERRUPTIBLE_CODE;
5454

5555
/**
56-
* Repository that collects and writes used classes, packages, modules, and classloaders.
56+
* Repository that collects and writes used classes, packages, modules, and classloaders. There are
57+
* three kinds of tables used by this class: epochTypeData, flushed*, and typeInfo. The flushed*
58+
* tables record which classes have already been flushed to disk. The epochTypeData tables hold
59+
* classes that have yet to be flushed as well as classes that are already flushed (they are written
60+
* by threads emitting events). The typeInfo table is derived at flushpoints by using the
61+
* epochTypeData and flushed* tables to determine the set of classes that have yet to be flushed.
62+
*
63+
* Unlike other JFR repositories, there are no epoch data buffers that require lock protection.
64+
* Similar to other constant repositories, writes/reads to the current epochData are allowed to race
65+
* at flushpoints. There is no risk of separating events from constant data due to the write order
66+
* (constants before events during emission, and events before constants during flush). The
67+
* epochData tables are only cleared at rotation safepoints.
5768
*/
5869
public class JfrTypeRepository implements JfrRepository {
5970
private static final String BOOTSTRAP_NAME = "bootstrap";
60-
// The following tables are only used by the flushing/rotating thread
71+
// The following tables are only used by the flushing/rotating thread.
6172
private final JfrClassInfoTable flushedClasses;
6273
private final JfrPackageInfoTable flushedPackages;
6374
private final JfrModuleInfoTable flushedModules;
6475
private final JfrClassLoaderInfoTable flushedClassLoaders;
6576
private final TypeInfo typeInfo;
6677

6778
/*
68-
* epochTypeData tables are written to from threads emitting events and read from the
69-
* flushing/rotating thread Their purpose is to lazily collect tagged JFR classes, which may
70-
* later be serialized during flush/rotation.
79+
* epochTypeData tables are written by threads emitting events and read from the
80+
* flushing/rotating thread. Their purpose is to lazily collect tagged JFR classes, which are
81+
* later serialized during flush/rotation.
7182
*/
7283
private final JfrClassInfoTable epochTypeData0;
7384
private final JfrClassInfoTable epochTypeData1;
@@ -140,11 +151,7 @@ public int write(JfrChunkWriter writer, boolean flushpoint) {
140151
* referenced classes.
141152
*
142153
* This method does not need to be marked uninterruptible since the epoch cannot change while
143-
* the chunkwriter lock is held. Unlike other JFR repositories, locking is not needed to protect
144-
* a data buffer. Similar to other constant repositories, writes/reads to the current epochData
145-
* are allowed to race at flushpoints. There is no risk of separating events from constant data
146-
* due to the write order (constants before events during emission, and events before constants
147-
* during flush). The epochData tables are only cleared at rotation safepoints.
154+
* the chunkwriter lock is held.
148155
*/
149156
private void collectTypeInfo(boolean flushpoint) {
150157
JfrClassInfoTable classInfoTable = getEpochData(!flushpoint);
@@ -255,8 +262,10 @@ private static long getSymbolId(JfrChunkWriter writer, String symbol, boolean fl
255262
return SubstrateJVM.getSymbolRepository().getSymbolId(symbol, !flushpoint, replaceDotWithSlash);
256263
}
257264

258-
// Copy to a new buffer so each table has its own copy of the data. This simplifies cleanup and
259-
// mitigates double frees.
265+
/*
266+
* Copy to a new buffer so each table has its own copy of the data. This simplifies cleanup and
267+
* mitigates double frees.
268+
*/
260269
@Uninterruptible(reason = "Needed for JfrSymbolRepository.getSymbolId().")
261270
private static long getSymbolId(JfrChunkWriter writer, PointerBase source, UnsignedWord length, int hash, boolean flushpoint) {
262271
Pointer destination = NullableNativeMemory.malloc(length, NmtCategory.JFR);
@@ -571,8 +580,10 @@ private void setPackageNameAndLength(Class<?> clazz, PackageInfoRaw packageInfoR
571580

572581
assert buffer.add(dot).belowOrEqual(bufferEnd);
573582

574-
// Since we're serializing now, we must do replacements here, instead of the symbol
575-
// repository.
583+
/*
584+
* Since we're serializing now, we must do replacements here, instead of the symbol
585+
* repository.
586+
*/
576587
Pointer packageNameEnd = UninterruptibleUtils.String.toModifiedUTF8(str, dot, buffer, bufferEnd, false, dotWithSlash);
577588
packageInfoRaw.setModifiedUTF8Name(buffer);
578589

@@ -702,7 +713,7 @@ private abstract class JfrTypeInfoTable extends AbstractUninterruptibleHashtable
702713
protected boolean isEqual(UninterruptibleEntry v0, UninterruptibleEntry v1) {
703714
JfrTypeInfo a = (JfrTypeInfo) v0;
704715
JfrTypeInfo b = (JfrTypeInfo) v1;
705-
return a.getName() == b.getName();
716+
return a.getName() != null ? a.getName().equals(b.getName()) : b.getName() == null;
706717
}
707718

708719
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)

0 commit comments

Comments
 (0)