Mercurial > hg > graal-jvmci-8
annotate jvmci/jdk.internal.jvmci.hotspot.jfr/src/jdk/internal/jvmci/hotspot/jfr/events/JFREventProvider.java @ 22581:3884a98ebcde
consistently use HotSpotVMConfig.config() for static access to the HotSpotVMConfig instance
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 18 Sep 2015 15:05:04 +0200 |
parents | ec96f33a101d |
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 */ | |
22054 | 23 package jdk.internal.jvmci.hotspot.jfr.events; |
15663 | 24 |
22581
3884a98ebcde
consistently use HotSpotVMConfig.config() for static access to the HotSpotVMConfig instance
Doug Simon <doug.simon@oracle.com>
parents:
22569
diff
changeset
|
25 import static jdk.internal.jvmci.hotspot.HotSpotVMConfig.config; |
3884a98ebcde
consistently use HotSpotVMConfig.config() for static access to the HotSpotVMConfig instance
Doug Simon <doug.simon@oracle.com>
parents:
22569
diff
changeset
|
26 |
22569
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22453
diff
changeset
|
27 import java.net.URISyntaxException; |
15663 | 28 |
22569
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22453
diff
changeset
|
29 import jdk.internal.jvmci.hotspot.events.EmptyEventProvider.EmptyCompilationEvent; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22453
diff
changeset
|
30 import jdk.internal.jvmci.hotspot.events.EmptyEventProvider.EmptyCompilerFailureEvent; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22453
diff
changeset
|
31 import jdk.internal.jvmci.hotspot.events.EventProvider; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22453
diff
changeset
|
32 import jdk.internal.jvmci.service.ServiceProvider; |
15663 | 33 |
34 /** | |
35 * A JFR implementation for {@link EventProvider}. This implementation is used when Flight Recorder | |
36 * 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
|
37 * |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22453
diff
changeset
|
38 * Note: The use of fully qualified names for deprecated types is a workaround for <a |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22453
diff
changeset
|
39 * href="https://bugs.openjdk.java.net/browse/JDK-8032211">JDK-8032211</a>. |
15663 | 40 */ |
41 @ServiceProvider(EventProvider.class) | |
22569
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22453
diff
changeset
|
42 @SuppressWarnings("deprecation") |
15663 | 43 public final class JFREventProvider implements EventProvider { |
44 | |
21631
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
45 private final boolean enabled; |
15663 | 46 |
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
|
47 /** |
d6bbd5d8d81e
need to hold onto JFR Producer object to prevent it being garbage collected
Doug Simon <doug.simon@oracle.com>
parents:
22054
diff
changeset
|
48 * 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
|
49 */ |
22569
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22453
diff
changeset
|
50 @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
|
51 |
15663 | 52 public JFREventProvider() { |
22581
3884a98ebcde
consistently use HotSpotVMConfig.config() for static access to the HotSpotVMConfig instance
Doug Simon <doug.simon@oracle.com>
parents:
22569
diff
changeset
|
53 enabled = config().flightRecorder; |
22569
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22453
diff
changeset
|
54 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
|
55 if (enabled) { |
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
56 try { |
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
57 /* |
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
58 * 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
|
59 * 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
|
60 * 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
|
61 * 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
|
62 */ |
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 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
|
64 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
|
65 // 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
|
66 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
|
67 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
|
68 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
|
69 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
|
70 } |
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
71 } |
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
72 } 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
|
73 throw new InternalError(e); |
15663 | 74 } |
75 } | |
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
|
76 this.producer = p; |
15663 | 77 } |
78 | |
79 /** | |
22569
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22453
diff
changeset
|
80 * Register an event class with the {@link com.oracle.jrockit.jfr.Producer}. |
15663 | 81 * |
82 * @param c event class | |
83 * @return the {@link EventToken event token} | |
84 */ | |
22569
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22453
diff
changeset
|
85 @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
|
86 private static com.oracle.jrockit.jfr.EventToken registerEvent(com.oracle.jrockit.jfr.Producer producer, Class<?> c) { |
15663 | 87 try { |
88 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
|
89 } catch (com.oracle.jrockit.jfr.InvalidEventDefinitionException | com.oracle.jrockit.jfr.InvalidValueException e) { |
15663 | 90 throw new InternalError(e); |
91 } | |
92 } | |
93 | |
94 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
|
95 if (enabled) { |
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
96 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
|
97 } |
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
98 return new EmptyCompilationEvent(); |
15663 | 99 } |
100 | |
101 /** | |
102 * A JFR compilation event. | |
103 * | |
104 * <p> | |
105 * See: event {@code Compilation} in {@code src/share/vm/trace/trace.xml} | |
106 */ | |
22569
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22453
diff
changeset
|
107 @com.oracle.jrockit.jfr.EventDefinition(name = "Compilation", path = "vm/compiler/compilation") |
15663 | 108 public static class JFRCompilationEvent extends com.oracle.jrockit.jfr.DurationEvent implements CompilationEvent { |
109 | |
110 /* | |
111 * FIXME method should be a Method* but we can't express that in Java. | |
112 */ | |
22569
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22453
diff
changeset
|
113 @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
|
114 @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
|
115 @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
|
116 @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
|
117 @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
|
118 @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
|
119 @com.oracle.jrockit.jfr.ValueDefinition(name = "Inlined Code Size", contentType = com.oracle.jrockit.jfr.ContentType.Bytes) public int inlinedBytes; |
15663 | 120 |
121 public void setMethod(String method) { | |
122 this.method = method; | |
123 } | |
124 | |
125 public void setCompileId(int id) { | |
126 this.compileId = id; | |
127 } | |
128 | |
129 public void setCompileLevel(int compileLevel) { | |
130 this.compileLevel = (short) compileLevel; | |
131 } | |
132 | |
133 public void setSucceeded(boolean succeeded) { | |
134 this.succeeded = succeeded; | |
135 } | |
136 | |
137 public void setIsOsr(boolean isOsr) { | |
138 this.isOsr = isOsr; | |
139 } | |
140 | |
141 public void setCodeSize(int codeSize) { | |
142 this.codeSize = codeSize; | |
143 } | |
144 | |
145 public void setInlinedBytes(int inlinedBytes) { | |
146 this.inlinedBytes = inlinedBytes; | |
147 } | |
148 } | |
149 | |
150 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
|
151 if (enabled) { |
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
152 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
|
153 } |
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
154 return new EmptyCompilerFailureEvent(); |
15663 | 155 } |
156 | |
157 /** | |
158 * A JFR compiler failure event. | |
159 * | |
160 * <p> | |
161 * See: event {@code CompilerFailure} in {@code src/share/vm/trace/trace.xml} | |
162 */ | |
22569
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22453
diff
changeset
|
163 @com.oracle.jrockit.jfr.EventDefinition(name = "Compilation Failure", path = "vm/compiler/failure") |
15663 | 164 public static class JFRCompilerFailureEvent extends com.oracle.jrockit.jfr.InstantEvent implements CompilerFailureEvent { |
165 | |
22569
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22453
diff
changeset
|
166 @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
|
167 @com.oracle.jrockit.jfr.ValueDefinition(name = "Message", description = "The failure message") public String failure; |
15663 | 168 |
169 public void setCompileId(int id) { | |
170 this.compileId = id; | |
171 } | |
172 | |
173 public void setMessage(String message) { | |
174 this.failure = message; | |
175 } | |
176 } | |
177 | |
178 } |