@@ -334,10 +334,9 @@ enum IsCurrentExecutorCheckMode: unsigned {
334
334
static IsCurrentExecutorCheckMode isCurrentExecutorMode =
335
335
Swift6_UseCheckIsolated_AllowCrash;
336
336
337
-
338
337
// Shimming call to Swift runtime because Swift Embedded does not have
339
338
// these symbols defined.
340
- bool swift_bincompat_useLegacyNonCrashingExecutorChecks () {
339
+ bool __swift_bincompat_useLegacyNonCrashingExecutorChecks () {
341
340
#if !SWIFT_CONCURRENCY_EMBEDDED
342
341
return swift::runtime::bincompat::
343
342
swift_bincompat_useLegacyNonCrashingExecutorChecks ();
@@ -346,22 +345,30 @@ bool swift_bincompat_useLegacyNonCrashingExecutorChecks() {
346
345
#endif
347
346
}
348
347
349
- // Check override of executor checking mode.
350
- static void checkIsCurrentExecutorMode ( void *context) {
351
- auto useLegacyMode =
352
- swift_bincompat_useLegacyNonCrashingExecutorChecks ();
348
+ // Done this way because of the interaction with the initial value of
349
+ // 'unexpectedExecutorLogLevel'
350
+ bool swift_bincompat_useLegacyNonCrashingExecutorChecks () {
351
+ bool legacyMode = __swift_bincompat_useLegacyNonCrashingExecutorChecks ();
353
352
354
353
// Potentially, override the platform detected mode, primarily used in tests.
355
354
#if SWIFT_STDLIB_HAS_ENVIRON
356
- if (const char *modeStr = runtime::environment::concurrencyIsCurrentExecutorLegacyModeOverride ()) {
355
+ if (const char *modeStr = runtime::environment::
356
+ concurrencyIsCurrentExecutorLegacyModeOverride ()) {
357
357
if (strcmp (modeStr, " nocrash" ) == 0 || strcmp (modeStr, " legacy" ) == 0 ) {
358
- useLegacyMode = true ;
358
+ return true ;
359
359
} else if (strcmp (modeStr, " crash" ) == 0 || strcmp (modeStr, " swift6" ) == 0 ) {
360
- useLegacyMode = false ;
360
+ return false ; // don't use the legacy mode
361
361
} // else, just use the platform detected mode
362
- }
362
+ } // no override, use the default mode
363
363
#endif // SWIFT_STDLIB_HAS_ENVIRON
364
364
365
+ return legacyMode;
366
+ }
367
+
368
+ // Check override of executor checking mode.
369
+ static void checkIsCurrentExecutorMode (void *context) {
370
+ bool useLegacyMode =
371
+ swift_bincompat_useLegacyNonCrashingExecutorChecks ();
365
372
isCurrentExecutorMode = useLegacyMode ? Legacy_NoCheckIsolated_NonCrashing
366
373
: Swift6_UseCheckIsolated_AllowCrash;
367
374
}
@@ -520,12 +527,9 @@ static void checkUnexpectedExecutorLogLevel(void *context) {
520
527
if (!levelStr)
521
528
return ;
522
529
523
- auto isCurrentExecutorLegacyMode =
524
- swift_bincompat_useLegacyNonCrashingExecutorChecks ();
525
-
526
530
long level = strtol (levelStr, nullptr , 0 );
527
531
if (level >= 0 && level < 3 ) {
528
- if (isCurrentExecutorLegacyMode ) {
532
+ if (swift_bincompat_useLegacyNonCrashingExecutorChecks () ) {
529
533
// legacy mode permits doing nothing or just logging, since the method
530
534
// used to perform the check itself is not going to crash:
531
535
unexpectedExecutorLogLevel = level;
0 commit comments