Skip to content

GH-131498: Cases generator: Parse down to C statement level. #131948

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Apr 2, 2025
9 changes: 0 additions & 9 deletions Lib/test/test_generated_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,6 @@ def test_error_if_plain_with_comment(self):
if (cond) {
JUMP_TO_LABEL(label);
}
// Comment is ok
DISPATCH();
}
"""
Expand Down Expand Up @@ -586,7 +585,6 @@ def test_suppress_dispatch(self):

LABEL(somewhere)
{

}
"""
self.run_cases_test(input, output)
Expand Down Expand Up @@ -1351,7 +1349,6 @@ def test_pop_on_error_peeks(self):
}
// THIRD
{
// Mark j and k as used
if (cond) {
JUMP_TO_LABEL(pop_2_error);
}
Expand Down Expand Up @@ -1757,17 +1754,14 @@ def test_complex_label(self):
output = """
LABEL(other_label)
{

}

LABEL(other_label2)
{

}

LABEL(my_label)
{
// Comment
_PyFrame_SetStackPointer(frame, stack_pointer);
do_thing();
stack_pointer = _PyFrame_GetStackPointer(frame);
Expand Down Expand Up @@ -1795,7 +1789,6 @@ def test_spilled_label(self):
output = """
LABEL(one)
{
/* STACK SPILLED */
stack_pointer = _PyFrame_GetStackPointer(frame);
JUMP_TO_LABEL(two);
}
Expand Down Expand Up @@ -1851,7 +1844,6 @@ def test_multiple_labels(self):
output = """
LABEL(my_label_1)
{
// Comment
_PyFrame_SetStackPointer(frame, stack_pointer);
do_thing1();
stack_pointer = _PyFrame_GetStackPointer(frame);
Expand All @@ -1860,7 +1852,6 @@ def test_multiple_labels(self):

LABEL(my_label_2)
{
// Comment
_PyFrame_SetStackPointer(frame, stack_pointer);
do_thing2();
stack_pointer = _PyFrame_GetStackPointer(frame);
Expand Down
8 changes: 5 additions & 3 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ dummy_func(
op(_CHECK_PERIODIC_IF_NOT_YIELD_FROM, (--)) {
if ((oparg & RESUME_OPARG_LOCATION_MASK) < RESUME_AFTER_YIELD_FROM) {
_Py_CHECK_EMSCRIPTEN_SIGNALS_PERIODICALLY();
QSBR_QUIESCENT_STATE(tstate); \
QSBR_QUIESCENT_STATE(tstate);
if (_Py_atomic_load_uintptr_relaxed(&tstate->eval_breaker) & _PY_EVAL_EVENTS_MASK) {
int err = _Py_HandlePending(tstate);
ERROR_IF(err != 0, error);
Expand Down Expand Up @@ -2237,7 +2237,8 @@ dummy_func(
PyObject *attr_o = FT_ATOMIC_LOAD_PTR_ACQUIRE(*value_ptr);
DEOPT_IF(attr_o == NULL);
#ifdef Py_GIL_DISABLED
if (!_Py_TryIncrefCompareStackRef(value_ptr, attr_o, &attr)) {
int increfed = _Py_TryIncrefCompareStackRef(value_ptr, attr_o, &attr);
if (!increfed) {
DEOPT_IF(true);
}
#else
Expand Down Expand Up @@ -2314,7 +2315,8 @@ dummy_func(
}
STAT_INC(LOAD_ATTR, hit);
#ifdef Py_GIL_DISABLED
if (!_Py_TryIncrefCompareStackRef(&ep->me_value, attr_o, &attr)) {
int increfed = _Py_TryIncrefCompareStackRef(&ep->me_value, attr_o, &attr);
if (!increfed) {
DEOPT_IF(true);
}
#else
Expand Down
Loading
Loading