Skip to content

Commit c6ecb38

Browse files
OracleLabsAutomationelkorchi
authored andcommitted
[GR-59791] Backport to 24.1: Make PosixPlatformTimeUtils.javaTimeSystemUTC uninterruptible
PullRequest: graal/19405
2 parents 757e9cc + 5c36ce3 commit c6ecb38

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixPlatformTimeUtils.java

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

2727
import org.graalvm.nativeimage.StackValue;
2828

29+
import com.oracle.svm.core.Uninterruptible;
2930
import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton;
3031
import com.oracle.svm.core.posix.headers.Time;
3132
import com.oracle.svm.core.util.BasedOnJDKFile;
@@ -36,10 +37,20 @@ public final class PosixPlatformTimeUtils extends PlatformTimeUtils {
3637

3738
@Override
3839
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-24+3/src/hotspot/os/posix/os_posix.cpp#L1409-L1415")
39-
protected SecondsNanos javaTimeSystemUTC() {
40+
@Uninterruptible(reason = "Must not migrate platform threads when executing on a virtual thread.")
41+
public SecondsNanos javaTimeSystemUTC() {
4042
Time.timespec ts = StackValue.get(Time.timespec.class);
4143
int status = PosixUtils.clock_gettime(Time.CLOCK_REALTIME(), ts);
4244
PosixUtils.checkStatusIs0(status, "javaTimeSystemUTC: clock_gettime(CLOCK_REALTIME) failed.");
43-
return new SecondsNanos(ts.tv_sec(), ts.tv_nsec());
45+
return allocateSecondsNanos0(ts.tv_sec(), ts.tv_nsec());
46+
}
47+
48+
@Uninterruptible(reason = "Wrap the now safe call to interruptibly allocate a SecondsNanos object.", calleeMustBe = false)
49+
private static SecondsNanos allocateSecondsNanos0(long seconds, long nanos) {
50+
return allocateSecondsNanos(seconds, nanos);
51+
}
52+
53+
private static SecondsNanos allocateSecondsNanos(long seconds, long nanos) {
54+
return new SecondsNanos(seconds, nanos);
4455
}
4556
}

0 commit comments

Comments
 (0)