Mercurial > hg > truffle
comparison graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotJVMCIRuntime.java @ 21780:3d15183f3c93
Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
author | Gilles Duboscq <gilles.m.duboscq@oracle.com> |
---|---|
date | Wed, 03 Jun 2015 15:47:54 +0200 |
parents | 2e8c01def9a5 |
children |
comparison
equal
deleted
inserted
replaced
21779:20ace3139510 | 21780:3d15183f3c93 |
---|---|
195 } | 195 } |
196 }; | 196 }; |
197 | 197 |
198 private final Map<Class<? extends Architecture>, JVMCIBackend> backends = new HashMap<>(); | 198 private final Map<Class<? extends Architecture>, JVMCIBackend> backends = new HashMap<>(); |
199 | 199 |
200 private final HotSpotVMEventListener vmEventListener; | 200 private final Iterable<HotSpotVMEventListener> vmEventListeners; |
201 | 201 |
202 private HotSpotJVMCIRuntime() { | 202 private HotSpotJVMCIRuntime() { |
203 CompilerToVM toVM = new CompilerToVMImpl(); | 203 CompilerToVM toVM = new CompilerToVMImpl(); |
204 compilerToVm = toVM; | 204 compilerToVm = toVM; |
205 try (InitTimer t = timer("HotSpotVMConfig<init>")) { | 205 try (InitTimer t = timer("HotSpotVMConfig<init>")) { |
218 } | 218 } |
219 try (InitTimer t = timer("create JVMCI backend:", hostArchitecture)) { | 219 try (InitTimer t = timer("create JVMCI backend:", hostArchitecture)) { |
220 hostBackend = registerBackend(factory.createJVMCIBackend(this, null)); | 220 hostBackend = registerBackend(factory.createJVMCIBackend(this, null)); |
221 } | 221 } |
222 | 222 |
223 HotSpotVMEventListener listener = Services.loadSingle(HotSpotVMEventListener.class, false); | 223 Iterable<HotSpotVMEventListener> listeners = Services.load(HotSpotVMEventListener.class); |
224 if (listener == null) { | 224 if (!listeners.iterator().hasNext()) { |
225 listener = new HotSpotVMEventListener() { | 225 listeners = Arrays.asList(new HotSpotVMEventListener() { |
226 }; | 226 }); |
227 } | 227 } |
228 vmEventListener = listener; | 228 vmEventListeners = listeners; |
229 } | 229 } |
230 | 230 |
231 private JVMCIBackend registerBackend(JVMCIBackend backend) { | 231 private JVMCIBackend registerBackend(JVMCIBackend backend) { |
232 Class<? extends Architecture> arch = backend.getCodeCache().getTarget().arch.getClass(); | 232 Class<? extends Architecture> arch = backend.getCodeCache().getTarget().arch.getClass(); |
233 JVMCIBackend oldValue = backends.put(arch, backend); | 233 JVMCIBackend oldValue = backends.put(arch, backend); |
297 /** | 297 /** |
298 * Called from the VM. | 298 * Called from the VM. |
299 */ | 299 */ |
300 @SuppressWarnings({"unused"}) | 300 @SuppressWarnings({"unused"}) |
301 private void compileMetaspaceMethod(long metaspaceMethod, int entryBCI, long jvmciEnv, int id) { | 301 private void compileMetaspaceMethod(long metaspaceMethod, int entryBCI, long jvmciEnv, int id) { |
302 vmEventListener.compileMetaspaceMethod(metaspaceMethod, entryBCI, jvmciEnv, id); | 302 for (HotSpotVMEventListener vmEventListener : vmEventListeners) { |
303 vmEventListener.compileMetaspaceMethod(metaspaceMethod, entryBCI, jvmciEnv, id); | |
304 } | |
303 } | 305 } |
304 | 306 |
305 /** | 307 /** |
306 * Called from the VM. | 308 * Called from the VM. |
307 */ | 309 */ |
308 @SuppressWarnings({"unused"}) | 310 @SuppressWarnings({"unused"}) |
309 private void compileTheWorld() throws Throwable { | 311 private void compileTheWorld() throws Throwable { |
310 vmEventListener.notifyCompileTheWorld(); | 312 for (HotSpotVMEventListener vmEventListener : vmEventListeners) { |
313 vmEventListener.notifyCompileTheWorld(); | |
314 } | |
311 } | 315 } |
312 | 316 |
313 /** | 317 /** |
314 * Shuts down the runtime. | 318 * Shuts down the runtime. |
315 * | 319 * |
316 * Called from the VM. | 320 * Called from the VM. |
317 */ | 321 */ |
318 @SuppressWarnings({"unused"}) | 322 @SuppressWarnings({"unused"}) |
319 private void shutdown() throws Exception { | 323 private void shutdown() throws Exception { |
320 vmEventListener.notifyShutdown(); | 324 for (HotSpotVMEventListener vmEventListener : vmEventListeners) { |
325 vmEventListener.notifyShutdown(); | |
326 } | |
321 } | 327 } |
322 } | 328 } |