Mercurial > hg > graal-jvmci-8
annotate jvmci/jdk.vm.ci.hotspot.jfr/src/jdk/vm/ci/hotspot/jfr/events/JFREventProvider.java @ 24096:63d6fa35faad
Merge
author | Gilles Duboscq <gilles.m.duboscq@oracle.com> |
---|---|
date | Tue, 07 Feb 2017 18:22:03 +0100 |
parents | 5cf445d2acf6 |
children |
rev | line source |
---|---|
15663 | 1 /* |
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 */ | |
22672
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22581
diff
changeset
|
23 package jdk.vm.ci.hotspot.jfr.events; |
15663 | 24 |
22569
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22453
diff
changeset
|
25 import java.net.URISyntaxException; |
15663 | 26 |
23785
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
23679
diff
changeset
|
27 import jdk.vm.ci.hotspot.EventProvider; |
23679
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
28 import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime; |
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
29 import jdk.vm.ci.hotspot.HotSpotVMConfigAccess; |
23785
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
23679
diff
changeset
|
30 import jdk.vm.ci.services.JVMCIServiceLocator; |
15663 | 31 |
32 /** | |
33 * A JFR implementation for {@link EventProvider}. This implementation is used when Flight Recorder | |
34 * is turned on. | |
22569
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22453
diff
changeset
|
35 * |
23345
1c4b6a7f1917
update to Eclipse 4.5.2 format style
Doug Simon <doug.simon@oracle.com>
parents:
22761
diff
changeset
|
36 * Note: The use of fully qualified names for deprecated types is a workaround for |
1c4b6a7f1917
update to Eclipse 4.5.2 format style
Doug Simon <doug.simon@oracle.com>
parents:
22761
diff
changeset
|
37 * <a href="https://bugs.openjdk.java.net/browse/JDK-8032211">JDK-8032211</a>. |
15663 | 38 */ |
22569
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22453
diff
changeset
|
39 @SuppressWarnings("deprecation") |
23785
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
23679
diff
changeset
|
40 public final class JFREventProvider implements EventProvider { |
15663 | 41 |
21631
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
42 private final boolean enabled; |
15663 | 43 |
23785
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
23679
diff
changeset
|
44 public static class Locator extends JVMCIServiceLocator { |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
23679
diff
changeset
|
45 |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
23679
diff
changeset
|
46 @Override |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
23679
diff
changeset
|
47 public <S> S getProvider(Class<S> service) { |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
23679
diff
changeset
|
48 if (service == EventProvider.class) { |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
23679
diff
changeset
|
49 return service.cast(new JFREventProvider()); |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
23679
diff
changeset
|
50 } |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
23679
diff
changeset
|
51 return null; |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
23679
diff
changeset
|
52 } |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
23679
diff
changeset
|
53 } |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
23679
diff
changeset
|
54 |
22453
d6bbd5d8d81e
need to hold onto JFR Producer object to prevent it being garbage collected
Doug Simon <doug.simon@oracle.com>
parents:
22054
diff
changeset
|
55 /** |
d6bbd5d8d81e
need to hold onto JFR Producer object to prevent it being garbage collected
Doug Simon <doug.simon@oracle.com>
parents:
22054
diff
changeset
|
56 * Need to store the producer in a field so that it doesn't disappear. |
d6bbd5d8d81e
need to hold onto JFR Producer object to prevent it being garbage collected
Doug Simon <doug.simon@oracle.com>
parents:
22054
diff
changeset
|
57 */ |
22569
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22453
diff
changeset
|
58 @SuppressWarnings("unused") private final com.oracle.jrockit.jfr.Producer producer; |
22453
d6bbd5d8d81e
need to hold onto JFR Producer object to prevent it being garbage collected
Doug Simon <doug.simon@oracle.com>
parents:
22054
diff
changeset
|
59 |
15663 | 60 public JFREventProvider() { |
23679
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
61 HotSpotVMConfigAccess config = new HotSpotVMConfigAccess(HotSpotJVMCIRuntime.runtime().getConfigStore()); |
23785
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
23679
diff
changeset
|
62 enabled = config.getFlag("FlightRecorder", Boolean.class, false); |
22569
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22453
diff
changeset
|
63 com.oracle.jrockit.jfr.Producer p = null; |
21631
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
64 if (enabled) { |
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
65 try { |
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
66 /* |
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
67 * The "HotSpot JVM" producer is a native producer and we cannot use it. So we |
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
68 * create our own. This has the downside that Mission Control is confused and |
21789
5b9adb645217
fixed remnants of "graal" names in JVMCI code
Doug Simon <doug.simon@oracle.com>
parents:
21631
diff
changeset
|
69 * doesn't show JVMCI events in the "Code" tab. There are plans to revise the JFR |
21631
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
70 * code for JDK 9. |
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
71 */ |
22569
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22453
diff
changeset
|
72 p = new com.oracle.jrockit.jfr.Producer("HotSpot JVM", "Oracle Hotspot JVM", "http://www.oracle.com/hotspot/jvm/"); |
22453
d6bbd5d8d81e
need to hold onto JFR Producer object to prevent it being garbage collected
Doug Simon <doug.simon@oracle.com>
parents:
22054
diff
changeset
|
73 p.register(); |
21631
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
74 // Register event classes with Producer. |
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
75 for (Class<?> c : JFREventProvider.class.getDeclaredClasses()) { |
22569
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22453
diff
changeset
|
76 if (c.isAnnotationPresent(com.oracle.jrockit.jfr.EventDefinition.class)) { |
21631
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
77 assert com.oracle.jrockit.jfr.InstantEvent.class.isAssignableFrom(c) : c; |
22453
d6bbd5d8d81e
need to hold onto JFR Producer object to prevent it being garbage collected
Doug Simon <doug.simon@oracle.com>
parents:
22054
diff
changeset
|
78 registerEvent(p, c); |
21631
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
79 } |
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
80 } |
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
81 } catch (URISyntaxException e) { |
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
82 throw new InternalError(e); |
15663 | 83 } |
84 } | |
22453
d6bbd5d8d81e
need to hold onto JFR Producer object to prevent it being garbage collected
Doug Simon <doug.simon@oracle.com>
parents:
22054
diff
changeset
|
85 this.producer = p; |
15663 | 86 } |
87 | |
88 /** | |
22569
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22453
diff
changeset
|
89 * Register an event class with the {@link com.oracle.jrockit.jfr.Producer}. |
15663 | 90 * |
91 * @param c event class | |
92 * @return the {@link EventToken event token} | |
93 */ | |
22569
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22453
diff
changeset
|
94 @SuppressWarnings({"javadoc", "unchecked"}) |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22453
diff
changeset
|
95 private static com.oracle.jrockit.jfr.EventToken registerEvent(com.oracle.jrockit.jfr.Producer producer, Class<?> c) { |
15663 | 96 try { |
97 return producer.addEvent((Class<? extends com.oracle.jrockit.jfr.InstantEvent>) c); | |
22569
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22453
diff
changeset
|
98 } catch (com.oracle.jrockit.jfr.InvalidEventDefinitionException | com.oracle.jrockit.jfr.InvalidValueException e) { |
15663 | 99 throw new InternalError(e); |
100 } | |
101 } | |
102 | |
23363
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
23345
diff
changeset
|
103 @Override |
15663 | 104 public CompilationEvent newCompilationEvent() { |
21631
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
105 if (enabled) { |
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
106 return new JFRCompilationEvent(); |
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
107 } |
23363
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
23345
diff
changeset
|
108 return EventProvider.createEmptyCompilationEvent(); |
15663 | 109 } |
110 | |
111 /** | |
112 * A JFR compilation event. | |
113 * | |
114 * <p> | |
115 * See: event {@code Compilation} in {@code src/share/vm/trace/trace.xml} | |
116 */ | |
22569
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22453
diff
changeset
|
117 @com.oracle.jrockit.jfr.EventDefinition(name = "Compilation", path = "vm/compiler/compilation") |
15663 | 118 public static class JFRCompilationEvent extends com.oracle.jrockit.jfr.DurationEvent implements CompilationEvent { |
119 | |
23393
1d4ce2d19e52
clean up and minimize JVMCI (JDK-8156835)
Doug Simon <doug.simon@oracle.com>
parents:
23363
diff
changeset
|
120 /** |
1d4ce2d19e52
clean up and minimize JVMCI (JDK-8156835)
Doug Simon <doug.simon@oracle.com>
parents:
23363
diff
changeset
|
121 * Should be a {@code Method*} but we can't express that in Java. |
15663 | 122 */ |
22569
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22453
diff
changeset
|
123 @com.oracle.jrockit.jfr.ValueDefinition(name = "Java Method") public String method; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22453
diff
changeset
|
124 @com.oracle.jrockit.jfr.ValueDefinition(name = "Compilation ID", relationKey = "COMP_ID") public int compileId; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22453
diff
changeset
|
125 @com.oracle.jrockit.jfr.ValueDefinition(name = "Compilation Level") public short compileLevel; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22453
diff
changeset
|
126 @com.oracle.jrockit.jfr.ValueDefinition(name = "Succeeded") public boolean succeeded; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22453
diff
changeset
|
127 @com.oracle.jrockit.jfr.ValueDefinition(name = "On Stack Replacement") public boolean isOsr; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22453
diff
changeset
|
128 @com.oracle.jrockit.jfr.ValueDefinition(name = "Compiled Code Size", contentType = com.oracle.jrockit.jfr.ContentType.Bytes) public int codeSize; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22453
diff
changeset
|
129 @com.oracle.jrockit.jfr.ValueDefinition(name = "Inlined Code Size", contentType = com.oracle.jrockit.jfr.ContentType.Bytes) public int inlinedBytes; |
15663 | 130 |
131 public void setMethod(String method) { | |
132 this.method = method; | |
133 } | |
134 | |
135 public void setCompileId(int id) { | |
136 this.compileId = id; | |
137 } | |
138 | |
139 public void setCompileLevel(int compileLevel) { | |
140 this.compileLevel = (short) compileLevel; | |
141 } | |
142 | |
143 public void setSucceeded(boolean succeeded) { | |
144 this.succeeded = succeeded; | |
145 } | |
146 | |
147 public void setIsOsr(boolean isOsr) { | |
148 this.isOsr = isOsr; | |
149 } | |
150 | |
151 public void setCodeSize(int codeSize) { | |
152 this.codeSize = codeSize; | |
153 } | |
154 | |
155 public void setInlinedBytes(int inlinedBytes) { | |
156 this.inlinedBytes = inlinedBytes; | |
157 } | |
158 } | |
159 | |
23363
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
23345
diff
changeset
|
160 @Override |
15663 | 161 public CompilerFailureEvent newCompilerFailureEvent() { |
21631
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
162 if (enabled) { |
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
163 return new JFRCompilerFailureEvent(); |
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
164 } |
23363
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
23345
diff
changeset
|
165 return EventProvider.createEmptyCompilerFailureEvent(); |
15663 | 166 } |
167 | |
168 /** | |
169 * A JFR compiler failure event. | |
170 * | |
171 * <p> | |
172 * See: event {@code CompilerFailure} in {@code src/share/vm/trace/trace.xml} | |
173 */ | |
22569
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22453
diff
changeset
|
174 @com.oracle.jrockit.jfr.EventDefinition(name = "Compilation Failure", path = "vm/compiler/failure") |
15663 | 175 public static class JFRCompilerFailureEvent extends com.oracle.jrockit.jfr.InstantEvent implements CompilerFailureEvent { |
176 | |
22569
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22453
diff
changeset
|
177 @com.oracle.jrockit.jfr.ValueDefinition(name = "Compilation ID", relationKey = "COMP_ID") public int compileId; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22453
diff
changeset
|
178 @com.oracle.jrockit.jfr.ValueDefinition(name = "Message", description = "The failure message") public String failure; |
15663 | 179 |
180 public void setCompileId(int id) { | |
181 this.compileId = id; | |
182 } | |
183 | |
184 public void setMessage(String message) { | |
185 this.failure = message; | |
186 } | |
187 } | |
188 | |
189 } |