Skip to content

Commit db8247e

Browse files
Apply review suggestions
1 parent 6b73046 commit db8247e

File tree

4 files changed

+19
-17
lines changed

4 files changed

+19
-17
lines changed

Objects/longobject.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static inline void
4343
_Py_DECREF_INT(PyLongObject *op)
4444
{
4545
assert(PyLong_CheckExact(op));
46-
_Py_DECREF_SPECIALIZED((PyObject *)op, (destructor)PyObject_Free); // needs to be converted to freelist?
46+
_Py_DECREF_SPECIALIZED((PyObject *)op, (destructor) _PyLong_ExactDealloc);
4747
}
4848

4949
static inline int
@@ -222,7 +222,9 @@ _PyLong_FromMedium(sdigit x)
222222
assert(!IS_SMALL_INT(x));
223223
assert(is_medium_int(x));
224224

225-
PyLongObject *v = _Py_FREELIST_POP(PyLongObject, ints);
225+
// The small int cache is incompatible with _Py_NewReference which is called
226+
// by _Py_FREELIST_POP.
227+
PyLongObject *v = (PyLongObject *)_Py_FREELIST_POP_MEM(ints);
226228
if (v == NULL) {
227229
v = PyObject_Malloc(sizeof(PyLongObject));
228230
if (v == NULL) {
@@ -3618,13 +3620,13 @@ long_richcompare(PyObject *self, PyObject *other, int op)
36183620
void
36193621
_PyLong_ExactDealloc(PyObject *self)
36203622
{
3621-
assert(PyLong_CheckExact(self));
3622-
3623-
if (_PyLong_IsCompact((PyLongObject *)self)) {
3624-
_Py_FREELIST_FREE(ints, self, PyObject_Free);
3625-
return;
3623+
if (PyLong_CheckExact(self)) {
3624+
if (_PyLong_IsCompact((PyLongObject *)self)) {
3625+
_Py_FREELIST_FREE(ints, self, PyObject_Free);
3626+
return;
3627+
}
36263628
}
3627-
PyObject_Free(self);
3629+
Py_TYPE(self)->tp_free(self);
36283630
}
36293631

36303632
static void

Python/bytecodes.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ dummy_func(
516516
STAT_INC(BINARY_OP, hit);
517517
PyObject *res_o = _PyLong_Multiply((PyLongObject *)left_o, (PyLongObject *)right_o);
518518
PyStackRef_CLOSE_SPECIALIZED(right, (destructor)_PyLong_ExactDealloc);
519-
PyStackRef_CLOSE_SPECIALIZED(left, (destructor)PyObject_Free); // needs to be converted to freelist
519+
PyStackRef_CLOSE_SPECIALIZED(left, (destructor)_PyLong_ExactDealloc);
520520
INPUTS_DEAD();
521521
ERROR_IF(res_o == NULL, error);
522522
res = PyStackRef_FromPyObjectSteal(res_o);
@@ -529,7 +529,7 @@ dummy_func(
529529
STAT_INC(BINARY_OP, hit);
530530
PyObject *res_o = _PyLong_Add((PyLongObject *)left_o, (PyLongObject *)right_o);
531531
PyStackRef_CLOSE_SPECIALIZED(right, (destructor)_PyLong_ExactDealloc);
532-
PyStackRef_CLOSE_SPECIALIZED(left, (destructor)PyObject_Free); // needs to be converted to freelist
532+
PyStackRef_CLOSE_SPECIALIZED(left, (destructor)_PyLong_ExactDealloc);
533533
INPUTS_DEAD();
534534
ERROR_IF(res_o == NULL, error);
535535
res = PyStackRef_FromPyObjectSteal(res_o);
@@ -542,7 +542,7 @@ dummy_func(
542542
STAT_INC(BINARY_OP, hit);
543543
PyObject *res_o = _PyLong_Subtract((PyLongObject *)left_o, (PyLongObject *)right_o);
544544
PyStackRef_CLOSE_SPECIALIZED(right, (destructor)_PyLong_ExactDealloc);
545-
PyStackRef_CLOSE_SPECIALIZED(left, (destructor)PyObject_Free); // needs to be converted to freelist
545+
PyStackRef_CLOSE_SPECIALIZED(left, (destructor)_PyLong_ExactDealloc);
546546
INPUTS_DEAD();
547547
ERROR_IF(res_o == NULL, error);
548548
res = PyStackRef_FromPyObjectSteal(res_o);

Python/executor_cases.c.h

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/generated_cases.c.h

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)