Skip to content

Commit ea43b6d

Browse files
committed
Revert changes to _PyLong_Add as not relevant to this PR
1 parent 036ffc5 commit ea43b6d

File tree

6 files changed

+13
-42
lines changed

6 files changed

+13
-42
lines changed

Include/internal/pycore_long.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ PyAPI_DATA(PyObject*) _PyLong_Rshift(PyObject *, int64_t);
113113
// Export for 'math' shared extension
114114
PyAPI_DATA(PyObject*) _PyLong_Lshift(PyObject *, int64_t);
115115

116-
PyAPI_FUNC(_PyStackRef) _PyLong_Add(PyLongObject *left, PyLongObject *right);
116+
PyAPI_FUNC(PyObject*) _PyLong_Add(PyLongObject *left, PyLongObject *right);
117117
PyAPI_FUNC(PyObject*) _PyLong_Multiply(PyLongObject *left, PyLongObject *right);
118118
PyAPI_FUNC(PyObject*) _PyLong_Subtract(PyLongObject *left, PyLongObject *right);
119119

Include/internal/pycore_stackref.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -339,12 +339,6 @@ static const _PyStackRef PyStackRef_NULL = { .bits = PyStackRef_NULL_BITS };
339339
#define PyStackRef_False ((_PyStackRef){.bits = ((uintptr_t)&_Py_FalseStruct) | Py_TAG_IMMORTAL })
340340
#define PyStackRef_None ((_PyStackRef){.bits = ((uintptr_t)&_Py_NoneStruct) | Py_TAG_IMMORTAL })
341341

342-
// #define PyStackRef_IsTrue(ref) ((ref).bits == (((uintptr_t)&_Py_TrueStruct) | Py_TAG_IMMORTAL))
343-
// #define PyStackRef_IsFalse(ref) ((ref).bits == (((uintptr_t)&_Py_FalseStruct) | Py_TAG_IMMORTAL))
344-
// #define
345-
346-
/* We should be able to guarantee that the tag bits are set for immortal objects */
347-
348342
#define PyStackRef_IsTrue(REF) ((REF).bits == (((uintptr_t)&_Py_TrueStruct) | Py_TAG_IMMORTAL))
349343
#define PyStackRef_IsFalse(REF) ((REF).bits == (((uintptr_t)&_Py_FalseStruct) | Py_TAG_IMMORTAL))
350344
#define PyStackRef_IsNone(REF) ((REF).bits == (((uintptr_t)&_Py_NoneStruct) | Py_TAG_IMMORTAL))

Objects/longobject.c

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -315,27 +315,6 @@ _PyLong_FromSTwoDigits(stwodigits x)
315315
return (PyLongObject*)_PyLong_FromLarge(x);
316316
}
317317

318-
/* Create a new int object from a C word-sized int, return a stackref */
319-
static inline _PyStackRef
320-
_PyLongRef_FromSTwoDigitsRef(stwodigits x)
321-
{
322-
if (IS_SMALL_INT(x)) {
323-
return PyStackRef_FromPyObjectImmortal(get_small_int((sdigit)x));
324-
}
325-
assert(x != 0);
326-
PyObject *res;
327-
if (is_medium_int(x)) {
328-
res = _PyLong_FromMedium((sdigit)x);
329-
}
330-
else {
331-
res = _PyLong_FromLarge(x);
332-
}
333-
if (res == NULL) {
334-
return PyStackRef_NULL;
335-
}
336-
return PyStackRef_FromPyObjectStealMortal(res);
337-
}
338-
339318
/* If a freshly-allocated int is already shared, it must
340319
be a small integer, so negating it must go to PyLong_FromLong */
341320
Py_LOCAL_INLINE(void)
@@ -3897,14 +3876,10 @@ long_add(PyLongObject *a, PyLongObject *b)
38973876
return z;
38983877
}
38993878

3900-
_PyStackRef
3879+
PyObject *
39013880
_PyLong_Add(PyLongObject *a, PyLongObject *b)
39023881
{
3903-
if (_PyLong_BothAreCompact(a, b)) {
3904-
stwodigits z = medium_value(a) + medium_value(b);
3905-
return _PyLongRef_FromSTwoDigitsRef(z);
3906-
}
3907-
return PyStackRef_FromPyObjectSteal((PyObject*)long_add(a, b));
3882+
return (PyObject*)long_add(a, b);
39083883
}
39093884

39103885
static PyObject *

Python/bytecodes.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,11 +601,12 @@ dummy_func(
601601
assert(PyLong_CheckExact(right_o));
602602

603603
STAT_INC(BINARY_OP, hit);
604-
res = _PyLong_Add((PyLongObject *)left_o, (PyLongObject *)right_o);
604+
PyObject *res_o = _PyLong_Add((PyLongObject *)left_o, (PyLongObject *)right_o);
605605
PyStackRef_CLOSE_SPECIALIZED(right, _PyLong_ExactDealloc);
606606
PyStackRef_CLOSE_SPECIALIZED(left, _PyLong_ExactDealloc);
607607
INPUTS_DEAD();
608-
ERROR_IF(PyStackRef_IsNull(res), error);
608+
ERROR_IF(res_o == NULL, error);
609+
res = PyStackRef_FromPyObjectSteal(res_o);
609610
}
610611

611612
pure op(_BINARY_OP_SUBTRACT_INT, (left, right -- res)) {

Python/executor_cases.c.h

Lines changed: 4 additions & 4 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 & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)