Mercurial > hg > graal-jvmci-8
annotate jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/services/EventProvider.java @ 23364:8153a654bd10
checkstyle fixes
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 29 Apr 2016 00:36:35 +0200 |
parents | 56479400913e |
children | cd8fd4cced6c |
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 */ | |
23363
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
23 package jdk.vm.ci.hotspot.services; |
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
24 |
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
25 import jdk.vm.ci.hotspot.services.EmptyEventProvider.EmptyCompilationEvent; |
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
26 import jdk.vm.ci.hotspot.services.EmptyEventProvider.EmptyCompilerFailureEvent; |
21631
77acf6ba2fc0
Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
15663
diff
changeset
|
27 |
15663 | 28 /** |
23363
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
29 * Service-provider class for logging compiler related events. |
15663 | 30 */ |
23363
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
31 public abstract class EventProvider { |
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
32 |
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
33 private static Void checkPermission() { |
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
34 SecurityManager sm = System.getSecurityManager(); |
23364 | 35 if (sm != null) { |
23363
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
36 sm.checkPermission(new RuntimePermission("jvmci")); |
23364 | 37 } |
23363
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
38 return null; |
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
39 } |
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
40 |
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
41 @SuppressWarnings("unused") |
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
42 EventProvider(Void ignore) { |
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
43 } |
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
44 |
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
45 /** |
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
46 * Initializes a new instance of this class. |
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
47 * |
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
48 * @throws SecurityException if a security manager has been installed and it denies |
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
49 * {@code RuntimePermission("jvmci")} |
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
50 */ |
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
51 protected EventProvider() { |
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
52 this(checkPermission()); |
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
53 } |
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
54 |
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
55 /** |
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
56 * Creates and returns an empty implementation for {@link EventProvider}. This implementation |
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
57 * can be used when no logging is requested. |
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
58 */ |
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
59 public static EventProvider createEmptyEventProvider() { |
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
60 return new EmptyEventProvider(); |
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
61 } |
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
62 |
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
63 /** |
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
64 * Creates and returns an empty implementation for {@link CompilationEvent}. |
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
65 */ |
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
66 public static CompilationEvent createEmptyCompilationEvent() { |
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
67 return new EmptyCompilationEvent(); |
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
68 } |
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
69 |
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
70 /** |
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
71 * Creates and returns an empty implementation for {@link CompilationEvent}. |
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
72 */ |
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
73 public static CompilerFailureEvent createEmptyCompilerFailureEvent() { |
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
74 return new EmptyCompilerFailureEvent(); |
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
75 } |
15663 | 76 |
77 /** | |
78 * An instant event is an event that is not considered to have taken any time. | |
79 */ | |
23363
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
80 public interface InstantEvent { |
15663 | 81 /** |
82 * Commits the event. | |
83 */ | |
84 void commit(); | |
85 | |
86 /** | |
87 * Determines if this particular event instance would be committed to the data stream right | |
88 * now if application called {@link #commit()}. This in turn depends on whether the event is | |
89 * enabled and possible other factors. | |
90 * | |
91 * @return if this event would be committed on a call to {@link #commit()}. | |
92 */ | |
93 boolean shouldWrite(); | |
94 } | |
95 | |
96 /** | |
97 * Timed events describe an operation that somehow consumes time. | |
98 */ | |
23363
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
99 public interface TimedEvent extends InstantEvent { |
15663 | 100 /** |
101 * Starts the timing for this event. | |
102 */ | |
103 void begin(); | |
104 | |
105 /** | |
106 * Ends the timing period for this event. | |
107 */ | |
108 void end(); | |
109 } | |
110 | |
111 /** | |
112 * Creates a new {@link CompilationEvent}. | |
113 * | |
114 * @return a compilation event | |
115 */ | |
23363
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
116 public abstract CompilationEvent newCompilationEvent(); |
15663 | 117 |
118 /** | |
119 * A compilation event. | |
120 */ | |
23363
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
121 public interface CompilationEvent extends TimedEvent { |
15663 | 122 void setMethod(String method); |
123 | |
124 void setCompileId(int compileId); | |
125 | |
126 void setCompileLevel(int compileLevel); | |
127 | |
128 void setSucceeded(boolean succeeded); | |
129 | |
130 void setIsOsr(boolean isOsr); | |
131 | |
132 void setCodeSize(int codeSize); | |
133 | |
134 void setInlinedBytes(int inlinedBytes); | |
135 } | |
136 | |
137 /** | |
138 * Creates a new {@link CompilerFailureEvent}. | |
139 * | |
140 * @return a compiler failure event | |
141 */ | |
23363
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
142 public abstract CompilerFailureEvent newCompilerFailureEvent(); |
15663 | 143 |
144 /** | |
145 * A compiler failure event. | |
146 */ | |
23363
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
147 public interface CompilerFailureEvent extends InstantEvent { |
15663 | 148 void setCompileId(int compileId); |
149 | |
150 void setMessage(String message); | |
151 } | |
152 } |