Skip to content

Commit cc4c5aa

Browse files
[GR-51505] [GR-51751] Cleanups and minor fixes.
PullRequest: graal/16792
2 parents 41e3c79 + cac6eae commit cc4c5aa

File tree

5 files changed

+28
-69
lines changed

5 files changed

+28
-69
lines changed

substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/thread/PosixJavaThreads.java

Lines changed: 0 additions & 52 deletions
This file was deleted.

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/IsolateArgumentParser.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,7 @@ public static void verifyOptionValues() {
210210
}
211211

212212
private static boolean shouldValidate(RuntimeOptionKey<?> option) {
213-
if (!option.hasBeenSet()) {
214-
/* Workaround for one specific Truffle language that does something weird. */
215-
return false;
216-
} else if (SubstrateOptions.UseSerialGC.getValue()) {
213+
if (SubstrateOptions.UseSerialGC.getValue()) {
217214
/* The serial GC supports changing the heap size at run-time to some degree. */
218215
return option != SubstrateGCOptions.MinHeapSize && option != SubstrateGCOptions.MaxHeapSize && option != SubstrateGCOptions.MaxNewSize;
219216
}

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/JavaMainWrapper.java

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,10 @@
6969
import com.oracle.svm.core.jdk.RuntimeSupport;
7070
import com.oracle.svm.core.jni.JNIJavaVMList;
7171
import com.oracle.svm.core.jni.functions.JNIFunctionTables;
72+
import com.oracle.svm.core.log.Log;
7273
import com.oracle.svm.core.thread.JavaThreads;
7374
import com.oracle.svm.core.thread.PlatformThreads;
75+
import com.oracle.svm.core.thread.ThreadingSupportImpl;
7476
import com.oracle.svm.core.thread.VMThreads;
7577
import com.oracle.svm.core.thread.VMThreads.OSThreadHandle;
7678
import com.oracle.svm.core.util.UserError;
@@ -244,22 +246,32 @@ private static int runCore0() {
244246

245247
@Uninterruptible(reason = "The caller initialized the thread state, so the callees do not need to be uninterruptible.", calleeMustBe = false)
246248
private static void runShutdown() {
249+
ThreadingSupportImpl.pauseRecurringCallback("Recurring callbacks can't be executed during shutdown.");
247250
runShutdown0();
248251
}
249252

250253
private static void runShutdown0() {
251-
PlatformThreads.ensureCurrentAssigned("DestroyJavaVM", null, false);
254+
try {
255+
PlatformThreads.ensureCurrentAssigned("DestroyJavaVM", null, false);
256+
} catch (Throwable e) {
257+
Log.log().string("PlatformThreads.ensureCurrentAssigned() failed during shutdown: ").exception(e).newline();
258+
return;
259+
}
252260

253-
// Shutdown sequence: First wait for all non-daemon threads to exit.
261+
/* Wait for all non-daemon threads to exit. */
254262
PlatformThreads.singleton().joinAllNonDaemons();
255263

256-
/*
257-
* Run shutdown hooks (both our own hooks and application-registered hooks) and teardown
258-
* hooks. Note that this can start new non-daemon threads. We are not responsible to wait
259-
* until they have exited.
260-
*/
261-
RuntimeSupport.getRuntimeSupport().shutdown();
262-
RuntimeSupport.executeTearDownHooks();
264+
try {
265+
/*
266+
* Run shutdown hooks (both our own hooks and application-registered hooks) and teardown
267+
* hooks. Note that this can start new non-daemon threads. We are not responsible to
268+
* wait until they have exited.
269+
*/
270+
RuntimeSupport.getRuntimeSupport().shutdown();
271+
RuntimeSupport.executeTearDownHooks();
272+
} catch (Throwable e) {
273+
Log.log().string("Exception occurred while executing shutdown hooks: ").exception(e).newline();
274+
}
263275
}
264276

265277
@Uninterruptible(reason = "Thread state not set up yet.")
@@ -278,6 +290,7 @@ private static int doRun(int argc, CCharPointerPointer argv) {
278290
try {
279291
CPUFeatureAccess cpuFeatureAccess = ImageSingletons.lookup(CPUFeatureAccess.class);
280292
cpuFeatureAccess.verifyHostSupportsArchitectureEarlyOrExit();
293+
281294
// Create the isolate and attach the current C thread as the main Java thread.
282295
EnterCreateIsolateWithCArgumentsPrologue.enter(argc, argv);
283296
assert !VMThreads.wasStartedByCurrentIsolate(CurrentIsolate.getCurrentThread()) : "re-attach would cause issues otherwise";

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateOptions.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,8 @@ protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, Boolean o
373373
@Option(help = "The size of each thread stack at run-time, in bytes.", type = OptionType.User)//
374374
public static final RuntimeOptionKey<Long> StackSize = new RuntimeOptionKey<>(0L);
375375

376-
@Option(help = "The size of each internal thread stack, in bytes.", type = OptionType.Expert)//
377-
public static final HostedOptionKey<Long> InternalThreadStackSize = new HostedOptionKey<>(2L * 1024 * 1024);
376+
@Option(help = "Deprecated, has no effect.", deprecated = true) //
377+
public static final HostedOptionKey<Long> InternalThreadStackSize = new HostedOptionKey<>(0L);
378378

379379
/**
380380
* Cached value of {@link ConcealedOptions#MaxJavaStackTraceDepth}. Also used as default value.

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/PlatformThreads.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,8 +433,9 @@ static void assignCurrent(Thread thread) {
433433
}
434434

435435
/*
436-
* First of all, ensure we are in RUNNABLE state. If !manuallyStarted, we race with the
437-
* thread that launched us to set the status and we could still be in status NEW.
436+
* First of all, ensure we are in RUNNABLE state. If this thread was started by the current
437+
* isolate, we race with the thread that launched us to set the status and we could still be
438+
* in status NEW.
438439
*/
439440
setThreadStatus(thread, ThreadStatus.RUNNABLE);
440441
assignCurrent0(thread);

0 commit comments

Comments
 (0)