Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions Include/internal/pycore_opcode_metadata.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Include/internal/pycore_uop_metadata.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 14 additions & 2 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,24 @@ dummy_func(
};

op(_CHECK_PERIODIC, (--)) {
CHECK_EVAL_BREAKER();
_Py_CHECK_EMSCRIPTEN_SIGNALS_PERIODICALLY();
QSBR_QUIESCENT_STATE(tstate); \
if (_Py_atomic_load_uintptr_relaxed(&tstate->eval_breaker) & _PY_EVAL_EVENTS_MASK) {
if (_Py_HandlePending(tstate) != 0) {
GOTO_ERROR(error); \
}
}
}

op(_CHECK_PERIODIC_NOT_YIELD_FROM, (--)) {
Comment thread
markshannon marked this conversation as resolved.
Outdated
if ((oparg & RESUME_OPARG_LOCATION_MASK) < RESUME_AFTER_YIELD_FROM) {
CHECK_EVAL_BREAKER();
_Py_CHECK_EMSCRIPTEN_SIGNALS_PERIODICALLY();
QSBR_QUIESCENT_STATE(tstate); \
if (_Py_atomic_load_uintptr_relaxed(&tstate->eval_breaker) & _PY_EVAL_EVENTS_MASK) {
if (_Py_HandlePending(tstate) != 0) {
GOTO_ERROR(error); \
}
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be implemented as a macro that reuses _CHECK_PERIODIC? Like "if condition is false, exit, then do _CHECK_PERIODIC"?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the macro is the point of this PR. Macros are opaque to the code generator, so we need to special case them (which is OK for something very common like Py_DECREF). Avoiding the special case simplifies the code generator considerably.
It is the call to _Py_HandlePending that escapes, not the whole of _CHECK_PERIODIC and we want the code generator to know that.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant a macro instruction of the DSL.

Copy link
Copy Markdown
Member Author

@markshannon markshannon Aug 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see.
No it can't, as macros can only be composed in a linear sequence. We need branching here, not deoptimization.
EXIT_IF and DEOPT_IF only make sense in specialized instructions.

}
}

Expand Down
10 changes: 0 additions & 10 deletions Python/ceval_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,6 @@ do { \
// Use this instead of 'goto error' so Tier 2 can go to a different label
#define GOTO_ERROR(LABEL) goto LABEL

#define CHECK_EVAL_BREAKER() \
_Py_CHECK_EMSCRIPTEN_SIGNALS_PERIODICALLY(); \
QSBR_QUIESCENT_STATE(tstate); \
if (_Py_atomic_load_uintptr_relaxed(&tstate->eval_breaker) & _PY_EVAL_EVENTS_MASK) { \
if (_Py_HandlePending(tstate) != 0) { \
GOTO_ERROR(error); \
} \
}


/* Tuple access macros */

#ifndef Py_DEBUG
Expand Down
16 changes: 14 additions & 2 deletions Python/executor_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading