Skip to content

Commit 670f552

Browse files
[GR-54994] Remove duplicate thread sleep events and use a constant clock for JFR chunks.
PullRequest: graal/18279
2 parents 2fc0dbb + 2caaa38 commit 670f552

File tree

2 files changed

+5
-23
lines changed

2 files changed

+5
-23
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
import com.oracle.svm.core.Uninterruptible;
2828
import com.oracle.svm.core.util.TimeUtils;
29+
import com.oracle.svm.core.util.PlatformTimeUtils;
2930

3031
/**
3132
* Utility class to manage ticks for event timestamps based on an initial start point when the
@@ -72,6 +73,6 @@ public static long millisToTicks(long millis) {
7273
}
7374

7475
public static long currentTimeNanos() {
75-
return TimeUtils.millisToNanos(System.currentTimeMillis());
76+
return PlatformTimeUtils.singleton().nanosNow();
7677
}
7778
}

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/PlatformThreads.java

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@
8989
import com.oracle.svm.core.heap.VMOperationInfos;
9090
import com.oracle.svm.core.jdk.StackTraceUtils;
9191
import com.oracle.svm.core.jdk.UninterruptibleUtils;
92-
import com.oracle.svm.core.jfr.HasJfrSupport;
9392
import com.oracle.svm.core.locks.VMMutex;
9493
import com.oracle.svm.core.log.Log;
9594
import com.oracle.svm.core.memory.NativeMemory;
@@ -110,7 +109,6 @@
110109

111110
import jdk.graal.compiler.api.replacements.Fold;
112111
import jdk.graal.compiler.core.common.SuppressFBWarnings;
113-
import jdk.internal.event.ThreadSleepEvent;
114112
import jdk.internal.misc.Unsafe;
115113

116114
/**
@@ -983,37 +981,20 @@ static void unpark(Thread thread) {
983981
}
984982

985983
/**
986-
* Sleeps for the given number of nanoseconds, dealing with JFR events, wakups and
987-
* interruptions.
984+
* Sleeps for the given number of nanoseconds, dealing with early wake-ups and interruptions.
988985
*/
989986
static void sleep(long nanos) throws InterruptedException {
990987
assert !isCurrentThreadVirtual();
991-
if (HasJfrSupport.get() && ThreadSleepEvent.isTurnedOn()) {
992-
ThreadSleepEvent event = new ThreadSleepEvent();
993-
try {
994-
event.time = nanos;
995-
event.begin();
996-
sleep0(nanos);
997-
} finally {
998-
event.commit();
999-
}
1000-
} else {
1001-
sleep0(nanos);
1002-
}
1003-
}
1004-
1005-
/** Sleep for the given number of nanoseconds, dealing with early wakeups and interruptions. */
1006-
static void sleep0(long nanos) throws InterruptedException {
1007988
if (nanos < 0) {
1008989
throw new IllegalArgumentException("Timeout value is negative");
1009990
}
1010-
sleep1(nanos);
991+
sleep0(nanos);
1011992
if (Thread.interrupted()) { // clears the interrupted flag as required of Thread.sleep()
1012993
throw new InterruptedException();
1013994
}
1014995
}
1015996

1016-
private static void sleep1(long durationNanos) {
997+
private static void sleep0(long durationNanos) {
1017998
VMOperationControl.guaranteeOkayToBlock("[PlatformThreads.sleep(long): Should not sleep when it is not okay to block.]");
1018999
Thread thread = currentThread.get();
10191000
Parker sleepEvent = getCurrentThreadData().ensureSleepParker();

0 commit comments

Comments
 (0)