mirror of
https://github.com/python/cpython.git
synced 2025-08-22 17:55:18 +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
|
@ -26,6 +26,7 @@
|
|||
#include "pycore_pyerrors.h" // _PyErr_GetRaisedException()
|
||||
#include "pycore_pystate.h" // _PyInterpreterState_GET()
|
||||
#include "pycore_range.h" // _PyRangeIterObject
|
||||
#include "pycore_long.h" // _PyLong_ExactDealloc()
|
||||
#include "pycore_setobject.h" // _PySet_NextEntry()
|
||||
#include "pycore_sliceobject.h" // _PyBuildSlice_ConsumeRefs
|
||||
#include "pycore_tuple.h" // _PyTuple_ITEMS()
|
||||
|
@ -514,8 +515,8 @@ dummy_func(
|
|||
|
||||
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);
|
||||
INPUTS_DEAD();
|
||||
ERROR_IF(res_o == NULL, error);
|
||||
res = PyStackRef_FromPyObjectSteal(res_o);
|
||||
|
@ -527,8 +528,8 @@ dummy_func(
|
|||
|
||||
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);
|
||||
INPUTS_DEAD();
|
||||
ERROR_IF(res_o == NULL, error);
|
||||
res = PyStackRef_FromPyObjectSteal(res_o);
|
||||
|
@ -540,8 +541,8 @@ dummy_func(
|
|||
|
||||
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);
|
||||
INPUTS_DEAD();
|
||||
ERROR_IF(res_o == NULL, error);
|
||||
res = PyStackRef_FromPyObjectSteal(res_o);
|
||||
|
@ -801,7 +802,7 @@ dummy_func(
|
|||
assert(res_o != NULL);
|
||||
Py_INCREF(res_o);
|
||||
#endif
|
||||
PyStackRef_CLOSE_SPECIALIZED(sub_st, (destructor)PyObject_Free);
|
||||
PyStackRef_CLOSE_SPECIALIZED(sub_st, _PyLong_ExactDealloc);
|
||||
DEAD(sub_st);
|
||||
PyStackRef_CLOSE(list_st);
|
||||
res = PyStackRef_FromPyObjectSteal(res_o);
|
||||
|
@ -821,7 +822,7 @@ dummy_func(
|
|||
DEOPT_IF(Py_ARRAY_LENGTH(_Py_SINGLETON(strings).ascii) <= c);
|
||||
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);
|
||||
DEAD(sub_st);
|
||||
PyStackRef_CLOSE(str_st);
|
||||
res = PyStackRef_FromPyObjectSteal(res_o);
|
||||
|
@ -842,7 +843,7 @@ dummy_func(
|
|||
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);
|
||||
DEAD(sub_st);
|
||||
PyStackRef_CLOSE(tuple_st);
|
||||
res = PyStackRef_FromPyObjectSteal(res_o);
|
||||
|
@ -959,7 +960,7 @@ dummy_func(
|
|||
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);
|
||||
DEAD(sub_st);
|
||||
PyStackRef_CLOSE(list_st);
|
||||
}
|
||||
|
@ -2476,9 +2477,9 @@ dummy_func(
|
|||
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(left, _PyLong_ExactDealloc);
|
||||
DEAD(left);
|
||||
PyStackRef_CLOSE_SPECIALIZED(right, (destructor)PyObject_Free);
|
||||
PyStackRef_CLOSE_SPECIALIZED(right, _PyLong_ExactDealloc);
|
||||
DEAD(right);
|
||||
res = (sign_ish & oparg) ? PyStackRef_True : PyStackRef_False;
|
||||
// It's always a bool, so we don't care about oparg & 16.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue