Skip to content
Closed
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
@@ -0,0 +1,36 @@
/*
* 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.jdk;

import jdk.graal.compiler.serviceprovider.JavaVersionUtil;

import java.util.function.BooleanSupplier;

public class JDK23OrEarlier implements BooleanSupplier {
@Override
public boolean getAsBoolean() {
return JavaVersionUtil.JAVA_SPEC <= 23;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* 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.jdk;

import jdk.graal.compiler.serviceprovider.JavaVersionUtil;

import java.util.function.BooleanSupplier;

public class JDK24OrLater implements BooleanSupplier {
@Override
public boolean getAsBoolean() {
return JavaVersionUtil.JAVA_SPEC >= 24;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, 2024, 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.JDK24OrLater;

@TargetClass(className = "jdk.jfr.internal.HiddenWait", onlyWith = {HasJfrSupport.class, JDK24OrLater.class})
public final class Target_jdk_jfr_internal_HiddenWait {
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import com.oracle.svm.core.heap.PhysicalMemory.PhysicalMemorySupport;
import com.oracle.svm.core.jdk.JDK22OrLater;
import com.oracle.svm.core.jdk.JDK23OrLater;
import com.oracle.svm.core.jdk.JDK24OrLater;
import com.oracle.svm.core.jfr.traceid.JfrTraceId;
import com.oracle.svm.core.util.VMError;
import com.oracle.svm.util.ReflectionUtil;
Expand Down Expand Up @@ -198,6 +199,12 @@ public static long getTicksFrequency() {
return JfrTicks.getTicksFrequency();
}

@Substitute
@TargetElement(onlyWith = JDK24OrLater.class)
public static long nanosNow() {
return JfrTicks.currentTimeNanos();
}

/** See {@link JVM#log}. */
@Substitute
public static void log(int tagSetId, int level, String message) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
package com.oracle.svm.core.jfr;

import com.oracle.svm.core.annotate.TargetClass;
import com.oracle.svm.core.jdk.JDK23OrEarlier;

@TargetClass(className = "jdk.jfr.internal.JVM$ChunkRotationMonitor", onlyWith = HasJfrSupport.class)
@TargetClass(className = "jdk.jfr.internal.JVM$ChunkRotationMonitor", onlyWith = {HasJfrSupport.class, JDK23OrEarlier.class})
public final class Target_jdk_jfr_internal_JVM_ChunkRotationMonitor {
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
package com.oracle.svm.core.jfr.events;

import jdk.graal.compiler.word.Word;

import jdk.graal.compiler.serviceprovider.JavaVersionUtil;
import com.oracle.svm.core.Uninterruptible;
import com.oracle.svm.core.jfr.HasJfrSupport;
import com.oracle.svm.core.jfr.JfrEvent;
Expand All @@ -37,11 +37,21 @@
import com.oracle.svm.core.jfr.JfrTicks;
import com.oracle.svm.core.jfr.SubstrateJVM;
import com.oracle.svm.core.jfr.Target_jdk_jfr_internal_JVM_ChunkRotationMonitor;
import com.oracle.svm.core.jfr.Target_jdk_jfr_internal_HiddenWait;

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())) {
emit0(startTicks, obj, notifier, timeout, timedOut);
if (!HasJfrSupport.get() || obj == null) {
return;
}
if (JavaVersionUtil.JAVA_SPEC >= 24) {
if (!Target_jdk_jfr_internal_HiddenWait.class.equals(obj.getClass())) {
emit0(startTicks, obj, notifier, timeout, timedOut);
}
} else {
if (!Target_jdk_jfr_internal_JVM_ChunkRotationMonitor.class.equals(obj.getClass())) {
emit0(startTicks, obj, notifier, timeout, timedOut);
}
}
}

Expand Down