Skip to content

Commit ca90c11

Browse files
committed
Resolved review comments.
1 parent 16673af commit ca90c11

File tree

5 files changed

+17
-26
lines changed

5 files changed

+17
-26
lines changed

sdk/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ This changelog summarizes major changes between GraalVM SDK versions. The main f
99
* GR-66817 Make `--polyglot` the default for language launchers, so there is no need to specify it anymore to use other languages in standalones. As a result, `AbstractLanguageLauncher#getDefaultLanguages()` and `Launcher#canPolyglot()` have been deprecated.
1010
* GR-65404 Remove `PolyglotLauncher` as it is no longer used.
1111
* GR-68613: JavaScript polyglot isolate now includes support for the WebAssembly (Wasm) language.
12+
* GR-69590: Closing a garbage-collected engine or context now logs only the first failure by default. To log all failures, use `engine.CloseOnGCFailureAction.PrintAll`.
1213

1314
## Version 25.0.0
1415
* GR-60636 Truffle now stops compiling when the code cache fills up on HotSpot. A warning is printed when that happens.

truffle/mx.truffle/mx_truffle.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,6 @@ def apply(self, config):
321321

322322
# Disable VirtualThread warning
323323
vmArgs = vmArgs + ['-Dpolyglot.engine.WarnVirtualThreadSupport=false']
324-
# Print only a single close on context collected error
325-
vmArgs = vmArgs + ['-Dpolyglot.engine.CloseOnGCFailureAction=PrintOnce']
326324
enable_truffle_native_access(vmArgs)
327325
enable_sun_misc_unsafe(vmArgs)
328326
return (vmArgs, mainClass, mainClassArgs)

truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/EngineAccessor.java

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,40 +1439,32 @@ public boolean isKnownLoggerId(Object loggerCache, String id) {
14391439
if (PolyglotLoggers.getInternalIds().contains(id)) {
14401440
return true;
14411441
}
1442-
PolyglotEngineImpl polyglotEngine = lookupPolyglotEngineForLoggerCache(loggerCache);
1443-
if (polyglotEngine != null) {
1444-
return polyglotEngine.idToLanguage.containsKey(id) || polyglotEngine.idToInstrument.containsKey(id);
1445-
} else {
1442+
if (loggerCache == PolyglotLoggers.LoggerCache.DEFAULT) {
14461443
/*
14471444
* TruffleLogger#getLogger() is invoked from a static initializer, no vmObject
14481445
* anchor is available at this point.
14491446
*/
14501447
return LanguageCache.languages().containsKey(id) || InstrumentCache.load().containsKey(id);
1448+
} else {
1449+
PolyglotEngineImpl polyglotEngine = ((PolyglotLoggers.LoggerCache) loggerCache).getOwner().getEngine();
1450+
return polyglotEngine.idToLanguage.containsKey(id) || polyglotEngine.idToInstrument.containsKey(id);
14511451
}
14521452
}
14531453

1454-
private static PolyglotEngineImpl lookupPolyglotEngineForLoggerCache(Object loggerCache) {
1455-
VMObject vmObject = ((PolyglotLoggers.LoggerCache) loggerCache).getOwner();
1456-
if (vmObject == null) {
1457-
vmObject = PolyglotFastThreadLocals.getContext(null);
1458-
}
1459-
return vmObject != null ? vmObject.getEngine() : null;
1460-
}
1461-
14621454
@Override
14631455
public Collection<String> getKnownLoggerIds(Object loggerCache) {
14641456
List<String> ids = new ArrayList<>(PolyglotLoggers.getInternalIds());
1465-
PolyglotEngineImpl polyglotEngine = lookupPolyglotEngineForLoggerCache(loggerCache);
1466-
if (polyglotEngine != null) {
1467-
ids.addAll(polyglotEngine.idToLanguage.keySet());
1468-
ids.addAll(polyglotEngine.idToInstrument.keySet());
1469-
} else {
1457+
if (loggerCache == PolyglotLoggers.LoggerCache.DEFAULT) {
14701458
/*
14711459
* TruffleLogger#getLogger() is invoked from a static initializer, no vmObject
14721460
* anchor is available at this point.
14731461
*/
14741462
ids.addAll(LanguageCache.languages().keySet());
14751463
ids.addAll(InstrumentCache.load().keySet());
1464+
} else {
1465+
PolyglotEngineImpl polyglotEngine = ((PolyglotLoggers.LoggerCache) loggerCache).getOwner().getEngine();
1466+
ids.addAll(polyglotEngine.idToLanguage.keySet());
1467+
ids.addAll(polyglotEngine.idToInstrument.keySet());
14761468
}
14771469
Collections.sort(ids);
14781470
return ids;

truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotEngineImpl.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2445,12 +2445,12 @@ static void logCloseOnCollectedError(PolyglotEngineImpl engine, String reason, T
24452445
switch (engine.getEngineOptionValues().get(PolyglotEngineOptions.CloseOnGCFailureAction)) {
24462446
case Ignore -> {
24472447
}
2448-
case PrintOnce -> {
2448+
case Print -> {
24492449
if (closeOnCollectedErrorLogged.compareAndSet(false, true)) {
24502450
logCloseOnCollectedError(reason, exception);
24512451
}
24522452
}
2453-
case Print -> logCloseOnCollectedError(reason, exception);
2453+
case PrintAll -> logCloseOnCollectedError(reason, exception);
24542454
case Throw -> throw new RuntimeException(reason, exception);
24552455
}
24562456
}
@@ -2465,8 +2465,8 @@ private static void logCloseOnCollectedError(String reason, Throwable exception)
24652465
To customize the behavior of this warning, use 'engine.CloseOnGCFailureAction' option or the 'polyglot.engine.CloseOnGCFailureAction' system property.
24662466
The accepted values are:
24672467
- Ignore: Do not print this warning.
2468-
- PrintOnce: Print this warning only for the first occurrence; suppress subsequent ones.
2469-
- Print: Print this warning (default value).
2468+
- Print: Print this warning only for the first occurrence; suppress subsequent ones (default value).
2469+
- PrintAll: Print this warning.
24702470
- Throw: Throw an exception instead of printing this warning.
24712471
""", reason);
24722472
exception.printStackTrace(errWriter);

truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotEngineOptions.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,15 +191,15 @@ public StaticObjectStorageStrategies apply(String s) {
191191

192192
enum CloseOnGCExceptionAction {
193193
Ignore,
194-
PrintOnce,
195194
Print,
195+
PrintAll,
196196
Throw;
197197

198198
private static final String HELP = "Specifies the action to take when closing a garbage-collected engine or context fails.%n" +
199199
"The accepted values are:%n" +
200200
" Ignore: Ignore the exception that occurs during close.%n" +
201-
" PrintOnce: Log the failure only for the first occurrence; suppress subsequent ones.%n" +
202-
" Print: Log each failure (default value).%n" +
201+
" Print: Log the failure only for the first occurrence; suppress subsequent ones (default value).%n" +
202+
" PrintAll: Log each failure.%n" +
203203
" Throw: Throw an exception instead of logging the failure.";
204204
}
205205
}

0 commit comments

Comments
 (0)