mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-126868: Add freelist for compact int objects (GH-126865)
This commit is contained in:
parent
9b4bbf4401
commit
5fc6bb2754
8 changed files with 102 additions and 55 deletions
24
Python/generated_cases.c.h
generated
24
Python/generated_cases.c.h
generated
|
@ -118,8 +118,8 @@
|
|||
PyObject *right_o = PyStackRef_AsPyObjectBorrow(right);
|
||||
STAT_INC(BINARY_OP, hit);
|
||||
PyObject *res_o = _PyLong_Add((PyLongObject *)left_o, (PyLongObject *)right_o);
|
||||
PyStackRef_CLOSE_SPECIALIZED(right, (destructor)PyObject_Free);
|
||||
PyStackRef_CLOSE_SPECIALIZED(left, (destructor)PyObject_Free);
|
||||
PyStackRef_CLOSE_SPECIALIZED(right, _PyLong_ExactDealloc);
|
||||
PyStackRef_CLOSE_SPECIALIZED(left, _PyLong_ExactDealloc);
|
||||
if (res_o == NULL) goto pop_2_error;
|
||||
res = PyStackRef_FromPyObjectSteal(res_o);
|
||||
}
|
||||
|
@ -285,8 +285,8 @@
|
|||
PyObject *right_o = PyStackRef_AsPyObjectBorrow(right);
|
||||
STAT_INC(BINARY_OP, hit);
|
||||
PyObject *res_o = _PyLong_Multiply((PyLongObject *)left_o, (PyLongObject *)right_o);
|
||||
PyStackRef_CLOSE_SPECIALIZED(right, (destructor)PyObject_Free);
|
||||
PyStackRef_CLOSE_SPECIALIZED(left, (destructor)PyObject_Free);
|
||||
PyStackRef_CLOSE_SPECIALIZED(right, _PyLong_ExactDealloc);
|
||||
PyStackRef_CLOSE_SPECIALIZED(left, _PyLong_ExactDealloc);
|
||||
if (res_o == NULL) goto pop_2_error;
|
||||
res = PyStackRef_FromPyObjectSteal(res_o);
|
||||
}
|
||||
|
@ -356,8 +356,8 @@
|
|||
PyObject *right_o = PyStackRef_AsPyObjectBorrow(right);
|
||||
STAT_INC(BINARY_OP, hit);
|
||||
PyObject *res_o = _PyLong_Subtract((PyLongObject *)left_o, (PyLongObject *)right_o);
|
||||
PyStackRef_CLOSE_SPECIALIZED(right, (destructor)PyObject_Free);
|
||||
PyStackRef_CLOSE_SPECIALIZED(left, (destructor)PyObject_Free);
|
||||
PyStackRef_CLOSE_SPECIALIZED(right, _PyLong_ExactDealloc);
|
||||
PyStackRef_CLOSE_SPECIALIZED(left, _PyLong_ExactDealloc);
|
||||
if (res_o == NULL) goto pop_2_error;
|
||||
res = PyStackRef_FromPyObjectSteal(res_o);
|
||||
}
|
||||
|
@ -590,7 +590,7 @@
|
|||
assert(res_o != NULL);
|
||||
Py_INCREF(res_o);
|
||||
#endif
|
||||
PyStackRef_CLOSE_SPECIALIZED(sub_st, (destructor)PyObject_Free);
|
||||
PyStackRef_CLOSE_SPECIALIZED(sub_st, _PyLong_ExactDealloc);
|
||||
PyStackRef_CLOSE(list_st);
|
||||
res = PyStackRef_FromPyObjectSteal(res_o);
|
||||
stack_pointer[-2] = res;
|
||||
|
@ -622,7 +622,7 @@
|
|||
DEOPT_IF(Py_ARRAY_LENGTH(_Py_SINGLETON(strings).ascii) <= c, BINARY_SUBSCR);
|
||||
STAT_INC(BINARY_SUBSCR, hit);
|
||||
PyObject *res_o = (PyObject*)&_Py_SINGLETON(strings).ascii[c];
|
||||
PyStackRef_CLOSE_SPECIALIZED(sub_st, (destructor)PyObject_Free);
|
||||
PyStackRef_CLOSE_SPECIALIZED(sub_st, _PyLong_ExactDealloc);
|
||||
PyStackRef_CLOSE(str_st);
|
||||
res = PyStackRef_FromPyObjectSteal(res_o);
|
||||
stack_pointer[-2] = res;
|
||||
|
@ -654,7 +654,7 @@
|
|||
PyObject *res_o = PyTuple_GET_ITEM(tuple, index);
|
||||
assert(res_o != NULL);
|
||||
Py_INCREF(res_o);
|
||||
PyStackRef_CLOSE_SPECIALIZED(sub_st, (destructor)PyObject_Free);
|
||||
PyStackRef_CLOSE_SPECIALIZED(sub_st, _PyLong_ExactDealloc);
|
||||
PyStackRef_CLOSE(tuple_st);
|
||||
res = PyStackRef_FromPyObjectSteal(res_o);
|
||||
stack_pointer[-2] = res;
|
||||
|
@ -3333,8 +3333,8 @@
|
|||
Py_ssize_t iright = _PyLong_CompactValue((PyLongObject *)right_o);
|
||||
// 2 if <, 4 if >, 8 if ==; this matches the low 4 bits of the oparg
|
||||
int sign_ish = COMPARISON_BIT(ileft, iright);
|
||||
PyStackRef_CLOSE_SPECIALIZED(left, (destructor)PyObject_Free);
|
||||
PyStackRef_CLOSE_SPECIALIZED(right, (destructor)PyObject_Free);
|
||||
PyStackRef_CLOSE_SPECIALIZED(left, _PyLong_ExactDealloc);
|
||||
PyStackRef_CLOSE_SPECIALIZED(right, _PyLong_ExactDealloc);
|
||||
res = (sign_ish & oparg) ? PyStackRef_True : PyStackRef_False;
|
||||
// It's always a bool, so we don't care about oparg & 16.
|
||||
}
|
||||
|
@ -7721,7 +7721,7 @@
|
|||
assert(old_value != NULL);
|
||||
UNLOCK_OBJECT(list); // unlock before decrefs!
|
||||
Py_DECREF(old_value);
|
||||
PyStackRef_CLOSE_SPECIALIZED(sub_st, (destructor)PyObject_Free);
|
||||
PyStackRef_CLOSE_SPECIALIZED(sub_st, _PyLong_ExactDealloc);
|
||||
PyStackRef_CLOSE(list_st);
|
||||
stack_pointer += -3;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue