Skip to content

Commit e0ab6c0

Browse files
committed
Add changelog entries. Cleanups and minor improvements to compiler control.
1 parent 9e46a60 commit e0ab6c0

File tree

6 files changed

+45
-33
lines changed

6 files changed

+45
-33
lines changed

sdk/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
This changelog summarizes major changes between GraalVM SDK versions. The main focus is on APIs exported by GraalVM SDK.
44

5+
## Version 25.0.0
6+
* GR-60636 Truffle now stops compiling when the code cache fills up on HotSpot. A warning is printed when that happens.
7+
58
## Version 24.2.0
69
* GR-54905 When using Truffle NFI with the Panama backend, native access must now be granted to the Truffle module instead of the NFI Panama module. Use the `--enable-native-access=org.graalvm.truffle` Java command line option to enable the native access for the NFI Panama backend.
710
* GR-57681 Added the ability to use `Value#as(byte[].class)` to copy the contents of a guest language byte buffer (`Value#hasBufferElements()`) to a new byte array. The new functionality has precedence over accessing the guest object as array (`Value#hasArrayElements()`) if both ways are available.

truffle/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
This changelog summarizes major changes between Truffle versions relevant to languages implementors building upon the Truffle framework. The main focus is on APIs exported by Truffle.
44

5+
## Version 24.2.0
6+
* GR-60636 Truffle now stops compiling when the code cache fills up on HotSpot. A warning is printed when that happens.
7+
58
## Version 24.2.0
69
* GR-57658 Added `TruffleLanguage.Env.getLanguageInfo(Class<? extends TruffleLanguage>)` to lookup a `LanguageInfo` instance for a language class returned by `InteropLibrary.getLanguage(Object)`.
710
* GR-57164 Added support for reading unaligned ints, shorts and long to `ByteArraySupport`.

truffle/docs/Options.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ The accepted values are:
8181
- `--engine.PartialBlockMaximumSize=[1, inf)` : Sets the maximum non-trivial Truffle node size for partial compilation of BlockNode nodes (default: 10000).
8282
- `--engine.SingleTierCompilationThreshold=[1, inf)` : Minimum number of invocations or loop iterations needed to compile a guest language root when not using multi tier (default: 1000).
8383
- `--engine.Splitting=true|false` : Enable automatic duplication of compilation profiles (splitting) (default: true).
84+
- `--engine.StoppedCompilationRetryDelay=<ms>` : Before the Truffle runtime submits an OptimizedCallTarget for compilation, it checks for the compilation activity mode in the host VM. If the activity mode indicates a full code cache, no new compilation requests are submitted and the compilation queue is flushed. After 'StoppedCompilationRetryDelay' milliseconds new compilations will be submitted again (which might trigger a sweep of the code cache and a reset of the compilation activity mode in the host JVM). The option is only supported on the HotSpot Truffle runtime. On runtimes which don't support it the option has no effect. default: 5000
8485
- `--engine.TraceCompilation` : Print information for compilation results.
8586
- `--compiler.EncodedGraphCache` : Cache encoded graphs across Truffle compilations to speed up partial evaluation. (default: true).
8687
- `--compiler.FirstTierUseEconomy` : Whether to use the economy configuration in the first-tier compilations. (default: true, syntax: true|false)

truffle/src/com.oracle.truffle.runtime/src/com/oracle/truffle/runtime/OptimizedCallTarget.java

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -859,25 +859,24 @@ final boolean isCompilationFailed() {
859859
return compilationFailed;
860860
}
861861

