8000 GH-100240: Generic freelist, applied to ints by iritkatriel · Pull Request #101453 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

GH-100240: Generic freelist, applied to ints #101453

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

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
use _PyLong_Free in specialized bytecodes
  • Loading branch information
iritkatriel committed Feb 3, 2023
commit 1d811986848b84e3ce191fc283acd59638d563ce
2 changes: 2 additions & 0 deletions Include/internal/pycore_long.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ _PyLong_IsPositiveSingleDigit(PyObject* sub) {
return ((size_t)signed_size) <= 1;
}

void _PyLong_Free(PyLongObject *op);

#ifdef __cplusplus
}
#endif
Expand Down
6 changes: 3 additions & 3 deletions Objects/longobject.c
8000
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,8 @@ _PyLong_FromSTwoDigits(stwodigits x)
return _PyLong_FromLarge(x);
}

static void
int_dealloc(PyLongObject *op)
void
_PyLong_Free(PyLongObject *op)
{
if (PyLong_CheckExact(op) && IS_MEDIUM_VALUE(op)) {
PyInterpreterState *interp = _PyInterpreterState_GET();
Expand Down Expand Up @@ -6307,7 +6307,7 @@ PyTypeObject PyLong_Type = {
"int", /* tp_name */
offsetof(PyLongObject, long_value.ob_digit), /* tp_basicsize */
sizeof(digit), /* tp_itemsize */
(destructor)int_dealloc, /* tp_dealloc */
(destructor)_PyLong_Free, /* tp_dealloc */
0, /* tp_vectorcall_offset */
0, /* tp_getattr */
0, /* tp_setattr */
Expand Down
22 changes: 11 additions & 11 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ dummy_func(
DEOPT_IF(!PyLong_CheckExact(right), BINARY_OP);
STAT_INC(BINARY_OP, hit);
prod = _PyLong_Multiply((PyLongObject *)left, (PyLongObject *)right);
_Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free);
8000 _Py_DECREF_SPECIALIZED(left, (destructor)PyObject_Free);
_Py_DECREF_SPECIALIZED(right, (destructor)_PyLong_Free);
_Py_DECREF_SPECIALIZED(left, (destructor)_PyLong_Free);
ERROR_IF(prod == NULL, error);
}

Expand All @@ -207,8 +207,8 @@ dummy_func(
DEOPT_IF(!PyLong_CheckExact(right), BINARY_OP);
STAT_INC(BINARY_OP, hit);
sub = _PyLong_Subtract((PyLongObject *)left, (PyLongObject *)right);
_Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free);
_Py_DECREF_SPECIALIZED(left, (destructor)PyObject_Free);
_Py_DECREF_SPECIALIZED(right, (destructor)_PyLong_Free);
_Py_DECREF_SPECIALIZED(left, (destructor)_PyLong_Free);
ERROR_IF(sub == NULL, error);
}

Expand Down Expand Up @@ -290,8 +290,8 @@ dummy_func(
DEOPT_IF(Py_TYPE(right) != Py_TYPE(left), BINARY_OP);
STAT_INC(BINARY_OP, hit);
sum = _PyLong_Add((PyLongObject *)left, (PyLongObject *)right);
_Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free);
_Py_DECREF_SPECIALIZED(left, (destructor)PyObject_Free);
_Py_DECREF_SPECIALIZED(right, (destructor)_PyLong_Free);
_Py_DECREF_SPECIALIZED(left, (destructor)_PyLong_Free);
ERROR_IF(sum == NULL, error);
}

Expand Down Expand Up @@ -364,7 +364,7 @@ dummy_func(
res = PyList_GET_ITEM(list, index);
assert(res != NULL);
Py_INCREF(res);
_Py_DECREF_SPECIALIZED(sub, (destructor)PyObject_Free);
_Py_DECREF_SPECIALIZED(sub, (destructor)_PyLong_Free);
Py_DECREF(list);
}

Expand All @@ -382,7 +382,7 @@ dummy_func(
res = PyTuple_GET_ITEM(tuple, index);
assert(res != NULL);
Py_INCREF(res);
_Py_DECREF_SPECIALIZED(sub, (destructor)PyObject_Free);
_Py_DECREF_SPECIALIZED(sub, (destructor)_PyLong_Free);
Py_DECREF(tuple);
}

Expand Down Expand Up @@ -478,7 +478,7 @@ dummy_func(
PyList_SET_ITEM(list, index, value);
assert(old_value != NULL);
Py_DECREF(old_value);
_Py_DECREF_SPECIALIZED(sub, (destructor)PyObject_Free);
_Py_DECREF_SPECIALIZED(sub, (destructor)_PyLong_Free);
Py_DECREF(list);
}

Expand Down Expand Up @@ -1838,8 +1838,8 @@ dummy_func(
Py_ssize_t iright = Py_SIZE(right) * ((PyLongObject *)right)->long_value.ob_digit[0];
// 2 if <, 4 if >, 8 if ==; this matches the low 4 bits of the oparg
int sign_ish = COMPARISON_BIT(ileft, iright);
_Py_DECREF_SPECIALIZED(left, (destructor)PyObject_Free);
_Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free);
_Py_DECREF_SPECIALIZED(left, (destructor)_PyLong_Free);
_Py_DECREF_SPECIALIZED(right, (destructor)_PyLong_Free);
if (sign_ish & oparg) {
int offset = _Py_OPARG(next_instr[1]);
JUMPBY(offset);
Expand Down
22 changes: 11 additions & 11 deletions Python/generated_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0