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 @@ -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
Expand Down Expand Up @@ -72,6 +73,6 @@ public static long millisToTicks(long millis) {
}

public static long currentTimeNanos() {
return TimeUtils.millisToNanos(System.currentTimeMillis());
return PlatformTimeUtils.singleton().nanosNow();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

/**
Expand Down Expand Up @@ -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();
Expand Down