Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import java.util.Map;
import java.util.Objects;
import java.util.ServiceLoader;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Predicate;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -509,18 +510,7 @@ T get() {

private final Map<Class<? extends Architecture>, JVMCIBackend> backends = new HashMap<>();

private volatile List<HotSpotVMEventListener> vmEventListeners;

private Iterable<HotSpotVMEventListener> getVmEventListeners() {
if (vmEventListeners == null) {
synchronized (this) {
if (vmEventListeners == null) {
vmEventListeners = JVMCIServiceLocator.getProviders(HotSpotVMEventListener.class);
}
}
}
return vmEventListeners;
}
private final List<HotSpotVMEventListener> vmEventListeners;

@SuppressWarnings("try")
private HotSpotJVMCIRuntime() {
Expand Down Expand Up @@ -580,6 +570,8 @@ private HotSpotJVMCIRuntime() {
if (Option.PrintConfig.getBoolean()) {
configStore.printConfig(this);
}

vmEventListeners = JVMCIServiceLocator.getProviders(HotSpotVMEventListener.class);
}

/**
Expand Down Expand Up @@ -938,22 +930,21 @@ private boolean isGCSupported(int gcIdentifier) {
}

/**
* 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.
*/
@VMEntryPoint
private synchronized void shutdown() throws Exception {
if (!isShutdown) {
isShutdown = true;
private void shutdown() throws Exception {
if (isShutdown.compareAndSet(false, true)) {
// Cleaners are normally only processed when a new Cleaner is
// instantiated so process all remaining cleaners now.
Cleaner.clean();

for (HotSpotVMEventListener vmEventListener : getVmEventListeners()) {
for (HotSpotVMEventListener vmEventListener : vmEventListeners) {
vmEventListener.notifyShutdown();
}
}
Expand All @@ -964,7 +955,7 @@ private synchronized void shutdown() throws Exception {
*/
@VMEntryPoint
private void bootstrapFinished() throws Exception {
for (HotSpotVMEventListener vmEventListener : getVmEventListeners()) {
for (HotSpotVMEventListener vmEventListener : vmEventListeners) {
vmEventListener.notifyBootstrapFinished();
}
}
Expand All @@ -977,7 +968,7 @@ private void bootstrapFinished() throws Exception {
* @param compiledCode
*/
void notifyInstall(HotSpotCodeCacheProvider hotSpotCodeCacheProvider, InstalledCode installedCode, CompiledCode compiledCode) {
for (HotSpotVMEventListener vmEventListener : getVmEventListeners()) {
for (HotSpotVMEventListener vmEventListener : vmEventListeners) {
vmEventListener.notifyInstall(hotSpotCodeCacheProvider, installedCode, compiledCode);
}
}
Expand Down