Skip to content

Commit

Permalink
8331877: JFR: Remove JIInliner framework
Browse files Browse the repository at this point in the history
Reviewed-by: mgronlun
  • Loading branch information
egahlin committed May 31, 2024
1 parent d9e7b7e commit 5abc029
Show file tree
Hide file tree
Showing 13 changed files with 10 additions and 766 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,35 +23,26 @@
* questions.
*/

package jdk.jfr.internal.instrument;
package jdk.jfr.internal;

import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

import jdk.internal.access.SharedSecrets;
import jdk.internal.event.JFRTracing;
import jdk.internal.event.ThrowableTracer;
import jdk.internal.platform.Container;
import jdk.internal.platform.Metrics;
import jdk.jfr.Event;
import jdk.jfr.events.ActiveRecordingEvent;
import jdk.jfr.events.ActiveSettingEvent;
import jdk.jfr.events.ContainerIOUsageEvent;
import jdk.jfr.events.ContainerConfigurationEvent;
import jdk.jfr.events.ContainerCPUUsageEvent;
import jdk.jfr.events.ContainerCPUThrottlingEvent;
import jdk.jfr.events.ContainerCPUUsageEvent;
import jdk.jfr.events.ContainerConfigurationEvent;
import jdk.jfr.events.ContainerIOUsageEvent;
import jdk.jfr.events.ContainerMemoryUsageEvent;
import jdk.jfr.events.DirectBufferStatisticsEvent;
import jdk.jfr.events.FileForceEvent;
import jdk.jfr.events.InitialSecurityPropertyEvent;

import jdk.jfr.internal.JVM;
import jdk.jfr.internal.LogLevel;
import jdk.jfr.internal.LogTag;
import jdk.jfr.internal.Logger;
import jdk.jfr.internal.SecuritySupport;
import jdk.jfr.internal.periodic.PeriodicEvents;
import jdk.internal.platform.Container;
import jdk.internal.platform.Metrics;

public final class JDKEvents {

Expand Down Expand Up @@ -85,11 +76,6 @@ public final class JDKEvents {
InitialSecurityPropertyEvent.class,
};

// This is a list of the classes with instrumentation code that should be applied.
private static final Class<?>[] instrumentationClasses = new Class<?>[] {
};

private static final Class<?>[] targetClasses = new Class<?>[instrumentationClasses.length];
private static final Runnable emitExceptionStatistics = JDKEvents::emitExceptionStatistics;
private static final Runnable emitDirectBufferStatistics = JDKEvents::emitDirectBufferStatistics;
private static final Runnable emitContainerConfiguration = JDKEvents::emitContainerConfiguration;
Expand Down Expand Up @@ -121,24 +107,6 @@ public static synchronized void initialize() {
}
}

public static void addInstrumentation() {
try {
List<Class<?>> list = new ArrayList<>();
for (int i = 0; i < instrumentationClasses.length; i++) {
JIInstrumentationTarget tgt = instrumentationClasses[i].getAnnotation(JIInstrumentationTarget.class);
Class<?> clazz = Class.forName(tgt.value());
targetClasses[i] = clazz;
list.add(clazz);
}
Logger.log(LogTag.JFR_SYSTEM, LogLevel.INFO, "Retransformed JDK classes");
JVM.retransformClasses(list.toArray(new Class<?>[list.size()]));
} catch (IllegalStateException ise) {
throw ise;
} catch (Exception e) {
Logger.log(LogTag.JFR_SYSTEM, LogLevel.WARN, "Could not add instrumentation for JDK events. " + e.getMessage());
}
}

