File tree 2 files changed +9
-10
lines changed
substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core
2 files changed +9
-10
lines changed Original file line number Diff line number Diff line change 30
30
import org .graalvm .nativeimage .Platforms ;
31
31
32
32
import com .oracle .svm .core .Uninterruptible ;
33
+ import com .oracle .svm .core .thread .Target_java_lang_VirtualThread ;
33
34
import com .oracle .svm .core .thread .VMOperation ;
34
35
35
36
import jdk .graal .compiler .api .replacements .Fold ;
@@ -43,7 +44,12 @@ public class JfrTraceIdEpoch {
43
44
private static final long EPOCH_0_BIT = 0b01;
44
45
private static final long EPOCH_1_BIT = 0b10;
45
46
46
- private long epochId ;
47
+ /**
48
+ * Start the epoch id at 1, so that we can inject fields into JDK classes that store the epoch
49
+ * id (see for example {@link Target_java_lang_VirtualThread#jfrEpochId}). This avoids problems
50
+ * with uninitialized injected fields that have the value 0 by default.
51
+ */
52
+ private long epochId = 1 ;
47
53
48
54
@ Fold
49
55
public static JfrTraceIdEpoch getInstance () {
Original file line number Diff line number Diff line change @@ -123,8 +123,8 @@ public final class Target_java_lang_VirtualThread {
123
123
// Checkstyle: resume
124
124
125
125
@ Inject //
126
- @ RecomputeFieldValue (kind = RecomputeFieldValue .Kind .Custom , declClass = ResetToMinusOneTransformer . class ) //
127
- public long jfrEpochId = - 1 ;
126
+ @ RecomputeFieldValue (kind = RecomputeFieldValue .Kind .Reset ) //
127
+ public long jfrEpochId ;
128
128
129
129
@ Alias
130
130
private static native ForkJoinPool createDefaultScheduler ();
@@ -602,10 +602,3 @@ static Thread asThread(Object obj) {
602
602
private VirtualThreadHelper () {
603
603
}
604
604
}
605
-
606
- final class ResetToMinusOneTransformer implements FieldValueTransformer {
607
- @ Override
608
- public Object transform (Object receiver , Object originalValue ) {
609
- return -1L ;
610
- }
611
- }
You can’t perform that action at this time.
0 commit comments