diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrTicks.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrTicks.java index 0c012bfb21e6..f1d13c66e87d 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrTicks.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrTicks.java @@ -26,6 +26,7 @@ import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.util.TimeUtils; +import com.oracle.svm.core.util.PlatformTimeUtils; /** * 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) { } public static long currentTimeNanos() { - return TimeUtils.millisToNanos(System.currentTimeMillis()); + return PlatformTimeUtils.singleton().nanosNow(); } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/PlatformThreads.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/PlatformThreads.java index 02b739935554..e8930ec79a07 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/PlatformThreads.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/PlatformThreads.java @@ -89,7 +89,6 @@ import com.oracle.svm.core.heap.VMOperationInfos; import com.oracle.svm.core.jdk.StackTraceUtils; import com.oracle.svm.core.jdk.UninterruptibleUtils; -import com.oracle.svm.core.jfr.HasJfrSupport; import com.oracle.svm.core.locks.VMMutex; import com.oracle.svm.core.log.Log; import com.oracle.svm.core.memory.NativeMemory; @@ -110,7 +109,6 @@ import jdk.graal.compiler.api.replacements.Fold; import jdk.graal.compiler.core.common.SuppressFBWarnings; -import jdk.internal.event.ThreadSleepEvent; import jdk.internal.misc.Unsafe; /** @@ -983,37 +981,20 @@ static void unpark(Thread thread) { } /** - * Sleeps for the given number of nanoseconds, dealing with JFR events, wakups and - * interruptions. + * Sleeps for the given number of nanoseconds, dealing with early wake-ups and interruptions. */ static void sleep(long nanos) throws InterruptedException { assert !isCurrentThreadVirtual(); - if (HasJfrSupport.get() && ThreadSleepEvent.isTurnedOn()) { - ThreadSleepEvent event = new ThreadSleepEvent(); - try { - event.time = nanos; - event.begin(); - sleep0(nanos); - } finally { - event.commit(); - } - } else { - sleep0(nanos); - } - } - - /** Sleep for the given number of nanoseconds, dealing with early wakeups and interruptions. */ - static void sleep0(long nanos) throws InterruptedException { if (nanos < 0) { throw new IllegalArgumentException("Timeout value is negative"); } - sleep1(nanos); + sleep0(nanos); if (Thread.interrupted()) { // clears the interrupted flag as required of Thread.sleep() throw new InterruptedException(); } } - private static void sleep1(long durationNanos) { + private static void sleep0(long durationNanos) { VMOperationControl.guaranteeOkayToBlock("[PlatformThreads.sleep(long): Should not sleep when it is not okay to block.]"); Thread thread = currentThread.get(); Parker sleepEvent = getCurrentThreadData().ensureSleepParker();