Skip to content

Commit ea5b15e

Browse files
committed
Move check periodic code into helper function
1 parent 2fca753 commit ea5b15e

File tree

4 files changed

+185
-346
lines changed

4 files changed

+185
-346
lines changed

Python/bytecodes.c

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -153,31 +153,19 @@ dummy_func(
153153
macro(NOT_TAKEN) = NOP;
154154

155155
op(_CHECK_PERIODIC, (--)) {
156-
_Py_CHECK_EMSCRIPTEN_SIGNALS_PERIODICALLY();
157-
QSBR_QUIESCENT_STATE(tstate);
158-
if (_Py_atomic_load_uintptr_relaxed(&tstate->eval_breaker) & _PY_EVAL_EVENTS_MASK) {
159-
int err = _Py_HandlePending(tstate);
160-
ERROR_IF(err != 0);
161-
}
156+
int err = check_periodics(tstate);
157+
ERROR_IF(err != 0);
162158
}
163159

164160
replaced op(_CHECK_PERIODIC_AT_END, (--)) {
165-
_Py_CHECK_EMSCRIPTEN_SIGNALS_PERIODICALLY();
166-
QSBR_QUIESCENT_STATE(tstate);
167-
if (_Py_atomic_load_uintptr_relaxed(&tstate->eval_breaker) & _PY_EVAL_EVENTS_MASK) {
168-
int err = _Py_HandlePending(tstate);
169-
ERROR_IF(err != 0);
170-
}
161+
int err = check_periodics(tstate);
162+
ERROR_IF(err != 0);
171163
}
172164

173165
op(_CHECK_PERIODIC_IF_NOT_YIELD_FROM, (--)) {
174166
if ((oparg & RESUME_OPARG_LOCATION_MASK) < RESUME_AFTER_YIELD_FROM) {
175-
_Py_CHECK_EMSCRIPTEN_SIGNALS_PERIODICALLY();
176-
QSBR_QUIESCENT_STATE(tstate);
177-
if (_Py_atomic_load_uintptr_relaxed(&tstate->eval_breaker) & _PY_EVAL_EVENTS_MASK) {
178-
int err = _Py_HandlePending(tstate);
179-
ERROR_IF(err != 0);
180-
}
167+
int err = check_periodics(tstate);
168+
ERROR_IF(err != 0);
181169
}
182170
}
183171

Python/ceval_macros.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,3 +422,14 @@ do { \
422422
_PyObjectArray_Free(NAME - 1, NAME##_temp);
423423

424424
#define CONVERSION_FAILED(NAME) ((NAME) == NULL)
425+
426+
static inline int
427+
check_periodics(PyThreadState *tstate) {
428+
_Py_CHECK_EMSCRIPTEN_SIGNALS_PERIODICALLY();
429+
QSBR_QUIESCENT_STATE(tstate);
430+
if (_Py_atomic_load_uintptr_relaxed(&tstate->eval_breaker) & _PY_EVAL_EVENTS_MASK) {
431+
return _Py_HandlePending(tstate);
432+
}
433+
return 0;
434+
}
435+

Python/executor_cases.c.h

Lines changed: 10 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)