mirror of https://github.com/python/cpython
gh-125323: Remove some unsafe Py_DECREFs in bytecodes.c, replacing them with PyStackRef_CLOSEs (GH-125324)
This commit is contained in:
parent
b52c7306ea
commit
4b358ee647
|
@ -153,6 +153,8 @@ PyStackRef_AsStrongReference(_PyStackRef stackref)
|
||||||
return PyStackRef_FromPyObjectSteal(PyStackRef_AsPyObjectSteal(stackref));
|
return PyStackRef_FromPyObjectSteal(PyStackRef_AsPyObjectSteal(stackref));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define PyStackRef_CLOSE_SPECIALIZED(stackref, dealloc) PyStackRef_CLOSE(stackref)
|
||||||
|
|
||||||
|
|
||||||
#else // Py_GIL_DISABLED
|
#else // Py_GIL_DISABLED
|
||||||
|
|
||||||
|
@ -177,6 +179,7 @@ static const _PyStackRef PyStackRef_NULL = { .bits = 0 };
|
||||||
|
|
||||||
#define PyStackRef_DUP(stackref) PyStackRef_FromPyObjectSteal(Py_NewRef(PyStackRef_AsPyObjectBorrow(stackref)))
|
#define PyStackRef_DUP(stackref) PyStackRef_FromPyObjectSteal(Py_NewRef(PyStackRef_AsPyObjectBorrow(stackref)))
|
||||||
|
|
||||||
|
#define PyStackRef_CLOSE_SPECIALIZED(stackref, dealloc) _Py_DECREF_SPECIALIZED(PyStackRef_AsPyObjectBorrow(stackref), dealloc)
|
||||||
|
|
||||||
#endif // Py_GIL_DISABLED
|
#endif // Py_GIL_DISABLED
|
||||||
|
|
||||||
|
|
|
@ -474,8 +474,8 @@ dummy_func(
|
||||||
|
|
||||||
STAT_INC(BINARY_OP, hit);
|
STAT_INC(BINARY_OP, hit);
|
||||||
PyObject *res_o = _PyLong_Multiply((PyLongObject *)left_o, (PyLongObject *)right_o);
|
PyObject *res_o = _PyLong_Multiply((PyLongObject *)left_o, (PyLongObject *)right_o);
|
||||||
_Py_DECREF_SPECIALIZED(right_o, (destructor)PyObject_Free);
|
PyStackRef_CLOSE_SPECIALIZED(right, (destructor)PyObject_Free);
|
||||||
_Py_DECREF_SPECIALIZED(left_o, (destructor)PyObject_Free);
|
PyStackRef_CLOSE_SPECIALIZED(left, (destructor)PyObject_Free);
|
||||||
INPUTS_DEAD();
|
INPUTS_DEAD();
|
||||||
ERROR_IF(res_o == NULL, error);
|
ERROR_IF(res_o == NULL, error);
|
||||||
res = PyStackRef_FromPyObjectSteal(res_o);
|
res = PyStackRef_FromPyObjectSteal(res_o);
|
||||||
|
@ -487,8 +487,8 @@ dummy_func(
|
||||||
|
|
||||||
STAT_INC(BINARY_OP, hit);
|
STAT_INC(BINARY_OP, hit);
|
||||||
PyObject *res_o = _PyLong_Add((PyLongObject *)left_o, (PyLongObject *)right_o);
|
PyObject *res_o = _PyLong_Add((PyLongObject *)left_o, (PyLongObject *)right_o);
|
||||||
_Py_DECREF_SPECIALIZED(right_o, (destructor)PyObject_Free);
|
PyStackRef_CLOSE_SPECIALIZED(right, (destructor)PyObject_Free);
|
||||||
_Py_DECREF_SPECIALIZED(left_o, (destructor)PyObject_Free);
|
PyStackRef_CLOSE_SPECIALIZED(left, (destructor)PyObject_Free);
|
||||||
INPUTS_DEAD();
|
INPUTS_DEAD();
|
||||||
ERROR_IF(res_o == NULL, error);
|
ERROR_IF(res_o == NULL, error);
|
||||||
res = PyStackRef_FromPyObjectSteal(res_o);
|
res = PyStackRef_FromPyObjectSteal(res_o);
|
||||||
|
@ -500,8 +500,8 @@ dummy_func(
|
||||||
|
|
||||||
STAT_INC(BINARY_OP, hit);
|
STAT_INC(BINARY_OP, hit);
|
||||||
PyObject *res_o = _PyLong_Subtract((PyLongObject *)left_o, (PyLongObject *)right_o);
|
PyObject *res_o = _PyLong_Subtract((PyLongObject *)left_o, (PyLongObject *)right_o);
|
||||||
_Py_DECREF_SPECIALIZED(right_o, (destructor)PyObject_Free);
|
PyStackRef_CLOSE_SPECIALIZED(right, (destructor)PyObject_Free);
|
||||||
_Py_DECREF_SPECIALIZED(left_o, (destructor)PyObject_Free);
|
PyStackRef_CLOSE_SPECIALIZED(left, (destructor)PyObject_Free);
|
||||||
INPUTS_DEAD();
|
INPUTS_DEAD();
|
||||||
ERROR_IF(res_o == NULL, error);
|
ERROR_IF(res_o == NULL, error);
|
||||||
res = PyStackRef_FromPyObjectSteal(res_o);
|
res = PyStackRef_FromPyObjectSteal(res_o);
|
||||||
|
@ -594,8 +594,8 @@ dummy_func(
|
||||||
|
|
||||||
STAT_INC(BINARY_OP, hit);
|
STAT_INC(BINARY_OP, hit);
|
||||||
PyObject *res_o = PyUnicode_Concat(left_o, right_o);
|
PyObject *res_o = PyUnicode_Concat(left_o, right_o);
|
||||||
_Py_DECREF_SPECIALIZED(left_o, _PyUnicode_ExactDealloc);
|
PyStackRef_CLOSE_SPECIALIZED(left, _PyUnicode_ExactDealloc);
|
||||||
_Py_DECREF_SPECIALIZED(right_o, _PyUnicode_ExactDealloc);
|
PyStackRef_CLOSE_SPECIALIZED(right, _PyUnicode_ExactDealloc);
|
||||||
INPUTS_DEAD();
|
INPUTS_DEAD();
|
||||||
ERROR_IF(res_o == NULL, error);
|
ERROR_IF(res_o == NULL, error);
|
||||||
res = PyStackRef_FromPyObjectSteal(res_o);
|
res = PyStackRef_FromPyObjectSteal(res_o);
|
||||||
|
@ -636,12 +636,12 @@ dummy_func(
|
||||||
* that the string is safe to mutate.
|
* that the string is safe to mutate.
|
||||||
*/
|
*/
|
||||||
assert(Py_REFCNT(left_o) >= 2);
|
assert(Py_REFCNT(left_o) >= 2);
|
||||||
_Py_DECREF_NO_DEALLOC(left_o);
|
PyStackRef_CLOSE(left);
|
||||||
DEAD(left);
|
DEAD(left);
|
||||||
PyObject *temp = PyStackRef_AsPyObjectBorrow(*target_local);
|
PyObject *temp = PyStackRef_AsPyObjectBorrow(*target_local);
|
||||||
PyUnicode_Append(&temp, right_o);
|
PyUnicode_Append(&temp, right_o);
|
||||||
*target_local = PyStackRef_FromPyObjectSteal(temp);
|
*target_local = PyStackRef_FromPyObjectSteal(temp);
|
||||||
_Py_DECREF_SPECIALIZED(right_o, _PyUnicode_ExactDealloc);
|
PyStackRef_CLOSE_SPECIALIZED(right, _PyUnicode_ExactDealloc);
|
||||||
DEAD(right);
|
DEAD(right);
|
||||||
ERROR_IF(PyStackRef_IsNull(*target_local), error);
|
ERROR_IF(PyStackRef_IsNull(*target_local), error);
|
||||||
#if TIER_ONE
|
#if TIER_ONE
|
||||||
|
@ -755,7 +755,7 @@ dummy_func(
|
||||||
PyObject *res_o = PyList_GET_ITEM(list, index);
|
PyObject *res_o = PyList_GET_ITEM(list, index);
|
||||||
assert(res_o != NULL);
|
assert(res_o != NULL);
|
||||||
Py_INCREF(res_o);
|
Py_INCREF(res_o);
|
||||||
_Py_DECREF_SPECIALIZED(sub, (destructor)PyObject_Free);
|
PyStackRef_CLOSE_SPECIALIZED(sub_st, (destructor)PyObject_Free);
|
||||||
DEAD(sub_st);
|
DEAD(sub_st);
|
||||||
PyStackRef_CLOSE(list_st);
|
PyStackRef_CLOSE(list_st);
|
||||||
res = PyStackRef_FromPyObjectSteal(res_o);
|
res = PyStackRef_FromPyObjectSteal(res_o);
|
||||||
|
@ -775,7 +775,7 @@ dummy_func(
|
||||||
DEOPT_IF(Py_ARRAY_LENGTH(_Py_SINGLETON(strings).ascii) <= c);
|
DEOPT_IF(Py_ARRAY_LENGTH(_Py_SINGLETON(strings).ascii) <= c);
|
||||||
STAT_INC(BINARY_SUBSCR, hit);
|
STAT_INC(BINARY_SUBSCR, hit);
|
||||||
PyObject *res_o = (PyObject*)&_Py_SINGLETON(strings).ascii[c];
|
PyObject *res_o = (PyObject*)&_Py_SINGLETON(strings).ascii[c];
|
||||||
_Py_DECREF_SPECIALIZED(sub, (destructor)PyObject_Free);
|
PyStackRef_CLOSE_SPECIALIZED(sub_st, (destructor)PyObject_Free);
|
||||||
DEAD(sub_st);
|
DEAD(sub_st);
|
||||||
PyStackRef_CLOSE(str_st);
|
PyStackRef_CLOSE(str_st);
|
||||||
res = PyStackRef_FromPyObjectSteal(res_o);
|
res = PyStackRef_FromPyObjectSteal(res_o);
|
||||||
|
@ -796,7 +796,7 @@ dummy_func(
|
||||||
PyObject *res_o = PyTuple_GET_ITEM(tuple, index);
|
PyObject *res_o = PyTuple_GET_ITEM(tuple, index);
|
||||||
assert(res_o != NULL);
|
assert(res_o != NULL);
|
||||||
Py_INCREF(res_o);
|
Py_INCREF(res_o);
|
||||||
_Py_DECREF_SPECIALIZED(sub, (destructor)PyObject_Free);
|
PyStackRef_CLOSE_SPECIALIZED(sub_st, (destructor)PyObject_Free);
|
||||||
DEAD(sub_st);
|
DEAD(sub_st);
|
||||||
PyStackRef_CLOSE(tuple_st);
|
PyStackRef_CLOSE(tuple_st);
|
||||||
res = PyStackRef_FromPyObjectSteal(res_o);
|
res = PyStackRef_FromPyObjectSteal(res_o);
|
||||||
|
@ -908,7 +908,7 @@ dummy_func(
|
||||||
PyList_SET_ITEM(list, index, PyStackRef_AsPyObjectSteal(value));
|
PyList_SET_ITEM(list, index, PyStackRef_AsPyObjectSteal(value));
|
||||||
assert(old_value != NULL);
|
assert(old_value != NULL);
|
||||||
Py_DECREF(old_value);
|
Py_DECREF(old_value);
|
||||||
_Py_DECREF_SPECIALIZED(sub, (destructor)PyObject_Free);
|
PyStackRef_CLOSE_SPECIALIZED(sub_st, (destructor)PyObject_Free);
|
||||||
DEAD(sub_st);
|
DEAD(sub_st);
|
||||||
PyStackRef_CLOSE(list_st);
|
PyStackRef_CLOSE(list_st);
|
||||||
}
|
}
|
||||||
|
@ -2398,9 +2398,9 @@ dummy_func(
|
||||||
double dright = PyFloat_AS_DOUBLE(right_o);
|
double dright = PyFloat_AS_DOUBLE(right_o);
|
||||||
// 1 if NaN, 2 if <, 4 if >, 8 if ==; this matches low four bits of the oparg
|
// 1 if NaN, 2 if <, 4 if >, 8 if ==; this matches low four bits of the oparg
|
||||||
int sign_ish = COMPARISON_BIT(dleft, dright);
|
int sign_ish = COMPARISON_BIT(dleft, dright);
|
||||||
_Py_DECREF_SPECIALIZED(left_o, _PyFloat_ExactDealloc);
|
PyStackRef_CLOSE_SPECIALIZED(left, _PyFloat_ExactDealloc);
|
||||||
DEAD(left);
|
DEAD(left);
|
||||||
_Py_DECREF_SPECIALIZED(right_o, _PyFloat_ExactDealloc);
|
PyStackRef_CLOSE_SPECIALIZED(right, _PyFloat_ExactDealloc);
|
||||||
DEAD(right);
|
DEAD(right);
|
||||||
res = (sign_ish & oparg) ? PyStackRef_True : PyStackRef_False;
|
res = (sign_ish & oparg) ? PyStackRef_True : PyStackRef_False;
|
||||||
// It's always a bool, so we don't care about oparg & 16.
|
// It's always a bool, so we don't care about oparg & 16.
|
||||||
|
@ -2420,9 +2420,9 @@ dummy_func(
|
||||||
Py_ssize_t iright = _PyLong_CompactValue((PyLongObject *)right_o);
|
Py_ssize_t iright = _PyLong_CompactValue((PyLongObject *)right_o);
|
||||||
// 2 if <, 4 if >, 8 if ==; this matches the low 4 bits of the oparg
|
// 2 if <, 4 if >, 8 if ==; this matches the low 4 bits of the oparg
|
||||||
int sign_ish = COMPARISON_BIT(ileft, iright);
|
int sign_ish = COMPARISON_BIT(ileft, iright);
|
||||||
_Py_DECREF_SPECIALIZED(left_o, (destructor)PyObject_Free);
|
PyStackRef_CLOSE_SPECIALIZED(left, (destructor)PyObject_Free);
|
||||||
DEAD(left);
|
DEAD(left);
|
||||||
_Py_DECREF_SPECIALIZED(right_o, (destructor)PyObject_Free);
|
PyStackRef_CLOSE_SPECIALIZED(right, (destructor)PyObject_Free);
|
||||||
DEAD(right);
|
DEAD(right);
|
||||||
res = (sign_ish & oparg) ? PyStackRef_True : PyStackRef_False;
|
res = (sign_ish & oparg) ? PyStackRef_True : PyStackRef_False;
|
||||||
// It's always a bool, so we don't care about oparg & 16.
|
// It's always a bool, so we don't care about oparg & 16.
|
||||||
|
@ -2436,9 +2436,9 @@ dummy_func(
|
||||||
STAT_INC(COMPARE_OP, hit);
|
STAT_INC(COMPARE_OP, hit);
|
||||||
int eq = _PyUnicode_Equal(left_o, right_o);
|
int eq = _PyUnicode_Equal(left_o, right_o);
|
||||||
assert((oparg >> 5) == Py_EQ || (oparg >> 5) == Py_NE);
|
assert((oparg >> 5) == Py_EQ || (oparg >> 5) == Py_NE);
|
||||||
_Py_DECREF_SPECIALIZED(left_o, _PyUnicode_ExactDealloc);
|
PyStackRef_CLOSE_SPECIALIZED(left, _PyUnicode_ExactDealloc);
|
||||||
DEAD(left);
|
DEAD(left);
|
||||||
_Py_DECREF_SPECIALIZED(right_o, _PyUnicode_ExactDealloc);
|
PyStackRef_CLOSE_SPECIALIZED(right, _PyUnicode_ExactDealloc);
|
||||||
DEAD(right);
|
DEAD(right);
|
||||||
assert(eq == 0 || eq == 1);
|
assert(eq == 0 || eq == 1);
|
||||||
assert((oparg & 0xf) == COMPARISON_NOT_EQUALS || (oparg & 0xf) == COMPARISON_EQUALS);
|
assert((oparg & 0xf) == COMPARISON_NOT_EQUALS || (oparg & 0xf) == COMPARISON_EQUALS);
|
||||||
|
|
|
@ -541,8 +541,8 @@
|
||||||
PyObject *right_o = PyStackRef_AsPyObjectBorrow(right);
|
PyObject *right_o = PyStackRef_AsPyObjectBorrow(right);
|
||||||
STAT_INC(BINARY_OP, hit);
|
STAT_INC(BINARY_OP, hit);
|
||||||
PyObject *res_o = _PyLong_Multiply((PyLongObject *)left_o, (PyLongObject *)right_o);
|
PyObject *res_o = _PyLong_Multiply((PyLongObject *)left_o, (PyLongObject *)right_o);
|
||||||
_Py_DECREF_SPECIALIZED(right_o, (destructor)PyObject_Free);
|
PyStackRef_CLOSE_SPECIALIZED(right, (destructor)PyObject_Free);
|
||||||
_Py_DECREF_SPECIALIZED(left_o, (destructor)PyObject_Free);
|
PyStackRef_CLOSE_SPECIALIZED(left, (destructor)PyObject_Free);
|
||||||
if (res_o == NULL) JUMP_TO_ERROR();
|
if (res_o == NULL) JUMP_TO_ERROR();
|
||||||
res = PyStackRef_FromPyObjectSteal(res_o);
|
res = PyStackRef_FromPyObjectSteal(res_o);
|
||||||
stack_pointer[-2] = res;
|
stack_pointer[-2] = res;
|
||||||
|
@ -561,8 +561,8 @@
|
||||||
PyObject *right_o = PyStackRef_AsPyObjectBorrow(right);
|
PyObject *right_o = PyStackRef_AsPyObjectBorrow(right);
|
||||||
STAT_INC(BINARY_OP, hit);
|
STAT_INC(BINARY_OP, hit);
|
||||||
PyObject *res_o = _PyLong_Add((PyLongObject *)left_o, (PyLongObject *)right_o);
|
PyObject *res_o = _PyLong_Add((PyLongObject *)left_o, (PyLongObject *)right_o);
|
||||||
_Py_DECREF_SPECIALIZED(right_o, (destructor)PyObject_Free);
|
PyStackRef_CLOSE_SPECIALIZED(right, (destructor)PyObject_Free);
|
||||||
_Py_DECREF_SPECIALIZED(left_o, (destructor)PyObject_Free);
|
PyStackRef_CLOSE_SPECIALIZED(left, (destructor)PyObject_Free);
|
||||||
if (res_o == NULL) JUMP_TO_ERROR();
|
if (res_o == NULL) JUMP_TO_ERROR();
|
||||||
res = PyStackRef_FromPyObjectSteal(res_o);
|
res = PyStackRef_FromPyObjectSteal(res_o);
|
||||||
stack_pointer[-2] = res;
|
stack_pointer[-2] = res;
|
||||||
|
@ -581,8 +581,8 @@
|
||||||
PyObject *right_o = PyStackRef_AsPyObjectBorrow(right);
|
PyObject *right_o = PyStackRef_AsPyObjectBorrow(right);
|
||||||
STAT_INC(BINARY_OP, hit);
|
STAT_INC(BINARY_OP, hit);
|
||||||
PyObject *res_o = _PyLong_Subtract((PyLongObject *)left_o, (PyLongObject *)right_o);
|
PyObject *res_o = _PyLong_Subtract((PyLongObject *)left_o, (PyLongObject *)right_o);
|
||||||
_Py_DECREF_SPECIALIZED(right_o, (destructor)PyObject_Free);
|
PyStackRef_CLOSE_SPECIALIZED(right, (destructor)PyObject_Free);
|
||||||
_Py_DECREF_SPECIALIZED(left_o, (destructor)PyObject_Free);
|
PyStackRef_CLOSE_SPECIALIZED(left, (destructor)PyObject_Free);
|
||||||
if (res_o == NULL) JUMP_TO_ERROR();
|
if (res_o == NULL) JUMP_TO_ERROR();
|
||||||
res = PyStackRef_FromPyObjectSteal(res_o);
|
res = PyStackRef_FromPyObjectSteal(res_o);
|
||||||
stack_pointer[-2] = res;
|
stack_pointer[-2] = res;
|
||||||
|
@ -722,8 +722,8 @@
|
||||||
PyObject *right_o = PyStackRef_AsPyObjectBorrow(right);
|
PyObject *right_o = PyStackRef_AsPyObjectBorrow(right);
|
||||||
STAT_INC(BINARY_OP, hit);
|
STAT_INC(BINARY_OP, hit);
|
||||||
PyObject *res_o = PyUnicode_Concat(left_o, right_o);
|
PyObject *res_o = PyUnicode_Concat(left_o, right_o);
|
||||||
_Py_DECREF_SPECIALIZED(left_o, _PyUnicode_ExactDealloc);
|
PyStackRef_CLOSE_SPECIALIZED(left, _PyUnicode_ExactDealloc);
|
||||||
_Py_DECREF_SPECIALIZED(right_o, _PyUnicode_ExactDealloc);
|
PyStackRef_CLOSE_SPECIALIZED(right, _PyUnicode_ExactDealloc);
|
||||||
if (res_o == NULL) JUMP_TO_ERROR();
|
if (res_o == NULL) JUMP_TO_ERROR();
|
||||||
res = PyStackRef_FromPyObjectSteal(res_o);
|
res = PyStackRef_FromPyObjectSteal(res_o);
|
||||||
stack_pointer[-2] = res;
|
stack_pointer[-2] = res;
|
||||||
|
@ -764,11 +764,11 @@
|
||||||
* that the string is safe to mutate.
|
* that the string is safe to mutate.
|
||||||
*/
|
*/
|
||||||
assert(Py_REFCNT(left_o) >= 2);
|
assert(Py_REFCNT(left_o) >= 2);
|
||||||
_Py_DECREF_NO_DEALLOC(left_o);
|
PyStackRef_CLOSE(left);
|
||||||
PyObject *temp = PyStackRef_AsPyObjectBorrow(*target_local);
|
PyObject *temp = PyStackRef_AsPyObjectBorrow(*target_local);
|
||||||
PyUnicode_Append(&temp, right_o);
|
PyUnicode_Append(&temp, right_o);
|
||||||
*target_local = PyStackRef_FromPyObjectSteal(temp);
|
*target_local = PyStackRef_FromPyObjectSteal(temp);
|
||||||
_Py_DECREF_SPECIALIZED(right_o, _PyUnicode_ExactDealloc);
|
PyStackRef_CLOSE_SPECIALIZED(right, _PyUnicode_ExactDealloc);
|
||||||
if (PyStackRef_IsNull(*target_local)) JUMP_TO_ERROR();
|
if (PyStackRef_IsNull(*target_local)) JUMP_TO_ERROR();
|
||||||
#if TIER_ONE
|
#if TIER_ONE
|
||||||
// The STORE_FAST is already done. This is done here in tier one,
|
// The STORE_FAST is already done. This is done here in tier one,
|
||||||
|
@ -904,7 +904,7 @@
|
||||||
PyObject *res_o = PyList_GET_ITEM(list, index);
|
PyObject *res_o = PyList_GET_ITEM(list, index);
|
||||||
assert(res_o != NULL);
|
assert(res_o != NULL);
|
||||||
Py_INCREF(res_o);
|
Py_INCREF(res_o);
|
||||||
_Py_DECREF_SPECIALIZED(sub, (destructor)PyObject_Free);
|
PyStackRef_CLOSE_SPECIALIZED(sub_st, (destructor)PyObject_Free);
|
||||||
PyStackRef_CLOSE(list_st);
|
PyStackRef_CLOSE(list_st);
|
||||||
res = PyStackRef_FromPyObjectSteal(res_o);
|
res = PyStackRef_FromPyObjectSteal(res_o);
|
||||||
stack_pointer[-2] = res;
|
stack_pointer[-2] = res;
|
||||||
|
@ -946,7 +946,7 @@
|
||||||
}
|
}
|
||||||
STAT_INC(BINARY_SUBSCR, hit);
|
STAT_INC(BINARY_SUBSCR, hit);
|
||||||
PyObject *res_o = (PyObject*)&_Py_SINGLETON(strings).ascii[c];
|
PyObject *res_o = (PyObject*)&_Py_SINGLETON(strings).ascii[c];
|
||||||
_Py_DECREF_SPECIALIZED(sub, (destructor)PyObject_Free);
|
PyStackRef_CLOSE_SPECIALIZED(sub_st, (destructor)PyObject_Free);
|
||||||
PyStackRef_CLOSE(str_st);
|
PyStackRef_CLOSE(str_st);
|
||||||
res = PyStackRef_FromPyObjectSteal(res_o);
|
res = PyStackRef_FromPyObjectSteal(res_o);
|
||||||
stack_pointer[-2] = res;
|
stack_pointer[-2] = res;
|
||||||
|
@ -985,7 +985,7 @@
|
||||||
PyObject *res_o = PyTuple_GET_ITEM(tuple, index);
|
PyObject *res_o = PyTuple_GET_ITEM(tuple, index);
|
||||||
assert(res_o != NULL);
|
assert(res_o != NULL);
|
||||||
Py_INCREF(res_o);
|
Py_INCREF(res_o);
|
||||||
_Py_DECREF_SPECIALIZED(sub, (destructor)PyObject_Free);
|
PyStackRef_CLOSE_SPECIALIZED(sub_st, (destructor)PyObject_Free);
|
||||||
PyStackRef_CLOSE(tuple_st);
|
PyStackRef_CLOSE(tuple_st);
|
||||||
res = PyStackRef_FromPyObjectSteal(res_o);
|
res = PyStackRef_FromPyObjectSteal(res_o);
|
||||||
stack_pointer[-2] = res;
|
stack_pointer[-2] = res;
|
||||||
|
@ -1160,7 +1160,7 @@
|
||||||
PyList_SET_ITEM(list, index, PyStackRef_AsPyObjectSteal(value));
|
PyList_SET_ITEM(list, index, PyStackRef_AsPyObjectSteal(value));
|
||||||
assert(old_value != NULL);
|
assert(old_value != NULL);
|
||||||
Py_DECREF(old_value);
|
Py_DECREF(old_value);
|
||||||
_Py_DECREF_SPECIALIZED(sub, (destructor)PyObject_Free);
|
PyStackRef_CLOSE_SPECIALIZED(sub_st, (destructor)PyObject_Free);
|
||||||
PyStackRef_CLOSE(list_st);
|
PyStackRef_CLOSE(list_st);
|
||||||
stack_pointer += -3;
|
stack_pointer += -3;
|
||||||
assert(WITHIN_STACK_BOUNDS());
|
assert(WITHIN_STACK_BOUNDS());
|
||||||
|
@ -2912,8 +2912,8 @@
|
||||||
double dright = PyFloat_AS_DOUBLE(right_o);
|
double dright = PyFloat_AS_DOUBLE(right_o);
|
||||||
// 1 if NaN, 2 if <, 4 if >, 8 if ==; this matches low four bits of the oparg
|
// 1 if NaN, 2 if <, 4 if >, 8 if ==; this matches low four bits of the oparg
|
||||||
int sign_ish = COMPARISON_BIT(dleft, dright);
|
int sign_ish = COMPARISON_BIT(dleft, dright);
|
||||||
_Py_DECREF_SPECIALIZED(left_o, _PyFloat_ExactDealloc);
|
PyStackRef_CLOSE_SPECIALIZED(left, _PyFloat_ExactDealloc);
|
||||||
_Py_DECREF_SPECIALIZED(right_o, _PyFloat_ExactDealloc);
|
PyStackRef_CLOSE_SPECIALIZED(right, _PyFloat_ExactDealloc);
|
||||||
res = (sign_ish & oparg) ? PyStackRef_True : PyStackRef_False;
|
res = (sign_ish & oparg) ? PyStackRef_True : PyStackRef_False;
|
||||||
// It's always a bool, so we don't care about oparg & 16.
|
// It's always a bool, so we don't care about oparg & 16.
|
||||||
stack_pointer[-2] = res;
|
stack_pointer[-2] = res;
|
||||||
|
@ -2946,8 +2946,8 @@
|
||||||
Py_ssize_t iright = _PyLong_CompactValue((PyLongObject *)right_o);
|
Py_ssize_t iright = _PyLong_CompactValue((PyLongObject *)right_o);
|
||||||
// 2 if <, 4 if >, 8 if ==; this matches the low 4 bits of the oparg
|
// 2 if <, 4 if >, 8 if ==; this matches the low 4 bits of the oparg
|
||||||
int sign_ish = COMPARISON_BIT(ileft, iright);
|
int sign_ish = COMPARISON_BIT(ileft, iright);
|
||||||
_Py_DECREF_SPECIALIZED(left_o, (destructor)PyObject_Free);
|
PyStackRef_CLOSE_SPECIALIZED(left, (destructor)PyObject_Free);
|
||||||
_Py_DECREF_SPECIALIZED(right_o, (destructor)PyObject_Free);
|
PyStackRef_CLOSE_SPECIALIZED(right, (destructor)PyObject_Free);
|
||||||
res = (sign_ish & oparg) ? PyStackRef_True : PyStackRef_False;
|
res = (sign_ish & oparg) ? PyStackRef_True : PyStackRef_False;
|
||||||
// It's always a bool, so we don't care about oparg & 16.
|
// It's always a bool, so we don't care about oparg & 16.
|
||||||
stack_pointer[-2] = res;
|
stack_pointer[-2] = res;
|
||||||
|
@ -2968,8 +2968,8 @@
|
||||||
STAT_INC(COMPARE_OP, hit);
|
STAT_INC(COMPARE_OP, hit);
|
||||||
int eq = _PyUnicode_Equal(left_o, right_o);
|
int eq = _PyUnicode_Equal(left_o, right_o);
|
||||||
assert((oparg >> 5) == Py_EQ || (oparg >> 5) == Py_NE);
|
assert((oparg >> 5) == Py_EQ || (oparg >> 5) == Py_NE);
|
||||||
_Py_DECREF_SPECIALIZED(left_o, _PyUnicode_ExactDealloc);
|
PyStackRef_CLOSE_SPECIALIZED(left, _PyUnicode_ExactDealloc);
|
||||||
_Py_DECREF_SPECIALIZED(right_o, _PyUnicode_ExactDealloc);
|
PyStackRef_CLOSE_SPECIALIZED(right, _PyUnicode_ExactDealloc);
|
||||||
assert(eq == 0 || eq == 1);
|
assert(eq == 0 || eq == 1);
|
||||||
assert((oparg & 0xf) == COMPARISON_NOT_EQUALS || (oparg & 0xf) == COMPARISON_EQUALS);
|
assert((oparg & 0xf) == COMPARISON_NOT_EQUALS || (oparg & 0xf) == COMPARISON_EQUALS);
|
||||||
assert(COMPARISON_NOT_EQUALS + 1 == COMPARISON_EQUALS);
|
assert(COMPARISON_NOT_EQUALS + 1 == COMPARISON_EQUALS);
|
||||||
|
|
|
@ -118,8 +118,8 @@
|
||||||
PyObject *right_o = PyStackRef_AsPyObjectBorrow(right);
|
PyObject *right_o = PyStackRef_AsPyObjectBorrow(right);
|
||||||
STAT_INC(BINARY_OP, hit);
|
STAT_INC(BINARY_OP, hit);
|
||||||
PyObject *res_o = _PyLong_Add((PyLongObject *)left_o, (PyLongObject *)right_o);
|
PyObject *res_o = _PyLong_Add((PyLongObject *)left_o, (PyLongObject *)right_o);
|
||||||
_Py_DECREF_SPECIALIZED(right_o, (destructor)PyObject_Free);
|
PyStackRef_CLOSE_SPECIALIZED(right, (destructor)PyObject_Free);
|
||||||
_Py_DECREF_SPECIALIZED(left_o, (destructor)PyObject_Free);
|
PyStackRef_CLOSE_SPECIALIZED(left, (destructor)PyObject_Free);
|
||||||
if (res_o == NULL) goto pop_2_error;
|
if (res_o == NULL) goto pop_2_error;
|
||||||
res = PyStackRef_FromPyObjectSteal(res_o);
|
res = PyStackRef_FromPyObjectSteal(res_o);
|
||||||
}
|
}
|
||||||
|
@ -153,8 +153,8 @@
|
||||||
PyObject *right_o = PyStackRef_AsPyObjectBorrow(right);
|
PyObject *right_o = PyStackRef_AsPyObjectBorrow(right);
|
||||||
STAT_INC(BINARY_OP, hit);
|
STAT_INC(BINARY_OP, hit);
|
||||||
PyObject *res_o = PyUnicode_Concat(left_o, right_o);
|
PyObject *res_o = PyUnicode_Concat(left_o, right_o);
|
||||||
_Py_DECREF_SPECIALIZED(left_o, _PyUnicode_ExactDealloc);
|
PyStackRef_CLOSE_SPECIALIZED(left, _PyUnicode_ExactDealloc);
|
||||||
_Py_DECREF_SPECIALIZED(right_o, _PyUnicode_ExactDealloc);
|
PyStackRef_CLOSE_SPECIALIZED(right, _PyUnicode_ExactDealloc);
|
||||||
if (res_o == NULL) goto pop_2_error;
|
if (res_o == NULL) goto pop_2_error;
|
||||||
res = PyStackRef_FromPyObjectSteal(res_o);
|
res = PyStackRef_FromPyObjectSteal(res_o);
|
||||||
}
|
}
|
||||||
|
@ -207,11 +207,11 @@
|
||||||
* that the string is safe to mutate.
|
* that the string is safe to mutate.
|
||||||
*/
|
*/
|
||||||
assert(Py_REFCNT(left_o) >= 2);
|
assert(Py_REFCNT(left_o) >= 2);
|
||||||
_Py_DECREF_NO_DEALLOC(left_o);
|
PyStackRef_CLOSE(left);
|
||||||
PyObject *temp = PyStackRef_AsPyObjectBorrow(*target_local);
|
PyObject *temp = PyStackRef_AsPyObjectBorrow(*target_local);
|
||||||
PyUnicode_Append(&temp, right_o);
|
PyUnicode_Append(&temp, right_o);
|
||||||
*target_local = PyStackRef_FromPyObjectSteal(temp);
|
*target_local = PyStackRef_FromPyObjectSteal(temp);
|
||||||
_Py_DECREF_SPECIALIZED(right_o, _PyUnicode_ExactDealloc);
|
PyStackRef_CLOSE_SPECIALIZED(right, _PyUnicode_ExactDealloc);
|
||||||
if (PyStackRef_IsNull(*target_local)) goto pop_2_error;
|
if (PyStackRef_IsNull(*target_local)) goto pop_2_error;
|
||||||
#if TIER_ONE
|
#if TIER_ONE
|
||||||
// The STORE_FAST is already done. This is done here in tier one,
|
// The STORE_FAST is already done. This is done here in tier one,
|
||||||
|
@ -285,8 +285,8 @@
|
||||||
PyObject *right_o = PyStackRef_AsPyObjectBorrow(right);
|
PyObject *right_o = PyStackRef_AsPyObjectBorrow(right);
|
||||||
STAT_INC(BINARY_OP, hit);
|
STAT_INC(BINARY_OP, hit);
|
||||||
PyObject *res_o = _PyLong_Multiply((PyLongObject *)left_o, (PyLongObject *)right_o);
|
PyObject *res_o = _PyLong_Multiply((PyLongObject *)left_o, (PyLongObject *)right_o);
|
||||||
_Py_DECREF_SPECIALIZED(right_o, (destructor)PyObject_Free);
|
PyStackRef_CLOSE_SPECIALIZED(right, (destructor)PyObject_Free);
|
||||||
_Py_DECREF_SPECIALIZED(left_o, (destructor)PyObject_Free);
|
PyStackRef_CLOSE_SPECIALIZED(left, (destructor)PyObject_Free);
|
||||||
if (res_o == NULL) goto pop_2_error;
|
if (res_o == NULL) goto pop_2_error;
|
||||||
res = PyStackRef_FromPyObjectSteal(res_o);
|
res = PyStackRef_FromPyObjectSteal(res_o);
|
||||||
}
|
}
|
||||||
|
@ -356,8 +356,8 @@
|
||||||
PyObject *right_o = PyStackRef_AsPyObjectBorrow(right);
|
PyObject *right_o = PyStackRef_AsPyObjectBorrow(right);
|
||||||
STAT_INC(BINARY_OP, hit);
|
STAT_INC(BINARY_OP, hit);
|
||||||
PyObject *res_o = _PyLong_Subtract((PyLongObject *)left_o, (PyLongObject *)right_o);
|
PyObject *res_o = _PyLong_Subtract((PyLongObject *)left_o, (PyLongObject *)right_o);
|
||||||
_Py_DECREF_SPECIALIZED(right_o, (destructor)PyObject_Free);
|
PyStackRef_CLOSE_SPECIALIZED(right, (destructor)PyObject_Free);
|
||||||
_Py_DECREF_SPECIALIZED(left_o, (destructor)PyObject_Free);
|
PyStackRef_CLOSE_SPECIALIZED(left, (destructor)PyObject_Free);
|
||||||
if (res_o == NULL) goto pop_2_error;
|
if (res_o == NULL) goto pop_2_error;
|
||||||
res = PyStackRef_FromPyObjectSteal(res_o);
|
res = PyStackRef_FromPyObjectSteal(res_o);
|
||||||
}
|
}
|
||||||
|
@ -582,7 +582,7 @@
|
||||||
PyObject *res_o = PyList_GET_ITEM(list, index);
|
PyObject *res_o = PyList_GET_ITEM(list, index);
|
||||||
assert(res_o != NULL);
|
assert(res_o != NULL);
|
||||||
Py_INCREF(res_o);
|
Py_INCREF(res_o);
|
||||||
_Py_DECREF_SPECIALIZED(sub, (destructor)PyObject_Free);
|
PyStackRef_CLOSE_SPECIALIZED(sub_st, (destructor)PyObject_Free);
|
||||||
PyStackRef_CLOSE(list_st);
|
PyStackRef_CLOSE(list_st);
|
||||||
res = PyStackRef_FromPyObjectSteal(res_o);
|
res = PyStackRef_FromPyObjectSteal(res_o);
|
||||||
stack_pointer[-2] = res;
|
stack_pointer[-2] = res;
|
||||||
|
@ -614,7 +614,7 @@
|
||||||
DEOPT_IF(Py_ARRAY_LENGTH(_Py_SINGLETON(strings).ascii) <= c, BINARY_SUBSCR);
|
DEOPT_IF(Py_ARRAY_LENGTH(_Py_SINGLETON(strings).ascii) <= c, BINARY_SUBSCR);
|
||||||
STAT_INC(BINARY_SUBSCR, hit);
|
STAT_INC(BINARY_SUBSCR, hit);
|
||||||
PyObject *res_o = (PyObject*)&_Py_SINGLETON(strings).ascii[c];
|
PyObject *res_o = (PyObject*)&_Py_SINGLETON(strings).ascii[c];
|
||||||
_Py_DECREF_SPECIALIZED(sub, (destructor)PyObject_Free);
|
PyStackRef_CLOSE_SPECIALIZED(sub_st, (destructor)PyObject_Free);
|
||||||
PyStackRef_CLOSE(str_st);
|
PyStackRef_CLOSE(str_st);
|
||||||
res = PyStackRef_FromPyObjectSteal(res_o);
|
res = PyStackRef_FromPyObjectSteal(res_o);
|
||||||
stack_pointer[-2] = res;
|
stack_pointer[-2] = res;
|
||||||
|
@ -646,7 +646,7 @@
|
||||||
PyObject *res_o = PyTuple_GET_ITEM(tuple, index);
|
PyObject *res_o = PyTuple_GET_ITEM(tuple, index);
|
||||||
assert(res_o != NULL);
|
assert(res_o != NULL);
|
||||||
Py_INCREF(res_o);
|
Py_INCREF(res_o);
|
||||||
_Py_DECREF_SPECIALIZED(sub, (destructor)PyObject_Free);
|
PyStackRef_CLOSE_SPECIALIZED(sub_st, (destructor)PyObject_Free);
|
||||||
PyStackRef_CLOSE(tuple_st);
|
PyStackRef_CLOSE(tuple_st);
|
||||||
res = PyStackRef_FromPyObjectSteal(res_o);
|
res = PyStackRef_FromPyObjectSteal(res_o);
|
||||||
stack_pointer[-2] = res;
|
stack_pointer[-2] = res;
|
||||||
|
@ -3284,8 +3284,8 @@
|
||||||
double dright = PyFloat_AS_DOUBLE(right_o);
|
double dright = PyFloat_AS_DOUBLE(right_o);
|
||||||
// 1 if NaN, 2 if <, 4 if >, 8 if ==; this matches low four bits of the oparg
|
// 1 if NaN, 2 if <, 4 if >, 8 if ==; this matches low four bits of the oparg
|
||||||
int sign_ish = COMPARISON_BIT(dleft, dright);
|
int sign_ish = COMPARISON_BIT(dleft, dright);
|
||||||
_Py_DECREF_SPECIALIZED(left_o, _PyFloat_ExactDealloc);
|
PyStackRef_CLOSE_SPECIALIZED(left, _PyFloat_ExactDealloc);
|
||||||
_Py_DECREF_SPECIALIZED(right_o, _PyFloat_ExactDealloc);
|
PyStackRef_CLOSE_SPECIALIZED(right, _PyFloat_ExactDealloc);
|
||||||
res = (sign_ish & oparg) ? PyStackRef_True : PyStackRef_False;
|
res = (sign_ish & oparg) ? PyStackRef_True : PyStackRef_False;
|
||||||
// It's always a bool, so we don't care about oparg & 16.
|
// It's always a bool, so we don't care about oparg & 16.
|
||||||
}
|
}
|
||||||
|
@ -3326,8 +3326,8 @@
|
||||||
Py_ssize_t iright = _PyLong_CompactValue((PyLongObject *)right_o);
|
Py_ssize_t iright = _PyLong_CompactValue((PyLongObject *)right_o);
|
||||||
// 2 if <, 4 if >, 8 if ==; this matches the low 4 bits of the oparg
|
// 2 if <, 4 if >, 8 if ==; this matches the low 4 bits of the oparg
|
||||||
int sign_ish = COMPARISON_BIT(ileft, iright);
|
int sign_ish = COMPARISON_BIT(ileft, iright);
|
||||||
_Py_DECREF_SPECIALIZED(left_o, (destructor)PyObject_Free);
|
PyStackRef_CLOSE_SPECIALIZED(left, (destructor)PyObject_Free);
|
||||||
_Py_DECREF_SPECIALIZED(right_o, (destructor)PyObject_Free);
|
PyStackRef_CLOSE_SPECIALIZED(right, (destructor)PyObject_Free);
|
||||||
res = (sign_ish & oparg) ? PyStackRef_True : PyStackRef_False;
|
res = (sign_ish & oparg) ? PyStackRef_True : PyStackRef_False;
|
||||||
// It's always a bool, so we don't care about oparg & 16.
|
// It's always a bool, so we don't care about oparg & 16.
|
||||||
}
|
}
|
||||||
|
@ -3362,8 +3362,8 @@
|
||||||
STAT_INC(COMPARE_OP, hit);
|
STAT_INC(COMPARE_OP, hit);
|
||||||
int eq = _PyUnicode_Equal(left_o, right_o);
|
int eq = _PyUnicode_Equal(left_o, right_o);
|
||||||
assert((oparg >> 5) == Py_EQ || (oparg >> 5) == Py_NE);
|
assert((oparg >> 5) == Py_EQ || (oparg >> 5) == Py_NE);
|
||||||
_Py_DECREF_SPECIALIZED(left_o, _PyUnicode_ExactDealloc);
|
PyStackRef_CLOSE_SPECIALIZED(left, _PyUnicode_ExactDealloc);
|
||||||
_Py_DECREF_SPECIALIZED(right_o, _PyUnicode_ExactDealloc);
|
PyStackRef_CLOSE_SPECIALIZED(right, _PyUnicode_ExactDealloc);
|
||||||
assert(eq == 0 || eq == 1);
|
assert(eq == 0 || eq == 1);
|
||||||
assert((oparg & 0xf) == COMPARISON_NOT_EQUALS || (oparg & 0xf) == COMPARISON_EQUALS);
|
assert((oparg & 0xf) == COMPARISON_NOT_EQUALS || (oparg & 0xf) == COMPARISON_EQUALS);
|
||||||
assert(COMPARISON_NOT_EQUALS + 1 == COMPARISON_EQUALS);
|
assert(COMPARISON_NOT_EQUALS + 1 == COMPARISON_EQUALS);
|
||||||
|
@ -7720,7 +7720,7 @@
|
||||||
PyList_SET_ITEM(list, index, PyStackRef_AsPyObjectSteal(value));
|
PyList_SET_ITEM(list, index, PyStackRef_AsPyObjectSteal(value));
|
||||||
assert(old_value != NULL);
|
assert(old_value != NULL);
|
||||||
Py_DECREF(old_value);
|
Py_DECREF(old_value);
|
||||||
_Py_DECREF_SPECIALIZED(sub, (destructor)PyObject_Free);
|
PyStackRef_CLOSE_SPECIALIZED(sub_st, (destructor)PyObject_Free);
|
||||||
PyStackRef_CLOSE(list_st);
|
PyStackRef_CLOSE(list_st);
|
||||||
stack_pointer += -3;
|
stack_pointer += -3;
|
||||||
assert(WITHIN_STACK_BOUNDS());
|
assert(WITHIN_STACK_BOUNDS());
|
||||||
|
|
|
@ -540,6 +540,7 @@ NON_ESCAPING_FUNCTIONS = (
|
||||||
"PyStackRef_AsPyObjectSteal",
|
"PyStackRef_AsPyObjectSteal",
|
||||||
"PyStackRef_CLEAR",
|
"PyStackRef_CLEAR",
|
||||||
"PyStackRef_CLOSE",
|
"PyStackRef_CLOSE",
|
||||||
|
"PyStackRef_CLOSE_SPECIALIZED",
|
||||||
"PyStackRef_DUP",
|
"PyStackRef_DUP",
|
||||||
"PyStackRef_False",
|
"PyStackRef_False",
|
||||||
"PyStackRef_FromPyObjectImmortal",
|
"PyStackRef_FromPyObjectImmortal",
|
||||||
|
|
|
@ -116,6 +116,7 @@ class Emitter:
|
||||||
"SAVE_STACK": self.save_stack,
|
"SAVE_STACK": self.save_stack,
|
||||||
"RELOAD_STACK": self.reload_stack,
|
"RELOAD_STACK": self.reload_stack,
|
||||||
"PyStackRef_CLOSE": self.stackref_close,
|
"PyStackRef_CLOSE": self.stackref_close,
|
||||||
|
"PyStackRef_CLOSE_SPECIALIZED": self.stackref_close,
|
||||||
"PyStackRef_AsPyObjectSteal": self.stackref_steal,
|
"PyStackRef_AsPyObjectSteal": self.stackref_steal,
|
||||||
"DISPATCH": self.dispatch
|
"DISPATCH": self.dispatch
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue