@@ -334,10 +334,9 @@ enum IsCurrentExecutorCheckMode: unsigned {
334334static IsCurrentExecutorCheckMode isCurrentExecutorMode =
335335 Swift6_UseCheckIsolated_AllowCrash;
336336
337-
338337// Shimming call to Swift runtime because Swift Embedded does not have
339338// these symbols defined.
340- bool swift_bincompat_useLegacyNonCrashingExecutorChecks () {
339+ bool __swift_bincompat_useLegacyNonCrashingExecutorChecks () {
341340#if !SWIFT_CONCURRENCY_EMBEDDED
342341 return swift::runtime::bincompat::
343342 swift_bincompat_useLegacyNonCrashingExecutorChecks ();
@@ -346,22 +345,30 @@ bool swift_bincompat_useLegacyNonCrashingExecutorChecks() {
346345#endif
347346}
348347
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 ();
353352
354353 // Potentially, override the platform detected mode, primarily used in tests.
355354#if SWIFT_STDLIB_HAS_ENVIRON
356- if (const char *modeStr = runtime::environment::concurrencyIsCurrentExecutorLegacyModeOverride ()) {
355+ if (const char *modeStr = runtime::environment::
356+ concurrencyIsCurrentExecutorLegacyModeOverride ()) {
357357 if (strcmp (modeStr, " nocrash" ) == 0 || strcmp (modeStr, " legacy" ) == 0 ) {
358- useLegacyMode = true ;
358+ return true ;
359359 } else if (strcmp (modeStr, " crash" ) == 0 || strcmp (modeStr, " swift6" ) == 0 ) {
360- useLegacyMode = false ;
360+ return false ; // don't use the legacy mode
361361 } // else, just use the platform detected mode
362- }
362+ } // no override, use the default mode
363363#endif // SWIFT_STDLIB_HAS_ENVIRON
364364
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 ();
365372 isCurrentExecutorMode = useLegacyMode ? Legacy_NoCheckIsolated_NonCrashing
366373 : Swift6_UseCheckIsolated_AllowCrash;
367374}
@@ -520,12 +527,9 @@ static void checkUnexpectedExecutorLogLevel(void *context) {
520527 if (!levelStr)
521528 return ;
522529
523- auto isCurrentExecutorLegacyMode =
524- swift_bincompat_useLegacyNonCrashingExecutorChecks ();
525-
526530 long level = strtol (levelStr, nullptr , 0 );
527531 if (level >= 0 && level < 3 ) {
528- if (isCurrentExecutorLegacyMode ) {
532+ if (swift_bincompat_useLegacyNonCrashingExecutorChecks () ) {
529533 // legacy mode permits doing nothing or just logging, since the method
530534 // used to perform the check itself is not going to crash:
531535 unexpectedExecutorLogLevel = level;
0 commit comments