Skip to content

Commit

Permalink
Automatic merge of master into galahad
Browse files Browse the repository at this point in the history
  • Loading branch information
OracleLabsAutomation committed May 29, 2024
2 parents ceaac5f + 8f0d1e6 commit f1a2d95
Show file tree
Hide file tree
Showing 36 changed files with 486 additions and 2,439 deletions.
14 changes: 7 additions & 7 deletions common.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@
"labsjdk-ee-21-llvm": {"name": "labsjdk", "version": "ee-21.0.2+13-jvmci-23.1-b33-sulong", "platformspecific": true },
"graalvm-ee-21": {"name": "graalvm-java21", "version": "23.1.3", "platformspecific": true },

"oraclejdk-latest": {"name": "jpg-jdk", "version": "23", "build_id": "jdk-23+23", "platformspecific": true, "extrabundles": ["static-libs"]},
"labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-23+23-jvmci-b01", "platformspecific": true },
"labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-23+23-jvmci-b01-debug", "platformspecific": true },
"labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-23+23-jvmci-b01-sulong", "platformspecific": true },
"labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-23+23-jvmci-b01", "platformspecific": true },
"labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-23+23-jvmci-b01-debug", "platformspecific": true },
"labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-23+23-jvmci-b01-sulong", "platformspecific": true }
"oraclejdk-latest": {"name": "jpg-jdk", "version": "23", "build_id": "jdk-23+24", "platformspecific": true, "extrabundles": ["static-libs"]},
"labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-23+24-jvmci-b01", "platformspecific": true },
"labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-23+24-jvmci-b01-debug", "platformspecific": true },
"labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-23+24-jvmci-b01-sulong", "platformspecific": true },
"labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-23+24-jvmci-b01", "platformspecific": true },
"labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-23+24-jvmci-b01-debug", "platformspecific": true },
"labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-23+24-jvmci-b01-sulong", "platformspecific": true }
},

"eclipse": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@

import java.util.Arrays;

