mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
GH-120024: Move three more escaping calls out of conditional statements (GH-122734)
This commit is contained in:
parent
8ce70d6c69
commit
4c31791848
3 changed files with 32 additions and 10 deletions
|
@ -191,7 +191,8 @@ dummy_func(
|
||||||
uintptr_t global_version = _Py_atomic_load_uintptr_relaxed(&tstate->eval_breaker) & ~_PY_EVAL_EVENTS_MASK;
|
uintptr_t global_version = _Py_atomic_load_uintptr_relaxed(&tstate->eval_breaker) & ~_PY_EVAL_EVENTS_MASK;
|
||||||
uintptr_t code_version = FT_ATOMIC_LOAD_UINTPTR_ACQUIRE(_PyFrame_GetCode(frame)->_co_instrumentation_version);
|
uintptr_t code_version = FT_ATOMIC_LOAD_UINTPTR_ACQUIRE(_PyFrame_GetCode(frame)->_co_instrumentation_version);
|
||||||
if (code_version != global_version && tstate->tracing == 0) {
|
if (code_version != global_version && tstate->tracing == 0) {
|
||||||
if (_Py_Instrument(_PyFrame_GetCode(frame), tstate->interp)) {
|
int err = _Py_Instrument(_PyFrame_GetCode(frame), tstate->interp);
|
||||||
|
if (err) {
|
||||||
ERROR_NO_POP();
|
ERROR_NO_POP();
|
||||||
}
|
}
|
||||||
next_instr = this_instr;
|
next_instr = this_instr;
|
||||||
|
@ -1802,7 +1803,12 @@ dummy_func(
|
||||||
assert(PyDict_CheckExact(dict));
|
assert(PyDict_CheckExact(dict));
|
||||||
/* dict[key] = value */
|
/* dict[key] = value */
|
||||||
// Do not DECREF INPUTS because the function steals the references
|
// Do not DECREF INPUTS because the function steals the references
|
||||||
ERROR_IF(_PyDict_SetItem_Take2((PyDictObject *)dict, PyStackRef_AsPyObjectSteal(key), PyStackRef_AsPyObjectSteal(value)) != 0, error);
|
int err = _PyDict_SetItem_Take2(
|
||||||
|
(PyDictObject *)dict,
|
||||||
|
PyStackRef_AsPyObjectSteal(key),
|
||||||
|
PyStackRef_AsPyObjectSteal(value)
|
||||||
|
);
|
||||||
|
ERROR_IF(err != 0, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
inst(INSTRUMENTED_LOAD_SUPER_ATTR, (unused/1, unused, unused, unused -- unused, unused if (oparg & 1))) {
|
inst(INSTRUMENTED_LOAD_SUPER_ATTR, (unused/1, unused, unused, unused -- unused, unused if (oparg & 1))) {
|
||||||
|
@ -2455,7 +2461,8 @@ dummy_func(
|
||||||
PyObject *right_o = PyStackRef_AsPyObjectBorrow(right);
|
PyObject *right_o = PyStackRef_AsPyObjectBorrow(right);
|
||||||
|
|
||||||
assert(PyExceptionInstance_Check(left_o));
|
assert(PyExceptionInstance_Check(left_o));
|
||||||
if (_PyEval_CheckExceptTypeValid(tstate, right_o) < 0) {
|
int err = _PyEval_CheckExceptTypeValid(tstate, right_o);
|
||||||
|
if (err < 0) {
|
||||||
DECREF_INPUTS();
|
DECREF_INPUTS();
|
||||||
ERROR_IF(true, error);
|
ERROR_IF(true, error);
|
||||||
}
|
}
|
||||||
|
@ -4107,7 +4114,8 @@ dummy_func(
|
||||||
// It converts all dict subtypes in kwargs into regular dicts.
|
// It converts all dict subtypes in kwargs into regular dicts.
|
||||||
assert(kwargs == NULL || PyDict_CheckExact(kwargs));
|
assert(kwargs == NULL || PyDict_CheckExact(kwargs));
|
||||||
if (!PyTuple_CheckExact(callargs)) {
|
if (!PyTuple_CheckExact(callargs)) {
|
||||||
if (check_args_iterable(tstate, func, callargs) < 0) {
|
int err = check_args_iterable(tstate, func, callargs);
|
||||||
|
if (err < 0) {
|
||||||
ERROR_NO_POP();
|
ERROR_NO_POP();
|
||||||
}
|
}
|
||||||
PyObject *tuple = PySequence_Tuple(callargs);
|
PyObject *tuple = PySequence_Tuple(callargs);
|
||||||
|
|
10
Python/executor_cases.c.h
generated
10
Python/executor_cases.c.h
generated
|
@ -2085,7 +2085,12 @@
|
||||||
assert(PyDict_CheckExact(dict));
|
assert(PyDict_CheckExact(dict));
|
||||||
/* dict[key] = value */
|
/* dict[key] = value */
|
||||||
// Do not DECREF INPUTS because the function steals the references
|
// Do not DECREF INPUTS because the function steals the references
|
||||||
if (_PyDict_SetItem_Take2((PyDictObject *)dict, PyStackRef_AsPyObjectSteal(key), PyStackRef_AsPyObjectSteal(value)) != 0) JUMP_TO_ERROR();
|
int err = _PyDict_SetItem_Take2(
|
||||||
|
(PyDictObject *)dict,
|
||||||
|
PyStackRef_AsPyObjectSteal(key),
|
||||||
|
PyStackRef_AsPyObjectSteal(value)
|
||||||
|
);
|
||||||
|
if (err != 0) JUMP_TO_ERROR();
|
||||||
stack_pointer += -2;
|
stack_pointer += -2;
|
||||||
assert(WITHIN_STACK_BOUNDS());
|
assert(WITHIN_STACK_BOUNDS());
|
||||||
break;
|
break;
|
||||||
|
@ -2895,7 +2900,8 @@
|
||||||
PyObject *left_o = PyStackRef_AsPyObjectBorrow(left);
|
PyObject *left_o = PyStackRef_AsPyObjectBorrow(left);
|
||||||
PyObject *right_o = PyStackRef_AsPyObjectBorrow(right);
|
PyObject *right_o = PyStackRef_AsPyObjectBorrow(right);
|
||||||
assert(PyExceptionInstance_Check(left_o));
|
assert(PyExceptionInstance_Check(left_o));
|
||||||
if (_PyEval_CheckExceptTypeValid(tstate, right_o) < 0) {
|
int err = _PyEval_CheckExceptTypeValid(tstate, right_o);
|
||||||
|
if (err < 0) {
|
||||||
PyStackRef_CLOSE(right);
|
PyStackRef_CLOSE(right);
|
||||||
if (true) JUMP_TO_ERROR();
|
if (true) JUMP_TO_ERROR();
|
||||||
}
|
}
|
||||||
|
|
16
Python/generated_cases.c.h
generated
16
Python/generated_cases.c.h
generated
|
@ -1508,7 +1508,8 @@
|
||||||
// It converts all dict subtypes in kwargs into regular dicts.
|
// It converts all dict subtypes in kwargs into regular dicts.
|
||||||
assert(kwargs == NULL || PyDict_CheckExact(kwargs));
|
assert(kwargs == NULL || PyDict_CheckExact(kwargs));
|
||||||
if (!PyTuple_CheckExact(callargs)) {
|
if (!PyTuple_CheckExact(callargs)) {
|
||||||
if (check_args_iterable(tstate, func, callargs) < 0) {
|
int err = check_args_iterable(tstate, func, callargs);
|
||||||
|
if (err < 0) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
PyObject *tuple = PySequence_Tuple(callargs);
|
PyObject *tuple = PySequence_Tuple(callargs);
|
||||||
|
@ -2502,7 +2503,8 @@
|
||||||
PyObject *left_o = PyStackRef_AsPyObjectBorrow(left);
|
PyObject *left_o = PyStackRef_AsPyObjectBorrow(left);
|
||||||
PyObject *right_o = PyStackRef_AsPyObjectBorrow(right);
|
PyObject *right_o = PyStackRef_AsPyObjectBorrow(right);
|
||||||
assert(PyExceptionInstance_Check(left_o));
|
assert(PyExceptionInstance_Check(left_o));
|
||||||
if (_PyEval_CheckExceptTypeValid(tstate, right_o) < 0) {
|
int err = _PyEval_CheckExceptTypeValid(tstate, right_o);
|
||||||
|
if (err < 0) {
|
||||||
PyStackRef_CLOSE(right);
|
PyStackRef_CLOSE(right);
|
||||||
if (true) goto pop_1_error;
|
if (true) goto pop_1_error;
|
||||||
}
|
}
|
||||||
|
@ -4033,7 +4035,8 @@
|
||||||
uintptr_t global_version = _Py_atomic_load_uintptr_relaxed(&tstate->eval_breaker) & ~_PY_EVAL_EVENTS_MASK;
|
uintptr_t global_version = _Py_atomic_load_uintptr_relaxed(&tstate->eval_breaker) & ~_PY_EVAL_EVENTS_MASK;
|
||||||
uintptr_t code_version = FT_ATOMIC_LOAD_UINTPTR_ACQUIRE(_PyFrame_GetCode(frame)->_co_instrumentation_version);
|
uintptr_t code_version = FT_ATOMIC_LOAD_UINTPTR_ACQUIRE(_PyFrame_GetCode(frame)->_co_instrumentation_version);
|
||||||
if (code_version != global_version && tstate->tracing == 0) {
|
if (code_version != global_version && tstate->tracing == 0) {
|
||||||
if (_Py_Instrument(_PyFrame_GetCode(frame), tstate->interp)) {
|
int err = _Py_Instrument(_PyFrame_GetCode(frame), tstate->interp);
|
||||||
|
if (err) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
next_instr = this_instr;
|
next_instr = this_instr;
|
||||||
|
@ -5546,7 +5549,12 @@
|
||||||
assert(PyDict_CheckExact(dict));
|
assert(PyDict_CheckExact(dict));
|
||||||
/* dict[key] = value */
|
/* dict[key] = value */
|
||||||
// Do not DECREF INPUTS because the function steals the references
|
// Do not DECREF INPUTS because the function steals the references
|
||||||
if (_PyDict_SetItem_Take2((PyDictObject *)dict, PyStackRef_AsPyObjectSteal(key), PyStackRef_AsPyObjectSteal(value)) != 0) goto pop_2_error;
|
int err = _PyDict_SetItem_Take2(
|
||||||
|
(PyDictObject *)dict,
|
||||||
|
PyStackRef_AsPyObjectSteal(key),
|
||||||
|
PyStackRef_AsPyObjectSteal(value)
|
||||||
|
);
|
||||||
|
if (err != 0) goto pop_2_error;
|
||||||
stack_pointer += -2;
|
stack_pointer += -2;
|
||||||
assert(WITHIN_STACK_BOUNDS());
|
assert(WITHIN_STACK_BOUNDS());
|
||||||
DISPATCH();
|
DISPATCH();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue