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