import jdk.graal.compiler.core.common.PermanentBailoutException;
import jdk.graal.compiler.core.common.util.EventCounter.EventCounterMarker;
import jdk.graal.compiler.debug.Assertions;
import jdk.graal.compiler.debug.TTY;
import jdk.graal.compiler.core.common.PermanentBailoutException;
import jdk.graal.compiler.graph.Graph;
import jdk.graal.compiler.options.Option;
import jdk.graal.compiler.options.OptionKey;
Expand Down Expand Up @@ -195,8 +196,8 @@ private static void overflowAction(OptionValues opt, EventCounter counter) {
* hang and throw a bailout.
*/
private static void assertProgress(OptionValues opt, EventCounter counter) {
final EventCounter lastCounter = lastCounterForThread.get();
if (lastCounter != null && !lastCounter.equals(counter)) {
final EventCounterMarker lastMarker = lastMarkerForThread.get();
if (lastMarker != null && lastMarker != counter.getEventCounterMarker()) {
resetProgressDetection();
return;
}
Expand Down Expand Up @@ -231,9 +232,9 @@ private static void assertProgress(OptionValues opt, EventCounter counter) {
if (lastStackTrace == null || lastStackTrace.length != currentStackTrace.length || !Arrays.equals(lastStackTrace, currentStackTrace)) {
lastStackTraceForThread.set(currentStackTrace);
lastUniqueStackTraceForThreadMS.set(System.currentTimeMillis());
lastCounterForThread.set(counter);
lastMarkerForThread.set(counter.getEventCounterMarker());
} else {
assertProgressSlowPath(opt, lastStackTrace, lastCounter, currentStackTrace);
assertProgressSlowPath(opt, lastStackTrace, counter, currentStackTrace);
}
}

Expand All @@ -243,15 +244,15 @@ private static void assertProgressNoTracking(OptionValues opt, EventCounter coun
* n seconds
*/
lastUniqueStackTraceForThreadMS.set(System.currentTimeMillis());
lastCounterForThread.set(counter);
lastMarkerForThread.set(counter.getEventCounterMarker());
noProgressStartPeriodMS.set((long) (Options.CompilationNoProgressStartTrackingProgressPeriod.getValue(opt) * 1000));

if (LOG_PROGRESS_DETECTION) {
TTY.printf("CompilationAlarm: Progress detection %s; taking first time stamp, no stack yet%n", counter.eventCounterToString());
}
}

private static void assertProgressSlowPath(OptionValues opt, StackTraceElement[] lastStackTrace, EventCounter lastCounter, StackTraceElement[] currentStackTrace) {
private static void assertProgressSlowPath(OptionValues opt, StackTraceElement[] lastStackTrace, EventCounter counter, StackTraceElement[] currentStackTrace) {
/*
* We perform this check inside here since its cheaper to take the last stack trace (last
* will be null for the first in the current compile) than actually checking the option
Expand All @@ -276,24 +277,31 @@ private static void assertProgressSlowPath(OptionValues opt, StackTraceElement[]

if (LOG_PROGRESS_DETECTION) {
TTY.printf("CompilationAlarm: Progress detection %s; no progress for %d ms; stuck? %s; stuck threshold %d ms%n",
lastCounter, elapsed, stuck, stuckThreshold);
counter, elapsed, stuck, stuckThreshold);
}

if (stuck) {
throw new PermanentBailoutException("Observed identical stack traces for %d ms, indicating a stuck compilation, counter = %s, stack is:%n%s",
elapsed, lastCounter, Util.toString(lastStackTrace));
elapsed, counter, Util.toString(lastStackTrace));
}
}

public static void resetProgressDetection() {
lastStackTraceForThread.set(null);
lastUniqueStackTraceForThreadMS.set(null);
lastCounterForThread.set(null);
lastMarkerForThread.set(null);
noProgressStartPeriodMS.set(null);
}

private static final ThreadLocal<StackTraceElement[]> lastStackTraceForThread = new ThreadLocal<>();
private static final ThreadLocal<Long> lastUniqueStackTraceForThreadMS = new ThreadLocal<>();
private static final ThreadLocal<EventCounter> lastCounterForThread = new ThreadLocal<>();
/**
* Note that all these thread locals are not necessarily reset for a while even if worker
* threads have moved on to do actual work (but just not compiling graphs). Especially in the
* native image generator, not all {@link #assertProgress} calls can be in a closeable scope
* that invokes {@link #resetProgressDetection}. It is therefore critical that they do not keep
* large data structures like actual Graal graphs or LIR alive.
*/
private static final ThreadLocal<EventCounterMarker> lastMarkerForThread = new ThreadLocal<>();
private static final ThreadLocal<Long> noProgressStartPeriodMS = new ThreadLocal<>();
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,19 @@
*/
public interface EventCounter {

/**
* A shallow marker that can be kept alive by {@link CompilationAlarm} without keeping large
* data structures (the actual {@link EventCounter} implementation classes) alive.
*/
final class EventCounterMarker {
}

/**
* Returns the unique marker object for this event counter. This object is used by
* {@link CompilationAlarm} to check for progress.
*/
EventCounterMarker getEventCounterMarker();

/**
* Increment the current counter and determine if it overflows max and reset it if so. Users of
* this class typically take some action if an overflow happens.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ public int hashCode(Object k) {
* used to trigger certain operations.
*/
private int eventCounter;
private final EventCounterMarker eventCounterMarker = new EventCounterMarker();

@Override
public EventCounterMarker getEventCounterMarker() {
return eventCounterMarker;
}

@Override
public boolean eventCounterOverflows(int max) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public final class JVMCIVersionCheck {
private static final Map<String, Map<String, Version>> JVMCI_MIN_VERSIONS = Map.of(
"21", Map.of(DEFAULT_VENDOR_ENTRY, createLegacyVersion(23, 1, 33)),
"23", Map.of(
"Oracle Corporation", createLabsJDKVersion("23+23", 1),
DEFAULT_VENDOR_ENTRY, createLabsJDKVersion("23+23", 1)));
"Oracle Corporation", createLabsJDKVersion("23+24", 1),
DEFAULT_VENDOR_ENTRY, createLabsJDKVersion("23+24", 1)));
private static final int NA = 0;
/**
* Minimum Java release supported by Graal.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public final class LIR extends LIRGenerator.VariableProvider implements EventCou
* to trigger certain operations.
*/
private int eventCounter;
private final EventCounterMarker eventCounterMarker = new EventCounterMarker();

/**
* Creates a new LIR instance for the specified compilation.
Expand All @@ -98,6 +99,11 @@ public LIR(AbstractControlFlowGraph<?> cfg,
this.debug = debug;
}

@Override
public EventCounterMarker getEventCounterMarker() {
return eventCounterMarker;
}

@Override
public boolean eventCounterOverflows(int max) {
if (eventCounter++ > max) {
Expand Down

0 comments on commit f1a2d95

Please sign in to comment.