Skip to content

Commit

Permalink
Moved all Target_* classes to com.oracle.svm.core.
Browse files Browse the repository at this point in the history
  • Loading branch information
christianhaeubl committed Jan 24, 2022
1 parent c4fc9cb commit c158d87
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,10 @@ public static boolean get() {
return ImageSingletons.contains(JfrManager.class);
}
}

class JfrHostedEnabled implements BooleanSupplier {
@Override
public boolean getAsBoolean() {
return ImageSingletons.contains(JfrManager.class) && ImageSingletons.lookup(JfrManager.class).hostedEnabled;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,11 @@
public class JfrManager {
private static final String DEFAULT_JFC_NAME = "default";

final boolean hostedEnabled;

@Platforms(Platform.HOSTED_ONLY.class)
public JfrManager() {
public JfrManager(boolean hostedEnabled) {
this.hostedEnabled = hostedEnabled;
}

@Fold
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.oracle.svm.hosted.jfr;
package com.oracle.svm.core.jfr;

import com.oracle.svm.core.annotate.Alias;
import com.oracle.svm.core.annotate.RecomputeFieldValue;
import com.oracle.svm.core.annotate.TargetClass;

@TargetClass(className = "com.sun.jmx.mbeanserver.MXBeanIntrospector", onlyWith = JfrFeature.JfrHostedEnabled.class)
@TargetClass(className = "com.sun.jmx.mbeanserver.MXBeanIntrospector", onlyWith = JfrHostedEnabled.class)
final class Target_com_sun_jmx_mbeanserver_MXBeanIntrospector {

/* Reset caches that are used at image build time when FlightRecorder is enabled. */
Expand All @@ -38,6 +38,6 @@ final class Target_com_sun_jmx_mbeanserver_MXBeanIntrospector {
private static Target_com_sun_jmx_mbeanserver_MBeanIntrospector_MBeanInfoMap mbeanInfoMap;
}

@TargetClass(className = "com.sun.jmx.mbeanserver.MBeanIntrospector", innerClass = "MBeanInfoMap", onlyWith = JfrFeature.JfrHostedEnabled.class)
@TargetClass(className = "com.sun.jmx.mbeanserver.MBeanIntrospector", innerClass = "MBeanInfoMap", onlyWith = JfrHostedEnabled.class)
final class Target_com_sun_jmx_mbeanserver_MBeanIntrospector_MBeanInfoMap {
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.oracle.svm.hosted.jfr;
package com.oracle.svm.core.jfr;

import com.oracle.svm.core.annotate.Alias;
import com.oracle.svm.core.annotate.RecomputeFieldValue;
import com.oracle.svm.core.annotate.TargetClass;

@TargetClass(className = "com.sun.jmx.mbeanserver.MXBeanLookup", onlyWith = JfrFeature.JfrHostedEnabled.class)
@TargetClass(className = "com.sun.jmx.mbeanserver.MXBeanLookup", onlyWith = JfrHostedEnabled.class)
final class Target_com_sun_jmx_mbeanserver_MXBeanLookup {

/* Reset caches that are used at image build time when FlightRecorder is enabled. */
@Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.NewInstance, declClassName = "com.sun.jmx.mbeanserver.WeakIdentityHashMap") //
private static Target_com_sun_jmx_mbeanserver_WeakIdentityHashMap mbscToLookup;
}

@TargetClass(className = "com.sun.jmx.mbeanserver.WeakIdentityHashMap", onlyWith = JfrFeature.JfrHostedEnabled.class)
@TargetClass(className = "com.sun.jmx.mbeanserver.WeakIdentityHashMap", onlyWith = JfrHostedEnabled.class)
final class Target_com_sun_jmx_mbeanserver_WeakIdentityHashMap {
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.oracle.svm.hosted.jfr;
package com.oracle.svm.core.jfr;

import java.util.ArrayList;

Expand All @@ -32,7 +32,7 @@
import com.oracle.svm.core.annotate.RecomputeFieldValue;
import com.oracle.svm.core.annotate.TargetClass;

@TargetClass(className = "javax.management.MBeanServerFactory", onlyWith = JfrFeature.JfrHostedEnabled.class)
@TargetClass(className = "javax.management.MBeanServerFactory", onlyWith = JfrHostedEnabled.class)
final class Target_javax_management_MBeanServerFactory {

/* Reset caches that are used at image build time when FlightRecorder is enabled. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.oracle.svm.hosted.jfr;
package com.oracle.svm.core.jfr;

import com.oracle.svm.core.annotate.Alias;
import com.oracle.svm.core.annotate.RecomputeFieldValue;
import com.oracle.svm.core.annotate.TargetClass;

import jdk.jfr.FlightRecorder;

@TargetClass(value = jdk.jfr.FlightRecorder.class, onlyWith = JfrFeature.JfrHostedEnabled.class)
@TargetClass(value = jdk.jfr.FlightRecorder.class, onlyWith = JfrHostedEnabled.class)
final class Target_jdk_jfr_FlightRecorder {
/*
* Ignore all state of the FlightRecorder maintained when profiling the image generator itself.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.function.BooleanSupplier;

import com.oracle.svm.core.jfr.JfrChunkWriter;
import com.oracle.svm.core.jfr.JfrFrameTypeSerializer;
import com.oracle.svm.core.jfr.JfrGlobalMemory;
import com.oracle.svm.core.jfr.JfrManager;
import com.oracle.svm.core.jfr.JfrNativeEventWriter;
import com.oracle.svm.core.jfr.JfrNativeEventWriterData;
import com.oracle.svm.core.jfr.JfrRecorderThread;
import com.oracle.svm.core.jfr.JfrSerializerSupport;
import com.oracle.svm.core.jfr.JfrThreadLocal;
import com.oracle.svm.core.jfr.JfrThreadStateSerializer;
import com.oracle.svm.core.jfr.SubstrateJVM;
import org.graalvm.nativeimage.ImageSingletons;
import org.graalvm.nativeimage.hosted.Feature;
import org.graalvm.nativeimage.hosted.RuntimeClassInitialization;
Expand All @@ -55,16 +43,27 @@
import com.oracle.svm.core.hub.DynamicHub;
import com.oracle.svm.core.hub.DynamicHubSupport;
import com.oracle.svm.core.jdk.RuntimeSupport;
import com.oracle.svm.core.jfr.JfrChunkWriter;
import com.oracle.svm.core.jfr.JfrFrameTypeSerializer;
import com.oracle.svm.core.jfr.JfrGlobalMemory;
import com.oracle.svm.core.jfr.JfrManager;
import com.oracle.svm.core.jfr.JfrNativeEventWriter;
import com.oracle.svm.core.jfr.JfrNativeEventWriterData;
import com.oracle.svm.core.jfr.JfrRecorderThread;
import com.oracle.svm.core.jfr.JfrSerializerSupport;
import com.oracle.svm.core.jfr.JfrThreadLocal;
import com.oracle.svm.core.jfr.JfrThreadStateSerializer;
import com.oracle.svm.core.jfr.SubstrateJVM;
import com.oracle.svm.core.jfr.traceid.JfrTraceId;
import com.oracle.svm.core.jfr.traceid.JfrTraceIdEpoch;
import com.oracle.svm.core.jfr.traceid.JfrTraceIdMap;
import com.oracle.svm.core.meta.SharedType;
import com.oracle.svm.core.thread.ThreadListenerFeature;
import com.oracle.svm.core.thread.ThreadListenerSupport;
import com.oracle.svm.core.util.UserError;
import com.oracle.svm.core.util.VMError;
import com.oracle.svm.hosted.FeatureImpl;
import com.oracle.svm.hosted.FeatureImpl.DuringAnalysisAccessImpl;
import com.oracle.svm.core.jfr.traceid.JfrTraceId;
import com.oracle.svm.core.jfr.traceid.JfrTraceIdEpoch;
import com.oracle.svm.core.jfr.traceid.JfrTraceIdMap;
import com.oracle.svm.util.ModuleSupport;
import com.oracle.svm.util.ReflectionUtil;
import com.sun.management.HotSpotDiagnosticMXBean;
Expand Down Expand Up @@ -119,17 +118,10 @@
@AutomaticFeature
public class JfrFeature implements Feature {

public static final class JfrHostedEnabled implements BooleanSupplier {
@Override
public boolean getAsBoolean() {
return ImageSingletons.contains(JfrFeature.class) && ImageSingletons.lookup(JfrFeature.class).hostedEnabled;
}
}

private final boolean hostedEnabled;

public JfrFeature() {
hostedEnabled = Boolean.valueOf(getDiagnosticBean().getVMOption("FlightRecorder").getValue());
hostedEnabled = Boolean.parseBoolean(getDiagnosticBean().getVMOption("FlightRecorder").getValue());
}

@Override
Expand Down Expand Up @@ -181,8 +173,8 @@ public void afterRegistration(AfterRegistrationAccess access) {
List<Configuration> knownConfigurations = JFC.getConfigurations();
JVM.getJVM().createNativeJFR();

ImageSingletons.add(JfrManager.class, new JfrManager(hostedEnabled));
ImageSingletons.add(SubstrateJVM.class, new SubstrateJVM(knownConfigurations));
ImageSingletons.add(JfrManager.class, new JfrManager());
ImageSingletons.add(JfrSerializerSupport.class, new JfrSerializerSupport());
ImageSingletons.add(JfrTraceIdMap.class, new JfrTraceIdMap());
ImageSingletons.add(JfrTraceIdEpoch.class, new JfrTraceIdEpoch());
Expand Down

0 comments on commit c158d87

Please sign in to comment.