8315566: [JVMCI] deadlock in JVMCI startup when bad option specified
Reviewed-by: thartmann, never
This commit is contained in:
parent
94a74a0a45
commit
d1cabe4f22
@ -49,6 +49,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.ServiceLoader;
|
import java.util.ServiceLoader;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@ -509,18 +510,7 @@ public final class HotSpotJVMCIRuntime implements JVMCIRuntime {
|
|||||||
|
|
||||||
private final Map<Class<? extends Architecture>, JVMCIBackend> backends = new HashMap<>();
|
private final Map<Class<? extends Architecture>, JVMCIBackend> backends = new HashMap<>();
|
||||||
|
|
||||||
private volatile List<HotSpotVMEventListener> vmEventListeners;
|
private final List<HotSpotVMEventListener> vmEventListeners;
|
||||||
|
|
||||||
private Iterable<HotSpotVMEventListener> getVmEventListeners() {
|
|
||||||
if (vmEventListeners == null) {
|
|
||||||
synchronized (this) {
|
|
||||||
if (vmEventListeners == null) {
|
|
||||||
vmEventListeners = JVMCIServiceLocator.getProviders(HotSpotVMEventListener.class);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return vmEventListeners;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("try")
|
@SuppressWarnings("try")
|
||||||
private HotSpotJVMCIRuntime() {
|
private HotSpotJVMCIRuntime() {
|
||||||
@ -580,6 +570,8 @@ public final class HotSpotJVMCIRuntime implements JVMCIRuntime {
|
|||||||
if (Option.PrintConfig.getBoolean()) {
|
if (Option.PrintConfig.getBoolean()) {
|
||||||
configStore.printConfig(this);
|
configStore.printConfig(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vmEventListeners = JVMCIServiceLocator.getProviders(HotSpotVMEventListener.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -938,22 +930,21 @@ public final class HotSpotJVMCIRuntime implements JVMCIRuntime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Guard to ensure shut down actions are performed at most once.
|
* Guard to ensure shut down actions are performed by at most one thread.
|
||||||
*/
|
*/
|
||||||
private boolean isShutdown;
|
private final AtomicBoolean isShutdown = new AtomicBoolean();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shuts down the runtime.
|
* Shuts down the runtime.
|
||||||
*/
|
*/
|
||||||
@VMEntryPoint
|
@VMEntryPoint
|
||||||
private synchronized void shutdown() throws Exception {
|
private void shutdown() throws Exception {
|
||||||
if (!isShutdown) {
|
if (isShutdown.compareAndSet(false, true)) {
|
||||||
isShutdown = true;
|
|
||||||
// Cleaners are normally only processed when a new Cleaner is
|
// Cleaners are normally only processed when a new Cleaner is
|
||||||
// instantiated so process all remaining cleaners now.
|
// instantiated so process all remaining cleaners now.
|
||||||
Cleaner.clean();
|
Cleaner.clean();
|
||||||
|
|
||||||
for (HotSpotVMEventListener vmEventListener : getVmEventListeners()) {
|
for (HotSpotVMEventListener vmEventListener : vmEventListeners) {
|
||||||
vmEventListener.notifyShutdown();
|
vmEventListener.notifyShutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -964,7 +955,7 @@ public final class HotSpotJVMCIRuntime implements JVMCIRuntime {
|
|||||||
*/
|
*/
|
||||||
@VMEntryPoint
|
@VMEntryPoint
|
||||||
private void bootstrapFinished() throws Exception {
|
private void bootstrapFinished() throws Exception {
|
||||||
for (HotSpotVMEventListener vmEventListener : getVmEventListeners()) {
|
for (HotSpotVMEventListener vmEventListener : vmEventListeners) {
|
||||||
vmEventListener.notifyBootstrapFinished();
|
vmEventListener.notifyBootstrapFinished();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -977,7 +968,7 @@ public final class HotSpotJVMCIRuntime implements JVMCIRuntime {
|
|||||||
* @param compiledCode
|
* @param compiledCode
|
||||||
*/
|
*/
|
||||||
void notifyInstall(HotSpotCodeCacheProvider hotSpotCodeCacheProvider, InstalledCode installedCode, CompiledCode compiledCode) {
|
void notifyInstall(HotSpotCodeCacheProvider hotSpotCodeCacheProvider, InstalledCode installedCode, CompiledCode compiledCode) {
|
||||||
for (HotSpotVMEventListener vmEventListener : getVmEventListeners()) {
|
for (HotSpotVMEventListener vmEventListener : vmEventListeners) {
|
||||||
vmEventListener.notifyInstall(hotSpotCodeCacheProvider, installedCode, compiledCode);
|
vmEventListener.notifyInstall(hotSpotCodeCacheProvider, installedCode, compiledCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user