Skip to content

Refactor and add framework for native jfr event support #3770

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

Closed
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
71 changes: 38 additions & 33 deletions substratevm/mx.substratevm/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@
"spotbugs": "false",
},


"com.oracle.svm.core.jdk8": {
"subDir": "src",
"sourceDirs": ["src"],
Expand All @@ -195,26 +196,49 @@
"com.oracle.svm.core.jdk11": {
"subDir": "src",
"sourceDirs": ["src"],
"dependencies": ["com.oracle.svm.core"],
"dependencies": [
"com.oracle.svm.core.jfr",
],
"requires" : [
"jdk.jfr",
"jdk.management",
"java.logging",
"jdk.unsupported",
"java.compiler",
],
"requiresConcealed" : {
"java.base" : [
"jdk.internal.event",
"jdk.internal.module",
"jdk.internal.reflect",
"jdk.internal.misc",
"jdk.internal.logger",
"jdk.internal.loader",
"jdk.internal.org.xml.sax.helpers",
"sun.util.resources",
"jdk.internal.util.xml",
"jdk.internal.util.xml.impl",
"sun.text.spi",
"jdk.internal.perf",
"sun.util.locale.provider",
"jdk.internal.loader"
],
"jdk.jfr": [
"jdk.jfr.internal",
"jdk.jfr.internal.consumer",
"jdk.jfr.internal.jfc",
"jdk.jfr.internal.handlers",
"jdk.jfr.events"
],
"jdk.internal.vm.ci": [
"jdk.vm.ci.meta",
"jdk.vm.ci.code",
"jdk.vm.ci.hotspot"
],
},
"annotationProcessors": [
"compiler:GRAAL_PROCESSOR",
],
"javaCompliance": "11+",
"checkstyle": "com.oracle.svm.core",
"workingSets": "SVM",
Expand Down Expand Up @@ -428,10 +452,18 @@
"com.oracle.svm.hosted",
"com.oracle.svm.core.jdk11"
],
"requires" : ["java.instrument"],
"requires" : [
"java.instrument",
"jdk.jfr",
"jdk.unsupported",
],
"requiresConcealed" : {
"jdk.internal.vm.ci": ["jdk.vm.ci.meta"],
"java.base" : ["jdk.internal.module"],
"jdk.jfr" : [
"jdk.jfr.internal",
"jdk.jfr.internal.jfc",
]
},
"javaCompliance": "11+",
"checkstyle" : "com.oracle.svm.hosted",
Expand Down Expand Up @@ -570,40 +602,14 @@
"spotbugs": "false",
},

