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