862-
final CompilationActivityMode getCompilationActivityMode() {
862+
private CompilationActivityMode getCompilationActivityMode() {
863863
CompilationActivityMode compilationActivityMode = runtime().getCompilationActivityMode();
864-
long sct = runtime().stoppedCompilationTime().get();
864+
long stoppedTime = runtime().stoppedCompilationTime().get();
865865
if (compilationActivityMode == CompilationActivityMode.STOP_COMPILATION) {
866-
if (sct != 0 && System.currentTimeMillis() - sct > engine.stoppedCompilationRetryDelay) {
867-
runtime().stoppedCompilationTime().compareAndSet(sct, 0);
866+
if (stoppedTime != 0 && System.currentTimeMillis() - stoppedTime > engine.stoppedCompilationRetryDelay) {
867+
runtime().stoppedCompilationTime().compareAndSet(stoppedTime, 0);
868868
// Try again every StoppedCompilationRetryDelay milliseconds to potentially trigger
869869
// a code cache sweep.
870870
compilationActivityMode = CompilationActivityMode.RUN_COMPILATION;
871871
}
872872
}
873873

874874
switch (compilationActivityMode) {
875-
case RUN_COMPILATION: {
875+
case RUN_COMPILATION:
876876
// This is the common case - compilations are not stopped.
877877
return CompilationActivityMode.RUN_COMPILATION;
878-
}
879-
case STOP_COMPILATION: {
880-
if (sct == 0) {
878+
case STOP_COMPILATION:
879+
if (stoppedTime == 0) {
881880
runtime().stoppedCompilationTime().compareAndSet(0, System.currentTimeMillis());
882881
}
883882
// Flush the compilations queue for now. There's still a chance that compilation
@@ -892,8 +891,7 @@ final CompilationActivityMode getCompilationActivityMode() {
892891
}
893892
}
894893
return CompilationActivityMode.STOP_COMPILATION;
895-
}
896-
case SHUTDOWN_COMPILATION: {
894+
case SHUTDOWN_COMPILATION:
897895
// Compilation was shut down permanently because the hosts code cache ran full and
898896
// the host was configured without support for code cache sweeping.
899897
TruffleLogger logger = engine.getLogger("engine");
@@ -908,11 +906,9 @@ final CompilationActivityMode getCompilationActivityMode() {
908906
target.compilationFailed = true;
909907
}
910908
return CompilationActivityMode.SHUTDOWN_COMPILATION;
911-
}
912909
default:
913-
CompilerDirectives.shouldNotReachHere("Invalid compilation activity mode: " + compilationActivityMode);
910+
throw CompilerDirectives.shouldNotReachHere("Invalid compilation activity mode: " + compilationActivityMode);
914911
}
915-
return CompilationActivityMode.RUN_COMPILATION;
916912
}
917913

918914
/**

truffle/src/com.oracle.truffle.runtime/src/com/oracle/truffle/runtime/OptimizedTruffleRuntime.java

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,30 +1490,25 @@ static OptionCategory matchCategory(TruffleCompilerOptionDescriptor d) {
14901490
}
14911491
}
14921492

1493-
/**
1494-
* Represents HotSpot's compilation activity mode which is one of: {@code stop_compilation = 0},
1495-
* {@code run_compilation = 1} or {@code shutdown_compilation = 2}. Should be in sync with the
1496-
* {@code CompilerActivity} enum in {@code hotspot/share/compiler/compileBroker.hpp}.
1497-
*/
14981493
public enum CompilationActivityMode {
1499-
STOP_COMPILATION,
1494+
/**
1495+
* Process compilations regularly.
1496+
*/
15001497
RUN_COMPILATION,
1498+
/**
1499+
* Stop compilations temporarily.
1500+
*/
1501+
STOP_COMPILATION,
1502+
/**
1503+
* Shutdown compilations permanently.
1504+
*/
15011505
SHUTDOWN_COMPILATION;
1502-
1503-
public static CompilationActivityMode fromInteger(int i) {
1504-
return switch (i) {
1505-
case 0 -> STOP_COMPILATION;
1506-
case 1 -> RUN_COMPILATION;
1507-
case 2 -> SHUTDOWN_COMPILATION;
1508-
default -> throw new RuntimeException("Invalid CompilationActivityMode " + i);
1509-
};
1510-
}
15111506
}
15121507

15131508
/**
15141509
* Returns the current host compilation activity mode. The default is to run compilations.
15151510
*/
1516-
public CompilationActivityMode getCompilationActivityMode() {
1511+
protected CompilationActivityMode getCompilationActivityMode() {
15171512
return CompilationActivityMode.RUN_COMPILATION;
15181513
}
15191514
}

truffle/src/com.oracle.truffle.runtime/src/com/oracle/truffle/runtime/hotspot/HotSpotTruffleRuntime.java

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ public boolean isLibGraalCompilationEnabled() {
695695
return compilationSupport instanceof LibGraalTruffleCompilationSupport;
696696
}
697697

698-
static final MethodHandle getCompilationActivityMode;
698+
private static final MethodHandle getCompilationActivityMode;
699699
static {
700700
MethodHandle mHandle = null;
701701
try {
@@ -711,15 +711,29 @@ public boolean isLibGraalCompilationEnabled() {
711711
* Returns the current host compilation activity mode based on HotSpot's code cache state.
712712
*/
713713
@Override
714-
public CompilationActivityMode getCompilationActivityMode() {
714+
protected CompilationActivityMode getCompilationActivityMode() {
715715
int activityMode = 1; // Default is to run compilations
716716
if (getCompilationActivityMode != null) {
717717
try {
718718
activityMode = (int) getCompilationActivityMode.invokeExact(HotSpotJVMCIRuntime.runtime());
719719
} catch (Throwable t) {
720-
throw new RuntimeException("Can't get HotSpot's compilation activity mode", t);
720+
throw CompilerDirectives.shouldNotReachHere("Can't get HotSpot's compilation activity mode", t);
721721
}
722722
}
723-
return CompilationActivityMode.fromInteger(activityMode);
723+
return resolveHotSpotActivityMode(activityMode);
724+
}
725+
726+
/**
727+
* Represents HotSpot's compilation activity mode which is one of: {@code stop_compilation = 0},
728+
* {@code run_compilation = 1} or {@code shutdown_compilation = 2}. Should be in sync with the
729+
* {@code CompilerActivity} enum in {@code hotspot/share/compiler/compileBroker.hpp}.
730+
*/
731+
private static CompilationActivityMode resolveHotSpotActivityMode(int i) {
732+
return switch (i) {
733+
case 0 -> CompilationActivityMode.STOP_COMPILATION;
734+
case 1 -> CompilationActivityMode.RUN_COMPILATION;
735+
case 2 -> CompilationActivityMode.SHUTDOWN_COMPILATION;
736+
default -> throw CompilerDirectives.shouldNotReachHere("Invalid CompilationActivityMode " + i);
737+
};
724738
}
725739
}

0 commit comments

Comments
 (0)