forked from graalvm/mandrel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
svm: adopt 'JDK-8304732: jdk/jfr/api/consumer/recordingstream/TestSto…
…p.java failed again with "Expected outer stream to have 3 events"' (cherry picked from commit fbc44e9)
- Loading branch information
1 parent
6b5e921
commit 16bcf85
Showing
8 changed files
with
238 additions
and
4 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
...m/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixPlatformTimeUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()); | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
...com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsPlatformTimeUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...c/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_HiddenWait.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/util/PlatformTimeUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} |