Skip to content

Commit 0447a8a

Browse files
committed
use continue to leave JL_TRY before return
1 parent ff412d5 commit 0447a8a

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/julia.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2376,8 +2376,8 @@ extern int had_exception;
23762376
size_t __excstack_state = jl_excstack_state(__eh_ct); \
23772377
jl_enter_handler(__eh_ct, &__eh); \
23782378
__eh_ct->eh = &__eh; \
2379-
if (1)
2380-
/* TRY BLOCK; */
2379+
for (i__try=1; i__try; i__try=0)
2380+
23812381
#define JL_CATCH \
23822382
if (!had_exception) \
23832383
jl_eh_restore_state_noexcept(__eh_ct, &__eh); \

src/scheduler.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -465,15 +465,13 @@ JL_DLLEXPORT jl_task_t *jl_task_get_next(jl_value_t *trypoptask, jl_value_t *q,
465465
if (set_not_sleeping(ptls)) {
466466
JL_PROBE_RT_SLEEP_CHECK_TASK_WAKE(ptls);
467467
}
468-
if (task)
469-
return task;
470-
continue;
468+
continue; // jump to JL_CATCH
471469
}
472470
if (task) {
473471
if (set_not_sleeping(ptls)) {
474472
JL_PROBE_RT_SLEEP_CHECK_TASK_WAKE(ptls);
475473
}
476-
return task;
474+
continue; // jump to JL_CATCH
477475
}
478476

479477
// IO is always permitted, but outside a threaded region, only
@@ -533,7 +531,7 @@ JL_DLLEXPORT jl_task_t *jl_task_get_next(jl_value_t *trypoptask, jl_value_t *q,
533531
JL_PROBE_RT_SLEEP_CHECK_UV_WAKE(ptls);
534532
}
535533
start_cycles = 0;
536-
continue;
534+
continue; // jump to JL_CATCH
537535
}
538536
if (!enter_eventloop && !jl_atomic_load_relaxed(&_threadedregion) && ptls->tid == jl_atomic_load_relaxed(&io_loop_tid)) {
539537
// thread 0 is the only thread permitted to run the event loop
@@ -542,7 +540,7 @@ JL_DLLEXPORT jl_task_t *jl_task_get_next(jl_value_t *trypoptask, jl_value_t *q,
542540
JL_PROBE_RT_SLEEP_CHECK_UV_WAKE(ptls);
543541
}
544542
start_cycles = 0;
545-
continue;
543+
continue; // jump to JL_CATCH
546544
}
547545
}
548546

@@ -596,16 +594,18 @@ JL_DLLEXPORT jl_task_t *jl_task_get_next(jl_value_t *trypoptask, jl_value_t *q,
596594
if (task) {
597595
assert(task == wait_empty);
598596
wait_empty = NULL;
599-
return task;
597+
continue;
600598
}
601599
}
602-
JL_CATCH { // probably SIGINT, but possibly a user mistake in trypoptask
600+
JL_CATCH {
601+
// probably SIGINT, but possibly a user mistake in trypoptask
603602
if (!isrunning)
604603
jl_atomic_fetch_add_relaxed(&nrunning, 1);
605604
set_not_sleeping(ptls);
606-
// TODO: if (task != NULL) instead attach this exception there, so that we don't forgot to ever reschedule it
607605
jl_rethrow();
608606
}
607+
if (task)
608+
return task;
609609
}
610610
else {
611611
// maybe check the kernel for new messages too

0 commit comments

Comments
 (0)