Mercurial > hg > truffle
annotate graal/com.oracle.graal.hotspot.jfr/src/com/oracle/graal/hotspot/jfr/events/JFREventProvider.java @ 18408:2c3666f44855
Truffle: initial commit of object API implementation
author | Andreas Woess <andreas.woess@jku.at> |
---|---|
date | Tue, 18 Nov 2014 23:19:43 +0100 |
parents | c88ab4f1f04a |
children | c1e2fdb5fea3 |
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 */ | |
23 package com.oracle.graal.hotspot.jfr.events; | |
24 | |
25 import java.net.*; | |
26 | |
27 import com.oracle.graal.api.runtime.*; | |
28 import com.oracle.graal.hotspot.events.*; | |
29 import com.oracle.jrockit.jfr.*; | |
30 | |
31 /** | |
32 * A JFR implementation for {@link EventProvider}. This implementation is used when Flight Recorder | |
33 * is turned on. | |
34 */ | |
35 @ServiceProvider(EventProvider.class) | |
36 public final class JFREventProvider implements EventProvider { | |
37 | |
38 @SuppressWarnings("deprecation") private final Producer producer; | |
39 | |
40 @SuppressWarnings("deprecation") | |
41 public JFREventProvider() { | |
42 try { | |
43 /* | |
44 * The "HotSpot JVM" producer is a native producer and we cannot use it. So we create | |
45 * our own. This has the downside that Mission Control is confused and doesn't show | |
46 * Graal's events in the "Code" tab. There are plans to revise the JFR code for JDK 9. | |
47 */ | |
48 producer = new Producer("HotSpot JVM", "Oracle Hotspot JVM", "http://www.oracle.com/hotspot/jvm/"); | |
49 producer.register(); | |
50 } catch (URISyntaxException e) { | |
51 throw new InternalError(e); | |
52 } | |
53 | |
54 // Register event classes with Producer. | |
55 for (Class<?> c : JFREventProvider.class.getDeclaredClasses()) { | |
56 if (c.isAnnotationPresent(EventDefinition.class)) { | |
57 assert com.oracle.jrockit.jfr.InstantEvent.class.isAssignableFrom(c) : c; | |
58 registerEvent(c); | |
59 } | |
60 } | |
61 } | |
62 | |
63 /** | |
64 * Register an event class with the {@link Producer}. | |
65 * | |
66 * @param c event class | |
67 * @return the {@link EventToken event token} | |
68 */ | |
69 @SuppressWarnings({"deprecation", "javadoc", "unchecked"}) | |
18163
c88ab4f1f04a
re-enabled Checkstyle with the release of 6.0 that supports Java 8; fixed existing Checkstyle warnings
Doug Simon <doug.simon@oracle.com>
parents:
15663
diff
changeset
|
70 private EventToken registerEvent(Class<?> c) { |
15663 | 71 try { |
72 return producer.addEvent((Class<? extends com.oracle.jrockit.jfr.InstantEvent>) c); | |
73 } catch (InvalidEventDefinitionException | InvalidValueException e) { | |
74 throw new InternalError(e); | |
75 } | |
76 } | |
77 | |
78 public CompilationEvent newCompilationEvent() { | |
79 return new JFRCompilationEvent(); | |
80 } | |
81 | |
82 /** | |
83 * A JFR compilation event. | |
84 * | |
85 * <p> | |
86 * See: event {@code Compilation} in {@code src/share/vm/trace/trace.xml} | |
87 */ | |
88 @SuppressWarnings("deprecation") | |
89 @EventDefinition(name = "Compilation", path = "vm/compiler/compilation") | |
90 public static class JFRCompilationEvent extends com.oracle.jrockit.jfr.DurationEvent implements CompilationEvent { | |
91 | |
92 /* | |
93 * FIXME method should be a Method* but we can't express that in Java. | |
94 */ | |
95 @ValueDefinition(name = "Java Method") public String method; | |
96 @ValueDefinition(name = "Compilation ID", relationKey = "COMP_ID") public int compileId; | |
97 @ValueDefinition(name = "Compilation Level") public short compileLevel; | |
98 @ValueDefinition(name = "Succeeded") public boolean succeeded; | |
99 @ValueDefinition(name = "On Stack Replacement") public boolean isOsr; | |
100 @ValueDefinition(name = "Compiled Code Size", contentType = ContentType.Bytes) public int codeSize; | |
101 @ValueDefinition(name = "Inlined Code Size", contentType = ContentType.Bytes) public int inlinedBytes; | |
102 | |
103 public void setMethod(String method) { | |
104 this.method = method; | |
105 } | |
106 | |
107 public void setCompileId(int id) { | |
108 this.compileId = id; | |
109 } | |
110 | |
111 public void setCompileLevel(int compileLevel) { | |
112 this.compileLevel = (short) compileLevel; | |
113 } | |
114 | |
115 public void setSucceeded(boolean succeeded) { | |
116 this.succeeded = succeeded; | |
117 } | |
118 | |
119 public void setIsOsr(boolean isOsr) { | |
120 this.isOsr = isOsr; | |
121 } | |
122 | |
123 public void setCodeSize(int codeSize) { | |
124 this.codeSize = codeSize; | |
125 } | |
126 | |
127 public void setInlinedBytes(int inlinedBytes) { | |
128 this.inlinedBytes = inlinedBytes; | |
129 } | |
130 } | |
131 | |
132 public CompilerFailureEvent newCompilerFailureEvent() { | |
133 return new JFRCompilerFailureEvent(); | |
134 } | |
135 | |
136 /** | |
137 * A JFR compiler failure event. | |
138 * | |
139 * <p> | |
140 * See: event {@code CompilerFailure} in {@code src/share/vm/trace/trace.xml} | |
141 */ | |
142 @SuppressWarnings("deprecation") | |
143 @EventDefinition(name = "Compilation Failure", path = "vm/compiler/failure") | |
144 public static class JFRCompilerFailureEvent extends com.oracle.jrockit.jfr.InstantEvent implements CompilerFailureEvent { | |
145 | |
146 @ValueDefinition(name = "Compilation ID", relationKey = "COMP_ID") public int compileId; | |
147 @ValueDefinition(name = "Message", description = "The failure message") public String failure; | |
148 | |
149 public void setCompileId(int id) { | |
150 this.compileId = id; | |
151 } | |
152 | |
153 public void setMessage(String message) { | |
154 this.failure = message; | |
155 } | |
156 } | |
157 | |
158 } |