Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.graalvm.nativeimage.Platforms;

import com.oracle.svm.core.Uninterruptible;
import com.oracle.svm.core.thread.Target_java_lang_VirtualThread;
import com.oracle.svm.core.thread.VMOperation;

import jdk.graal.compiler.api.replacements.Fold;
Expand All @@ -43,7 +44,12 @@ public class JfrTraceIdEpoch {
private static final long EPOCH_0_BIT = 0b01;
private static final long EPOCH_1_BIT = 0b10;

private long epochId;
/**
* Start the epoch id at 1, so that we can inject fields into JDK classes that store the epoch
* id (see for example {@link Target_java_lang_VirtualThread#jfrEpochId}). This avoids problems
* with uninitialized injected fields that have the value 0 by default.
*/
private long epochId = 1;

@Fold
public static JfrTraceIdEpoch getInstance() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ public final class Target_java_lang_VirtualThread {
// Checkstyle: resume

@Inject //
@RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Custom, declClass = ResetToMinusOneTransformer.class) //
public long jfrEpochId = -1;
@RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset) //
public long jfrEpochId;

@Alias
private static native ForkJoinPool createDefaultScheduler();
Expand Down Expand Up @@ -602,10 +602,3 @@ static Thread asThread(Object obj) {
private VirtualThreadHelper() {
}
}

final class ResetToMinusOneTransformer implements FieldValueTransformer {
@Override
public Object transform(Object receiver, Object originalValue) {
return -1L;
}
}