"com.oracle.svm.jfr": {
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be better to have the JFR implementation (and its dependencies) in a separate project. Pretty much all VM-internal events should use the JfrNativeEventWriter anyways (via some JDK-independent abstraction).

"com.oracle.svm.core.jfr": {
"subDir": "src",
"sourceDirs": ["src"],
"dependencies": [
"com.oracle.svm.hosted",
"com.oracle.svm.core",
],
"checkstyle": "com.oracle.svm.core",
"javaCompliance": "11+",
"requires": [
"jdk.jfr",
"jdk.management",
"jdk.unsupported"
],
"requiresConcealed": {
"jdk.jfr": [
"jdk.jfr.internal",
"jdk.jfr.internal.consumer",
"jdk.jfr.internal.jfc",
"jdk.jfr.internal.handlers",
"jdk.jfr.events"
],
"jdk.internal.vm.ci": [
"jdk.vm.ci.meta",
"jdk.vm.ci.code",
"jdk.vm.ci.hotspot"
],
"java.base": [
"jdk.internal.event",
"jdk.internal.misc",
"jdk.internal.util.xml",
"jdk.internal.util.xml.impl",
"jdk.internal.org.xml.sax.helpers"
]
},
"javaCompliance": "8+",
"annotationProcessors": [
"compiler:GRAAL_PROCESSOR",
],
Expand Down Expand Up @@ -1079,7 +1085,6 @@
"com.oracle.svm.core.genscavenge",
"com.oracle.svm.core.containers",
"com.oracle.svm.jni",
"com.oracle.svm.jfr",
"com.oracle.svm.reflect",
"com.oracle.svm.methodhandles"
],
Expand All @@ -1100,7 +1105,7 @@
"com.oracle.svm.core.snippets", # Uses of com.oracle.svm.core.snippets.KnownIntrinsics
"com.oracle.svm.core", # Uses of com.oracle.svm.core.TypeResult
"com.oracle.svm.core.util", # Uses of com.oracle.svm.core.util.VMError
"com.oracle.svm.jfr", # Uses of com.oracle.svm.jfr.JfrEnabled
"com.oracle.svm.core.jdk11.jfr", # Uses of com.oracle.svm.core.jdk11.jfr.JfrEnabled
"com.oracle.svm.hosted to java.base",
"com.oracle.svm.hosted.agent to java.instrument",
"com.oracle.svm.truffle.api to org.graalvm.truffle",
Expand Down
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.jfr;
package com.oracle.svm.core.jdk11.jfr;

import org.graalvm.nativeimage.c.struct.RawField;
import org.graalvm.nativeimage.c.struct.RawFieldOffset;
Expand Down
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.jfr;
package com.oracle.svm.core.jdk11.jfr;

import org.graalvm.compiler.api.replacements.Fold;
import org.graalvm.compiler.nodes.NamedLocationIdentity;
Expand Down
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.jfr;
package com.oracle.svm.core.jdk11.jfr;

import org.graalvm.nativeimage.c.struct.RawPointerTo;
import org.graalvm.word.PointerBase;
Expand Down
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.jfr;
package com.oracle.svm.core.jdk11.jfr;

import java.nio.charset.StandardCharsets;
import java.util.concurrent.locks.ReentrantLock;
Expand All @@ -42,7 +42,7 @@
import com.oracle.svm.core.thread.VMOperation;
import com.oracle.svm.core.thread.VMOperationControl;
import com.oracle.svm.core.thread.VMThreads;
import com.oracle.svm.jfr.traceid.JfrTraceIdEpoch;
import com.oracle.svm.core.jdk11.jfr.traceid.JfrTraceIdEpoch;

/**
* This class is used when writing the in-memory JFR data to a file. For all operations, except
Expand Down
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.jfr;
package com.oracle.svm.core.jdk11.jfr;

import com.oracle.svm.core.annotate.Uninterruptible;

Expand Down
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.jfr;
package com.oracle.svm.core.jdk11.jfr;

import java.util.function.BooleanSupplier;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright (c) 2021, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2021, 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.jdk11.jfr;

import org.graalvm.compiler.serviceprovider.JavaVersionUtil;
import org.graalvm.nativeimage.hosted.Feature;
import org.graalvm.nativeimage.ImageSingletons;

import com.oracle.svm.core.annotate.AutomaticFeature;
import com.oracle.svm.core.jfr.JfrEventSupport;

/**
* Jfr event support for supported JDK versions.
*/
final class JfrEventSupportJDK11OrLater extends JfrEventSupport {
}

@AutomaticFeature
final class JfrFeatureJDK11OrLater implements Feature {
@Override
public boolean isInConfiguration(IsInConfigurationAccess access) {
return JavaVersionUtil.JAVA_SPEC >= 11;
}

@Override
public void afterRegistration(AfterRegistrationAccess access) {
ImageSingletons.add(JfrEventSupport.class, new JfrEventSupportJDK11OrLater());
}
}
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.jfr;
package com.oracle.svm.core.jdk11.jfr;

//Checkstyle: allow reflection
import java.lang.reflect.Field;
Expand Down
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.jfr;
package com.oracle.svm.core.jdk11.jfr;

import com.oracle.svm.core.annotate.Uninterruptible;
import com.oracle.svm.core.util.VMError;
Expand Down
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.jfr;
package com.oracle.svm.core.jdk11.jfr;

import org.graalvm.nativeimage.Platform;
import org.graalvm.nativeimage.Platforms;
Expand Down
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.jfr;
package com.oracle.svm.core.jdk11.jfr;

import org.graalvm.nativeimage.Platform;
import org.graalvm.nativeimage.Platforms;
Expand Down
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.jfr;
package com.oracle.svm.core.jdk11.jfr;

import org.graalvm.nativeimage.Platform;
import org.graalvm.nativeimage.Platforms;
Expand Down
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.jfr;
package com.oracle.svm.core.jdk11.jfr;

import java.util.ArrayList;
import java.util.List;
Expand Down
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.jfr;
package com.oracle.svm.core.jdk11.jfr;

import java.io.FileNotFoundException;
import java.io.IOException;
Expand All @@ -44,13 +44,13 @@
import com.oracle.svm.core.SubstrateOptions;
import com.oracle.svm.core.util.UserError.UserException;
import com.oracle.svm.core.util.VMError;
import com.oracle.svm.jfr.events.ClassLoadingStatistics;
import com.oracle.svm.jfr.events.InitialEnvironmentVariable;
import com.oracle.svm.jfr.events.InitialSystemProperty;
import com.oracle.svm.jfr.events.JVMInformation;
import com.oracle.svm.jfr.events.JavaThreadStatistics;
import com.oracle.svm.jfr.events.OSInformation;
import com.oracle.svm.jfr.events.PhysicalMemory;
import com.oracle.svm.core.jdk11.jfr.events.ClassLoadingStatistics;
import com.oracle.svm.core.jdk11.jfr.events.InitialEnvironmentVariable;
import com.oracle.svm.core.jdk11.jfr.events.InitialSystemProperty;
import com.oracle.svm.core.jdk11.jfr.events.JVMInformation;
import com.oracle.svm.core.jdk11.jfr.events.JavaThreadStatistics;
import com.oracle.svm.core.jdk11.jfr.events.OSInformation;
import com.oracle.svm.core.jdk11.jfr.events.PhysicalMemory;

import jdk.jfr.FlightRecorder;
import jdk.jfr.Recording;
Expand All @@ -74,11 +74,11 @@ public JfrManager() {
}

@Fold
static JfrManager get() {
public static JfrManager get() {
return ImageSingletons.lookup(JfrManager.class);
}

Runnable startupHook() {
public Runnable startupHook() {
return () -> {
parseFlightRecorderLogging(SubstrateOptions.FlightRecorderLogging.getValue());
if (SubstrateOptions.FlightRecorder.getValue()) {
Expand All @@ -88,7 +88,7 @@ Runnable startupHook() {
};
}

Runnable shutdownHook() {
public Runnable shutdownHook() {
return () -> {
if (SubstrateOptions.FlightRecorder.getValue()) {
// Everything should already have been torn down by JVM.destroyJFR(), which is
Expand Down
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.jfr;
package com.oracle.svm.core.jdk11.jfr;

import com.oracle.svm.core.annotate.Uninterruptible;
import org.graalvm.nativeimage.Platform;
Expand Down
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.jfr;
package com.oracle.svm.core.jdk11.jfr;

import org.graalvm.nativeimage.CurrentIsolate;
import org.graalvm.nativeimage.IsolateThread;
Expand Down
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.jfr;
package com.oracle.svm.core.jdk11.jfr;

import org.graalvm.nativeimage.c.struct.RawField;
import org.graalvm.nativeimage.c.struct.RawStructure;
Expand Down
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.jfr;
package com.oracle.svm.core.jdk11.jfr;

import com.oracle.svm.core.annotate.Uninterruptible;

Expand Down
Loading