Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GR-48372] Remove no longer needed JDK-specific JFR code. #7341

Merged
merged 1 commit into from
Sep 5, 2023
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
3 changes: 0 additions & 3 deletions substratevm/mx.substratevm/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,6 @@
"jdk.jfr.internal",
"jdk.jfr.internal.jfc",
],
"jdk.jfr@11..18": [
"jdk.jfr.internal.handlers",
],
"jdk.internal.vm.ci": [
"jdk.vm.ci.meta",
"jdk.vm.ci.code",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import java.lang.reflect.Field;

import org.graalvm.compiler.serviceprovider.JavaVersionUtil;
import org.graalvm.nativeimage.Platform;
import org.graalvm.nativeimage.Platforms;
import org.graalvm.word.Pointer;
Expand Down Expand Up @@ -56,32 +55,21 @@ private JfrEventWriterAccess() {

@Platforms(Platform.HOSTED_ONLY.class)
public static Class<?> getEventWriterClass() {
String className;
if (JavaVersionUtil.JAVA_SPEC >= 19) {
className = "jdk.jfr.internal.event.EventWriter";
} else {
className = "jdk.jfr.internal.EventWriter";
}
return ReflectionUtil.lookupClass(false, className);
return ReflectionUtil.lookupClass(false, "jdk.jfr.internal.event.EventWriter");
}

public static Target_jdk_jfr_internal_EventWriter newEventWriter(JfrBuffer buffer, boolean isCurrentThreadExcluded) {
public static Target_jdk_jfr_internal_event_EventWriter newEventWriter(JfrBuffer buffer, boolean isCurrentThreadExcluded) {
assert JfrBufferAccess.isEmpty(buffer) : "a fresh JFR buffer must be empty";

long committedPos = buffer.getCommittedPos().rawValue();
long maxPos = JfrBufferAccess.getDataEnd(buffer).rawValue();
long jfrThreadId = SubstrateJVM.getCurrentThreadId();
if (JavaVersionUtil.JAVA_SPEC >= 19) {
return new Target_jdk_jfr_internal_EventWriter(committedPos, maxPos, jfrThreadId, true, isCurrentThreadExcluded);
} else {
long addressOfCommittedPos = JfrBufferAccess.getAddressOfCommittedPos(buffer).rawValue();
return new Target_jdk_jfr_internal_EventWriter(committedPos, maxPos, addressOfCommittedPos, jfrThreadId, true);
}
return new Target_jdk_jfr_internal_event_EventWriter(committedPos, maxPos, jfrThreadId, true, isCurrentThreadExcluded);
}

/** Update the EventWriter so that it uses the correct buffer and positions. */
@Uninterruptible(reason = "Accesses a JFR buffer.")
public static void update(Target_jdk_jfr_internal_EventWriter writer, JfrBuffer buffer, int uncommittedSize, boolean valid) {
public static void update(Target_jdk_jfr_internal_event_EventWriter writer, JfrBuffer buffer, int uncommittedSize, boolean valid) {
assert SubstrateJVM.getThreadLocal().getJavaBuffer() == buffer;
assert JfrBufferAccess.verify(buffer);

Expand All @@ -98,7 +86,7 @@ public static void update(Target_jdk_jfr_internal_EventWriter writer, JfrBuffer
}

@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
public static void markAsInvalid(Target_jdk_jfr_internal_EventWriter writer) {
public static void markAsInvalid(Target_jdk_jfr_internal_event_EventWriter writer) {
/* The VM should never write true (only the JDK code may do that). */
U.putBooleanVolatile(writer, U.objectFieldOffset(VALID_FIELD), false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

import org.graalvm.compiler.core.common.NumUtil;
import org.graalvm.compiler.options.OptionsParser;
import org.graalvm.compiler.serviceprovider.JavaVersionUtil;
import org.graalvm.nativeimage.Platform;
import org.graalvm.nativeimage.Platforms;

Expand Down Expand Up @@ -70,13 +69,7 @@ private static Collection<Type> getTypes0() {
MetadataRepository.getInstance();

Method getTypes = ReflectionUtil.lookupMethod(TypeLibrary.class, "getTypes");
if (JavaVersionUtil.JAVA_SPEC >= 21) {
return (Collection<Type>) getTypes.invoke(null);
} else {
Method getInstance = ReflectionUtil.lookupMethod(TypeLibrary.class, "getInstance");
TypeLibrary instance = (TypeLibrary) getInstance.invoke(null);
return (Collection<Type>) getTypes.invoke(instance);
}
return (Collection<Type>) getTypes.invoke(null);
} catch (Throwable e) {
throw VMError.shouldNotReachHere("Error while calling TypeLibrary.getTypes().", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
*/
package com.oracle.svm.core.jfr;

import com.oracle.svm.core.threadlocal.FastThreadLocalInt;
import org.graalvm.compiler.api.replacements.Fold;
import org.graalvm.nativeimage.CurrentIsolate;
import org.graalvm.nativeimage.IsolateThread;
Expand All @@ -49,6 +48,7 @@
import com.oracle.svm.core.thread.ThreadListener;
import com.oracle.svm.core.thread.VMOperation;
import com.oracle.svm.core.threadlocal.FastThreadLocalFactory;
import com.oracle.svm.core.threadlocal.FastThreadLocalInt;
import com.oracle.svm.core.threadlocal.FastThreadLocalLong;
import com.oracle.svm.core.threadlocal.FastThreadLocalObject;
import com.oracle.svm.core.threadlocal.FastThreadLocalWord;
Expand Down Expand Up @@ -79,7 +79,7 @@
*/
public class JfrThreadLocal implements ThreadListener {
/* Event-related thread-locals. */
private static final FastThreadLocalObject<Target_jdk_jfr_internal_EventWriter> javaEventWriter = FastThreadLocalFactory.createObject(Target_jdk_jfr_internal_EventWriter.class,
private static final FastThreadLocalObject<Target_jdk_jfr_internal_event_EventWriter> javaEventWriter = FastThreadLocalFactory.createObject(Target_jdk_jfr_internal_event_EventWriter.class,
"JfrThreadLocal.javaEventWriter");
private static final FastThreadLocalWord<JfrBuffer> javaBuffer = FastThreadLocalFactory.createWord("JfrThreadLocal.javaBuffer");
private static final FastThreadLocalWord<JfrBuffer> nativeBuffer = FastThreadLocalFactory.createWord("JfrThreadLocal.nativeBuffer");
Expand Down Expand Up @@ -258,8 +258,8 @@ public static boolean isCurrentThreadExcluded() {
return tjlt.jfrExcluded;
}

public static Target_jdk_jfr_internal_EventWriter getEventWriter() {
Target_jdk_jfr_internal_EventWriter eventWriter = javaEventWriter.get();
public static Target_jdk_jfr_internal_event_EventWriter getEventWriter() {
Target_jdk_jfr_internal_event_EventWriter eventWriter = javaEventWriter.get();
/*
* EventWriter objects cache various thread-specific values. Virtual threads use the
* EventWriter object of their carrier thread, so we need to update all cached values so
Expand All @@ -278,15 +278,15 @@ public static Target_jdk_jfr_internal_EventWriter getEventWriter() {
* sufficiently consistent as the JFR buffer is still empty. So, this method does not need to be
* uninterruptible.
*/
public Target_jdk_jfr_internal_EventWriter newEventWriter() {
public Target_jdk_jfr_internal_event_EventWriter newEventWriter() {
assert javaEventWriter.get() == null;

JfrBuffer buffer = reinstateJavaBuffer(getJavaBuffer());
if (buffer.isNull()) {
throw new OutOfMemoryError("OOME for thread local buffer");
}

Target_jdk_jfr_internal_EventWriter result = JfrEventWriterAccess.newEventWriter(buffer, isCurrentThreadExcluded());
Target_jdk_jfr_internal_event_EventWriter result = JfrEventWriterAccess.newEventWriter(buffer, isCurrentThreadExcluded());
javaEventWriter.set(result);
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
*/
package com.oracle.svm.core.jfr;

import org.graalvm.compiler.serviceprovider.JavaVersionUtil;
import org.graalvm.nativeimage.IsolateThread;
import org.graalvm.nativeimage.Platform;
import org.graalvm.nativeimage.Platforms;
Expand Down Expand Up @@ -135,9 +134,7 @@ public void registerThread(Thread thread) {
JfrNativeEventWriter.putString(data, thread.getName()); // Java thread name
JfrNativeEventWriter.putLong(data, threadId); // Java thread id
JfrNativeEventWriter.putLong(data, threadGroupId); // Java thread group
if (JavaVersionUtil.JAVA_SPEC >= 19) {
JfrNativeEventWriter.putBoolean(data, isVirtual);
}
JfrNativeEventWriter.putBoolean(data, isVirtual);
if (!JfrNativeEventWriter.commit(data)) {
return;
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ public void setThreadBufferSize(long size) {
* See {@link JVM#flush}.
*/
@Uninterruptible(reason = "Accesses a JFR buffer.")
public boolean flush(Target_jdk_jfr_internal_EventWriter writer, int uncommittedSize, int requestedSize) {
public boolean flush(Target_jdk_jfr_internal_event_EventWriter writer, int uncommittedSize, int requestedSize) {
assert writer != null;
assert uncommittedSize >= 0;

Expand Down Expand Up @@ -627,14 +627,14 @@ public void subscribeLogLevel(@SuppressWarnings("unused") LogTag lt, @SuppressWa
/**
* See {@link JVM#getEventWriter}.
*/
public Target_jdk_jfr_internal_EventWriter getEventWriter() {
public Target_jdk_jfr_internal_event_EventWriter getEventWriter() {
return JfrThreadLocal.getEventWriter();
}

/**
* See {@link JVM#newEventWriter}.
*/
public Target_jdk_jfr_internal_EventWriter newEventWriter() {
public Target_jdk_jfr_internal_event_EventWriter newEventWriter() {
return threadLocal.newEventWriter();
}

Expand Down

This file was deleted.

This file was deleted.

Loading