private static void initializeContainerEvents() {
if (JVM.isContainerized() ) {
Logger.log(LogTag.JFR_SYSTEM, LogLevel.DEBUG, "JVM is containerized");
Expand Down Expand Up @@ -225,20 +193,6 @@ private static void emitContainerCPUThrottling() {
}
}

@SuppressWarnings("deprecation")
public static byte[] retransformCallback(Class<?> klass, byte[] oldBytes) throws Throwable {
for (int i = 0; i < targetClasses.length; i++) {
if (targetClasses[i].equals(klass)) {
Class<?> c = instrumentationClasses[i];
if (Logger.shouldLog(LogTag.JFR_SYSTEM, LogLevel.TRACE)) {
Logger.log(LogTag.JFR_SYSTEM, LogLevel.TRACE, "Processing instrumentation class: " + c);
}
return new JIClassInstrumentation(instrumentationClasses[i], klass, oldBytes).getNewBytes();
}
}
return oldBytes;
}

public static void remove() {
PeriodicEvents.removeEvent(emitExceptionStatistics);
PeriodicEvents.removeEvent(emitDirectBufferStatistics);
Expand Down
3 changes: 1 addition & 2 deletions src/jdk.jfr/share/classes/jdk/jfr/internal/JVMUpcalls.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import java.lang.reflect.Modifier;

import jdk.jfr.internal.event.EventConfiguration;
import jdk.jfr.internal.instrument.JDKEvents;
import jdk.jfr.internal.util.Bytecode;
/**
* All upcalls from the JVM should go through this class.
Expand Down Expand Up @@ -78,7 +77,7 @@ static byte[] onRetransform(long traceId, boolean dummy1, boolean dummy2, Class<
Bytecode.log(clazz.getName(), bytes);
return bytes;
}
return JDKEvents.retransformCallback(clazz, oldBytes);
return oldBytes;
} catch (Throwable t) {
Logger.log(LogTag.JFR_SYSTEM, LogLevel.WARN, "Unexpected error when adding instrumentation to event class " + clazz.getName());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 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
Expand Down Expand Up @@ -57,7 +57,6 @@
import jdk.jfr.internal.SecuritySupport.SafePath;
import jdk.jfr.internal.SecuritySupport.SecureRecorderListener;
import jdk.jfr.internal.consumer.EventLog;
import jdk.jfr.internal.instrument.JDKEvents;
import jdk.jfr.internal.periodic.PeriodicEvents;
import jdk.jfr.internal.util.Utils;

Expand All @@ -83,7 +82,6 @@ public PlatformRecorder() throws Exception {
Logger.log(JFR_SYSTEM, INFO, "Created native");
JDKEvents.initialize();
Logger.log(JFR_SYSTEM, INFO, "Registered JDK events");
JDKEvents.addInstrumentation();
startDiskMonitor();
shutdownHook = SecuritySupport.createThreadWitNoPermissions("JFR Shutdown Hook", new ShutdownHook(this));
SecuritySupport.setUncaughtExceptionHandler(shutdownHook, new ShutdownHook.ExceptionHandler());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
*/
public final class SecuritySupport {
private static final String EVENTS_PACKAGE_NAME = "jdk.jfr.events";
private static final String INSTRUMENT_PACKAGE_NAME = "jdk.jfr.internal.instrument";
private static final String EVENT_PACKAGE_NAME = "jdk.jfr.internal.event";

public static final String REGISTER_EVENT = "registerEvent";
Expand All @@ -89,7 +88,6 @@ public final class SecuritySupport {
addReadEdge(Object.class);
addInternalEventExport(Object.class);
addEventsExport(Object.class);
addInstrumentExport(Object.class);
}

static final class SecureRecorderListener implements FlightRecorderListener {
Expand Down Expand Up @@ -323,10 +321,6 @@ static void addEventsExport(Class<?> clazz) {
Modules.addExports(JFR_MODULE, EVENTS_PACKAGE_NAME, clazz.getModule());
}

static void addInstrumentExport(Class<?> clazz) {
Modules.addExports(JFR_MODULE, INSTRUMENT_PACKAGE_NAME, clazz.getModule());
}

static void addReadEdge(Class<?> clazz) {
Modules.addReads(clazz.getModule(), JFR_MODULE);
}
Expand Down

This file was deleted.

Loading

1 comment on commit 5abc029

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.