Mercurial > hg > truffle
annotate graal/com.oracle.jvmci.hotspot.jfr/src/com/oracle/jvmci/hotspot/jfr/events/JFREventProvider.java @ 21754:aa5fa1190d6c
count all type check hint misses not just the last one
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 05 Jun 2015 23:03:41 +0200 |
parents | 77acf6ba2fc0 |
children | 5b9adb645217 |
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 */ | |
21631
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
23 package com.oracle.jvmci.hotspot.jfr.events; |
15663 | 24 |
25 import java.net.*; | |
26 | |
27 import com.oracle.jrockit.jfr.*; | |
21631
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
28 import com.oracle.jvmci.hotspot.*; |
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
29 import com.oracle.jvmci.hotspot.events.*; |
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
30 import com.oracle.jvmci.hotspot.events.EmptyEventProvider.EmptyCompilerFailureEvent; |
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
31 import com.oracle.jvmci.hotspot.events.EmptyEventProvider.EmptyCompilationEvent; |
21604
93f282187d90
moved JVMCI service API into separate com.oracle.jvmci.service module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21538
diff
changeset
|
32 import com.oracle.jvmci.service.*; |
15663 | 33 |
34 /** | |
35 * A JFR implementation for {@link EventProvider}. This implementation is used when Flight Recorder | |
36 * is turned on. | |
37 */ | |
38 @ServiceProvider(EventProvider.class) | |
39 public final class JFREventProvider implements EventProvider { | |
40 | |
21631
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
41 private final boolean enabled; |
15663 | 42 |
43 @SuppressWarnings("deprecation") | |
44 public JFREventProvider() { | |
21631
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
45 enabled = HotSpotJVMCIRuntime.runtime().getConfig().flightRecorder; |
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
46 if (enabled) { |
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
47 try { |
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
48 /* |
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
49 * 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
|
50 * create our own. This has the downside that Mission Control is confused and |
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
51 * doesn't show Graal's events in the "Code" tab. There are plans to revise the JFR |
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
52 * 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
|
53 */ |
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
54 Producer producer = new Producer("HotSpot JVM", "Oracle Hotspot JVM", "http://www.oracle.com/hotspot/jvm/"); |
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
55 producer.register(); |
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
56 // 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
|
57 for (Class<?> c : JFREventProvider.class.getDeclaredClasses()) { |
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
58 if (c.isAnnotationPresent(EventDefinition.class)) { |
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
59 assert com.oracle.jrockit.jfr.InstantEvent.class.isAssignableFrom(c) : c; |
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
60 registerEvent(producer, c); |
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
61 } |
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
62 } |
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
63 } 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
|
64 throw new InternalError(e); |
15663 | 65 } |
66 } | |
67 } | |
68 | |
69 /** | |
70 * Register an event class with the {@link Producer}. | |
71 * | |
72 * @param c event class | |
73 * @return the {@link EventToken event token} | |
74 */ | |
75 @SuppressWarnings({"deprecation", "javadoc", "unchecked"}) | |
21631
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
76 private static EventToken registerEvent(Producer producer, Class<?> c) { |
15663 | 77 try { |
78 return producer.addEvent((Class<? extends com.oracle.jrockit.jfr.InstantEvent>) c); | |
79 } catch (InvalidEventDefinitionException | InvalidValueException e) { | |
80 throw new InternalError(e); | |
81 } | |
82 } | |
83 | |
84 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
|
85 if (enabled) { |
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
86 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
|
87 } |
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
88 return new EmptyCompilationEvent(); |
15663 | 89 } |
90 | |
91 /** | |
92 * A JFR compilation event. | |
93 * | |
94 * <p> | |
95 * See: event {@code Compilation} in {@code src/share/vm/trace/trace.xml} | |
96 */ | |
97 @SuppressWarnings("deprecation") | |
98 @EventDefinition(name = "Compilation", path = "vm/compiler/compilation") | |
99 public static class JFRCompilationEvent extends com.oracle.jrockit.jfr.DurationEvent implements CompilationEvent { | |
100 | |
101 /* | |
102 * FIXME method should be a Method* but we can't express that in Java. | |
103 */ | |
104 @ValueDefinition(name = "Java Method") public String method; | |
105 @ValueDefinition(name = "Compilation ID", relationKey = "COMP_ID") public int compileId; | |
106 @ValueDefinition(name = "Compilation Level") public short compileLevel; | |
107 @ValueDefinition(name = "Succeeded") public boolean succeeded; | |
108 @ValueDefinition(name = "On Stack Replacement") public boolean isOsr; | |
109 @ValueDefinition(name = "Compiled Code Size", contentType = ContentType.Bytes) public int codeSize; | |
110 @ValueDefinition(name = "Inlined Code Size", contentType = ContentType.Bytes) public int inlinedBytes; | |
111 | |
112 public void setMethod(String method) { | |
113 this.method = method; | |
114 } | |
115 | |
116 public void setCompileId(int id) { | |
117 this.compileId = id; | |
118 } | |
119 | |
120 public void setCompileLevel(int compileLevel) { | |
121 this.compileLevel = (short) compileLevel; | |
122 } | |
123 | |
124 public void setSucceeded(boolean succeeded) { | |
125 this.succeeded = succeeded; | |
126 } | |
127 | |
128 public void setIsOsr(boolean isOsr) { | |
129 this.isOsr = isOsr; | |
130 } | |
131 | |
132 public void setCodeSize(int codeSize) { | |
133 this.codeSize = codeSize; | |
134 } | |
135 | |
136 public void setInlinedBytes(int inlinedBytes) { | |
137 this.inlinedBytes = inlinedBytes; | |
138 } | |
139 } | |
140 | |
141 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
|
142 if (enabled) { |
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
143 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
|
144 } |
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21604
diff
changeset
|
145 return new EmptyCompilerFailureEvent(); |
15663 | 146 } |
147 | |
148 /** | |
149 * A JFR compiler failure event. | |
150 * | |
151 * <p> | |
152 * See: event {@code CompilerFailure} in {@code src/share/vm/trace/trace.xml} | |
153 */ | |
154 @SuppressWarnings("deprecation") | |
155 @EventDefinition(name = "Compilation Failure", path = "vm/compiler/failure") | |
156 public static class JFRCompilerFailureEvent extends com.oracle.jrockit.jfr.InstantEvent implements CompilerFailureEvent { | |
157 | |
158 @ValueDefinition(name = "Compilation ID", relationKey = "COMP_ID") public int compileId; | |
159 @ValueDefinition(name = "Message", description = "The failure message") public String failure; | |
160 | |
161 public void setCompileId(int id) { | |
162 this.compileId = id; | |
163 } | |
164 | |
165 public void setMessage(String message) { | |
166 this.failure = message; | |
167 } | |
168 } | |
169 | |
170 } |