diff --git a/common.json b/common.json index f2ac2a82090d..35d571232a65 100644 --- a/common.json +++ b/common.json @@ -45,13 +45,13 @@ "labsjdk-ee-21-llvm": {"name": "labsjdk", "version": "ee-21.0.2+13-jvmci-23.1-b33-sulong", "platformspecific": true }, "graalvm-ee-21": {"name": "graalvm-java21", "version": "23.1.3", "platformspecific": true }, - "oraclejdk-latest": {"name": "jpg-jdk", "version": "24", "build_id": "jdk-24+2", "platformspecific": true, "extrabundles": ["static-libs"]}, - "labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-24+2-jvmci-b01", "platformspecific": true }, - "labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-24+2-jvmci-b01-debug", "platformspecific": true }, - "labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-24+2-jvmci-b01-sulong", "platformspecific": true }, - "labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-24+2-jvmci-b01", "platformspecific": true }, - "labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-24+2-jvmci-b01-debug", "platformspecific": true }, - "labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-24+2-jvmci-b01-sulong", "platformspecific": true } + "oraclejdk-latest": {"name": "jpg-jdk", "version": "24", "build_id": "jdk-24+3", "platformspecific": true, "extrabundles": ["static-libs"]}, + "labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-24+3-jvmci-b01", "platformspecific": true }, + "labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-24+3-jvmci-b01-debug", "platformspecific": true }, + "labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-24+3-jvmci-b01-sulong", "platformspecific": true }, + "labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-24+3-jvmci-b01", "platformspecific": true }, + "labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-24+3-jvmci-b01-debug", "platformspecific": true }, + "labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-24+3-jvmci-b01-sulong", "platformspecific": true } }, "eclipse": { diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/JVMCIVersionCheck.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/JVMCIVersionCheck.java index a33824172520..926b9994f8b6 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/JVMCIVersionCheck.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/JVMCIVersionCheck.java @@ -55,8 +55,8 @@ public final class JVMCIVersionCheck { private static final Map> JVMCI_MIN_VERSIONS = Map.of( "21", Map.of(DEFAULT_VENDOR_ENTRY, createLegacyVersion(23, 1, 33)), "24", Map.of( - "Oracle Corporation", createLabsJDKVersion("24+2", 1), - DEFAULT_VENDOR_ENTRY, createLabsJDKVersion("24+2", 1))); + "Oracle Corporation", createLabsJDKVersion("24+3", 1), + DEFAULT_VENDOR_ENTRY, createLabsJDKVersion("24+3", 1))); private static final int NA = 0; /** * Minimum Java release supported by Graal. diff --git a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/parser/RegexLexer.java b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/parser/RegexLexer.java index baacf222f242..75d82d3219d0 100644 --- a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/parser/RegexLexer.java +++ b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/parser/RegexLexer.java @@ -44,7 +44,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import java.util.function.Predicate; +import java.util.function.IntPredicate; import org.graalvm.collections.EconomicSet; @@ -557,7 +557,7 @@ protected boolean lookahead(String match) { return pattern.regionMatches(position, match, 0, match.length()); } - protected boolean lookahead(Predicate predicate, int length) { + protected boolean lookahead(IntPredicate predicate, int length) { if (pattern.length() - position < length) { return false; } @@ -588,7 +588,7 @@ protected boolean consumingLookahead(String match) { return matches; } - protected boolean consumingLookahead(Predicate predicate, int length) { + protected boolean consumingLookahead(IntPredicate predicate, int length) { final boolean matches = lookahead(predicate, length); if (matches) { position += length; @@ -603,19 +603,19 @@ protected boolean lookbehind(char c) { return pattern.charAt(position - 1) == c; } - protected int count(Predicate predicate) { + protected int count(IntPredicate predicate) { return count(predicate, position, pattern.length()); } - protected int countUpTo(Predicate predicate, int max) { + protected int countUpTo(IntPredicate predicate, int max) { return count(predicate, position, (int) Math.min(((long) position) + max, pattern.length())); } - protected int countFrom(Predicate predicate, int fromIndex) { + protected int countFrom(IntPredicate predicate, int fromIndex) { return count(predicate, fromIndex, pattern.length()); } - protected int count(Predicate predicate, int fromIndex, int toIndex) { + protected int count(IntPredicate predicate, int fromIndex, int toIndex) { for (int i = fromIndex; i < toIndex; i++) { if (!predicate.test(pattern.charAt(i))) { return i - fromIndex; diff --git a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/parser/flavors/RubyRegexParser.java b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/parser/flavors/RubyRegexParser.java index 8a09d72cf77c..af3a7df40664 100644 --- a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/parser/flavors/RubyRegexParser.java +++ b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/parser/flavors/RubyRegexParser.java @@ -53,7 +53,7 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.function.Predicate; +import java.util.function.IntPredicate; import org.graalvm.collections.Pair; @@ -457,7 +457,7 @@ private int consumeChar() { return c; } - private String getMany(Predicate pred) { + private String getMany(IntPredicate pred) { StringBuilder out = new StringBuilder(); while (!atEnd() && pred.test(curChar())) { out.appendCodePoint(consumeChar()); @@ -465,7 +465,7 @@ private String getMany(Predicate pred) { return out.toString(); } - private String getUpTo(int count, Predicate pred) { + private String getUpTo(int count, IntPredicate pred) { StringBuilder out = new StringBuilder(); int found = 0; while (found < count && !atEnd() && pred.test(curChar())) { diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixPlatformTimeUtils.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixPlatformTimeUtils.java new file mode 100644 index 000000000000..dfe8945d3814 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixPlatformTimeUtils.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.posix; + +import org.graalvm.nativeimage.StackValue; + +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; +import com.oracle.svm.core.posix.headers.Time; +import com.oracle.svm.core.util.BasedOnJDKFile; +import com.oracle.svm.core.util.PlatformTimeUtils; + +@AutomaticallyRegisteredImageSingleton(PlatformTimeUtils.class) +public final class PosixPlatformTimeUtils extends PlatformTimeUtils { + + @Override + @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-24+3/src/hotspot/os/posix/os_posix.cpp#L1409-L1415") + protected SecondsNanos javaTimeSystemUTC() { + Time.timespec ts = StackValue.get(Time.timespec.class); + int status = PosixUtils.clock_gettime(Time.CLOCK_REALTIME(), ts); + PosixUtils.checkStatusIs0(status, "javaTimeSystemUTC: clock_gettime(CLOCK_REALTIME) failed."); + return new SecondsNanos(ts.tv_sec(), ts.tv_nsec()); + } +} diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsPlatformTimeUtils.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsPlatformTimeUtils.java new file mode 100644 index 000000000000..2722ffaa18a4 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsPlatformTimeUtils.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2024, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.windows; + +import static com.oracle.svm.core.windows.headers.SysinfoAPI.GetSystemTimeAsFileTime; + +import org.graalvm.nativeimage.StackValue; +import org.graalvm.word.WordFactory; + +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; +import com.oracle.svm.core.util.BasedOnJDKFile; +import com.oracle.svm.core.util.PlatformTimeUtils; +import com.oracle.svm.core.windows.headers.WinBase.FILETIME; + +@AutomaticallyRegisteredImageSingleton(PlatformTimeUtils.class) +public final class WindowsPlatformTimeUtils extends PlatformTimeUtils { + + @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-24+3/src/hotspot/os/windows/os_windows.cpp#L1123") // + private static final long OFFSET = 116444736000000000L; + + @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-24+3/src/hotspot/os/windows/os_windows.cpp#L1153-L1155") + private static long offset() { + return OFFSET; + } + + /* Returns time ticks in (10th of micro seconds) */ + @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-24+3/src/hotspot/os/windows/os_windows.cpp#L1158-L1161") + private static long windowsToTimeTicks(FILETIME wt) { + long a = WordFactory.unsigned(wt.dwHighDateTime()).shiftLeft(32).or(WordFactory.unsigned(wt.dwLowDateTime())).rawValue(); + return (a - offset()); + } + + @Override + @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-24+3/src/hotspot/os/windows/os_windows.cpp#L1198-L1205") + protected SecondsNanos javaTimeSystemUTC() { + FILETIME wt = StackValue.get(FILETIME.class); + GetSystemTimeAsFileTime(wt); + long ticks = windowsToTimeTicks(wt); // 10th of micros + long secs = ticks / 10000000L; // 10000 * 1000 + long seconds = secs; + long nanos = (ticks - (secs * 10000000L)) * 100L; + return new SecondsNanos(seconds, nanos); + } + +} diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/headers/SysinfoAPI.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/headers/SysinfoAPI.java index 54ad46091a3b..5735a034e073 100644 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/headers/SysinfoAPI.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/headers/SysinfoAPI.java @@ -34,6 +34,7 @@ import org.graalvm.nativeimage.c.type.CCharPointer; import org.graalvm.word.PointerBase; +import com.oracle.svm.core.windows.headers.WinBase.FILETIME; import com.oracle.svm.core.windows.headers.WindowsLibC.WCharPointer; // Checkstyle: stop @@ -89,6 +90,13 @@ public interface SYSTEM_INFO extends PointerBase { short wProcessorRevision(); } + /** + * Retrieves the current system date and time. The information is in Coordinated Universal Time + * (UTC) format. + */ + @CFunction(transition = NO_TRANSITION) + public static native void GetSystemTimeAsFileTime(FILETIME lpSystemTimeAsFileTime); + /** Retrieves the path of the Windows directory. */ @CFunction(transition = NO_TRANSITION) public static native int GetWindowsDirectoryW(WCharPointer lpBuffer, int uSize); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_HiddenWait.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_HiddenWait.java new file mode 100644 index 000000000000..42a0eadc2252 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_HiddenWait.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2023, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.oracle.svm.core.jfr; + +import com.oracle.svm.core.annotate.TargetClass; +import com.oracle.svm.core.jdk.JDK23OrLater; + +@TargetClass(className = "jdk.jfr.internal.HiddenWait", onlyWith = {HasJfrSupport.class, JDK23OrLater.class}) +public final class Target_jdk_jfr_internal_HiddenWait { +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_JVM.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_JVM.java index bc05e841eb65..874fdbcf2359 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_JVM.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_JVM.java @@ -43,6 +43,7 @@ import com.oracle.svm.core.jdk.JDK22OrLater; import com.oracle.svm.core.jdk.JDK23OrLater; import com.oracle.svm.core.jfr.traceid.JfrTraceId; +import com.oracle.svm.core.util.PlatformTimeUtils; import com.oracle.svm.core.util.VMError; import com.oracle.svm.util.ReflectionUtil; @@ -198,6 +199,13 @@ public static long getTicksFrequency() { return JfrTicks.getTicksFrequency(); } + /** See {@code JVM#nanosNow}. */ + @Substitute + @TargetElement(onlyWith = JDK23OrLater.class) + public static long nanosNow() { + return PlatformTimeUtils.singleton().nanosNow(); + } + /** See {@link JVM#log}. */ @Substitute public static void log(int tagSetId, int level, String message) { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_JVM_ChunkRotationMonitor.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_JVM_ChunkRotationMonitor.java index b899031a14c4..665d350fea39 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_JVM_ChunkRotationMonitor.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_JVM_ChunkRotationMonitor.java @@ -27,7 +27,8 @@ package com.oracle.svm.core.jfr; import com.oracle.svm.core.annotate.TargetClass; +import com.oracle.svm.core.jdk.JDK21OrEarlier; -@TargetClass(className = "jdk.jfr.internal.JVM$ChunkRotationMonitor", onlyWith = HasJfrSupport.class) +@TargetClass(className = "jdk.jfr.internal.JVM$ChunkRotationMonitor", onlyWith = {HasJfrSupport.class, JDK21OrEarlier.class}) public final class Target_jdk_jfr_internal_JVM_ChunkRotationMonitor { } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/events/JavaMonitorWaitEvent.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/events/JavaMonitorWaitEvent.java index 2e6c2ac0957b..b9e3dd5a2bfd 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/events/JavaMonitorWaitEvent.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/events/JavaMonitorWaitEvent.java @@ -26,8 +26,6 @@ package com.oracle.svm.core.jfr.events; -import jdk.graal.compiler.word.Word; - import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.jfr.HasJfrSupport; import com.oracle.svm.core.jfr.JfrEvent; @@ -36,11 +34,14 @@ import com.oracle.svm.core.jfr.JfrNativeEventWriterDataAccess; import com.oracle.svm.core.jfr.JfrTicks; import com.oracle.svm.core.jfr.SubstrateJVM; +import com.oracle.svm.core.jfr.Target_jdk_jfr_internal_HiddenWait; import com.oracle.svm.core.jfr.Target_jdk_jfr_internal_JVM_ChunkRotationMonitor; +import jdk.graal.compiler.word.Word; + public class JavaMonitorWaitEvent { public static void emit(long startTicks, Object obj, long notifier, long timeout, boolean timedOut) { - if (HasJfrSupport.get() && obj != null && !Target_jdk_jfr_internal_JVM_ChunkRotationMonitor.class.equals(obj.getClass())) { + if (HasJfrSupport.get() && obj != null && !Target_jdk_jfr_internal_JVM_ChunkRotationMonitor.class.equals(obj.getClass()) && !Target_jdk_jfr_internal_HiddenWait.class.equals(obj.getClass())) { emit0(startTicks, obj, notifier, timeout, timedOut); } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/util/PlatformTimeUtils.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/util/PlatformTimeUtils.java new file mode 100644 index 000000000000..d002f23e1ea7 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/util/PlatformTimeUtils.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2024, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.util; + +import org.graalvm.nativeimage.ImageSingletons; +import org.graalvm.nativeimage.Platform; +import org.graalvm.nativeimage.Platforms; + +import jdk.graal.compiler.api.replacements.Fold; + +/** + * Platform dependent time related utils. See also {@link TimeUtils} for platform independent utils. + */ +public abstract class PlatformTimeUtils { + + @Fold + public static PlatformTimeUtils singleton() { + return ImageSingletons.lookup(PlatformTimeUtils.class); + } + + @Platforms(Platform.HOSTED_ONLY.class) + protected PlatformTimeUtils() { + } + + private long last = 0; + + public record SecondsNanos(long seconds, long nanos) { + } + + @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-24+3/src/hotspot/share/jfr/recorder/repository/jfrChunk.cpp#L38-L54") + public long nanosNow() { + // Use same clock source as Instant.now() to ensure + // that Recording::getStopTime() returns an Instant that + // is in sync. + var t = javaTimeSystemUTC(); + long seconds = t.seconds; + long nanos = t.nanos; + long now = seconds * 1000000000 + nanos; + if (now > last) { + last = now; + } else { + ++last; + } + return last; + } + + protected abstract SecondsNanos javaTimeSystemUTC(); +}