hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java
equal
deleted
inserted
replaced
29 import java.io.PrintStream; |
29 import java.io.PrintStream; |
30 import java.lang.reflect.Array; |
30 import java.lang.reflect.Array; |
31 import java.lang.reflect.Field; |
31 import java.lang.reflect.Field; |
32 import java.lang.reflect.Method; |
32 import java.lang.reflect.Method; |
33 import java.lang.reflect.Modifier; |
33 import java.lang.reflect.Modifier; |
|
34 import java.util.ArrayList; |
34 import java.util.Collections; |
35 import java.util.Collections; |
35 import java.util.HashMap; |
36 import java.util.HashMap; |
|
37 import java.util.List; |
36 import java.util.Map; |
38 import java.util.Map; |
37 import java.util.Objects; |
39 import java.util.Objects; |
|
40 import java.util.ServiceLoader; |
38 import java.util.TreeMap; |
41 import java.util.TreeMap; |
39 |
42 |
40 import jdk.internal.misc.VM; |
43 import jdk.internal.misc.VM; |
41 import jdk.vm.ci.code.Architecture; |
44 import jdk.vm.ci.code.Architecture; |
42 import jdk.vm.ci.code.CompilationRequestResult; |
45 import jdk.vm.ci.code.CompilationRequestResult; |
211 */ |
214 */ |
212 @SuppressWarnings("unused") private final int compilationLevelAdjustment; |
215 @SuppressWarnings("unused") private final int compilationLevelAdjustment; |
213 |
216 |
214 private final Map<Class<? extends Architecture>, JVMCIBackend> backends = new HashMap<>(); |
217 private final Map<Class<? extends Architecture>, JVMCIBackend> backends = new HashMap<>(); |
215 |
218 |
216 private final Iterable<HotSpotVMEventListener> vmEventListeners; |
219 private volatile List<HotSpotVMEventListener> vmEventListeners; |
|
220 |
|
221 private Iterable<HotSpotVMEventListener> getVmEventListeners() { |
|
222 if (vmEventListeners == null) { |
|
223 synchronized (this) { |
|
224 if (vmEventListeners == null) { |
|
225 List<HotSpotVMEventListener> listeners = new ArrayList<>(); |
|
226 for (HotSpotVMEventListener vmEventListener : ServiceLoader.load(HotSpotVMEventListener.class)) { |
|
227 listeners.add(vmEventListener); |
|
228 } |
|
229 vmEventListeners = listeners; |
|
230 } |
|
231 } |
|
232 } |
|
233 return vmEventListeners; |
|
234 } |
217 |
235 |
218 /** |
236 /** |
219 * Stores the result of {@link HotSpotJVMCICompilerFactory#getTrivialPrefixes()} so that it can |
237 * Stores the result of {@link HotSpotJVMCICompilerFactory#getTrivialPrefixes()} so that it can |
220 * be read from the VM. |
238 * be read from the VM. |
221 */ |
239 */ |
237 } |
255 } |
238 |
256 |
239 try (InitTimer t = timer("create JVMCI backend:", hostArchitecture)) { |
257 try (InitTimer t = timer("create JVMCI backend:", hostArchitecture)) { |
240 hostBackend = registerBackend(factory.createJVMCIBackend(this, null)); |
258 hostBackend = registerBackend(factory.createJVMCIBackend(this, null)); |
241 } |
259 } |
242 |
|
243 vmEventListeners = Services.load(HotSpotVMEventListener.class); |
|
244 |
260 |
245 metaAccessContext = new HotSpotJVMCIMetaAccessContext(); |
261 metaAccessContext = new HotSpotJVMCIMetaAccessContext(); |
246 |
262 |
247 boolean printFlags = Option.PrintFlags.getBoolean(); |
263 boolean printFlags = Option.PrintFlags.getBoolean(); |
248 boolean showFlags = Option.ShowFlags.getBoolean(); |
264 boolean showFlags = Option.ShowFlags.getBoolean(); |
368 * |
384 * |
369 * Called from the VM. |
385 * Called from the VM. |
370 */ |
386 */ |
371 @SuppressWarnings({"unused"}) |
387 @SuppressWarnings({"unused"}) |
372 private void shutdown() throws Exception { |
388 private void shutdown() throws Exception { |
373 for (HotSpotVMEventListener vmEventListener : vmEventListeners) { |
389 for (HotSpotVMEventListener vmEventListener : getVmEventListeners()) { |
374 vmEventListener.notifyShutdown(); |
390 vmEventListener.notifyShutdown(); |
375 } |
391 } |
376 } |
392 } |
377 |
393 |
378 /** |
394 /** |
380 * |
396 * |
381 * Called from the VM. |
397 * Called from the VM. |
382 */ |
398 */ |
383 @SuppressWarnings({"unused"}) |
399 @SuppressWarnings({"unused"}) |
384 private void bootstrapFinished() throws Exception { |
400 private void bootstrapFinished() throws Exception { |
385 for (HotSpotVMEventListener vmEventListener : vmEventListeners) { |
401 for (HotSpotVMEventListener vmEventListener : getVmEventListeners()) { |
386 vmEventListener.notifyBootstrapFinished(); |
402 vmEventListener.notifyBootstrapFinished(); |
387 } |
403 } |
388 } |
404 } |
389 |
405 |
390 /** |
406 /** |
393 * @param hotSpotCodeCacheProvider |
409 * @param hotSpotCodeCacheProvider |
394 * @param installedCode |
410 * @param installedCode |
395 * @param compiledCode |
411 * @param compiledCode |
396 */ |
412 */ |
397 void notifyInstall(HotSpotCodeCacheProvider hotSpotCodeCacheProvider, InstalledCode installedCode, CompiledCode compiledCode) { |
413 void notifyInstall(HotSpotCodeCacheProvider hotSpotCodeCacheProvider, InstalledCode installedCode, CompiledCode compiledCode) { |
398 for (HotSpotVMEventListener vmEventListener : vmEventListeners) { |
414 for (HotSpotVMEventListener vmEventListener : getVmEventListeners()) { |
399 vmEventListener.notifyInstall(hotSpotCodeCacheProvider, installedCode, compiledCode); |
415 vmEventListener.notifyInstall(hotSpotCodeCacheProvider, installedCode, compiledCode); |
400 } |
416 } |
401 } |
417 } |
402 |
418 |
403 private static void printConfig(HotSpotVMConfig config, CompilerToVM vm) { |
419 private static void printConfig(HotSpotVMConfig config, CompilerToVM vm) { |