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