#include "pycore_bitutils.h" // _Py_popcount32()
#include "pycore_initconfig.h" // _PyStatus_OK()
#include "pycore_long.h" // _Py_SmallInts
-#include "pycore_object.h" // _PyObject_InitVar()
+#include "pycore_object.h" // _PyObject_Init()
#include "pycore_pystate.h" // _Py_IsMainInterpreter()
#include "pycore_runtime.h" // _PY_NSMALLPOSINTS
#include "pycore_structseq.h" // _PyStructSequence_FiniType()
[clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=ec0275e3422a36e3]*/
-/* Is this PyLong of size 1, 0 or -1? */
-#define IS_MEDIUM_VALUE(x) (((size_t)Py_SIZE(x)) + 1U < 3U)
-
-/* convert a PyLong of size 1, 0 or -1 to a C integer */
-static inline stwodigits
-medium_value(PyLongObject *x)
-{
- assert(IS_MEDIUM_VALUE(x));
- return ((stwodigits)Py_SIZE(x)) * x->long_value.ob_digit[0];
-}
+#define medium_value(x) ((stwodigits)_PyLong_CompactValue(x))
#define IS_SMALL_INT(ival) (-_PY_NSMALLNEGINTS <= (ival) && (ival) < _PY_NSMALLPOSINTS)
#define IS_SMALL_UINT(ival) ((ival) < _PY_NSMALLPOSINTS)
static PyLongObject *
maybe_small_long(PyLongObject *v)
{
- if (v && IS_MEDIUM_VALUE(v)) {
+ if (v && _PyLong_IsCompact(v)) {
stwodigits ival = medium_value(v);
if (IS_SMALL_INT(ival)) {
_Py_DECREF_INT(v);
static PyLongObject *
long_normalize(PyLongObject *v)
{
- Py_ssize_t j = Py_ABS(Py_SIZE(v));
+ Py_ssize_t j = _PyLong_DigitCount(v);
Py_ssize_t i = j;
while (i > 0 && v->long_value.ob_digit[i-1] == 0)
--i;
if (i != j) {
- Py_SET_SIZE(v, (Py_SIZE(v) < 0) ? -(i) : i);
+ if (i == 0) {
+ _PyLong_SetSignAndDigitCount(v, 0, 0);
+ }
+ else {
+ _PyLong_SetDigitCount(v, i);
+ }
}
return v;
}
PyLongObject *
_PyLong_New(Py_ssize_t size)
{
+ assert(size >= 0);
PyLongObject *result;
if (size > (Py_ssize_t)MAX_LONG_DIGITS) {
PyErr_SetString(PyExc_OverflowError,
Py_ssize_t ndigits = size ? size : 1;
/* Number of bytes needed is: offsetof(PyLongObject, ob_digit) +
sizeof(digit)*size. Previous incarnations of this code used
- sizeof(PyVarObject) instead of the offsetof, but this risks being
- incorrect in the presence of padding between the PyVarObject header
+ sizeof() instead of the offsetof, but this risks being
+ incorrect in the presence of padding between the header
and the digits. */
result = PyObject_Malloc(offsetof(PyLongObject, long_value.ob_digit) +
ndigits*sizeof(digit));
PyErr_NoMemory();
return NULL;
}
- _PyObject_InitVar((PyVarObject*)result, &PyLong_Type, size);
+ _PyLong_SetSignAndDigitCount(result, size != 0, size);
+ _PyObject_Init((PyObject*)result, &PyLong_Type);
+ return result;
+}
+
+PyLongObject *
+_PyLong_FromDigits(int negative, Py_ssize_t digit_count, digit *digits)
+{
+ assert(digit_count >= 0);
+ if (digit_count == 0) {
+ return (PyLongObject *)Py_NewRef(_PyLong_GetZero());
+ }
+ PyLongObject *result = _PyLong_New(digit_count);
+ if (result == NULL) {
+ PyErr_NoMemory();
+ return NULL;
+ }
+ _PyLong_SetSignAndDigitCount(result, negative?-1:1, digit_count);
+ memcpy(result->long_value.ob_digit, digits, digit_count * sizeof(digit));
return result;
}
PyObject *
_PyLong_Copy(PyLongObject *src)
{
- PyLongObject *result;
- Py_ssize_t i;
-
assert(src != NULL);
- i = Py_SIZE(src);
- if (i < 0)
- i = -(i);
- if (i < 2) {
+
+ if (_PyLong_IsCompact(src)) {
stwodigits ival = medium_value(src);
if (IS_SMALL_INT(ival)) {
return get_small_int((sdigit)ival);
}
}
- result = _PyLong_New(i);
- if (result != NULL) {
- Py_SET_SIZE(result, Py_SIZE(src));
- while (--i >= 0) {
- result->long_value.ob_digit[i] = src->long_value.ob_digit[i];
- }
- }
- return (PyObject *)result;
+ Py_ssize_t size = _PyLong_DigitCount(src);
+ return (PyObject *)_PyLong_FromDigits(_PyLong_IsNegative(src), size, src->long_value.ob_digit);
}
static PyObject *
PyErr_NoMemory();
return NULL;
}
- Py_ssize_t sign = x < 0 ? -1: 1;
digit abs_x = x < 0 ? -x : x;
- _PyObject_InitVar((PyVarObject*)v, &PyLong_Type, sign);
+ _PyLong_SetSignAndDigitCount(v, x<0?-1:1, 1);
+ _PyObject_Init((PyObject*)v, &PyLong_Type);
v->long_value.ob_digit[0] = abs_x;
return (PyObject*)v;
}
PyLongObject *v = _PyLong_New(ndigits);
if (v != NULL) {
digit *p = v->long_value.ob_digit;
- Py_SET_SIZE(v, ndigits * sign);
+ _PyLong_SetSignAndDigitCount(v, sign, ndigits);
t = abs_ival;
while (t) {
*p++ = Py_SAFE_DOWNCAST(
return _PyLong_FromLarge(x);
}
-int
-_PyLong_AssignValue(PyObject **target, Py_ssize_t value)
-{
- PyObject *old = *target;
- if (IS_SMALL_INT(value)) {
- *target = get_small_int(Py_SAFE_DOWNCAST(value, Py_ssize_t, sdigit));
- Py_XDECREF(old);
- return 0;
- }
- else if (old != NULL && PyLong_CheckExact(old) &&
- Py_REFCNT(old) == 1 && Py_SIZE(old) == 1 &&
- (size_t)value <= PyLong_MASK)
- {
- // Mutate in place if there are no other references the old
- // object. This avoids an allocation in a common case.
- // Since the primary use-case is iterating over ranges, which
- // are typically positive, only do this optimization
- // for positive integers (for now).
- ((PyLongObject *)old)->long_value.ob_digit[0] =
- Py_SAFE_DOWNCAST(value, Py_ssize_t, digit);
- return 0;
- }
- else {
- *target = PyLong_FromSsize_t(value);
- Py_XDECREF(old);
- if (*target == NULL) {
- return -1;
- }
- return 0;
- }
-}
-
/* If a freshly-allocated int is already shared, it must
be a small integer, so negating it must go to PyLong_FromLong */
Py_LOCAL_INLINE(void)
x = (PyLongObject *)*x_p;
if (Py_REFCNT(x) == 1) {
- Py_SET_SIZE(x, -Py_SIZE(x));
+ _PyLong_FlipSign(x);
return;
}
v = _PyLong_New(ndigits);
if (v != NULL) {
digit *p = v->long_value.ob_digit;
- Py_SET_SIZE(v, ival < 0 ? -ndigits : ndigits);
+ _PyLong_SetSignAndDigitCount(v, ival < 0 ? -1 : 1, ndigits);
t = abs_ival;
while (t) {
*p++ = (digit)(t & PyLong_MASK);
frac = ldexp(frac, PyLong_SHIFT);
}
if (neg) {
- Py_SET_SIZE(v, -(Py_SIZE(v)));
+ _PyLong_FlipSign(v);
}
return (PyObject *)v;
}
return -1;
do_decref = 1;
}
-
- res = -1;
- i = Py_SIZE(v);
-
- switch (i) {
- case -1:
- res = -(sdigit)v->long_value.ob_digit[0];
- break;
- case 0:
- res = 0;
- break;
- case 1:
- res = v->long_value.ob_digit[0];
- break;
- default:
- sign = 1;
- x = 0;
- if (i < 0) {
- sign = -1;
- i = -(i);
+ if (_PyLong_IsCompact(v)) {
+#if SIZEOF_LONG < SIZEOF_VOID_P
+ intptr_t tmp = _PyLong_CompactValue(v);
+ res = (long)tmp;
+ if (res != tmp) {
+ *overflow = tmp < 0 ? -1 : 1;
}
+#else
+ res = _PyLong_CompactValue(v);
+#endif
+ }
+ else {
+ res = -1;
+ i = _PyLong_DigitCount(v);
+ sign = _PyLong_NonCompactSign(v);
+ x = 0;
while (--i >= 0) {
prev = x;
x = (x << PyLong_SHIFT) | v->long_value.ob_digit[i];
}
}
/* Haven't lost any bits, but casting to long requires extra
- * care (see comment above).
- */
+ * care (see comment above).
+ */
if (x <= (unsigned long)LONG_MAX) {
res = (long)x * sign;
}
}
v = (PyLongObject *)vv;
- i = Py_SIZE(v);
- switch (i) {
- case -1: return -(sdigit)v->long_value.ob_digit[0];
- case 0: return 0;
- case 1: return v->long_value.ob_digit[0];
+ if (_PyLong_IsCompact(v)) {
+ return _PyLong_CompactValue(v);
}
- sign = 1;
+ i = _PyLong_DigitCount(v);
+ sign = _PyLong_NonCompactSign(v);
x = 0;
- if (i < 0) {
- sign = -1;
- i = -(i);
- }
while (--i >= 0) {
prev = x;
x = (x << PyLong_SHIFT) | v->long_value.ob_digit[i];
}
v = (PyLongObject *)vv;
- i = Py_SIZE(v);
- x = 0;
- if (i < 0) {
+ if (_PyLong_IsNonNegativeCompact(v)) {
+#if SIZEOF_LONG < SIZEOF_VOID_P
+ intptr_t tmp = _PyLong_CompactValue(v);
+ unsigned long res = (unsigned long)tmp;
+ if (res != tmp) {
+ goto overflow;
+ }
+#else
+ return _PyLong_CompactValue(v);
+#endif
+ }
+ if (_PyLong_IsNegative(v)) {
PyErr_SetString(PyExc_OverflowError,
"can't convert negative value to unsigned int");
return (unsigned long) -1;
}
- switch (i) {
- case 0: return 0;
- case 1: return v->long_value.ob_digit[0];
- }
+ i = _PyLong_DigitCount(v);
+ x = 0;
while (--i >= 0) {
prev = x;
x = (x << PyLong_SHIFT) | v->long_value.ob_digit[i];
if ((x >> PyLong_SHIFT) != prev) {
- PyErr_SetString(PyExc_OverflowError,
- "Python int too large to convert "
- "to C unsigned long");
- return (unsigned long) -1;
+ goto overflow;
}
}
return x;
+overflow:
+ PyErr_SetString(PyExc_OverflowError,
+ "Python int too large to convert "
+ "to C unsigned long");
+ return (unsigned long) -1;
}
/* Get a C size_t from an int object. Returns (size_t)-1 and sets
}
v = (PyLongObject *)vv;
- i = Py_SIZE(v);
- x = 0;
- if (i < 0) {
+ if (_PyLong_IsNonNegativeCompact(v)) {
+ return _PyLong_CompactValue(v);
+ }
+ if (_PyLong_IsNegative(v)) {
PyErr_SetString(PyExc_OverflowError,
"can't convert negative value to size_t");
return (size_t) -1;
}
- switch (i) {
- case 0: return 0;
- case 1: return v->long_value.ob_digit[0];
- }
+ i = _PyLong_DigitCount(v);
+ x = 0;
while (--i >= 0) {
prev = x;
x = (x << PyLong_SHIFT) | v->long_value.ob_digit[i];
PyLongObject *v;
unsigned long x;
Py_ssize_t i;
- int sign;
if (vv == NULL || !PyLong_Check(vv)) {
PyErr_BadInternalCall();
return (unsigned long) -1;
}
v = (PyLongObject *)vv;
- i = Py_SIZE(v);
- switch (i) {
- case 0: return 0;
- case 1: return v->long_value.ob_digit[0];
+ if (_PyLong_IsCompact(v)) {
+ return (unsigned long)_PyLong_CompactValue(v);
}
- sign = 1;
+ i = _PyLong_DigitCount(v);
+ int sign = _PyLong_NonCompactSign(v);
x = 0;
- if (i < 0) {
- sign = -1;
- i = -i;
- }
while (--i >= 0) {
x = (x << PyLong_SHIFT) | v->long_value.ob_digit[i];
}
assert(v != NULL);
assert(PyLong_Check(v));
-
- return Py_SIZE(v) == 0 ? 0 : (Py_SIZE(v) < 0 ? -1 : 1);
+ if (_PyLong_IsCompact(v)) {
+ return _PyLong_CompactSign(v);
+ }
+ return _PyLong_NonCompactSign(v);
}
static int
assert(v != NULL);
assert(PyLong_Check(v));
- ndigits = Py_ABS(Py_SIZE(v));
+ ndigits = _PyLong_DigitCount(v);
assert(ndigits == 0 || v->long_value.ob_digit[ndigits - 1] != 0);
if (ndigits > 0) {
digit msd = v->long_value.ob_digit[ndigits - 1];
}
}
- Py_SET_SIZE(v, is_signed ? -idigit : idigit);
+ int sign = is_signed ? -1: 1;
+ if (idigit == 0) {
+ sign = 0;
+ }
+ _PyLong_SetSignAndDigitCount(v, sign, idigit);
return (PyObject *)maybe_small_long(long_normalize(v));
}
int little_endian, int is_signed)
{
Py_ssize_t i; /* index into v->long_value.ob_digit */
- Py_ssize_t ndigits; /* |v->ob_size| */
+ Py_ssize_t ndigits; /* number of digits */
twodigits accum; /* sliding register */
unsigned int accumbits; /* # bits in accum */
int do_twos_comp; /* store 2's-comp? is_signed and v < 0 */
assert(v != NULL && PyLong_Check(v));
- if (Py_SIZE(v) < 0) {
- ndigits = -(Py_SIZE(v));
+ ndigits = _PyLong_DigitCount(v);
+ if (_PyLong_IsNegative(v)) {
if (!is_signed) {
PyErr_SetString(PyExc_OverflowError,
"can't convert negative int to unsigned");
do_twos_comp = 1;
}
else {
- ndigits = Py_SIZE(v);
do_twos_comp = 0;
}
#if SIZEOF_VOID_P <= SIZEOF_LONG
long x;
- if (PyLong_Check(vv) && _PyLong_Sign(vv) < 0)
+ if (PyLong_Check(vv) && _PyLong_IsNegative((PyLongObject *)vv)) {
x = PyLong_AsLong(vv);
- else
+ }
+ else {
x = PyLong_AsUnsignedLong(vv);
+ }
#else
#if SIZEOF_LONG_LONG < SIZEOF_VOID_P
#endif
long long x;
- if (PyLong_Check(vv) && _PyLong_Sign(vv) < 0)
+ if (PyLong_Check(vv) && _PyLong_IsNegative((PyLongObject *)vv)) {
x = PyLong_AsLongLong(vv);
- else
+ }
+ else {
x = PyLong_AsUnsignedLongLong(vv);
+ }
#endif /* SIZEOF_VOID_P <= SIZEOF_LONG */
v = _PyLong_New(ndigits);
if (v != NULL) {
digit *p = v->long_value.ob_digit;
- Py_SET_SIZE(v, ival < 0 ? -ndigits : ndigits);
+ _PyLong_SetSignAndDigitCount(v, ival < 0 ? -1 : 1, ndigits);
t = abs_ival;
while (t) {
*p++ = (digit)(t & PyLong_MASK);
v = _PyLong_New(ndigits);
if (v != NULL) {
digit *p = v->long_value.ob_digit;
- Py_SET_SIZE(v, negative ? -ndigits : ndigits);
+ _PyLong_SetSignAndDigitCount(v, negative ? -1 : 1, ndigits);
t = abs_ival;
while (t) {
*p++ = (digit)(t & PyLong_MASK);
do_decref = 1;
}
- res = 0;
- switch(Py_SIZE(v)) {
- case -1:
- bytes = -(sdigit)v->long_value.ob_digit[0];
- break;
- case 0:
- bytes = 0;
- break;
- case 1:
- bytes = v->long_value.ob_digit[0];
- break;
- default:
+ if (_PyLong_IsCompact(v)) {
+ res = 0;
+ bytes = _PyLong_CompactValue(v);
+ }
+ else {
res = _PyLong_AsByteArray((PyLongObject *)v, (unsigned char *)&bytes,
SIZEOF_LONG_LONG, PY_LITTLE_ENDIAN, 1);
}
}
v = (PyLongObject*)vv;
- switch(Py_SIZE(v)) {
- case 0: return 0;
- case 1: return v->long_value.ob_digit[0];
+ if (_PyLong_IsNonNegativeCompact(v)) {
+ res = 0;
+ bytes = _PyLong_CompactValue(v);
}
-
- res = _PyLong_AsByteArray((PyLongObject *)vv, (unsigned char *)&bytes,
+ else {
+ res = _PyLong_AsByteArray((PyLongObject *)vv, (unsigned char *)&bytes,
SIZEOF_LONG_LONG, PY_LITTLE_ENDIAN, 0);
+ }
/* Plan 9 can't handle long long in ? : expressions */
if (res < 0)
return (unsigned long long) -1;
}
v = (PyLongObject *)vv;
- switch(Py_SIZE(v)) {
- case 0: return 0;
- case 1: return v->long_value.ob_digit[0];
+ if (_PyLong_IsCompact(v)) {
+ return (unsigned long long)(signed long long)_PyLong_CompactValue(v);
}
- i = Py_SIZE(v);
- sign = 1;
+ i = _PyLong_DigitCount(v);
+ sign = _PyLong_NonCompactSign(v);
x = 0;
- if (i < 0) {
- sign = -1;
- i = -i;
- }
while (--i >= 0) {
x = (x << PyLong_SHIFT) | v->long_value.ob_digit[i];
}
return -1;
do_decref = 1;
}
-
- res = -1;
- i = Py_SIZE(v);
-
- switch (i) {
- case -1:
- res = -(sdigit)v->long_value.ob_digit[0];
- break;
- case 0:
- res = 0;
- break;
- case 1:
- res = v->long_value.ob_digit[0];
- break;
- default:
- sign = 1;
+ if (_PyLong_IsCompact(v)) {
+ res = _PyLong_CompactValue(v);
+ }
+ else {
+ i = _PyLong_DigitCount(v);
+ sign = _PyLong_NonCompactSign(v);
x = 0;
- if (i < 0) {
- sign = -1;
- i = -(i);
- }
while (--i >= 0) {
prev = x;
x = (x << PyLong_SHIFT) + v->long_value.ob_digit[i];
if ((x >> PyLong_SHIFT) != prev) {
*overflow = sign;
+ res = -1;
goto exit;
}
}
}
else {
*overflow = sign;
- /* res is already set to -1 */
+ res = -1;
}
}
exit:
{
unsigned long uval;
- if (PyLong_Check(obj) && _PyLong_Sign(obj) < 0) {
+ if (PyLong_Check(obj) && _PyLong_IsNegative((PyLongObject *)obj)) {
PyErr_SetString(PyExc_ValueError, "value must be positive");
return 0;
}
{
unsigned long uval;
- if (PyLong_Check(obj) && _PyLong_Sign(obj) < 0) {
+ if (PyLong_Check(obj) && _PyLong_IsNegative((PyLongObject *)obj)) {
PyErr_SetString(PyExc_ValueError, "value must be positive");
return 0;
}
{
unsigned long uval;
- if (PyLong_Check(obj) && _PyLong_Sign(obj) < 0) {
+ if (PyLong_Check(obj) && _PyLong_IsNegative((PyLongObject *)obj)) {
PyErr_SetString(PyExc_ValueError, "value must be positive");
return 0;
}
{
unsigned long long uval;
- if (PyLong_Check(obj) && _PyLong_Sign(obj) < 0) {
+ if (PyLong_Check(obj) && _PyLong_IsNegative((PyLongObject *)obj)) {
PyErr_SetString(PyExc_ValueError, "value must be positive");
return 0;
}
{
size_t uval;
- if (PyLong_Check(obj) && _PyLong_Sign(obj) < 0) {
+ if (PyLong_Check(obj) && _PyLong_IsNegative((PyLongObject *)obj)) {
PyErr_SetString(PyExc_ValueError, "value must be positive");
return 0;
}
static PyLongObject *
divrem1(PyLongObject *a, digit n, digit *prem)
{
- const Py_ssize_t size = Py_ABS(Py_SIZE(a));
+ const Py_ssize_t size = _PyLong_DigitCount(a);
PyLongObject *z;
assert(n > 0 && n <= PyLong_MASK);
static PyLongObject *
rem1(PyLongObject *a, digit n)
{
- const Py_ssize_t size = Py_ABS(Py_SIZE(a));
+ const Py_ssize_t size = _PyLong_DigitCount(a);
assert(n > 0 && n <= PyLong_MASK);
return (PyLongObject *)PyLong_FromLong(
PyErr_BadInternalCall();
return -1;
}
- size_a = Py_ABS(Py_SIZE(a));
- negative = Py_SIZE(a) < 0;
+ size_a = _PyLong_DigitCount(a);
+ negative = _PyLong_IsNegative(a);
/* quick and dirty pre-check for overflowing the decimal digit limit,
based on the inequality 10/3 >= log2(10)
PyErr_BadInternalCall();
return -1;
}
- size_a = Py_ABS(Py_SIZE(a));
- negative = Py_SIZE(a) < 0;
+ size_a = _PyLong_DigitCount(a);
+ negative = _PyLong_IsNegative(a);
/* Compute a rough upper bound for the length of the string */
switch (base) {
*res = NULL;
return 0;
}
- Py_SET_SIZE(z, 0);
+ _PyLong_SetSignAndDigitCount(z, 0, 0);
/* `convwidth` consecutive input digits are treated as a single
* digit in base `convmultmax`.
/* Multiply z by convmult, and add c. */
pz = z->long_value.ob_digit;
- pzstop = pz + Py_SIZE(z);
+ pzstop = pz + _PyLong_DigitCount(z);
for (; pz < pzstop; ++pz) {
c += (twodigits)*pz * convmult;
*pz = (digit)(c & PyLong_MASK);
/* carry off the current end? */
if (c) {
assert(c < PyLong_BASE);
- if (Py_SIZE(z) < size_z) {
+ if (_PyLong_DigitCount(z) < size_z) {
*pz = (digit)c;
- Py_SET_SIZE(z, Py_SIZE(z) + 1);
+ assert(!_PyLong_IsNegative(z));
+ _PyLong_SetSignAndDigitCount(z, 1, _PyLong_DigitCount(z) + 1);
}
else {
PyLongObject *tmp;
/* Extremely rare. Get more space. */
- assert(Py_SIZE(z) == size_z);
+ assert(_PyLong_DigitCount(z) == size_z);
tmp = _PyLong_New(size_z + 1);
if (tmp == NULL) {
Py_DECREF(z);
/* reset the base to 0, else the exception message
doesn't make too much sense */
base = 0;
- if (Py_SIZE(z) != 0) {
+ if (!_PyLong_IsZero(z)) {
goto onError;
}
/* there might still be other problems, therefore base
/* Set sign and normalize */
if (sign < 0) {
- Py_SET_SIZE(z, -(Py_SIZE(z)));
+ _PyLong_FlipSign(z);
}
long_normalize(z);
z = maybe_small_long(z);
long_divrem(PyLongObject *a, PyLongObject *b,
PyLongObject **pdiv, PyLongObject **prem)
{
- Py_ssize_t size_a = Py_ABS(Py_SIZE(a)), size_b = Py_ABS(Py_SIZE(b));
+ Py_ssize_t size_a = _PyLong_DigitCount(a), size_b = _PyLong_DigitCount(b);
PyLongObject *z;
if (size_b == 0) {
The quotient z has the sign of a*b;
the remainder r has the sign of a,
so a = b*z + r. */
- if ((Py_SIZE(a) < 0) != (Py_SIZE(b) < 0)) {
+ if ((_PyLong_IsNegative(a)) != (_PyLong_IsNegative(b))) {
_PyLong_Negate(&z);
if (z == NULL) {
Py_CLEAR(*prem);
return -1;
}
}
- if (Py_SIZE(a) < 0 && Py_SIZE(*prem) != 0) {
+ if (_PyLong_IsNegative(a) && !_PyLong_IsZero(*prem)) {
_PyLong_Negate(prem);
if (*prem == NULL) {
Py_DECREF(z);
static int
long_rem(PyLongObject *a, PyLongObject *b, PyLongObject **prem)
{
- Py_ssize_t size_a = Py_ABS(Py_SIZE(a)), size_b = Py_ABS(Py_SIZE(b));
+ Py_ssize_t size_a = _PyLong_DigitCount(a), size_b = _PyLong_DigitCount(b);
if (size_b == 0) {
PyErr_SetString(PyExc_ZeroDivisionError,
return -1;
}
/* Set the sign. */
- if (Py_SIZE(a) < 0 && Py_SIZE(*prem) != 0) {
+ if (_PyLong_IsNegative(a) && !_PyLong_IsZero(*prem)) {
_PyLong_Negate(prem);
if (*prem == NULL) {
Py_CLEAR(*prem);
}
/* Unsigned int division with remainder -- the algorithm. The arguments v1
- and w1 should satisfy 2 <= Py_ABS(Py_SIZE(w1)) <= Py_ABS(Py_SIZE(v1)). */
+ and w1 should satisfy 2 <= _PyLong_DigitCount(w1) <= _PyLong_DigitCount(v1). */
static PyLongObject *
x_divrem(PyLongObject *v1, PyLongObject *w1, PyLongObject **prem)
that won't overflow a digit. */
/* allocate space; w will also be used to hold the final remainder */
- size_v = Py_ABS(Py_SIZE(v1));
- size_w = Py_ABS(Py_SIZE(w1));
+ size_v = _PyLong_DigitCount(v1);
+ size_w = _PyLong_DigitCount(w1);
assert(size_v >= size_w && size_w >= 2); /* Assert checks by div() */
v = _PyLong_New(size_v+1);
if (v == NULL) {
multiple of 4, rounding ties to a multiple of 8. */
static const int half_even_correction[8] = {0, -1, -2, 1, 0, -1, 2, 1};
- a_size = Py_ABS(Py_SIZE(a));
+ a_size = _PyLong_DigitCount(a);
if (a_size == 0) {
/* Special case for 0: significand 0.0, exponent 0. */
*e = 0;
}
*e = a_bits;
- return Py_SIZE(a) < 0 ? -dx : dx;
+ return _PyLong_IsNegative(a) ? -dx : dx;
overflow:
/* exponent > PY_SSIZE_T_MAX */
PyErr_SetString(PyExc_TypeError, "an integer is required");
return -1.0;
}
- if (IS_MEDIUM_VALUE(v)) {
+ if (_PyLong_IsCompact((PyLongObject *)v)) {
/* Fast path; single digit long (31 bits) will cast safely
to double. This improves performance of FP/long operations
by 20%.
static Py_ssize_t
long_compare(PyLongObject *a, PyLongObject *b)
{
- Py_ssize_t sign = Py_SIZE(a) - Py_SIZE(b);
+ if (_PyLong_BothAreCompact(a, b)) {
+ return _PyLong_CompactValue(a) - _PyLong_CompactValue(b);
+ }
+ Py_ssize_t sign = _PyLong_SignedDigitCount(a) - _PyLong_SignedDigitCount(b);
if (sign == 0) {
- Py_ssize_t i = Py_ABS(Py_SIZE(a));
+ Py_ssize_t i = _PyLong_DigitCount(a);
sdigit diff = 0;
while (--i >= 0) {
diff = (sdigit) a->long_value.ob_digit[i] - (sdigit) b->long_value.ob_digit[i];
break;
}
}
- sign = Py_SIZE(a) < 0 ? -diff : diff;
+ sign = _PyLong_IsNegative(a) ? -diff : diff;
}
return sign;
}
Py_ssize_t i;
int sign;
- i = Py_SIZE(v);
- switch(i) {
- case -1: return v->long_value.ob_digit[0]==1 ? -2 : -(sdigit)v->long_value.ob_digit[0];
- case 0: return 0;
- case 1: return v->long_value.ob_digit[0];
+ if (_PyLong_IsCompact(v)) {
+ x = _PyLong_CompactValue(v);
+ if (x == (Py_uhash_t)-1) {
+ x = (Py_uhash_t)-2;
+ }
+ return x;
}
- sign = 1;
+ i = _PyLong_DigitCount(v);
+ sign = _PyLong_NonCompactSign(v);
x = 0;
- if (i < 0) {
- sign = -1;
- i = -(i);
- }
while (--i >= 0) {
/* Here x is a quantity in the range [0, _PyHASH_MODULUS); we
want to compute x * 2**PyLong_SHIFT + v->long_value.ob_digit[i] modulo
static PyLongObject *
x_add(PyLongObject *a, PyLongObject *b)
{
- Py_ssize_t size_a = Py_ABS(Py_SIZE(a)), size_b = Py_ABS(Py_SIZE(b));
+ Py_ssize_t size_a = _PyLong_DigitCount(a), size_b = _PyLong_DigitCount(b);
PyLongObject *z;
Py_ssize_t i;
digit carry = 0;
static PyLongObject *
x_sub(PyLongObject *a, PyLongObject *b)
{
- Py_ssize_t size_a = Py_ABS(Py_SIZE(a)), size_b = Py_ABS(Py_SIZE(b));
+ Py_ssize_t size_a = _PyLong_DigitCount(a), size_b = _PyLong_DigitCount(b);
PyLongObject *z;
Py_ssize_t i;
int sign = 1;
}
assert(borrow == 0);
if (sign < 0) {
- Py_SET_SIZE(z, -Py_SIZE(z));
+ _PyLong_FlipSign(z);
}
return maybe_small_long(long_normalize(z));
}
PyObject *
_PyLong_Add(PyLongObject *a, PyLongObject *b)
{
- if (IS_MEDIUM_VALUE(a) && IS_MEDIUM_VALUE(b)) {
+ if (_PyLong_BothAreCompact(a, b)) {
return _PyLong_FromSTwoDigits(medium_value(a) + medium_value(b));
}
PyLongObject *z;
- if (Py_SIZE(a) < 0) {
- if (Py_SIZE(b) < 0) {
+ if (_PyLong_IsNegative(a)) {
+ if (_PyLong_IsNegative(b)) {
z = x_add(a, b);
if (z != NULL) {
/* x_add received at least one multiple-digit int,
That also means z is not an element of
small_ints, so negating it in-place is safe. */
assert(Py_REFCNT(z) == 1);
- Py_SET_SIZE(z, -(Py_SIZE(z)));
+ _PyLong_FlipSign(z);
}
}
else
z = x_sub(b, a);
}
else {
- if (Py_SIZE(b) < 0)
+ if (_PyLong_IsNegative(b))
z = x_sub(a, b);
else
z = x_add(a, b);
{
PyLongObject *z;
- if (IS_MEDIUM_VALUE(a) && IS_MEDIUM_VALUE(b)) {
+ if (_PyLong_BothAreCompact(a, b)) {
return _PyLong_FromSTwoDigits(medium_value(a) - medium_value(b));
}
- if (Py_SIZE(a) < 0) {
- if (Py_SIZE(b) < 0) {
+ if (_PyLong_IsNegative(a)) {
+ if (_PyLong_IsNegative(b)) {
z = x_sub(b, a);
}
else {
z = x_add(a, b);
if (z != NULL) {
- assert(Py_SIZE(z) == 0 || Py_REFCNT(z) == 1);
- Py_SET_SIZE(z, -(Py_SIZE(z)));
+ assert(_PyLong_IsZero(z) || Py_REFCNT(z) == 1);
+ _PyLong_FlipSign(z);
}
}
}
else {
- if (Py_SIZE(b) < 0)
+ if (_PyLong_IsNegative(b))
z = x_add(a, b);
else
z = x_sub(a, b);
x_mul(PyLongObject *a, PyLongObject *b)
{
PyLongObject *z;
- Py_ssize_t size_a = Py_ABS(Py_SIZE(a));
- Py_ssize_t size_b = Py_ABS(Py_SIZE(b));
+ Py_ssize_t size_a = _PyLong_DigitCount(a);
+ Py_ssize_t size_b = _PyLong_DigitCount(b);
Py_ssize_t i;
z = _PyLong_New(size_a + size_b);
if (z == NULL)
return NULL;
- memset(z->long_value.ob_digit, 0, Py_SIZE(z) * sizeof(digit));
+ memset(z->long_value.ob_digit, 0, _PyLong_DigitCount(z) * sizeof(digit));
if (a == b) {
/* Efficient squaring per HAC, Algorithm 14.16:
* http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf
{
PyLongObject *hi, *lo;
Py_ssize_t size_lo, size_hi;
- const Py_ssize_t size_n = Py_ABS(Py_SIZE(n));
+ const Py_ssize_t size_n = _PyLong_DigitCount(n);
size_lo = Py_MIN(size_n, size);
size_hi = size_n - size_lo;
static PyLongObject *
k_mul(PyLongObject *a, PyLongObject *b)
{
- Py_ssize_t asize = Py_ABS(Py_SIZE(a));
- Py_ssize_t bsize = Py_ABS(Py_SIZE(b));
+ Py_ssize_t asize = _PyLong_DigitCount(a);
+ Py_ssize_t bsize = _PyLong_DigitCount(b);
PyLongObject *ah = NULL;
PyLongObject *al = NULL;
PyLongObject *bh = NULL;
/* If a is small compared to b, splitting on b gives a degenerate
* case with ah==0, and Karatsuba may be (even much) less efficient
* than "grade school" then. However, we can still win, by viewing
- * b as a string of "big digits", each of width a->ob_size. That
+ * b as a string of "big digits", each of the same width as a. That
* leads to a sequence of balanced calls to k_mul.
*/
if (2 * asize <= bsize)
/* Split a & b into hi & lo pieces. */
shift = bsize >> 1;
if (kmul_split(a, shift, &ah, &al) < 0) goto fail;
- assert(Py_SIZE(ah) > 0); /* the split isn't degenerate */
+ assert(_PyLong_IsPositive(ah)); /* the split isn't degenerate */
if (a == b) {
bh = (PyLongObject*)Py_NewRef(ah);
if (ret == NULL) goto fail;
#ifdef Py_DEBUG
/* Fill with trash, to catch reference to uninitialized digits. */
- memset(ret->long_value.ob_digit, 0xDF, Py_SIZE(ret) * sizeof(digit));
+ memset(ret->long_value.ob_digit, 0xDF, _PyLong_DigitCount(ret) * sizeof(digit));
#endif
/* 2. t1 <- ah*bh, and copy into high digits of result. */
if ((t1 = k_mul(ah, bh)) == NULL) goto fail;
- assert(Py_SIZE(t1) >= 0);
- assert(2*shift + Py_SIZE(t1) <= Py_SIZE(ret));
+ assert(!_PyLong_IsNegative(t1));
+ assert(2*shift + _PyLong_DigitCount(t1) <= _PyLong_DigitCount(ret));
memcpy(ret->long_value.ob_digit + 2*shift, t1->long_value.ob_digit,
- Py_SIZE(t1) * sizeof(digit));
+ _PyLong_DigitCount(t1) * sizeof(digit));
/* Zero-out the digits higher than the ah*bh copy. */
- i = Py_SIZE(ret) - 2*shift - Py_SIZE(t1);
+ i = _PyLong_DigitCount(ret) - 2*shift - _PyLong_DigitCount(t1);
if (i)
- memset(ret->long_value.ob_digit + 2*shift + Py_SIZE(t1), 0,
+ memset(ret->long_value.ob_digit + 2*shift + _PyLong_DigitCount(t1), 0,
i * sizeof(digit));
/* 3. t2 <- al*bl, and copy into the low digits. */
Py_DECREF(t1);
goto fail;
}
- assert(Py_SIZE(t2) >= 0);
- assert(Py_SIZE(t2) <= 2*shift); /* no overlap with high digits */
- memcpy(ret->long_value.ob_digit, t2->long_value.ob_digit, Py_SIZE(t2) * sizeof(digit));
+ assert(!_PyLong_IsNegative(t2));
+ assert(_PyLong_DigitCount(t2) <= 2*shift); /* no overlap with high digits */
+ memcpy(ret->long_value.ob_digit, t2->long_value.ob_digit, _PyLong_DigitCount(t2) * sizeof(digit));
/* Zero out remaining digits. */
- i = 2*shift - Py_SIZE(t2); /* number of uninitialized digits */
+ i = 2*shift - _PyLong_DigitCount(t2); /* number of uninitialized digits */
if (i)
- memset(ret->long_value.ob_digit + Py_SIZE(t2), 0, i * sizeof(digit));
+ memset(ret->long_value.ob_digit + _PyLong_DigitCount(t2), 0, i * sizeof(digit));
/* 4 & 5. Subtract ah*bh (t1) and al*bl (t2). We do al*bl first
* because it's fresher in cache.
*/
- i = Py_SIZE(ret) - shift; /* # digits after shift */
- (void)v_isub(ret->long_value.ob_digit + shift, i, t2->long_value.ob_digit, Py_SIZE(t2));
+ i = _PyLong_DigitCount(ret) - shift; /* # digits after shift */
+ (void)v_isub(ret->long_value.ob_digit + shift, i, t2->long_value.ob_digit, _PyLong_DigitCount(t2));
_Py_DECREF_INT(t2);
- (void)v_isub(ret->long_value.ob_digit + shift, i, t1->long_value.ob_digit, Py_SIZE(t1));
+ (void)v_isub(ret->long_value.ob_digit + shift, i, t1->long_value.ob_digit, _PyLong_DigitCount(t1));
_Py_DECREF_INT(t1);
/* 6. t3 <- (ah+al)(bh+bl), and add into result. */
_Py_DECREF_INT(t1);
_Py_DECREF_INT(t2);
if (t3 == NULL) goto fail;
- assert(Py_SIZE(t3) >= 0);
+ assert(!_PyLong_IsNegative(t3));
/* Add t3. It's not obvious why we can't run out of room here.
* See the (*) comment after this function.
*/
- (void)v_iadd(ret->long_value.ob_digit + shift, i, t3->long_value.ob_digit, Py_SIZE(t3));
+ (void)v_iadd(ret->long_value.ob_digit + shift, i, t3->long_value.ob_digit, _PyLong_DigitCount(t3));
_Py_DECREF_INT(t3);
return long_normalize(ret);
/* b has at least twice the digits of a, and a is big enough that Karatsuba
* would pay off *if* the inputs had balanced sizes. View b as a sequence
- * of slices, each with a->ob_size digits, and multiply the slices by a,
- * one at a time. This gives k_mul balanced inputs to work with, and is
- * also cache-friendly (we compute one double-width slice of the result
+ * of slices, each with the same number of digits as a, and multiply the
+ * slices by a, one at a time. This gives k_mul balanced inputs to work with,
+ * and is also cache-friendly (we compute one double-width slice of the result
* at a time, then move on, never backtracking except for the helpful
* single-width slice overlap between successive partial sums).
*/
static PyLongObject *
k_lopsided_mul(PyLongObject *a, PyLongObject *b)
{
- const Py_ssize_t asize = Py_ABS(Py_SIZE(a));
- Py_ssize_t bsize = Py_ABS(Py_SIZE(b));
+ const Py_ssize_t asize = _PyLong_DigitCount(a);
+ Py_ssize_t bsize = _PyLong_DigitCount(b);
Py_ssize_t nbdone; /* # of b digits already multiplied */
PyLongObject *ret;
PyLongObject *bslice = NULL;
ret = _PyLong_New(asize + bsize);
if (ret == NULL)
return NULL;
- memset(ret->long_value.ob_digit, 0, Py_SIZE(ret) * sizeof(digit));
+ memset(ret->long_value.ob_digit, 0, _PyLong_DigitCount(ret) * sizeof(digit));
/* Successive slices of b are copied into bslice. */
bslice = _PyLong_New(asize);
/* Multiply the next slice of b by a. */
memcpy(bslice->long_value.ob_digit, b->long_value.ob_digit + nbdone,
nbtouse * sizeof(digit));
- Py_SET_SIZE(bslice, nbtouse);
+ assert(nbtouse >= 0);
+ _PyLong_SetSignAndDigitCount(bslice, 1, nbtouse);
product = k_mul(a, bslice);
if (product == NULL)
goto fail;
/* Add into result. */
- (void)v_iadd(ret->long_value.ob_digit + nbdone, Py_SIZE(ret) - nbdone,
- product->long_value.ob_digit, Py_SIZE(product));
+ (void)v_iadd(ret->long_value.ob_digit + nbdone, _PyLong_DigitCount(ret) - nbdone,
+ product->long_value.ob_digit, _PyLong_DigitCount(product));
_Py_DECREF_INT(product);
bsize -= nbtouse;
PyLongObject *z;
/* fast path for single-digit multiplication */
- if (IS_MEDIUM_VALUE(a) && IS_MEDIUM_VALUE(b)) {
+ if (_PyLong_BothAreCompact(a, b)) {
stwodigits v = medium_value(a) * medium_value(b);
return _PyLong_FromSTwoDigits(v);
}
z = k_mul(a, b);
/* Negate if exactly one of the inputs is negative. */
- if (((Py_SIZE(a) ^ Py_SIZE(b)) < 0) && z) {
+ if (!_PyLong_SameSign(a, b) && z) {
_PyLong_Negate(&z);
if (z == NULL)
return NULL;
sdigit right = b->long_value.ob_digit[0];
sdigit mod;
- assert(Py_ABS(Py_SIZE(a)) == 1);
- assert(Py_ABS(Py_SIZE(b)) == 1);
-
- if (Py_SIZE(a) == Py_SIZE(b)) {
- /* 'a' and 'b' have the same sign. */
+ assert(_PyLong_DigitCount(a) == 1);
+ assert(_PyLong_DigitCount(b) == 1);
+ sdigit sign = _PyLong_CompactSign(b);
+ if (_PyLong_SameSign(a, b)) {
mod = left % right;
}
else {
mod = right - 1 - (left - 1) % right;
}
- return PyLong_FromLong(mod * (sdigit)Py_SIZE(b));
+ return PyLong_FromLong(mod * sign);
}
/* Fast floor division for single-digit longs. */
sdigit right = b->long_value.ob_digit[0];
sdigit div;
- assert(Py_ABS(Py_SIZE(a)) == 1);
- assert(Py_ABS(Py_SIZE(b)) == 1);
+ assert(_PyLong_DigitCount(a) == 1);
+ assert(_PyLong_DigitCount(b) == 1);
- if (Py_SIZE(a) == Py_SIZE(b)) {
- /* 'a' and 'b' have the same sign. */
+ if (_PyLong_SameSign(a, b)) {
div = left / right;
}
else {
{
PyLongObject *div, *mod;
- if (Py_ABS(Py_SIZE(v)) == 1 && Py_ABS(Py_SIZE(w)) == 1) {
+ if (_PyLong_DigitCount(v) == 1 && _PyLong_DigitCount(w) == 1) {
/* Fast path for single-digit longs */
div = NULL;
if (pdiv != NULL) {
return 0;
}
#if WITH_PYLONG_MODULE
- Py_ssize_t size_v = Py_ABS(Py_SIZE(v)); /* digits in numerator */
- Py_ssize_t size_w = Py_ABS(Py_SIZE(w)); /* digits in denominator */
+ Py_ssize_t size_v = _PyLong_DigitCount(v); /* digits in numerator */
+ Py_ssize_t size_w = _PyLong_DigitCount(w); /* digits in denominator */
if (size_w > 300 && (size_v - size_w) > 150) {
/* Switch to _pylong.int_divmod(). If the quotient is small then
"schoolbook" division is linear-time so don't use in that case.
#endif
if (long_divrem(v, w, &div, &mod) < 0)
return -1;
- if ((Py_SIZE(mod) < 0 && Py_SIZE(w) > 0) ||
- (Py_SIZE(mod) > 0 && Py_SIZE(w) < 0)) {
+ if ((_PyLong_IsNegative(mod) && _PyLong_IsPositive(w)) ||
+ (_PyLong_IsPositive(mod) && _PyLong_IsNegative(w))) {
PyLongObject *temp;
temp = (PyLongObject *) long_add(mod, w);
Py_SETREF(mod, temp);
PyLongObject *mod;
assert(pmod);
- if (Py_ABS(Py_SIZE(v)) == 1 && Py_ABS(Py_SIZE(w)) == 1) {
+ if (_PyLong_DigitCount(v) == 1 && _PyLong_DigitCount(w) == 1) {
/* Fast path for single-digit longs */
*pmod = (PyLongObject *)fast_mod(v, w);
return -(*pmod == NULL);
}
if (long_rem(v, w, &mod) < 0)
return -1;
- if ((Py_SIZE(mod) < 0 && Py_SIZE(w) > 0) ||
- (Py_SIZE(mod) > 0 && Py_SIZE(w) < 0)) {
+ if ((_PyLong_IsNegative(mod) && _PyLong_IsPositive(w)) ||
+ (_PyLong_IsPositive(mod) && _PyLong_IsNegative(w))) {
PyLongObject *temp;
temp = (PyLongObject *) long_add(mod, w);
Py_SETREF(mod, temp);
CHECK_BINOP(a, b);
- if (Py_ABS(Py_SIZE(a)) == 1 && Py_ABS(Py_SIZE(b)) == 1) {
+ if (_PyLong_DigitCount((PyLongObject*)a) == 1 && _PyLong_DigitCount((PyLongObject*)b) == 1) {
return fast_floor_div((PyLongObject*)a, (PyLongObject*)b);
}
*/
/* Reduce to case where a and b are both positive. */
- a_size = Py_ABS(Py_SIZE(a));
- b_size = Py_ABS(Py_SIZE(b));
- negate = (Py_SIZE(a) < 0) ^ (Py_SIZE(b) < 0);
+ a_size = _PyLong_DigitCount(a);
+ b_size = _PyLong_DigitCount(b);
+ negate = (_PyLong_IsNegative(a)) != (_PyLong_IsNegative(b));
if (b_size == 0) {
PyErr_SetString(PyExc_ZeroDivisionError,
"division by zero");
inexact = 1;
}
long_normalize(x);
- x_size = Py_SIZE(x);
+ x_size = _PyLong_SignedDigitCount(x);
/* x //= b. If the remainder is nonzero, set inexact. We own the only
reference to x, so it's safe to modify it in-place. */
Py_SETREF(x, div);
if (x == NULL)
goto error;
- if (Py_SIZE(rem))
+ if (!_PyLong_IsZero(rem))
inexact = 1;
Py_DECREF(rem);
}
- x_size = Py_ABS(Py_SIZE(x));
+ x_size = _PyLong_DigitCount(x);
assert(x_size > 0); /* result of division is never zero */
x_bits = (x_size-1)*PyLong_SHIFT+bit_length_digit(x->long_value.ob_digit[x_size-1]);
PyLongObject *b, *c;
/* Should only ever be called for positive n */
- assert(Py_SIZE(n) > 0);
+ assert(_PyLong_IsPositive(n));
b = (PyLongObject *)PyLong_FromLong(1L);
if (b == NULL) {
Py_INCREF(n);
/* references now owned: a, b, c, n */
- while (Py_SIZE(n) != 0) {
+ while (!_PyLong_IsZero(n)) {
PyLongObject *q, *r, *s, *t;
if (l_divmod(a, n, &q, &r) == -1) {
Py_RETURN_NOTIMPLEMENTED;
}
- if (Py_SIZE(b) < 0 && c == NULL) {
+ if (_PyLong_IsNegative(b) && c == NULL) {
/* if exponent is negative and there's no modulus:
return a float. This works because we know
that this calls float_pow() which converts its
if (c) {
/* if modulus == 0:
raise ValueError() */
- if (Py_SIZE(c) == 0) {
+ if (_PyLong_IsZero(c)) {
PyErr_SetString(PyExc_ValueError,
"pow() 3rd argument cannot be 0");
goto Error;
/* if modulus < 0:
negativeOutput = True
modulus = -modulus */
- if (Py_SIZE(c) < 0) {
+ if (_PyLong_IsNegative(c)) {
negativeOutput = 1;
temp = (PyLongObject *)_PyLong_Copy(c);
if (temp == NULL)
/* if modulus == 1:
return 0 */
- if ((Py_SIZE(c) == 1) && (c->long_value.ob_digit[0] == 1)) {
+ if (_PyLong_IsNonNegativeCompact(c) && (c->long_value.ob_digit[0] == 1)) {
z = (PyLongObject *)PyLong_FromLong(0L);
goto Done;
}
/* if exponent is negative, negate the exponent and
replace the base with a modular inverse */
- if (Py_SIZE(b) < 0) {
+ if (_PyLong_IsNegative(b)) {
temp = (PyLongObject *)_PyLong_Copy(b);
if (temp == NULL)
goto Error;
base % modulus instead.
We could _always_ do this reduction, but l_mod() isn't cheap,
so we only do it when it buys something. */
- if (Py_SIZE(a) < 0 || Py_SIZE(a) > Py_SIZE(c)) {
+ if (_PyLong_IsNegative(a) || _PyLong_DigitCount(a) > _PyLong_DigitCount(c)) {
if (l_mod(a, c, &temp) < 0)
goto Error;
Py_SETREF(a, temp);
REDUCE(result); \
} while(0)
- i = Py_SIZE(b);
+ i = _PyLong_SignedDigitCount(b);
digit bi = i ? b->long_value.ob_digit[i-1] : 0;
digit bit;
if (i <= 1 && bi <= 3) {
pending = 0; \
} while(0)
- for (i = Py_SIZE(b) - 1; i >= 0; --i) {
+ for (i = _PyLong_SignedDigitCount(b) - 1; i >= 0; --i) {
const digit bi = b->long_value.ob_digit[i];
for (j = PyLong_SHIFT - 1; j >= 0; --j) {
const int bit = (bi >> j) & 1;
ABSORB_PENDING;
}
- if (negativeOutput && (Py_SIZE(z) != 0)) {
+ if (negativeOutput && !_PyLong_IsZero(z)) {
temp = (PyLongObject *)long_sub(z, c);
if (temp == NULL)
goto Error;
{
/* Implement ~x as -(x+1) */
PyLongObject *x;
- if (IS_MEDIUM_VALUE(v))
+ if (_PyLong_IsCompact(v))
return _PyLong_FromSTwoDigits(~medium_value(v));
x = (PyLongObject *) long_add(v, (PyLongObject *)_PyLong_GetOne());
if (x == NULL)
return NULL;
_PyLong_Negate(&x);
- /* No need for maybe_small_long here, since any small
- longs will have been caught in the Py_SIZE <= 1 fast path. */
+ /* No need for maybe_small_long here, since any small longs
+ will have been caught in the _PyLong_IsCompact() fast path. */
return (PyObject *)x;
}
long_neg(PyLongObject *v)
{
PyLongObject *z;
- if (IS_MEDIUM_VALUE(v))
+ if (_PyLong_IsCompact(v))
return _PyLong_FromSTwoDigits(-medium_value(v));
z = (PyLongObject *)_PyLong_Copy(v);
if (z != NULL)
- Py_SET_SIZE(z, -(Py_SIZE(v)));
+ _PyLong_FlipSign(z);
return (PyObject *)z;
}
static PyObject *
long_abs(PyLongObject *v)
{
- if (Py_SIZE(v) < 0)
+ if (_PyLong_IsNegative(v))
return long_neg(v);
else
return long_long((PyObject *)v);
static int
long_bool(PyLongObject *v)
{
- return Py_SIZE(v) != 0;
+ return !_PyLong_IsZero(v);
}
/* wordshift, remshift = divmod(shiftby, PyLong_SHIFT) */
divmod_shift(PyObject *shiftby, Py_ssize_t *wordshift, digit *remshift)
{
assert(PyLong_Check(shiftby));
- assert(Py_SIZE(shiftby) >= 0);
+ assert(!_PyLong_IsNegative((PyLongObject *)shiftby));
Py_ssize_t lshiftby = PyLong_AsSsize_t((PyObject *)shiftby);
if (lshiftby >= 0) {
*wordshift = lshiftby / PyLong_SHIFT;
*remshift = lshiftby % PyLong_SHIFT;
return 0;
}
- /* PyLong_Check(shiftby) is true and Py_SIZE(shiftby) >= 0, so it must
+ /* PyLong_Check(shiftby) is true and shiftby is not negative, so it must
be that PyLong_AsSsize_t raised an OverflowError. */
assert(PyErr_ExceptionMatches(PyExc_OverflowError));
PyErr_Clear();
assert(remshift < PyLong_SHIFT);
/* Fast path for small a. */
- if (IS_MEDIUM_VALUE(a)) {
+ if (_PyLong_IsCompact(a)) {
stwodigits m, x;
digit shift;
m = medium_value(a);
return _PyLong_FromSTwoDigits(x);
}
- a_negative = Py_SIZE(a) < 0;
- size_a = Py_ABS(Py_SIZE(a));
+ a_negative = _PyLong_IsNegative(a);
+ size_a = _PyLong_DigitCount(a);
if (a_negative) {
/* For negative 'a', adjust so that 0 < remshift <= PyLong_SHIFT,
significant `wordshift` digits of `a` is nonzero. Digit `wordshift`
of `2**shift - 1` has value `PyLong_MASK >> hishift`.
*/
- Py_SET_SIZE(z, -newsize);
+ _PyLong_SetSignAndDigitCount(z, -1, newsize);
digit sticky = 0;
for (Py_ssize_t j = 0; j < wordshift; j++) {
CHECK_BINOP(a, b);
- if (Py_SIZE(b) < 0) {
+ if (_PyLong_IsNegative((PyLongObject *)b)) {
PyErr_SetString(PyExc_ValueError, "negative shift count");
return NULL;
}
- if (Py_SIZE(a) == 0) {
+ if (_PyLong_IsZero((PyLongObject *)a)) {
return PyLong_FromLong(0);
}
if (divmod_shift(b, &wordshift, &remshift) < 0)
digit remshift;
assert(PyLong_Check(a));
- if (Py_SIZE(a) == 0) {
+ if (_PyLong_IsZero((PyLongObject *)a)) {
return PyLong_FromLong(0);
}
wordshift = shiftby / PyLong_SHIFT;
Py_ssize_t oldsize, newsize, i, j;
twodigits accum;
- if (wordshift == 0 && IS_MEDIUM_VALUE(a)) {
+ if (wordshift == 0 && _PyLong_IsCompact(a)) {
stwodigits m = medium_value(a);
// bypass undefined shift operator behavior
stwodigits x = m < 0 ? -(-m << remshift) : m << remshift;
return _PyLong_FromSTwoDigits(x);
}
- oldsize = Py_ABS(Py_SIZE(a));
+ oldsize = _PyLong_DigitCount(a);
newsize = oldsize + wordshift;
if (remshift)
++newsize;
z = _PyLong_New(newsize);
if (z == NULL)
return NULL;
- if (Py_SIZE(a) < 0) {
+ if (_PyLong_IsNegative(a)) {
assert(Py_REFCNT(z) == 1);
- Py_SET_SIZE(z, -Py_SIZE(z));
+ _PyLong_FlipSign(z);
}
for (i = 0; i < wordshift; i++)
z->long_value.ob_digit[i] = 0;
CHECK_BINOP(a, b);
- if (Py_SIZE(b) < 0) {
+ if (_PyLong_IsNegative((PyLongObject *)b)) {
PyErr_SetString(PyExc_ValueError, "negative shift count");
return NULL;
}
- if (Py_SIZE(a) == 0) {
+ if (_PyLong_IsZero((PyLongObject *)a)) {
return PyLong_FromLong(0);
}
if (divmod_shift(b, &wordshift, &remshift) < 0)
digit remshift;
assert(PyLong_Check(a));
- if (Py_SIZE(a) == 0) {
+ if (_PyLong_IsZero((PyLongObject *)a)) {
return PyLong_FromLong(0);
}
wordshift = shiftby / PyLong_SHIFT;
result back to sign-magnitude at the end. */
/* If a is negative, replace it by its two's complement. */
- size_a = Py_ABS(Py_SIZE(a));
- nega = Py_SIZE(a) < 0;
+ size_a = _PyLong_DigitCount(a);
+ nega = _PyLong_IsNegative(a);
if (nega) {
z = _PyLong_New(size_a);
if (z == NULL)
Py_INCREF(a);
/* Same for b. */
- size_b = Py_ABS(Py_SIZE(b));
- negb = Py_SIZE(b) < 0;
+ size_b = _PyLong_DigitCount(b);
+ negb = _PyLong_IsNegative(b);
if (negb) {
z = _PyLong_New(size_b);
if (z == NULL) {
/* Complement result if negative. */
if (negz) {
- Py_SET_SIZE(z, -(Py_SIZE(z)));
+ _PyLong_FlipSign(z);
z->long_value.ob_digit[size_z] = PyLong_MASK;
v_complement(z->long_value.ob_digit, z->long_value.ob_digit, size_z+1);
}
CHECK_BINOP(a, b);
PyLongObject *x = (PyLongObject*)a;
PyLongObject *y = (PyLongObject*)b;
- if (IS_MEDIUM_VALUE(x) && IS_MEDIUM_VALUE(y)) {
+ if (_PyLong_IsCompact(x) && _PyLong_IsCompact(y)) {
return _PyLong_FromSTwoDigits(medium_value(x) & medium_value(y));
}
return long_bitwise(x, '&', y);
CHECK_BINOP(a, b);
PyLongObject *x = (PyLongObject*)a;
PyLongObject *y = (PyLongObject*)b;
- if (IS_MEDIUM_VALUE(x) && IS_MEDIUM_VALUE(y)) {
+ if (_PyLong_IsCompact(x) && _PyLong_IsCompact(y)) {
return _PyLong_FromSTwoDigits(medium_value(x) ^ medium_value(y));
}
return long_bitwise(x, '^', y);
CHECK_BINOP(a, b);
PyLongObject *x = (PyLongObject*)a;
PyLongObject *y = (PyLongObject*)b;
- if (IS_MEDIUM_VALUE(x) && IS_MEDIUM_VALUE(y)) {
+ if (_PyLong_IsCompact(x) && _PyLong_IsCompact(y)) {
return _PyLong_FromSTwoDigits(medium_value(x) | medium_value(y));
}
return long_bitwise(x, '|', y);
stwodigits x, y, q, s, t, c_carry, d_carry;
stwodigits A, B, C, D, T;
int nbits, k;
- Py_ssize_t size_a, size_b, alloc_a, alloc_b;
digit *a_digit, *b_digit, *c_digit, *d_digit, *a_end, *b_end;
a = (PyLongObject *)aarg;
b = (PyLongObject *)barg;
- size_a = Py_SIZE(a);
- size_b = Py_SIZE(b);
- if (-2 <= size_a && size_a <= 2 && -2 <= size_b && size_b <= 2) {
+ if (_PyLong_DigitCount(a) <= 2 && _PyLong_DigitCount(b) <= 2) {
Py_INCREF(a);
Py_INCREF(b);
goto simple;
}
/* We now own references to a and b */
- alloc_a = Py_SIZE(a);
- alloc_b = Py_SIZE(b);
+ Py_ssize_t size_a, size_b, alloc_a, alloc_b;
+ alloc_a = _PyLong_DigitCount(a);
+ alloc_b = _PyLong_DigitCount(b);
/* reduce until a fits into 2 digits */
- while ((size_a = Py_SIZE(a)) > 2) {
+ while ((size_a = _PyLong_DigitCount(a)) > 2) {
nbits = bit_length_digit(a->long_value.ob_digit[size_a-1]);
/* extract top 2*PyLong_SHIFT bits of a into x, along with
corresponding bits of b into y */
- size_b = Py_SIZE(b);
+ size_b = _PyLong_DigitCount(b);
assert(size_b <= size_a);
if (size_b == 0) {
if (size_a < alloc_a) {
Py_SETREF(a, b);
b = r;
alloc_a = alloc_b;
- alloc_b = Py_SIZE(b);
+ alloc_b = _PyLong_DigitCount(b);
continue;
}
T = -C; C = -D; D = T;
}
if (c != NULL) {
- Py_SET_SIZE(c, size_a);
+ assert(size_a >= 0);
+ _PyLong_SetSignAndDigitCount(c, 1, size_a);
}
else if (Py_REFCNT(a) == 1) {
c = (PyLongObject*)Py_NewRef(a);
}
if (d != NULL) {
- Py_SET_SIZE(d, size_a);
+ assert(size_a >= 0);
+ _PyLong_SetSignAndDigitCount(d, 1, size_a);
}
else if (Py_REFCNT(b) == 1 && size_a <= alloc_b) {
d = (PyLongObject*)Py_NewRef(b);
- Py_SET_SIZE(d, size_a);
+ assert(size_a >= 0);
+ _PyLong_SetSignAndDigitCount(d, 1, size_a);
}
else {
alloc_b = size_a;
if (tmp == NULL)
return NULL;
assert(PyLong_Check(tmp));
- n = Py_SIZE(tmp);
- if (n < 0)
- n = -n;
+ n = _PyLong_DigitCount(tmp);
/* Fast operations for single digit integers (including zero)
* assume that there is always at least one digit present. */
if (n == 0) {
return NULL;
}
assert(PyLong_Check(newobj));
- Py_SET_SIZE(newobj, Py_SIZE(tmp));
+ newobj->long_value.lv_tag = tmp->long_value.lv_tag;
for (i = 0; i < n; i++) {
newobj->long_value.ob_digit[i] = tmp->long_value.ob_digit[i];
}
}
/* Do a and b have different signs? If so, quotient is negative. */
- quo_is_neg = (Py_SIZE(a) < 0) != (Py_SIZE(b) < 0);
+ quo_is_neg = (_PyLong_IsNegative((PyLongObject *)a)) != (_PyLong_IsNegative((PyLongObject *)b));
if (long_divrem((PyLongObject*)a, (PyLongObject*)b, &quo, &rem) < 0)
goto error;
cmp = long_compare((PyLongObject *)twice_rem, (PyLongObject *)b);
Py_DECREF(twice_rem);
- quo_is_odd = Py_SIZE(quo) != 0 && ((quo->long_value.ob_digit[0] & 1) != 0);
- if ((Py_SIZE(b) < 0 ? cmp < 0 : cmp > 0) || (cmp == 0 && quo_is_odd)) {
+ quo_is_odd = (quo->long_value.ob_digit[0] & 1) != 0;
+ if ((_PyLong_IsNegative((PyLongObject *)b) ? cmp < 0 : cmp > 0) || (cmp == 0 && quo_is_odd)) {
/* fix up quotient */
if (quo_is_neg)
temp = long_sub(quo, (PyLongObject *)one);
return NULL;
/* if ndigits >= 0 then no rounding is necessary; return self unchanged */
- if (Py_SIZE(ndigits) >= 0) {
+ if (!_PyLong_IsNegative((PyLongObject *)ndigits)) {
Py_DECREF(ndigits);
return long_long(self);
}
/*[clinic end generated code: output=3303f008eaa6a0a5 input=9b51620c76fc4507]*/
{
/* using Py_MAX(..., 1) because we always allocate space for at least
- one digit, even though the integer zero has a Py_SIZE of 0 */
- Py_ssize_t ndigits = Py_MAX(Py_ABS(Py_SIZE(self)), 1);
+ one digit, even though the integer zero has a digit count of 0 */
+ Py_ssize_t ndigits = Py_MAX(_PyLong_DigitCount((PyLongObject *)self), 1);
return Py_TYPE(self)->tp_basicsize + Py_TYPE(self)->tp_itemsize * ndigits;
}
assert(self != NULL);
assert(PyLong_Check(self));
- ndigits = Py_ABS(Py_SIZE(self));
+ ndigits = _PyLong_DigitCount((PyLongObject *)self);
if (ndigits == 0)
return PyLong_FromLong(0);
assert(PyLong_Check(self));
PyLongObject *z = (PyLongObject *)self;
- Py_ssize_t ndigits = Py_ABS(Py_SIZE(z));
+ Py_ssize_t ndigits = _PyLong_DigitCount(z);
Py_ssize_t bit_count = 0;
/* Each digit has up to PyLong_SHIFT ones, so the accumulated bit count
DEOPT_IF(!PyList_CheckExact(list), BINARY_SUBSCR);
// Deopt unless 0 <= sub < PyList_Size(list)
- DEOPT_IF(!_PyLong_IsPositiveSingleDigit(sub), BINARY_SUBSCR);
- assert(((PyLongObject *)_PyLong_GetZero())->long_value.ob_digit[0] == 0);
+ DEOPT_IF(!_PyLong_IsNonNegativeCompact((PyLongObject *)sub), BINARY_SUBSCR);
Py_ssize_t index = ((PyLongObject*)sub)->long_value.ob_digit[0];
DEOPT_IF(index >= PyList_GET_SIZE(list), BINARY_SUBSCR);
STAT_INC(BINARY_SUBSCR, hit);
Py_INCREF(res);
_Py_DECREF_SPECIALIZED(sub, (destructor)PyObject_Free);
Py_DECREF(list);
- #line 561 "Python/generated_cases.c.h"
+ #line 560 "Python/generated_cases.c.h"
STACK_SHRINK(1);
stack_pointer[-1] = res;
next_instr += 4;
PyObject *sub = stack_pointer[-1];
PyObject *tuple = stack_pointer[-2];
PyObject *res;
- #line 361 "Python/bytecodes.c"
+ #line 360 "Python/bytecodes.c"
assert(cframe.use_tracing == 0);
DEOPT_IF(!PyLong_CheckExact(sub), BINARY_SUBSCR);
DEOPT_IF(!PyTuple_CheckExact(tuple), BINARY_SUBSCR);
// Deopt unless 0 <= sub < PyTuple_Size(list)
- DEOPT_IF(!_PyLong_IsPositiveSingleDigit(sub), BINARY_SUBSCR);
- assert(((PyLongObject *)_PyLong_GetZero())->long_value.ob_digit[0] == 0);
+ DEOPT_IF(!_PyLong_IsNonNegativeCompact((PyLongObject *)sub), BINARY_SUBSCR);
Py_ssize_t index = ((PyLongObject*)sub)->long_value.ob_digit[0];
DEOPT_IF(index >= PyTuple_GET_SIZE(tuple), BINARY_SUBSCR);
STAT_INC(BINARY_SUBSCR, hit);
Py_INCREF(res);
_Py_DECREF_SPECIALIZED(sub, (destructor)PyObject_Free);
Py_DECREF(tuple);
- #line 588 "Python/generated_cases.c.h"
+ #line 586 "Python/generated_cases.c.h"
STACK_SHRINK(1);
stack_pointer[-1] = res;
next_instr += 4;
PyObject *sub = stack_pointer[-1];
PyObject *dict = stack_pointer[-2];
PyObject *res;
- #line 379 "Python/bytecodes.c"
+ #line 377 "Python/bytecodes.c"
assert(cframe.use_tracing == 0);
DEOPT_IF(!PyDict_CheckExact(dict), BINARY_SUBSCR);
STAT_INC(BINARY_SUBSCR, hit);
if (!_PyErr_Occurred(tstate)) {
_PyErr_SetKeyError(sub);
}
- #line 608 "Python/generated_cases.c.h"
+ #line 606 "Python/generated_cases.c.h"
Py_DECREF(dict);
Py_DECREF(sub);
- #line 388 "Python/bytecodes.c"
+ #line 386 "Python/bytecodes.c"
if (true) goto pop_2_error;
}
Py_INCREF(res); // Do this before DECREF'ing dict, sub
- #line 615 "Python/generated_cases.c.h"
+ #line 613 "Python/generated_cases.c.h"
Py_DECREF(dict);
Py_DECREF(sub);
STACK_SHRINK(1);
PyObject *container = stack_pointer[-2];
uint32_t type_version = read_u32(&next_instr[1].cache);
uint16_t func_version = read_u16(&next_instr[3].cache);
- #line 395 "Python/bytecodes.c"
+ #line 393 "Python/bytecodes.c"
PyTypeObject *tp = Py_TYPE(container);
DEOPT_IF(tp->tp_version_tag != type_version, BINARY_SUBSCR);
assert(tp->tp_flags & Py_TPFLAGS_HEAPTYPE);
new_frame->localsplus[1] = sub;
JUMPBY(INLINE_CACHE_ENTRIES_BINARY_SUBSCR);
DISPATCH_INLINED(new_frame);
- #line 648 "Python/generated_cases.c.h"
+ #line 646 "Python/generated_cases.c.h"
}
TARGET(LIST_APPEND) {
PyObject *v = stack_pointer[-1];
PyObject *list = stack_pointer[-(2 + (oparg-1))];
- #line 416 "Python/bytecodes.c"
+ #line 414 "Python/bytecodes.c"
if (_PyList_AppendTakeRef((PyListObject *)list, v) < 0) goto pop_1_error;
- #line 656 "Python/generated_cases.c.h"
+ #line 654 "Python/generated_cases.c.h"
STACK_SHRINK(1);
PREDICT(JUMP_BACKWARD);
DISPATCH();
TARGET(SET_ADD) {
PyObject *v = stack_pointer[-1];
PyObject *set = stack_pointer[-(2 + (oparg-1))];
- #line 421 "Python/bytecodes.c"
+ #line 419 "Python/bytecodes.c"
int err = PySet_Add(set, v);
- #line 667 "Python/generated_cases.c.h"
+ #line 665 "Python/generated_cases.c.h"
Py_DECREF(v);
- #line 423 "Python/bytecodes.c"
+ #line 421 "Python/bytecodes.c"
if (err) goto pop_1_error;
- #line 671 "Python/generated_cases.c.h"
+ #line 669 "Python/generated_cases.c.h"
STACK_SHRINK(1);
PREDICT(JUMP_BACKWARD);
DISPATCH();
PyObject *container = stack_pointer[-2];
PyObject *v = stack_pointer[-3];
uint16_t counter = read_u16(&next_instr[0].cache);
- #line 434 "Python/bytecodes.c"
+ #line 432 "Python/bytecodes.c"
#if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_IS_ZERO(counter)) {
assert(cframe.use_tracing == 0);
#endif /* ENABLE_SPECIALIZATION */
/* container[sub] = v */
int err = PyObject_SetItem(container, sub, v);
- #line 700 "Python/generated_cases.c.h"
+ #line 698 "Python/generated_cases.c.h"
Py_DECREF(v);
Py_DECREF(container);
Py_DECREF(sub);
- #line 450 "Python/bytecodes.c"
+ #line 448 "Python/bytecodes.c"
if (err) goto pop_3_error;
- #line 706 "Python/generated_cases.c.h"
+ #line 704 "Python/generated_cases.c.h"
STACK_SHRINK(3);
next_instr += 1;
DISPATCH();
PyObject *sub = stack_pointer[-1];
PyObject *list = stack_pointer[-2];
PyObject *value = stack_pointer[-3];
- #line 454 "Python/bytecodes.c"
+ #line 452 "Python/bytecodes.c"
assert(cframe.use_tracing == 0);
DEOPT_IF(!PyLong_CheckExact(sub), STORE_SUBSCR);
DEOPT_IF(!PyList_CheckExact(list), STORE_SUBSCR);
// Ensure nonnegative, zero-or-one-digit ints.
- DEOPT_IF(!_PyLong_IsPositiveSingleDigit(sub), STORE_SUBSCR);
+ DEOPT_IF(!_PyLong_IsNonNegativeCompact((PyLongObject *)sub), STORE_SUBSCR);
Py_ssize_t index = ((PyLongObject*)sub)->long_value.ob_digit[0];
// Ensure index < len(list)
DEOPT_IF(index >= PyList_GET_SIZE(list), STORE_SUBSCR);
Py_DECREF(old_value);
_Py_DECREF_SPECIALIZED(sub, (destructor)PyObject_Free);
Py_DECREF(list);
- #line 734 "Python/generated_cases.c.h"
+ #line 732 "Python/generated_cases.c.h"
STACK_SHRINK(3);
next_instr += 1;
DISPATCH();
PyObject *sub = stack_pointer[-1];
PyObject *dict = stack_pointer[-2];
PyObject *value = stack_pointer[-3];
- #line 474 "Python/bytecodes.c"
+ #line 472 "Python/bytecodes.c"
assert(cframe.use_tracing == 0);
DEOPT_IF(!PyDict_CheckExact(dict), STORE_SUBSCR);
STAT_INC(STORE_SUBSCR, hit);
int err = _PyDict_SetItem_Take2((PyDictObject *)dict, sub, value);
Py_DECREF(dict);
if (err) goto pop_3_error;
- #line 751 "Python/generated_cases.c.h"
+ #line 749 "Python/generated_cases.c.h"
STACK_SHRINK(3);
next_instr += 1;
DISPATCH();
TARGET(DELETE_SUBSCR) {
PyObject *sub = stack_pointer[-1];
PyObject *container = stack_pointer[-2];
- #line 483 "Python/bytecodes.c"
+ #line 481 "Python/bytecodes.c"
/* del container[sub] */
int err = PyObject_DelItem(container, sub);
- #line 763 "Python/generated_cases.c.h"
+ #line 761 "Python/generated_cases.c.h"
Py_DECREF(container);
Py_DECREF(sub);
- #line 486 "Python/bytecodes.c"
+ #line 484 "Python/bytecodes.c"
if (err) goto pop_2_error;
- #line 768 "Python/generated_cases.c.h"
+ #line 766 "Python/generated_cases.c.h"
STACK_SHRINK(2);
DISPATCH();
}
TARGET(CALL_INTRINSIC_1) {
PyObject *value = stack_pointer[-1];
PyObject *res;
- #line 490 "Python/bytecodes.c"
+ #line 488 "Python/bytecodes.c"
assert(oparg <= MAX_INTRINSIC_1);
res = _PyIntrinsics_UnaryFunctions[oparg](tstate, value);
- #line 779 "Python/generated_cases.c.h"
+ #line 777 "Python/generated_cases.c.h"
Py_DECREF(value);
- #line 493 "Python/bytecodes.c"
+ #line 491 "Python/bytecodes.c"
if (res == NULL) goto pop_1_error;
- #line 783 "Python/generated_cases.c.h"
+ #line 781 "Python/generated_cases.c.h"
stack_pointer[-1] = res;
DISPATCH();
}
PyObject *value1 = stack_pointer[-1];
PyObject *value2 = stack_pointer[-2];
PyObject *res;
- #line 497 "Python/bytecodes.c"
+ #line 495 "Python/bytecodes.c"
assert(oparg <= MAX_INTRINSIC_2);
res = _PyIntrinsics_BinaryFunctions[oparg](tstate, value2, value1);
- #line 795 "Python/generated_cases.c.h"
+ #line 793 "Python/generated_cases.c.h"
Py_DECREF(value2);
Py_DECREF(value1);
- #line 500 "Python/bytecodes.c"
+ #line 498 "Python/bytecodes.c"
if (res == NULL) goto pop_2_error;
- #line 800 "Python/generated_cases.c.h"
+ #line 798 "Python/generated_cases.c.h"
STACK_SHRINK(1);
stack_pointer[-1] = res;
DISPATCH();
TARGET(RAISE_VARARGS) {
PyObject **args = (stack_pointer - oparg);
- #line 504 "Python/bytecodes.c"
+ #line 502 "Python/bytecodes.c"
PyObject *cause = NULL, *exc = NULL;
switch (oparg) {
case 2:
break;
}
if (true) { STACK_SHRINK(oparg); goto error; }
- #line 826 "Python/generated_cases.c.h"
+ #line 824 "Python/generated_cases.c.h"
}
TARGET(INTERPRETER_EXIT) {
PyObject *retval = stack_pointer[-1];
- #line 524 "Python/bytecodes.c"
+ #line 522 "Python/bytecodes.c"
assert(frame == &entry_frame);
assert(_PyFrame_IsIncomplete(frame));
STACK_SHRINK(1); // Since we're not going to DISPATCH()
assert(!_PyErr_Occurred(tstate));
_Py_LeaveRecursiveCallTstate(tstate);
return retval;
- #line 843 "Python/generated_cases.c.h"
+ #line 841 "Python/generated_cases.c.h"
}
TARGET(RETURN_VALUE) {
PyObject *retval = stack_pointer[-1];
- #line 538 "Python/bytecodes.c"
+ #line 536 "Python/bytecodes.c"
STACK_SHRINK(1);
assert(EMPTY());
_PyFrame_SetStackPointer(frame, stack_pointer);
_PyEvalFrameClearAndPop(tstate, dying);
_PyFrame_StackPush(frame, retval);
goto resume_frame;
- #line 862 "Python/generated_cases.c.h"
+ #line 860 "Python/generated_cases.c.h"
}
TARGET(RETURN_CONST) {
- #line 554 "Python/bytecodes.c"
+ #line 552 "Python/bytecodes.c"
PyObject *retval = GETITEM(frame->f_code->co_consts, oparg);
Py_INCREF(retval);
assert(EMPTY());
_PyEvalFrameClearAndPop(tstate, dying);
_PyFrame_StackPush(frame, retval);
goto resume_frame;
- #line 881 "Python/generated_cases.c.h"
+ #line 879 "Python/generated_cases.c.h"
}
TARGET(GET_AITER) {
PyObject *obj = stack_pointer[-1];
PyObject *iter;
- #line 571 "Python/bytecodes.c"
+ #line 569 "Python/bytecodes.c"
unaryfunc getter = NULL;
PyTypeObject *type = Py_TYPE(obj);
"'async for' requires an object with "
"__aiter__ method, got %.100s",
type->tp_name);
- #line 900 "Python/generated_cases.c.h"
+ #line 898 "Python/generated_cases.c.h"
Py_DECREF(obj);
- #line 584 "Python/bytecodes.c"
+ #line 582 "Python/bytecodes.c"
if (true) goto pop_1_error;
}
iter = (*getter)(obj);
- #line 907 "Python/generated_cases.c.h"
+ #line 905 "Python/generated_cases.c.h"
Py_DECREF(obj);
- #line 589 "Python/bytecodes.c"
+ #line 587 "Python/bytecodes.c"
if (iter == NULL) goto pop_1_error;
if (Py_TYPE(iter)->tp_as_async == NULL ||
Py_DECREF(iter);
if (true) goto pop_1_error;
}
- #line 922 "Python/generated_cases.c.h"
+ #line 920 "Python/generated_cases.c.h"
stack_pointer[-1] = iter;
DISPATCH();
}
TARGET(GET_ANEXT) {
PyObject *aiter = stack_pointer[-1];
PyObject *awaitable;
- #line 604 "Python/bytecodes.c"
+ #line 602 "Python/bytecodes.c"
unaryfunc getter = NULL;
PyObject *next_iter = NULL;
PyTypeObject *type = Py_TYPE(aiter);
}
}
- #line 974 "Python/generated_cases.c.h"
+ #line 972 "Python/generated_cases.c.h"
STACK_GROW(1);
stack_pointer[-1] = awaitable;
PREDICT(LOAD_CONST);
PREDICTED(GET_AWAITABLE);
PyObject *iterable = stack_pointer[-1];
PyObject *iter;
- #line 651 "Python/bytecodes.c"
+ #line 649 "Python/bytecodes.c"
iter = _PyCoro_GetAwaitableIter(iterable);
if (iter == NULL) {
format_awaitable_error(tstate, Py_TYPE(iterable), oparg);
}
- #line 992 "Python/generated_cases.c.h"
+ #line 990 "Python/generated_cases.c.h"
Py_DECREF(iterable);
- #line 658 "Python/bytecodes.c"
+ #line 656 "Python/bytecodes.c"
if (iter != NULL && PyCoro_CheckExact(iter)) {
PyObject *yf = _PyGen_yf((PyGenObject*)iter);
if (iter == NULL) goto pop_1_error;
- #line 1012 "Python/generated_cases.c.h"
+ #line 1010 "Python/generated_cases.c.h"
stack_pointer[-1] = iter;
PREDICT(LOAD_CONST);
DISPATCH();
PyObject *v = stack_pointer[-1];
PyObject *receiver = stack_pointer[-2];
PyObject *retval;
- #line 684 "Python/bytecodes.c"
+ #line 682 "Python/bytecodes.c"
#if ENABLE_SPECIALIZATION
_PySendCache *cache = (_PySendCache *)next_instr;
if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
assert(retval != NULL);
}
Py_DECREF(v);
- #line 1059 "Python/generated_cases.c.h"
+ #line 1057 "Python/generated_cases.c.h"
stack_pointer[-1] = retval;
next_instr += 1;
DISPATCH();
TARGET(SEND_GEN) {
PyObject *v = stack_pointer[-1];
PyObject *receiver = stack_pointer[-2];
- #line 722 "Python/bytecodes.c"
+ #line 720 "Python/bytecodes.c"
assert(cframe.use_tracing == 0);
PyGenObject *gen = (PyGenObject *)receiver;
DEOPT_IF(Py_TYPE(gen) != &PyGen_Type &&
tstate->exc_info = &gen->gi_exc_state;
JUMPBY(INLINE_CACHE_ENTRIES_SEND + oparg);
DISPATCH_INLINED(gen_frame);
- #line 1084 "Python/generated_cases.c.h"
+ #line 1082 "Python/generated_cases.c.h"
}
TARGET(YIELD_VALUE) {
PyObject *retval = stack_pointer[-1];
- #line 740 "Python/bytecodes.c"
+ #line 738 "Python/bytecodes.c"
// NOTE: It's important that YIELD_VALUE never raises an exception!
// The compiler treats any exception raised here as a failed close()
// or throw() call.
frame->prev_instr -= frame->yield_offset;
_PyFrame_StackPush(frame, retval);
goto resume_frame;
- #line 1108 "Python/generated_cases.c.h"
+ #line 1106 "Python/generated_cases.c.h"
}
TARGET(POP_EXCEPT) {
PyObject *exc_value = stack_pointer[-1];
- #line 761 "Python/bytecodes.c"
+ #line 759 "Python/bytecodes.c"
_PyErr_StackItem *exc_info = tstate->exc_info;
Py_XSETREF(exc_info->exc_value, exc_value);
- #line 1116 "Python/generated_cases.c.h"
+ #line 1114 "Python/generated_cases.c.h"
STACK_SHRINK(1);
DISPATCH();
}
TARGET(RERAISE) {
PyObject *exc = stack_pointer[-1];
PyObject **values = (stack_pointer - (1 + oparg));
- #line 766 "Python/bytecodes.c"
+ #line 764 "Python/bytecodes.c"
assert(oparg >= 0 && oparg <= 2);
if (oparg) {
PyObject *lasti = values[0];
Py_INCREF(exc);
_PyErr_SetRaisedException(tstate, exc);
goto exception_unwind;
- #line 1142 "Python/generated_cases.c.h"
+ #line 1140 "Python/generated_cases.c.h"
}
TARGET(END_ASYNC_FOR) {
PyObject *exc = stack_pointer[-1];
PyObject *awaitable = stack_pointer[-2];
- #line 786 "Python/bytecodes.c"
+ #line 784 "Python/bytecodes.c"
assert(exc && PyExceptionInstance_Check(exc));
if (PyErr_GivenExceptionMatches(exc, PyExc_StopAsyncIteration)) {
- #line 1151 "Python/generated_cases.c.h"
+ #line 1149 "Python/generated_cases.c.h"
Py_DECREF(awaitable);
Py_DECREF(exc);
- #line 789 "Python/bytecodes.c"
+ #line 787 "Python/bytecodes.c"
}
else {
Py_INCREF(exc);
_PyErr_SetRaisedException(tstate, exc);
goto exception_unwind;
}
- #line 1161 "Python/generated_cases.c.h"
+ #line 1159 "Python/generated_cases.c.h"
STACK_SHRINK(2);
DISPATCH();
}
PyObject *sub_iter = stack_pointer[-3];
PyObject *none;
PyObject *value;
- #line 798 "Python/bytecodes.c"
+ #line 796 "Python/bytecodes.c"
assert(throwflag);
assert(exc_value && PyExceptionInstance_Check(exc_value));
if (PyErr_GivenExceptionMatches(exc_value, PyExc_StopIteration)) {
value = Py_NewRef(((PyStopIterationObject *)exc_value)->value);
- #line 1177 "Python/generated_cases.c.h"
+ #line 1175 "Python/generated_cases.c.h"
Py_DECREF(sub_iter);
Py_DECREF(last_sent_val);
Py_DECREF(exc_value);
- #line 803 "Python/bytecodes.c"
+ #line 801 "Python/bytecodes.c"
none = Py_NewRef(Py_None);
}
else {
_PyErr_SetRaisedException(tstate, Py_NewRef(exc_value));
goto exception_unwind;
}
- #line 1188 "Python/generated_cases.c.h"
+ #line 1186 "Python/generated_cases.c.h"
STACK_SHRINK(1);
stack_pointer[-1] = value;
stack_pointer[-2] = none;
TARGET(LOAD_ASSERTION_ERROR) {
PyObject *value;
- #line 812 "Python/bytecodes.c"
+ #line 810 "Python/bytecodes.c"
value = Py_NewRef(PyExc_AssertionError);
- #line 1199 "Python/generated_cases.c.h"
+ #line 1197 "Python/generated_cases.c.h"
STACK_GROW(1);
stack_pointer[-1] = value;
DISPATCH();
TARGET(LOAD_BUILD_CLASS) {
PyObject *bc;
- #line 816 "Python/bytecodes.c"
+ #line 814 "Python/bytecodes.c"
if (PyDict_CheckExact(BUILTINS())) {
bc = _PyDict_GetItemWithError(BUILTINS(),
&_Py_ID(__build_class__));
if (true) goto error;
}
}
- #line 1229 "Python/generated_cases.c.h"
+ #line 1227 "Python/generated_cases.c.h"
STACK_GROW(1);
stack_pointer[-1] = bc;
DISPATCH();
TARGET(STORE_NAME) {
PyObject *v = stack_pointer[-1];
- #line 840 "Python/bytecodes.c"
+ #line 838 "Python/bytecodes.c"
PyObject *name = GETITEM(frame->f_code->co_names, oparg);
PyObject *ns = LOCALS();
int err;
if (ns == NULL) {
_PyErr_Format(tstate, PyExc_SystemError,
"no locals found when storing %R", name);
- #line 1244 "Python/generated_cases.c.h"
+ #line 1242 "Python/generated_cases.c.h"
Py_DECREF(v);
- #line 847 "Python/bytecodes.c"
+ #line 845 "Python/bytecodes.c"
if (true) goto pop_1_error;
}
if (PyDict_CheckExact(ns))
err = PyDict_SetItem(ns, name, v);
else
err = PyObject_SetItem(ns, name, v);
- #line 1253 "Python/generated_cases.c.h"
+ #line 1251 "Python/generated_cases.c.h"
Py_DECREF(v);
- #line 854 "Python/bytecodes.c"
+ #line 852 "Python/bytecodes.c"
if (err) goto pop_1_error;
- #line 1257 "Python/generated_cases.c.h"
+ #line 1255 "Python/generated_cases.c.h"
STACK_SHRINK(1);
DISPATCH();
}
TARGET(DELETE_NAME) {
- #line 858 "Python/bytecodes.c"
+ #line 856 "Python/bytecodes.c"
PyObject *name = GETITEM(frame->f_code->co_names, oparg);
PyObject *ns = LOCALS();
int err;
name);
goto error;
}
- #line 1280 "Python/generated_cases.c.h"
+ #line 1278 "Python/generated_cases.c.h"
DISPATCH();
}
PREDICTED(UNPACK_SEQUENCE);
static_assert(INLINE_CACHE_ENTRIES_UNPACK_SEQUENCE == 1, "incorrect cache size");
PyObject *seq = stack_pointer[-1];
- #line 884 "Python/bytecodes.c"
+ #line 882 "Python/bytecodes.c"
#if ENABLE_SPECIALIZATION
_PyUnpackSequenceCache *cache = (_PyUnpackSequenceCache *)next_instr;
if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
#endif /* ENABLE_SPECIALIZATION */
PyObject **top = stack_pointer + oparg - 1;
int res = unpack_iterable(tstate, seq, oparg, -1, top);
- #line 1302 "Python/generated_cases.c.h"
+ #line 1300 "Python/generated_cases.c.h"
Py_DECREF(seq);
- #line 898 "Python/bytecodes.c"
+ #line 896 "Python/bytecodes.c"
if (res == 0) goto pop_1_error;
- #line 1306 "Python/generated_cases.c.h"
+ #line 1304 "Python/generated_cases.c.h"
STACK_SHRINK(1);
STACK_GROW(oparg);
next_instr += 1;
TARGET(UNPACK_SEQUENCE_TWO_TUPLE) {
PyObject *seq = stack_pointer[-1];
PyObject **values = stack_pointer - (1);
- #line 902 "Python/bytecodes.c"
+ #line 900 "Python/bytecodes.c"
DEOPT_IF(!PyTuple_CheckExact(seq), UNPACK_SEQUENCE);
DEOPT_IF(PyTuple_GET_SIZE(seq) != 2, UNPACK_SEQUENCE);
assert(oparg == 2);
STAT_INC(UNPACK_SEQUENCE, hit);
values[0] = Py_NewRef(PyTuple_GET_ITEM(seq, 1));
values[1] = Py_NewRef(PyTuple_GET_ITEM(seq, 0));
- #line 1323 "Python/generated_cases.c.h"
+ #line 1321 "Python/generated_cases.c.h"
Py_DECREF(seq);
STACK_SHRINK(1);
STACK_GROW(oparg);
TARGET(UNPACK_SEQUENCE_TUPLE) {
PyObject *seq = stack_pointer[-1];
PyObject **values = stack_pointer - (1);
- #line 912 "Python/bytecodes.c"
+ #line 910 "Python/bytecodes.c"
DEOPT_IF(!PyTuple_CheckExact(seq), UNPACK_SEQUENCE);
DEOPT_IF(PyTuple_GET_SIZE(seq) != oparg, UNPACK_SEQUENCE);
STAT_INC(UNPACK_SEQUENCE, hit);
for (int i = oparg; --i >= 0; ) {
*values++ = Py_NewRef(items[i]);
}
- #line 1342 "Python/generated_cases.c.h"
+ #line 1340 "Python/generated_cases.c.h"
Py_DECREF(seq);
STACK_SHRINK(1);
STACK_GROW(oparg);
TARGET(UNPACK_SEQUENCE_LIST) {
PyObject *seq = stack_pointer[-1];
PyObject **values = stack_pointer - (1);
- #line 923 "Python/bytecodes.c"
+ #line 921 "Python/bytecodes.c"
DEOPT_IF(!PyList_CheckExact(seq), UNPACK_SEQUENCE);
DEOPT_IF(PyList_GET_SIZE(seq) != oparg, UNPACK_SEQUENCE);
STAT_INC(UNPACK_SEQUENCE, hit);
for (int i = oparg; --i >= 0; ) {
*values++ = Py_NewRef(items[i]);
}
- #line 1361 "Python/generated_cases.c.h"
+ #line 1359 "Python/generated_cases.c.h"
Py_DECREF(seq);
STACK_SHRINK(1);
STACK_GROW(oparg);
TARGET(UNPACK_EX) {
PyObject *seq = stack_pointer[-1];
- #line 934 "Python/bytecodes.c"
+ #line 932 "Python/bytecodes.c"
int totalargs = 1 + (oparg & 0xFF) + (oparg >> 8);
PyObject **top = stack_pointer + totalargs - 1;
int res = unpack_iterable(tstate, seq, oparg & 0xFF, oparg >> 8, top);
- #line 1375 "Python/generated_cases.c.h"
+ #line 1373 "Python/generated_cases.c.h"
Py_DECREF(seq);
- #line 938 "Python/bytecodes.c"
+ #line 936 "Python/bytecodes.c"
if (res == 0) goto pop_1_error;
- #line 1379 "Python/generated_cases.c.h"
+ #line 1377 "Python/generated_cases.c.h"
STACK_GROW((oparg & 0xFF) + (oparg >> 8));
DISPATCH();
}
PyObject *owner = stack_pointer[-1];
PyObject *v = stack_pointer[-2];
uint16_t counter = read_u16(&next_instr[0].cache);
- #line 949 "Python/bytecodes.c"
+ #line 947 "Python/bytecodes.c"
#if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_IS_ZERO(counter)) {
assert(cframe.use_tracing == 0);
#endif /* ENABLE_SPECIALIZATION */
PyObject *name = GETITEM(frame->f_code->co_names, oparg);
int err = PyObject_SetAttr(owner, name, v);
- #line 1407 "Python/generated_cases.c.h"
+ #line 1405 "Python/generated_cases.c.h"
Py_DECREF(v);
Py_DECREF(owner);
- #line 966 "Python/bytecodes.c"
+ #line 964 "Python/bytecodes.c"
if (err) goto pop_2_error;
- #line 1412 "Python/generated_cases.c.h"
+ #line 1410 "Python/generated_cases.c.h"
STACK_SHRINK(2);
next_instr += 4;
DISPATCH();
TARGET(DELETE_ATTR) {
PyObject *owner = stack_pointer[-1];
- #line 970 "Python/bytecodes.c"
+ #line 968 "Python/bytecodes.c"
PyObject *name = GETITEM(frame->f_code->co_names, oparg);
int err = PyObject_SetAttr(owner, name, (PyObject *)NULL);
- #line 1423 "Python/generated_cases.c.h"
+ #line 1421 "Python/generated_cases.c.h"
Py_DECREF(owner);
- #line 973 "Python/bytecodes.c"
+ #line 971 "Python/bytecodes.c"
if (err) goto pop_1_error;
- #line 1427 "Python/generated_cases.c.h"
+ #line 1425 "Python/generated_cases.c.h"
STACK_SHRINK(1);
DISPATCH();
}
TARGET(STORE_GLOBAL) {
PyObject *v = stack_pointer[-1];
- #line 977 "Python/bytecodes.c"
+ #line 975 "Python/bytecodes.c"
PyObject *name = GETITEM(frame->f_code->co_names, oparg);
int err = PyDict_SetItem(GLOBALS(), name, v);
- #line 1437 "Python/generated_cases.c.h"
+ #line 1435 "Python/generated_cases.c.h"
Py_DECREF(v);
- #line 980 "Python/bytecodes.c"
+ #line 978 "Python/bytecodes.c"
if (err) goto pop_1_error;
- #line 1441 "Python/generated_cases.c.h"
+ #line 1439 "Python/generated_cases.c.h"
STACK_SHRINK(1);
DISPATCH();
}
TARGET(DELETE_GLOBAL) {
- #line 984 "Python/bytecodes.c"
+ #line 982 "Python/bytecodes.c"
PyObject *name = GETITEM(frame->f_code->co_names, oparg);
int err;
err = PyDict_DelItem(GLOBALS(), name);
}
goto error;
}
- #line 1459 "Python/generated_cases.c.h"
+ #line 1457 "Python/generated_cases.c.h"
DISPATCH();
}
TARGET(LOAD_NAME) {
PyObject *v;
- #line 998 "Python/bytecodes.c"
+ #line 996 "Python/bytecodes.c"
PyObject *name = GETITEM(frame->f_code->co_names, oparg);
PyObject *locals = LOCALS();
if (locals == NULL) {
}
}
}
- #line 1524 "Python/generated_cases.c.h"
+ #line 1522 "Python/generated_cases.c.h"
STACK_GROW(1);
stack_pointer[-1] = v;
DISPATCH();
static_assert(INLINE_CACHE_ENTRIES_LOAD_GLOBAL == 4, "incorrect cache size");
PyObject *null = NULL;
PyObject *v;
- #line 1065 "Python/bytecodes.c"
+ #line 1063 "Python/bytecodes.c"
#if ENABLE_SPECIALIZATION
_PyLoadGlobalCache *cache = (_PyLoadGlobalCache *)next_instr;
if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
}
}
null = NULL;
- #line 1588 "Python/generated_cases.c.h"
+ #line 1586 "Python/generated_cases.c.h"
STACK_GROW(1);
STACK_GROW(((oparg & 1) ? 1 : 0));
stack_pointer[-1] = v;
PyObject *res;
uint16_t index = read_u16(&next_instr[1].cache);
uint16_t version = read_u16(&next_instr[2].cache);
- #line 1120 "Python/bytecodes.c"
+ #line 1118 "Python/bytecodes.c"
assert(cframe.use_tracing == 0);
DEOPT_IF(!PyDict_CheckExact(GLOBALS()), LOAD_GLOBAL);
PyDictObject *dict = (PyDictObject *)GLOBALS();
Py_INCREF(res);
STAT_INC(LOAD_GLOBAL, hit);
null = NULL;
- #line 1614 "Python/generated_cases.c.h"
+ #line 1612 "Python/generated_cases.c.h"
STACK_GROW(1);
STACK_GROW(((oparg & 1) ? 1 : 0));
stack_pointer[-1] = res;
uint16_t index = read_u16(&next_instr[1].cache);
uint16_t mod_version = read_u16(&next_instr[2].cache);
uint16_t bltn_version = read_u16(&next_instr[3].cache);
- #line 1134 "Python/bytecodes.c"
+ #line 1132 "Python/bytecodes.c"
assert(cframe.use_tracing == 0);
DEOPT_IF(!PyDict_CheckExact(GLOBALS()), LOAD_GLOBAL);
DEOPT_IF(!PyDict_CheckExact(BUILTINS()), LOAD_GLOBAL);
Py_INCREF(res);
STAT_INC(LOAD_GLOBAL, hit);
null = NULL;
- #line 1644 "Python/generated_cases.c.h"
+ #line 1642 "Python/generated_cases.c.h"
STACK_GROW(1);
STACK_GROW(((oparg & 1) ? 1 : 0));
stack_pointer[-1] = res;
}
TARGET(DELETE_FAST) {
- #line 1151 "Python/bytecodes.c"
+ #line 1149 "Python/bytecodes.c"
PyObject *v = GETLOCAL(oparg);
if (v == NULL) goto unbound_local_error;
SETLOCAL(oparg, NULL);
- #line 1658 "Python/generated_cases.c.h"
+ #line 1656 "Python/generated_cases.c.h"
DISPATCH();
}
TARGET(MAKE_CELL) {
- #line 1157 "Python/bytecodes.c"
+ #line 1155 "Python/bytecodes.c"
// "initial" is probably NULL but not if it's an arg (or set
// via PyFrame_LocalsToFast() before MAKE_CELL has run).
PyObject *initial = GETLOCAL(oparg);
goto resume_with_error;
}
SETLOCAL(oparg, cell);
- #line 1672 "Python/generated_cases.c.h"
+ #line 1670 "Python/generated_cases.c.h"
DISPATCH();
}
TARGET(DELETE_DEREF) {
- #line 1168 "Python/bytecodes.c"
+ #line 1166 "Python/bytecodes.c"
PyObject *cell = GETLOCAL(oparg);
PyObject *oldobj = PyCell_GET(cell);
// Can't use ERROR_IF here.
}
PyCell_SET(cell, NULL);
Py_DECREF(oldobj);
- #line 1688 "Python/generated_cases.c.h"
+ #line 1686 "Python/generated_cases.c.h"
DISPATCH();
}
TARGET(LOAD_CLASSDEREF) {
PyObject *value;
- #line 1181 "Python/bytecodes.c"
+ #line 1179 "Python/bytecodes.c"
PyObject *name, *locals = LOCALS();
assert(locals);
assert(oparg >= 0 && oparg < frame->f_code->co_nlocalsplus);
}
Py_INCREF(value);
}
- #line 1726 "Python/generated_cases.c.h"
+ #line 1724 "Python/generated_cases.c.h"
STACK_GROW(1);
stack_pointer[-1] = value;
DISPATCH();
TARGET(LOAD_DEREF) {
PyObject *value;
- #line 1215 "Python/bytecodes.c"
+ #line 1213 "Python/bytecodes.c"
PyObject *cell = GETLOCAL(oparg);
value = PyCell_GET(cell);
if (value == NULL) {
if (true) goto error;
}
Py_INCREF(value);
- #line 1742 "Python/generated_cases.c.h"
+ #line 1740 "Python/generated_cases.c.h"
STACK_GROW(1);
stack_pointer[-1] = value;
DISPATCH();
TARGET(STORE_DEREF) {
PyObject *v = stack_pointer[-1];
- #line 1225 "Python/bytecodes.c"
+ #line 1223 "Python/bytecodes.c"
PyObject *cell = GETLOCAL(oparg);
PyObject *oldobj = PyCell_GET(cell);
PyCell_SET(cell, v);
Py_XDECREF(oldobj);
- #line 1755 "Python/generated_cases.c.h"
+ #line 1753 "Python/generated_cases.c.h"
STACK_SHRINK(1);
DISPATCH();
}
TARGET(COPY_FREE_VARS) {
- #line 1232 "Python/bytecodes.c"
+ #line 1230 "Python/bytecodes.c"
/* Copy closure variables to free variables */
PyCodeObject *co = frame->f_code;
assert(PyFunction_Check(frame->f_funcobj));
PyObject *o = PyTuple_GET_ITEM(closure, i);
frame->localsplus[offset + i] = Py_NewRef(o);
}
- #line 1772 "Python/generated_cases.c.h"
+ #line 1770 "Python/generated_cases.c.h"
DISPATCH();
}
TARGET(BUILD_STRING) {
PyObject **pieces = (stack_pointer - oparg);
PyObject *str;
- #line 1245 "Python/bytecodes.c"
+ #line 1243 "Python/bytecodes.c"
str = _PyUnicode_JoinArray(&_Py_STR(empty), pieces, oparg);
- #line 1781 "Python/generated_cases.c.h"
+ #line 1779 "Python/generated_cases.c.h"
for (int _i = oparg; --_i >= 0;) {
Py_DECREF(pieces[_i]);
}
- #line 1247 "Python/bytecodes.c"
+ #line 1245 "Python/bytecodes.c"
if (str == NULL) { STACK_SHRINK(oparg); goto error; }
- #line 1787 "Python/generated_cases.c.h"
+ #line 1785 "Python/generated_cases.c.h"
STACK_SHRINK(oparg);
STACK_GROW(1);
stack_pointer[-1] = str;
TARGET(BUILD_TUPLE) {
PyObject **values = (stack_pointer - oparg);
PyObject *tup;
- #line 1251 "Python/bytecodes.c"
+ #line 1249 "Python/bytecodes.c"
tup = _PyTuple_FromArraySteal(values, oparg);
if (tup == NULL) { STACK_SHRINK(oparg); goto error; }
- #line 1800 "Python/generated_cases.c.h"
+ #line 1798 "Python/generated_cases.c.h"
STACK_SHRINK(oparg);
STACK_GROW(1);
stack_pointer[-1] = tup;
TARGET(BUILD_LIST) {
PyObject **values = (stack_pointer - oparg);
PyObject *list;
- #line 1256 "Python/bytecodes.c"
+ #line 1254 "Python/bytecodes.c"
list = _PyList_FromArraySteal(values, oparg);
if (list == NULL) { STACK_SHRINK(oparg); goto error; }
- #line 1813 "Python/generated_cases.c.h"
+ #line 1811 "Python/generated_cases.c.h"
STACK_SHRINK(oparg);
STACK_GROW(1);
stack_pointer[-1] = list;
TARGET(LIST_EXTEND) {
PyObject *iterable = stack_pointer[-1];
PyObject *list = stack_pointer[-(2 + (oparg-1))];
- #line 1261 "Python/bytecodes.c"
+ #line 1259 "Python/bytecodes.c"
PyObject *none_val = _PyList_Extend((PyListObject *)list, iterable);
if (none_val == NULL) {
if (_PyErr_ExceptionMatches(tstate, PyExc_TypeError) &&
"Value after * must be an iterable, not %.200s",
Py_TYPE(iterable)->tp_name);
}
- #line 1834 "Python/generated_cases.c.h"
+ #line 1832 "Python/generated_cases.c.h"
Py_DECREF(iterable);
- #line 1272 "Python/bytecodes.c"
+ #line 1270 "Python/bytecodes.c"
if (true) goto pop_1_error;
}
Py_DECREF(none_val);
- #line 1840 "Python/generated_cases.c.h"
+ #line 1838 "Python/generated_cases.c.h"
Py_DECREF(iterable);
STACK_SHRINK(1);
DISPATCH();
TARGET(SET_UPDATE) {
PyObject *iterable = stack_pointer[-1];
PyObject *set = stack_pointer[-(2 + (oparg-1))];
- #line 1279 "Python/bytecodes.c"
+ #line 1277 "Python/bytecodes.c"
int err = _PySet_Update(set, iterable);
- #line 1851 "Python/generated_cases.c.h"
+ #line 1849 "Python/generated_cases.c.h"
Py_DECREF(iterable);
- #line 1281 "Python/bytecodes.c"
+ #line 1279 "Python/bytecodes.c"
if (err < 0) goto pop_1_error;
- #line 1855 "Python/generated_cases.c.h"
+ #line 1853 "Python/generated_cases.c.h"
STACK_SHRINK(1);
DISPATCH();
}
TARGET(BUILD_SET) {
PyObject **values = (stack_pointer - oparg);
PyObject *set;
- #line 1285 "Python/bytecodes.c"
+ #line 1283 "Python/bytecodes.c"
set = PySet_New(NULL);
if (set == NULL)
goto error;
Py_DECREF(set);
if (true) { STACK_SHRINK(oparg); goto error; }
}
- #line 1878 "Python/generated_cases.c.h"
+ #line 1876 "Python/generated_cases.c.h"
STACK_SHRINK(oparg);
STACK_GROW(1);
stack_pointer[-1] = set;
TARGET(BUILD_MAP) {
PyObject **values = (stack_pointer - oparg*2);
PyObject *map;
- #line 1302 "Python/bytecodes.c"
+ #line 1300 "Python/bytecodes.c"
map = _PyDict_FromItems(
values, 2,
values+1, 2,
if (map == NULL)
goto error;
- #line 1896 "Python/generated_cases.c.h"
+ #line 1894 "Python/generated_cases.c.h"
for (int _i = oparg*2; --_i >= 0;) {
Py_DECREF(values[_i]);
}
- #line 1310 "Python/bytecodes.c"
+ #line 1308 "Python/bytecodes.c"
if (map == NULL) { STACK_SHRINK(oparg*2); goto error; }
- #line 1902 "Python/generated_cases.c.h"
+ #line 1900 "Python/generated_cases.c.h"
STACK_SHRINK(oparg*2);
STACK_GROW(1);
stack_pointer[-1] = map;
}
TARGET(SETUP_ANNOTATIONS) {
- #line 1314 "Python/bytecodes.c"
+ #line 1312 "Python/bytecodes.c"
int err;
PyObject *ann_dict;
if (LOCALS() == NULL) {
Py_DECREF(ann_dict);
}
}
- #line 1950 "Python/generated_cases.c.h"
+ #line 1948 "Python/generated_cases.c.h"
DISPATCH();
}
PyObject *keys = stack_pointer[-1];
PyObject **values = (stack_pointer - (1 + oparg));
PyObject *map;
- #line 1356 "Python/bytecodes.c"
+ #line 1354 "Python/bytecodes.c"
if (!PyTuple_CheckExact(keys) ||
PyTuple_GET_SIZE(keys) != (Py_ssize_t)oparg) {
_PyErr_SetString(tstate, PyExc_SystemError,
map = _PyDict_FromItems(
&PyTuple_GET_ITEM(keys, 0), 1,
values, 1, oparg);
- #line 1968 "Python/generated_cases.c.h"
+ #line 1966 "Python/generated_cases.c.h"
for (int _i = oparg; --_i >= 0;) {
Py_DECREF(values[_i]);
}
Py_DECREF(keys);
- #line 1366 "Python/bytecodes.c"
+ #line 1364 "Python/bytecodes.c"
if (map == NULL) { STACK_SHRINK(oparg); goto pop_1_error; }
- #line 1975 "Python/generated_cases.c.h"
+ #line 1973 "Python/generated_cases.c.h"
STACK_SHRINK(oparg);
stack_pointer[-1] = map;
DISPATCH();
TARGET(DICT_UPDATE) {
PyObject *update = stack_pointer[-1];
- #line 1370 "Python/bytecodes.c"
+ #line 1368 "Python/bytecodes.c"
PyObject *dict = PEEK(oparg + 1); // update is still on the stack
if (PyDict_Update(dict, update) < 0) {
if (_PyErr_ExceptionMatches(tstate, PyExc_AttributeError)) {
"'%.200s' object is not a mapping",
Py_TYPE(update)->tp_name);
}
- #line 1991 "Python/generated_cases.c.h"
+ #line 1989 "Python/generated_cases.c.h"
Py_DECREF(update);
- #line 1378 "Python/bytecodes.c"
+ #line 1376 "Python/bytecodes.c"
if (true) goto pop_1_error;
}
- #line 1996 "Python/generated_cases.c.h"
+ #line 1994 "Python/generated_cases.c.h"
Py_DECREF(update);
STACK_SHRINK(1);
DISPATCH();
TARGET(DICT_MERGE) {
PyObject *update = stack_pointer[-1];
- #line 1384 "Python/bytecodes.c"
+ #line 1382 "Python/bytecodes.c"
PyObject *dict = PEEK(oparg + 1); // update is still on the stack
if (_PyDict_MergeEx(dict, update, 2) < 0) {
format_kwargs_error(tstate, PEEK(3 + oparg), update);
- #line 2009 "Python/generated_cases.c.h"
+ #line 2007 "Python/generated_cases.c.h"
Py_DECREF(update);
- #line 1389 "Python/bytecodes.c"
+ #line 1387 "Python/bytecodes.c"
if (true) goto pop_1_error;
}
- #line 2014 "Python/generated_cases.c.h"
+ #line 2012 "Python/generated_cases.c.h"
Py_DECREF(update);
STACK_SHRINK(1);
PREDICT(CALL_FUNCTION_EX);
TARGET(MAP_ADD) {
PyObject *value = stack_pointer[-1];
PyObject *key = stack_pointer[-2];
- #line 1396 "Python/bytecodes.c"
+ #line 1394 "Python/bytecodes.c"
PyObject *dict = PEEK(oparg + 2); // key, value are still on the stack
assert(PyDict_CheckExact(dict));
/* dict[key] = value */
// Do not DECREF INPUTS because the function steals the references
if (_PyDict_SetItem_Take2((PyDictObject *)dict, key, value) != 0) goto pop_2_error;
- #line 2030 "Python/generated_cases.c.h"
+ #line 2028 "Python/generated_cases.c.h"
STACK_SHRINK(2);
PREDICT(JUMP_BACKWARD);
DISPATCH();
PyObject *owner = stack_pointer[-1];
PyObject *res2 = NULL;
PyObject *res;
- #line 1419 "Python/bytecodes.c"
+ #line 1417 "Python/bytecodes.c"
#if ENABLE_SPECIALIZATION
_PyAttrCache *cache = (_PyAttrCache *)next_instr;
if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
NULL | meth | arg1 | ... | argN
*/
- #line 2077 "Python/generated_cases.c.h"
+ #line 2075 "Python/generated_cases.c.h"
Py_DECREF(owner);
- #line 1454 "Python/bytecodes.c"
+ #line 1452 "Python/bytecodes.c"
if (meth == NULL) goto pop_1_error;
res2 = NULL;
res = meth;
else {
/* Classic, pushes one value. */
res = PyObject_GetAttr(owner, name);
- #line 2088 "Python/generated_cases.c.h"
+ #line 2086 "Python/generated_cases.c.h"
Py_DECREF(owner);
- #line 1463 "Python/bytecodes.c"
+ #line 1461 "Python/bytecodes.c"
if (res == NULL) goto pop_1_error;
}
- #line 2093 "Python/generated_cases.c.h"
+ #line 2091 "Python/generated_cases.c.h"
STACK_GROW(((oparg & 1) ? 1 : 0));
stack_pointer[-1] = res;
if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; }
PyObject *res;
uint32_t type_version = read_u32(&next_instr[1].cache);
uint16_t index = read_u16(&next_instr[3].cache);
- #line 1468 "Python/bytecodes.c"
+ #line 1466 "Python/bytecodes.c"
assert(cframe.use_tracing == 0);
PyTypeObject *tp = Py_TYPE(owner);
assert(type_version != 0);
STAT_INC(LOAD_ATTR, hit);
Py_INCREF(res);
res2 = NULL;
- #line 2121 "Python/generated_cases.c.h"
+ #line 2119 "Python/generated_cases.c.h"
Py_DECREF(owner);
STACK_GROW(((oparg & 1) ? 1 : 0));
stack_pointer[-1] = res;
PyObject *res;
uint32_t type_version = read_u32(&next_instr[1].cache);
uint16_t index = read_u16(&next_instr[3].cache);
- #line 1485 "Python/bytecodes.c"
+ #line 1483 "Python/bytecodes.c"
assert(cframe.use_tracing == 0);
DEOPT_IF(!PyModule_CheckExact(owner), LOAD_ATTR);
PyDictObject *dict = (PyDictObject *)((PyModuleObject *)owner)->md_dict;
STAT_INC(LOAD_ATTR, hit);
Py_INCREF(res);
res2 = NULL;
- #line 2150 "Python/generated_cases.c.h"
+ #line 2148 "Python/generated_cases.c.h"
Py_DECREF(owner);
STACK_GROW(((oparg & 1) ? 1 : 0));
stack_pointer[-1] = res;
PyObject *res;
uint32_t type_version = read_u32(&next_instr[1].cache);
uint16_t index = read_u16(&next_instr[3].cache);
- #line 1502 "Python/bytecodes.c"
+ #line 1500 "Python/bytecodes.c"
assert(cframe.use_tracing == 0);
PyTypeObject *tp = Py_TYPE(owner);
assert(type_version != 0);
STAT_INC(LOAD_ATTR, hit);
Py_INCREF(res);
res2 = NULL;
- #line 2193 "Python/generated_cases.c.h"
+ #line 2191 "Python/generated_cases.c.h"
Py_DECREF(owner);
STACK_GROW(((oparg & 1) ? 1 : 0));
stack_pointer[-1] = res;
PyObject *res;
uint32_t type_version = read_u32(&next_instr[1].cache);
uint16_t index = read_u16(&next_instr[3].cache);
- #line 1533 "Python/bytecodes.c"
+ #line 1531 "Python/bytecodes.c"
assert(cframe.use_tracing == 0);
PyTypeObject *tp = Py_TYPE(owner);
assert(type_version != 0);
STAT_INC(LOAD_ATTR, hit);
Py_INCREF(res);
res2 = NULL;
- #line 2219 "Python/generated_cases.c.h"
+ #line 2217 "Python/generated_cases.c.h"
Py_DECREF(owner);
STACK_GROW(((oparg & 1) ? 1 : 0));
stack_pointer[-1] = res;
PyObject *res;
uint32_t type_version = read_u32(&next_instr[1].cache);
PyObject *descr = read_obj(&next_instr[5].cache);
- #line 1547 "Python/bytecodes.c"
+ #line 1545 "Python/bytecodes.c"
assert(cframe.use_tracing == 0);
DEOPT_IF(!PyType_Check(cls), LOAD_ATTR);
res = descr;
assert(res != NULL);
Py_INCREF(res);
- #line 2247 "Python/generated_cases.c.h"
+ #line 2245 "Python/generated_cases.c.h"
Py_DECREF(cls);
STACK_GROW(((oparg & 1) ? 1 : 0));
stack_pointer[-1] = res;
uint32_t type_version = read_u32(&next_instr[1].cache);
uint32_t func_version = read_u32(&next_instr[3].cache);
PyObject *fget = read_obj(&next_instr[5].cache);
- #line 1563 "Python/bytecodes.c"
+ #line 1561 "Python/bytecodes.c"
assert(cframe.use_tracing == 0);
DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR);
new_frame->localsplus[0] = owner;
JUMPBY(INLINE_CACHE_ENTRIES_LOAD_ATTR);
DISPATCH_INLINED(new_frame);
- #line 2285 "Python/generated_cases.c.h"
+ #line 2283 "Python/generated_cases.c.h"
}
TARGET(LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN) {
uint32_t type_version = read_u32(&next_instr[1].cache);
uint32_t func_version = read_u32(&next_instr[3].cache);
PyObject *getattribute = read_obj(&next_instr[5].cache);
- #line 1589 "Python/bytecodes.c"
+ #line 1587 "Python/bytecodes.c"
assert(cframe.use_tracing == 0);
DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR);
PyTypeObject *cls = Py_TYPE(owner);
new_frame->localsplus[1] = Py_NewRef(name);
JUMPBY(INLINE_CACHE_ENTRIES_LOAD_ATTR);
DISPATCH_INLINED(new_frame);
- #line 2319 "Python/generated_cases.c.h"
+ #line 2317 "Python/generated_cases.c.h"
}
TARGET(STORE_ATTR_INSTANCE_VALUE) {
PyObject *value = stack_pointer[-2];
uint32_t type_version = read_u32(&next_instr[1].cache);
uint16_t index = read_u16(&next_instr[3].cache);
- #line 1617 "Python/bytecodes.c"
+ #line 1615 "Python/bytecodes.c"
assert(cframe.use_tracing == 0);
PyTypeObject *tp = Py_TYPE(owner);
assert(type_version != 0);
Py_DECREF(old_value);
}
Py_DECREF(owner);
- #line 2346 "Python/generated_cases.c.h"
+ #line 2344 "Python/generated_cases.c.h"
STACK_SHRINK(2);
next_instr += 4;
DISPATCH();
PyObject *value = stack_pointer[-2];
uint32_t type_version = read_u32(&next_instr[1].cache);
uint16_t hint = read_u16(&next_instr[3].cache);
- #line 1638 "Python/bytecodes.c"
+ #line 1636 "Python/bytecodes.c"
assert(cframe.use_tracing == 0);
PyTypeObject *tp = Py_TYPE(owner);
assert(type_version != 0);
/* PEP 509 */
dict->ma_version_tag = new_version;
Py_DECREF(owner);
- #line 2397 "Python/generated_cases.c.h"
+ #line 2395 "Python/generated_cases.c.h"
STACK_SHRINK(2);
next_instr += 4;
DISPATCH();
PyObject *value = stack_pointer[-2];
uint32_t type_version = read_u32(&next_instr[1].cache);
uint16_t index = read_u16(&next_instr[3].cache);
- #line 1680 "Python/bytecodes.c"
+ #line 1678 "Python/bytecodes.c"
assert(cframe.use_tracing == 0);
PyTypeObject *tp = Py_TYPE(owner);
assert(type_version != 0);
*(PyObject **)addr = value;
Py_XDECREF(old_value);
Py_DECREF(owner);
- #line 2419 "Python/generated_cases.c.h"
+ #line 2417 "Python/generated_cases.c.h"
STACK_SHRINK(2);
next_instr += 4;
DISPATCH();
PyObject *right = stack_pointer[-1];
PyObject *left = stack_pointer[-2];
PyObject *res;
- #line 1693 "Python/bytecodes.c"
+ #line 1691 "Python/bytecodes.c"
STAT_INC(COMPARE_OP, deferred);
assert((oparg >> 4) <= Py_GE);
res = PyObject_RichCompare(left, right, oparg>>4);
- #line 2433 "Python/generated_cases.c.h"
+ #line 2431 "Python/generated_cases.c.h"
Py_DECREF(left);
Py_DECREF(right);
- #line 1697 "Python/bytecodes.c"
+ #line 1695 "Python/bytecodes.c"
if (res == NULL) goto pop_2_error;
- #line 2438 "Python/generated_cases.c.h"
+ #line 2436 "Python/generated_cases.c.h"
STACK_SHRINK(1);
stack_pointer[-1] = res;
next_instr += 1;
PREDICTED(COMPARE_AND_BRANCH);
PyObject *right = stack_pointer[-1];
PyObject *left = stack_pointer[-2];
- #line 1709 "Python/bytecodes.c"
+ #line 1707 "Python/bytecodes.c"
#if ENABLE_SPECIALIZATION
_PyCompareOpCache *cache = (_PyCompareOpCache *)next_instr;
if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
#endif /* ENABLE_SPECIALIZATION */
assert((oparg >> 4) <= Py_GE);
PyObject *cond = PyObject_RichCompare(left, right, oparg>>4);
- #line 2463 "Python/generated_cases.c.h"
+ #line 2461 "Python/generated_cases.c.h"
Py_DECREF(left);
Py_DECREF(right);
- #line 1723 "Python/bytecodes.c"
+ #line 1721 "Python/bytecodes.c"
if (cond == NULL) goto pop_2_error;
assert(next_instr[1].op.code == POP_JUMP_IF_FALSE ||
next_instr[1].op.code == POP_JUMP_IF_TRUE);
if (jump_on_true == (err != 0)) {
JUMPBY(offset);
}
- #line 2478 "Python/generated_cases.c.h"
+ #line 2476 "Python/generated_cases.c.h"
STACK_SHRINK(2);
next_instr += 2;
DISPATCH();
TARGET(COMPARE_AND_BRANCH_FLOAT) {
PyObject *right = stack_pointer[-1];
PyObject *left = stack_pointer[-2];
- #line 1737 "Python/bytecodes.c"
+ #line 1735 "Python/bytecodes.c"
assert(cframe.use_tracing == 0);
DEOPT_IF(!PyFloat_CheckExact(left), COMPARE_AND_BRANCH);
DEOPT_IF(!PyFloat_CheckExact(right), COMPARE_AND_BRANCH);
int offset = next_instr[1].op.arg;
JUMPBY(offset);
}
- #line 2502 "Python/generated_cases.c.h"
+ #line 2500 "Python/generated_cases.c.h"
STACK_SHRINK(2);
next_instr += 2;
DISPATCH();
TARGET(COMPARE_AND_BRANCH_INT) {
PyObject *right = stack_pointer[-1];
PyObject *left = stack_pointer[-2];
- #line 1755 "Python/bytecodes.c"
+ #line 1753 "Python/bytecodes.c"
assert(cframe.use_tracing == 0);
DEOPT_IF(!PyLong_CheckExact(left), COMPARE_AND_BRANCH);
DEOPT_IF(!PyLong_CheckExact(right), COMPARE_AND_BRANCH);
- DEOPT_IF((size_t)(Py_SIZE(left) + 1) > 2, COMPARE_AND_BRANCH);
- DEOPT_IF((size_t)(Py_SIZE(right) + 1) > 2, COMPARE_AND_BRANCH);
+ DEOPT_IF(!_PyLong_IsCompact((PyLongObject *)left), COMPARE_AND_BRANCH);
+ DEOPT_IF(!_PyLong_IsCompact((PyLongObject *)right), COMPARE_AND_BRANCH);
STAT_INC(COMPARE_AND_BRANCH, hit);
- assert(Py_ABS(Py_SIZE(left)) <= 1 && Py_ABS(Py_SIZE(right)) <= 1);
- Py_ssize_t ileft = Py_SIZE(left) * ((PyLongObject *)left)->long_value.ob_digit[0];
- Py_ssize_t iright = Py_SIZE(right) * ((PyLongObject *)right)->long_value.ob_digit[0];
+ assert(_PyLong_DigitCount((PyLongObject *)left) <= 1 &&
+ _PyLong_DigitCount((PyLongObject *)right) <= 1);
+ Py_ssize_t ileft = _PyLong_CompactValue((PyLongObject *)left);
+ Py_ssize_t iright = _PyLong_CompactValue((PyLongObject *)right);
// 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);
int offset = next_instr[1].op.arg;
JUMPBY(offset);
}
- #line 2529 "Python/generated_cases.c.h"
+ #line 2528 "Python/generated_cases.c.h"
STACK_SHRINK(2);
next_instr += 2;
DISPATCH();
TARGET(COMPARE_AND_BRANCH_STR) {
PyObject *right = stack_pointer[-1];
PyObject *left = stack_pointer[-2];
- #line 1776 "Python/bytecodes.c"
+ #line 1775 "Python/bytecodes.c"
assert(cframe.use_tracing == 0);
DEOPT_IF(!PyUnicode_CheckExact(left), COMPARE_AND_BRANCH);
DEOPT_IF(!PyUnicode_CheckExact(right), COMPARE_AND_BRANCH);
int offset = next_instr[1].op.arg;
JUMPBY(offset);
}
- #line 2554 "Python/generated_cases.c.h"
+ #line 2553 "Python/generated_cases.c.h"
STACK_SHRINK(2);
next_instr += 2;
DISPATCH();
PyObject *right = stack_pointer[-1];
PyObject *left = stack_pointer[-2];
PyObject *b;
- #line 1794 "Python/bytecodes.c"
+ #line 1793 "Python/bytecodes.c"
int res = Py_Is(left, right) ^ oparg;
- #line 2566 "Python/generated_cases.c.h"
+ #line 2565 "Python/generated_cases.c.h"
Py_DECREF(left);
Py_DECREF(right);
- #line 1796 "Python/bytecodes.c"
+ #line 1795 "Python/bytecodes.c"
b = Py_NewRef(res ? Py_True : Py_False);
- #line 2571 "Python/generated_cases.c.h"
+ #line 2570 "Python/generated_cases.c.h"
STACK_SHRINK(1);
stack_pointer[-1] = b;
DISPATCH();
PyObject *right = stack_pointer[-1];
PyObject *left = stack_pointer[-2];
PyObject *b;
- #line 1800 "Python/bytecodes.c"
+ #line 1799 "Python/bytecodes.c"
int res = PySequence_Contains(right, left);
- #line 2583 "Python/generated_cases.c.h"
+ #line 2582 "Python/generated_cases.c.h"
Py_DECREF(left);
Py_DECREF(right);
- #line 1802 "Python/bytecodes.c"
+ #line 1801 "Python/bytecodes.c"
if (res < 0) goto pop_2_error;
b = Py_NewRef((res^oparg) ? Py_True : Py_False);
- #line 2589 "Python/generated_cases.c.h"
+ #line 2588 "Python/generated_cases.c.h"
STACK_SHRINK(1);
stack_pointer[-1] = b;
DISPATCH();
PyObject *exc_value = stack_pointer[-2];
PyObject *rest;
PyObject *match;
- #line 1807 "Python/bytecodes.c"
+ #line 1806 "Python/bytecodes.c"
if (check_except_star_type_valid(tstate, match_type) < 0) {
- #line 2602 "Python/generated_cases.c.h"
+ #line 2601 "Python/generated_cases.c.h"
Py_DECREF(exc_value);
Py_DECREF(match_type);
- #line 1809 "Python/bytecodes.c"
+ #line 1808 "Python/bytecodes.c"
if (true) goto pop_2_error;
}
rest = NULL;
int res = exception_group_match(exc_value, match_type,
&match, &rest);
- #line 2613 "Python/generated_cases.c.h"
+ #line 2612 "Python/generated_cases.c.h"
Py_DECREF(exc_value);
Py_DECREF(match_type);
- #line 1817 "Python/bytecodes.c"
+ #line 1816 "Python/bytecodes.c"
if (res < 0) goto pop_2_error;
assert((match == NULL) == (rest == NULL));
if (!Py_IsNone(match)) {
PyErr_SetExcInfo(NULL, Py_NewRef(match), NULL);
}
- #line 2625 "Python/generated_cases.c.h"
+ #line 2624 "Python/generated_cases.c.h"
stack_pointer[-1] = match;
stack_pointer[-2] = rest;
DISPATCH();
PyObject *right = stack_pointer[-1];
PyObject *left = stack_pointer[-2];
PyObject *b;
- #line 1828 "Python/bytecodes.c"
+ #line 1827 "Python/bytecodes.c"
assert(PyExceptionInstance_Check(left));
if (check_except_type_valid(tstate, right) < 0) {
- #line 2638 "Python/generated_cases.c.h"
+ #line 2637 "Python/generated_cases.c.h"
Py_DECREF(right);
- #line 1831 "Python/bytecodes.c"
+ #line 1830 "Python/bytecodes.c"
if (true) goto pop_1_error;
}
int res = PyErr_GivenExceptionMatches(left, right);
- #line 2645 "Python/generated_cases.c.h"
+ #line 2644 "Python/generated_cases.c.h"
Py_DECREF(right);
- #line 1836 "Python/bytecodes.c"
+ #line 1835 "Python/bytecodes.c"
b = Py_NewRef(res ? Py_True : Py_False);
- #line 2649 "Python/generated_cases.c.h"
+ #line 2648 "Python/generated_cases.c.h"
stack_pointer[-1] = b;
DISPATCH();
}
PyObject *fromlist = stack_pointer[-1];
PyObject *level = stack_pointer[-2];
PyObject *res;
- #line 1840 "Python/bytecodes.c"
+ #line 1839 "Python/bytecodes.c"
PyObject *name = GETITEM(frame->f_code->co_names, oparg);
res = import_name(tstate, frame, name, fromlist, level);
- #line 2661 "Python/generated_cases.c.h"
+ #line 2660 "Python/generated_cases.c.h"
Py_DECREF(level);
Py_DECREF(fromlist);
- #line 1843 "Python/bytecodes.c"
+ #line 1842 "Python/bytecodes.c"
if (res == NULL) goto pop_2_error;
- #line 2666 "Python/generated_cases.c.h"
+ #line 2665 "Python/generated_cases.c.h"
STACK_SHRINK(1);
stack_pointer[-1] = res;
DISPATCH();
TARGET(IMPORT_FROM) {
PyObject *from = stack_pointer[-1];
PyObject *res;
- #line 1847 "Python/bytecodes.c"
+ #line 1846 "Python/bytecodes.c"
PyObject *name = GETITEM(frame->f_code->co_names, oparg);
res = import_from(tstate, from, name);
if (res == NULL) goto error;
- #line 2679 "Python/generated_cases.c.h"
+ #line 2678 "Python/generated_cases.c.h"
STACK_GROW(1);
stack_pointer[-1] = res;
DISPATCH();
}
TARGET(JUMP_FORWARD) {
- #line 1853 "Python/bytecodes.c"
+ #line 1852 "Python/bytecodes.c"
JUMPBY(oparg);
- #line 2688 "Python/generated_cases.c.h"
+ #line 2687 "Python/generated_cases.c.h"
DISPATCH();
}
TARGET(JUMP_BACKWARD) {
PREDICTED(JUMP_BACKWARD);
- #line 1857 "Python/bytecodes.c"
+ #line 1856 "Python/bytecodes.c"
assert(oparg < INSTR_OFFSET());
JUMPBY(-oparg);
- #line 2697 "Python/generated_cases.c.h"
+ #line 2696 "Python/generated_cases.c.h"
CHECK_EVAL_BREAKER();
DISPATCH();
}
TARGET(POP_JUMP_IF_FALSE) {
PREDICTED(POP_JUMP_IF_FALSE);
PyObject *cond = stack_pointer[-1];
- #line 1863 "Python/bytecodes.c"
+ #line 1862 "Python/bytecodes.c"
if (Py_IsTrue(cond)) {
_Py_DECREF_NO_DEALLOC(cond);
}
}
else {
int err = PyObject_IsTrue(cond);
- #line 2715 "Python/generated_cases.c.h"
+ #line 2714 "Python/generated_cases.c.h"
Py_DECREF(cond);
- #line 1873 "Python/bytecodes.c"
+ #line 1872 "Python/bytecodes.c"
if (err == 0) {
JUMPBY(oparg);
}
if (err < 0) goto pop_1_error;
}
}
- #line 2725 "Python/generated_cases.c.h"
+ #line 2724 "Python/generated_cases.c.h"
STACK_SHRINK(1);
DISPATCH();
}
TARGET(POP_JUMP_IF_TRUE) {
PyObject *cond = stack_pointer[-1];
- #line 1883 "Python/bytecodes.c"
+ #line 1882 "Python/bytecodes.c"
if (Py_IsFalse(cond)) {
_Py_DECREF_NO_DEALLOC(cond);
}
}
else {
int err = PyObject_IsTrue(cond);
- #line 2742 "Python/generated_cases.c.h"
+ #line 2741 "Python/generated_cases.c.h"
Py_DECREF(cond);
- #line 1893 "Python/bytecodes.c"
+ #line 1892 "Python/bytecodes.c"
if (err > 0) {
JUMPBY(oparg);
}
if (err < 0) goto pop_1_error;
}
}
- #line 2752 "Python/generated_cases.c.h"
+ #line 2751 "Python/generated_cases.c.h"
STACK_SHRINK(1);
DISPATCH();
}
TARGET(POP_JUMP_IF_NOT_NONE) {
PyObject *value = stack_pointer[-1];
- #line 1903 "Python/bytecodes.c"
+ #line 1902 "Python/bytecodes.c"
if (!Py_IsNone(value)) {
- #line 2761 "Python/generated_cases.c.h"
+ #line 2760 "Python/generated_cases.c.h"
Py_DECREF(value);
- #line 1905 "Python/bytecodes.c"
+ #line 1904 "Python/bytecodes.c"
JUMPBY(oparg);
}
else {
_Py_DECREF_NO_DEALLOC(value);
}
- #line 2769 "Python/generated_cases.c.h"
+ #line 2768 "Python/generated_cases.c.h"
STACK_SHRINK(1);
DISPATCH();
}
TARGET(POP_JUMP_IF_NONE) {
PyObject *value = stack_pointer[-1];
- #line 1913 "Python/bytecodes.c"
+ #line 1912 "Python/bytecodes.c"
if (Py_IsNone(value)) {
_Py_DECREF_NO_DEALLOC(value);
JUMPBY(oparg);
}
else {
- #line 2782 "Python/generated_cases.c.h"
+ #line 2781 "Python/generated_cases.c.h"
Py_DECREF(value);
- #line 1919 "Python/bytecodes.c"
+ #line 1918 "Python/bytecodes.c"
}
- #line 2786 "Python/generated_cases.c.h"
+ #line 2785 "Python/generated_cases.c.h"
STACK_SHRINK(1);
DISPATCH();
}
TARGET(JUMP_IF_FALSE_OR_POP) {
PyObject *cond = stack_pointer[-1];
- #line 1923 "Python/bytecodes.c"
+ #line 1922 "Python/bytecodes.c"
bool jump = false;
int err;
if (Py_IsTrue(cond)) {
goto error;
}
}
- #line 2816 "Python/generated_cases.c.h"
+ #line 2815 "Python/generated_cases.c.h"
STACK_SHRINK(1);
STACK_GROW((jump ? 1 : 0));
DISPATCH();
TARGET(JUMP_IF_TRUE_OR_POP) {
PyObject *cond = stack_pointer[-1];
- #line 1948 "Python/bytecodes.c"
+ #line 1947 "Python/bytecodes.c"
bool jump = false;
int err;
if (Py_IsFalse(cond)) {
goto error;
}
}
- #line 2847 "Python/generated_cases.c.h"
+ #line 2846 "Python/generated_cases.c.h"
STACK_SHRINK(1);
STACK_GROW((jump ? 1 : 0));
DISPATCH();
}
TARGET(JUMP_BACKWARD_NO_INTERRUPT) {
- #line 1973 "Python/bytecodes.c"
+ #line 1972 "Python/bytecodes.c"
/* This bytecode is used in the `yield from` or `await` loop.
* If there is an interrupt, we want it handled in the innermost
* generator or coroutine, so we deliberately do not check it here.
* (see bpo-30039).
*/
JUMPBY(-oparg);
- #line 2861 "Python/generated_cases.c.h"
+ #line 2860 "Python/generated_cases.c.h"
DISPATCH();
}
TARGET(GET_LEN) {
PyObject *obj = stack_pointer[-1];
PyObject *len_o;
- #line 1982 "Python/bytecodes.c"
+ #line 1981 "Python/bytecodes.c"
// PUSH(len(TOS))
Py_ssize_t len_i = PyObject_Length(obj);
if (len_i < 0) goto error;
len_o = PyLong_FromSsize_t(len_i);
if (len_o == NULL) goto error;
- #line 2874 "Python/generated_cases.c.h"
+ #line 2873 "Python/generated_cases.c.h"
STACK_GROW(1);
stack_pointer[-1] = len_o;
DISPATCH();
PyObject *type = stack_pointer[-2];
PyObject *subject = stack_pointer[-3];
PyObject *attrs;
- #line 1990 "Python/bytecodes.c"
+ #line 1989 "Python/bytecodes.c"
// Pop TOS and TOS1. Set TOS to a tuple of attributes on success, or
// None on failure.
assert(PyTuple_CheckExact(names));
attrs = match_class(tstate, subject, type, oparg, names);
- #line 2890 "Python/generated_cases.c.h"
+ #line 2889 "Python/generated_cases.c.h"
Py_DECREF(subject);
Py_DECREF(type);
Py_DECREF(names);
- #line 1995 "Python/bytecodes.c"
+ #line 1994 "Python/bytecodes.c"
if (attrs) {
assert(PyTuple_CheckExact(attrs)); // Success!
}
if (_PyErr_Occurred(tstate)) goto pop_3_error;
attrs = Py_NewRef(Py_None); // Failure!
}
- #line 2902 "Python/generated_cases.c.h"
+ #line 2901 "Python/generated_cases.c.h"
STACK_SHRINK(2);
stack_pointer[-1] = attrs;
DISPATCH();
TARGET(MATCH_MAPPING) {
PyObject *subject = stack_pointer[-1];
PyObject *res;
- #line 2005 "Python/bytecodes.c"
+ #line 2004 "Python/bytecodes.c"
int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_MAPPING;
res = Py_NewRef(match ? Py_True : Py_False);
- #line 2914 "Python/generated_cases.c.h"
+ #line 2913 "Python/generated_cases.c.h"
STACK_GROW(1);
stack_pointer[-1] = res;
PREDICT(POP_JUMP_IF_FALSE);
TARGET(MATCH_SEQUENCE) {
PyObject *subject = stack_pointer[-1];
PyObject *res;
- #line 2011 "Python/bytecodes.c"
+ #line 2010 "Python/bytecodes.c"
int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_SEQUENCE;
res = Py_NewRef(match ? Py_True : Py_False);
- #line 2927 "Python/generated_cases.c.h"
+ #line 2926 "Python/generated_cases.c.h"
STACK_GROW(1);
stack_pointer[-1] = res;
PREDICT(POP_JUMP_IF_FALSE);
PyObject *keys = stack_pointer[-1];
PyObject *subject = stack_pointer[-2];
PyObject *values_or_none;
- #line 2017 "Python/bytecodes.c"
+ #line 2016 "Python/bytecodes.c"
// On successful match, PUSH(values). Otherwise, PUSH(None).
values_or_none = match_keys(tstate, subject, keys);
if (values_or_none == NULL) goto error;
- #line 2942 "Python/generated_cases.c.h"
+ #line 2941 "Python/generated_cases.c.h"
STACK_GROW(1);
stack_pointer[-1] = values_or_none;
DISPATCH();
TARGET(GET_ITER) {
PyObject *iterable = stack_pointer[-1];
PyObject *iter;
- #line 2023 "Python/bytecodes.c"
+ #line 2022 "Python/bytecodes.c"
/* before: [obj]; after [getiter(obj)] */
iter = PyObject_GetIter(iterable);
- #line 2954 "Python/generated_cases.c.h"
+ #line 2953 "Python/generated_cases.c.h"
Py_DECREF(iterable);
- #line 2026 "Python/bytecodes.c"
+ #line 2025 "Python/bytecodes.c"
if (iter == NULL) goto pop_1_error;
- #line 2958 "Python/generated_cases.c.h"
+ #line 2957 "Python/generated_cases.c.h"
stack_pointer[-1] = iter;
DISPATCH();
}
TARGET(GET_YIELD_FROM_ITER) {
PyObject *iterable = stack_pointer[-1];
PyObject *iter;
- #line 2030 "Python/bytecodes.c"
+ #line 2029 "Python/bytecodes.c"
/* before: [obj]; after [getiter(obj)] */
if (PyCoro_CheckExact(iterable)) {
/* `iterable` is a coroutine */
if (iter == NULL) {
goto error;
}
- #line 2989 "Python/generated_cases.c.h"
+ #line 2988 "Python/generated_cases.c.h"
Py_DECREF(iterable);
- #line 2053 "Python/bytecodes.c"
+ #line 2052 "Python/bytecodes.c"
}
- #line 2993 "Python/generated_cases.c.h"
+ #line 2992 "Python/generated_cases.c.h"
stack_pointer[-1] = iter;
PREDICT(LOAD_CONST);
DISPATCH();
static_assert(INLINE_CACHE_ENTRIES_FOR_ITER == 1, "incorrect cache size");
PyObject *iter = stack_pointer[-1];
PyObject *next;
- #line 2072 "Python/bytecodes.c"
+ #line 2071 "Python/bytecodes.c"
#if ENABLE_SPECIALIZATION
_PyForIterCache *cache = (_PyForIterCache *)next_instr;
if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
DISPATCH();
}
// Common case: no jump, leave it to the code generator
- #line 3037 "Python/generated_cases.c.h"
+ #line 3036 "Python/generated_cases.c.h"
STACK_GROW(1);
stack_pointer[-1] = next;
next_instr += 1;
TARGET(FOR_ITER_LIST) {
PyObject *iter = stack_pointer[-1];
PyObject *next;
- #line 2107 "Python/bytecodes.c"
+ #line 2106 "Python/bytecodes.c"
assert(cframe.use_tracing == 0);
DEOPT_IF(Py_TYPE(iter) != &PyListIter_Type, FOR_ITER);
_PyListIterObject *it = (_PyListIterObject *)iter;
DISPATCH();
end_for_iter_list:
// Common case: no jump, leave it to the code generator
- #line 3068 "Python/generated_cases.c.h"
+ #line 3067 "Python/generated_cases.c.h"
STACK_GROW(1);
stack_pointer[-1] = next;
next_instr += 1;
TARGET(FOR_ITER_TUPLE) {
PyObject *iter = stack_pointer[-1];
PyObject *next;
- #line 2130 "Python/bytecodes.c"
+ #line 2129 "Python/bytecodes.c"
assert(cframe.use_tracing == 0);
_PyTupleIterObject *it = (_PyTupleIterObject *)iter;
DEOPT_IF(Py_TYPE(it) != &PyTupleIter_Type, FOR_ITER);
DISPATCH();
end_for_iter_tuple:
// Common case: no jump, leave it to the code generator
- #line 3099 "Python/generated_cases.c.h"
+ #line 3098 "Python/generated_cases.c.h"
STACK_GROW(1);
stack_pointer[-1] = next;
next_instr += 1;
TARGET(FOR_ITER_RANGE) {
PyObject *iter = stack_pointer[-1];
PyObject *next;
- #line 2153 "Python/bytecodes.c"
+ #line 2152 "Python/bytecodes.c"
assert(cframe.use_tracing == 0);
_PyRangeIterObject *r = (_PyRangeIterObject *)iter;
DEOPT_IF(Py_TYPE(r) != &PyRangeIter_Type, FOR_ITER);
if (next == NULL) {
goto error;
}
- #line 3128 "Python/generated_cases.c.h"
+ #line 3127 "Python/generated_cases.c.h"
STACK_GROW(1);
stack_pointer[-1] = next;
next_instr += 1;
TARGET(FOR_ITER_GEN) {
PyObject *iter = stack_pointer[-1];
- #line 2174 "Python/bytecodes.c"
+ #line 2173 "Python/bytecodes.c"
assert(cframe.use_tracing == 0);
PyGenObject *gen = (PyGenObject *)iter;
DEOPT_IF(Py_TYPE(gen) != &PyGen_Type, FOR_ITER);
JUMPBY(INLINE_CACHE_ENTRIES_FOR_ITER + oparg);
assert(next_instr->op.code == END_FOR);
DISPATCH_INLINED(gen_frame);
- #line 3152 "Python/generated_cases.c.h"
+ #line 3151 "Python/generated_cases.c.h"
}
TARGET(BEFORE_ASYNC_WITH) {
PyObject *mgr = stack_pointer[-1];
PyObject *exit;
PyObject *res;
- #line 2191 "Python/bytecodes.c"
+ #line 2190 "Python/bytecodes.c"
PyObject *enter = _PyObject_LookupSpecial(mgr, &_Py_ID(__aenter__));
if (enter == NULL) {
if (!_PyErr_Occurred(tstate)) {
Py_DECREF(enter);
goto error;
}
- #line 3182 "Python/generated_cases.c.h"
+ #line 3181 "Python/generated_cases.c.h"
Py_DECREF(mgr);
- #line 2214 "Python/bytecodes.c"
+ #line 2213 "Python/bytecodes.c"
res = _PyObject_CallNoArgs(enter);
Py_DECREF(enter);
if (res == NULL) {
Py_DECREF(exit);
if (true) goto pop_1_error;
}
- #line 3191 "Python/generated_cases.c.h"
+ #line 3190 "Python/generated_cases.c.h"
STACK_GROW(1);
stack_pointer[-1] = res;
stack_pointer[-2] = exit;
PyObject *mgr = stack_pointer[-1];
PyObject *exit;
PyObject *res;
- #line 2224 "Python/bytecodes.c"
+ #line 2223 "Python/bytecodes.c"
/* pop the context manager, push its __exit__ and the
* value returned from calling its __enter__
*/
Py_DECREF(enter);
goto error;
}
- #line 3229 "Python/generated_cases.c.h"
+ #line 3228 "Python/generated_cases.c.h"
Py_DECREF(mgr);
- #line 2250 "Python/bytecodes.c"
+ #line 2249 "Python/bytecodes.c"
res = _PyObject_CallNoArgs(enter);
Py_DECREF(enter);
if (res == NULL) {
Py_DECREF(exit);
if (true) goto pop_1_error;
}
- #line 3238 "Python/generated_cases.c.h"
+ #line 3237 "Python/generated_cases.c.h"
STACK_GROW(1);
stack_pointer[-1] = res;
stack_pointer[-2] = exit;
PyObject *lasti = stack_pointer[-3];
PyObject *exit_func = stack_pointer[-4];
PyObject *res;
- #line 2259 "Python/bytecodes.c"
+ #line 2258 "Python/bytecodes.c"
/* At the top of the stack are 4 values:
- val: TOP = exc_info()
- unused: SECOND = previous exception
res = PyObject_Vectorcall(exit_func, stack + 1,
3 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
if (res == NULL) goto error;
- #line 3271 "Python/generated_cases.c.h"
+ #line 3270 "Python/generated_cases.c.h"
STACK_GROW(1);
stack_pointer[-1] = res;
DISPATCH();
TARGET(PUSH_EXC_INFO) {
PyObject *new_exc = stack_pointer[-1];
PyObject *prev_exc;
- #line 2282 "Python/bytecodes.c"
+ #line 2281 "Python/bytecodes.c"
_PyErr_StackItem *exc_info = tstate->exc_info;
if (exc_info->exc_value != NULL) {
prev_exc = exc_info->exc_value;
}
assert(PyExceptionInstance_Check(new_exc));
exc_info->exc_value = Py_NewRef(new_exc);
- #line 3290 "Python/generated_cases.c.h"
+ #line 3289 "Python/generated_cases.c.h"
STACK_GROW(1);
stack_pointer[-1] = new_exc;
stack_pointer[-2] = prev_exc;
uint32_t type_version = read_u32(&next_instr[1].cache);
uint32_t keys_version = read_u32(&next_instr[3].cache);
PyObject *descr = read_obj(&next_instr[5].cache);
- #line 2294 "Python/bytecodes.c"
+ #line 2293 "Python/bytecodes.c"
/* Cached method object */
assert(cframe.use_tracing == 0);
PyTypeObject *self_cls = Py_TYPE(self);
assert(_PyType_HasFeature(Py_TYPE(res2), Py_TPFLAGS_METHOD_DESCRIPTOR));
res = self;
assert(oparg & 1);
- #line 3322 "Python/generated_cases.c.h"
+ #line 3321 "Python/generated_cases.c.h"
STACK_GROW(((oparg & 1) ? 1 : 0));
stack_pointer[-1] = res;
if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; }
PyObject *res;
uint32_t type_version = read_u32(&next_instr[1].cache);
PyObject *descr = read_obj(&next_instr[5].cache);
- #line 2314 "Python/bytecodes.c"
+ #line 2313 "Python/bytecodes.c"
assert(cframe.use_tracing == 0);
PyTypeObject *self_cls = Py_TYPE(self);
DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR);
res2 = Py_NewRef(descr);
res = self;
assert(oparg & 1);
- #line 3347 "Python/generated_cases.c.h"
+ #line 3346 "Python/generated_cases.c.h"
STACK_GROW(((oparg & 1) ? 1 : 0));
stack_pointer[-1] = res;
if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; }
PyObject *res;
uint32_t type_version = read_u32(&next_instr[1].cache);
PyObject *descr = read_obj(&next_instr[5].cache);
- #line 2327 "Python/bytecodes.c"
+ #line 2326 "Python/bytecodes.c"
assert(cframe.use_tracing == 0);
PyTypeObject *self_cls = Py_TYPE(self);
DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR);
res2 = Py_NewRef(descr);
res = self;
assert(oparg & 1);
- #line 3376 "Python/generated_cases.c.h"
+ #line 3375 "Python/generated_cases.c.h"
STACK_GROW(((oparg & 1) ? 1 : 0));
stack_pointer[-1] = res;
if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; }
}
TARGET(KW_NAMES) {
- #line 2344 "Python/bytecodes.c"
+ #line 2343 "Python/bytecodes.c"
assert(kwnames == NULL);
assert(oparg < PyTuple_GET_SIZE(frame->f_code->co_consts));
kwnames = GETITEM(frame->f_code->co_consts, oparg);
- #line 3389 "Python/generated_cases.c.h"
+ #line 3388 "Python/generated_cases.c.h"
DISPATCH();
}
PyObject *callable = stack_pointer[-(1 + oparg)];
PyObject *method = stack_pointer[-(2 + oparg)];
PyObject *res;
- #line 2380 "Python/bytecodes.c"
+ #line 2379 "Python/bytecodes.c"
int is_meth = method != NULL;
int total_args = oparg;
if (is_meth) {
Py_DECREF(args[i]);
}
if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
- #line 3472 "Python/generated_cases.c.h"
+ #line 3471 "Python/generated_cases.c.h"
STACK_SHRINK(oparg);
STACK_SHRINK(1);
stack_pointer[-1] = res;
TARGET(CALL_BOUND_METHOD_EXACT_ARGS) {
PyObject *callable = stack_pointer[-(1 + oparg)];
PyObject *method = stack_pointer[-(2 + oparg)];
- #line 2458 "Python/bytecodes.c"
+ #line 2457 "Python/bytecodes.c"
DEOPT_IF(method != NULL, CALL);
DEOPT_IF(Py_TYPE(callable) != &PyMethod_Type, CALL);
STAT_INC(CALL, hit);
PEEK(oparg + 2) = Py_NewRef(meth); // method
Py_DECREF(callable);
GO_TO_INSTRUCTION(CALL_PY_EXACT_ARGS);
- #line 3494 "Python/generated_cases.c.h"
+ #line 3493 "Python/generated_cases.c.h"
}
TARGET(CALL_PY_EXACT_ARGS) {
PyObject *callable = stack_pointer[-(1 + oparg)];
PyObject *method = stack_pointer[-(2 + oparg)];
uint32_t func_version = read_u32(&next_instr[1].cache);
- #line 2470 "Python/bytecodes.c"
+ #line 2469 "Python/bytecodes.c"
assert(kwnames == NULL);
DEOPT_IF(tstate->interp->eval_frame, CALL);
int is_meth = method != NULL;
STACK_SHRINK(oparg + 2);
JUMPBY(INLINE_CACHE_ENTRIES_CALL);
DISPATCH_INLINED(new_frame);
- #line 3528 "Python/generated_cases.c.h"
+ #line 3527 "Python/generated_cases.c.h"
}
TARGET(CALL_PY_WITH_DEFAULTS) {
PyObject *method = stack_pointer[-(2 + oparg)];
uint32_t func_version = read_u32(&next_instr[1].cache);
uint16_t min_args = read_u16(&next_instr[3].cache);
- #line 2497 "Python/bytecodes.c"
+ #line 2496 "Python/bytecodes.c"
assert(kwnames == NULL);
DEOPT_IF(tstate->interp->eval_frame, CALL);
int is_meth = method != NULL;
STACK_SHRINK(oparg + 2);
JUMPBY(INLINE_CACHE_ENTRIES_CALL);
DISPATCH_INLINED(new_frame);
- #line 3567 "Python/generated_cases.c.h"
+ #line 3566 "Python/generated_cases.c.h"
}
TARGET(CALL_NO_KW_TYPE_1) {
PyObject *callable = stack_pointer[-(1 + oparg)];
PyObject *null = stack_pointer[-(2 + oparg)];
PyObject *res;
- #line 2529 "Python/bytecodes.c"
+ #line 2528 "Python/bytecodes.c"
assert(kwnames == NULL);
assert(cframe.use_tracing == 0);
assert(oparg == 1);
res = Py_NewRef(Py_TYPE(obj));
Py_DECREF(obj);
Py_DECREF(&PyType_Type); // I.e., callable
- #line 3586 "Python/generated_cases.c.h"
+ #line 3585 "Python/generated_cases.c.h"
STACK_SHRINK(oparg);
STACK_SHRINK(1);
stack_pointer[-1] = res;
PyObject *callable = stack_pointer[-(1 + oparg)];
PyObject *null = stack_pointer[-(2 + oparg)];
PyObject *res;
- #line 2542 "Python/bytecodes.c"
+ #line 2541 "Python/bytecodes.c"
assert(kwnames == NULL);
assert(cframe.use_tracing == 0);
assert(oparg == 1);
Py_DECREF(arg);
Py_DECREF(&PyUnicode_Type); // I.e., callable
if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
- #line 3611 "Python/generated_cases.c.h"
+ #line 3610 "Python/generated_cases.c.h"
STACK_SHRINK(oparg);
STACK_SHRINK(1);
stack_pointer[-1] = res;
PyObject *callable = stack_pointer[-(1 + oparg)];
PyObject *null = stack_pointer[-(2 + oparg)];
PyObject *res;
- #line 2557 "Python/bytecodes.c"
+ #line 2556 "Python/bytecodes.c"
assert(kwnames == NULL);
assert(oparg == 1);
DEOPT_IF(null != NULL, CALL);
Py_DECREF(arg);
Py_DECREF(&PyTuple_Type); // I.e., tuple
if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
- #line 3636 "Python/generated_cases.c.h"
+ #line 3635 "Python/generated_cases.c.h"
STACK_SHRINK(oparg);
STACK_SHRINK(1);
stack_pointer[-1] = res;
PyObject *callable = stack_pointer[-(1 + oparg)];
PyObject *method = stack_pointer[-(2 + oparg)];
PyObject *res;
- #line 2571 "Python/bytecodes.c"
+ #line 2570 "Python/bytecodes.c"
int is_meth = method != NULL;
int total_args = oparg;
if (is_meth) {
}
Py_DECREF(tp);
if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
- #line 3672 "Python/generated_cases.c.h"
+ #line 3671 "Python/generated_cases.c.h"
STACK_SHRINK(oparg);
STACK_SHRINK(1);
stack_pointer[-1] = res;
PyObject *callable = stack_pointer[-(1 + oparg)];
PyObject *method = stack_pointer[-(2 + oparg)];
PyObject *res;
- #line 2596 "Python/bytecodes.c"
+ #line 2595 "Python/bytecodes.c"
assert(cframe.use_tracing == 0);
/* Builtin METH_O functions */
assert(kwnames == NULL);
Py_DECREF(arg);
Py_DECREF(callable);
if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
- #line 3715 "Python/generated_cases.c.h"
+ #line 3714 "Python/generated_cases.c.h"
STACK_SHRINK(oparg);
STACK_SHRINK(1);
stack_pointer[-1] = res;
PyObject *callable = stack_pointer[-(1 + oparg)];
PyObject *method = stack_pointer[-(2 + oparg)];
PyObject *res;
- #line 2628 "Python/bytecodes.c"
+ #line 2627 "Python/bytecodes.c"
assert(cframe.use_tracing == 0);
/* Builtin METH_FASTCALL functions, without keywords */
assert(kwnames == NULL);
'invalid'). In those cases an exception is set, so we must
handle it.
*/
- #line 3762 "Python/generated_cases.c.h"
+ #line 3761 "Python/generated_cases.c.h"
STACK_SHRINK(oparg);
STACK_SHRINK(1);
stack_pointer[-1] = res;
PyObject *callable = stack_pointer[-(1 + oparg)];
PyObject *method = stack_pointer[-(2 + oparg)];
PyObject *res;
- #line 2664 "Python/bytecodes.c"
+ #line 2663 "Python/bytecodes.c"
assert(cframe.use_tracing == 0);
/* Builtin METH_FASTCALL | METH_KEYWORDS functions */
int is_meth = method != NULL;
}
Py_DECREF(callable);
if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
- #line 3809 "Python/generated_cases.c.h"
+ #line 3808 "Python/generated_cases.c.h"
STACK_SHRINK(oparg);
STACK_SHRINK(1);
stack_pointer[-1] = res;
PyObject *callable = stack_pointer[-(1 + oparg)];
PyObject *method = stack_pointer[-(2 + oparg)];
PyObject *res;
- #line 2700 "Python/bytecodes.c"
+ #line 2699 "Python/bytecodes.c"
assert(cframe.use_tracing == 0);
assert(kwnames == NULL);
/* len(o) */
Py_DECREF(callable);
Py_DECREF(arg);
if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
- #line 3849 "Python/generated_cases.c.h"
+ #line 3848 "Python/generated_cases.c.h"
STACK_SHRINK(oparg);
STACK_SHRINK(1);
stack_pointer[-1] = res;
PyObject *callable = stack_pointer[-(1 + oparg)];
PyObject *method = stack_pointer[-(2 + oparg)];
PyObject *res;
- #line 2728 "Python/bytecodes.c"
+ #line 2727 "Python/bytecodes.c"
assert(cframe.use_tracing == 0);
assert(kwnames == NULL);
/* isinstance(o, o2) */
Py_DECREF(cls);
Py_DECREF(callable);
if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
- #line 3890 "Python/generated_cases.c.h"
+ #line 3889 "Python/generated_cases.c.h"
STACK_SHRINK(oparg);
STACK_SHRINK(1);
stack_pointer[-1] = res;
PyObject **args = (stack_pointer - oparg);
PyObject *self = stack_pointer[-(1 + oparg)];
PyObject *method = stack_pointer[-(2 + oparg)];
- #line 2759 "Python/bytecodes.c"
+ #line 2758 "Python/bytecodes.c"
assert(cframe.use_tracing == 0);
assert(kwnames == NULL);
assert(oparg == 1);
JUMPBY(INLINE_CACHE_ENTRIES_CALL + 1);
assert(next_instr[-1].op.code == POP_TOP);
DISPATCH();
- #line 3921 "Python/generated_cases.c.h"
+ #line 3920 "Python/generated_cases.c.h"
}
TARGET(CALL_NO_KW_METHOD_DESCRIPTOR_O) {
PyObject **args = (stack_pointer - oparg);
PyObject *method = stack_pointer[-(2 + oparg)];
PyObject *res;
- #line 2780 "Python/bytecodes.c"
+ #line 2779 "Python/bytecodes.c"
assert(kwnames == NULL);
int is_meth = method != NULL;
int total_args = oparg;
Py_DECREF(arg);
Py_DECREF(callable);
if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
- #line 3959 "Python/generated_cases.c.h"
+ #line 3958 "Python/generated_cases.c.h"
STACK_SHRINK(oparg);
STACK_SHRINK(1);
stack_pointer[-1] = res;
PyObject **args = (stack_pointer - oparg);
PyObject *method = stack_pointer[-(2 + oparg)];
PyObject *res;
- #line 2814 "Python/bytecodes.c"
+ #line 2813 "Python/bytecodes.c"
int is_meth = method != NULL;
int total_args = oparg;
if (is_meth) {
}
Py_DECREF(callable);
if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
- #line 4001 "Python/generated_cases.c.h"
+ #line 4000 "Python/generated_cases.c.h"
STACK_SHRINK(oparg);
STACK_SHRINK(1);
stack_pointer[-1] = res;
PyObject **args = (stack_pointer - oparg);
PyObject *method = stack_pointer[-(2 + oparg)];
PyObject *res;
- #line 2846 "Python/bytecodes.c"
+ #line 2845 "Python/bytecodes.c"
assert(kwnames == NULL);
assert(oparg == 0 || oparg == 1);
int is_meth = method != NULL;
Py_DECREF(self);
Py_DECREF(callable);
if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
- #line 4043 "Python/generated_cases.c.h"
+ #line 4042 "Python/generated_cases.c.h"
STACK_SHRINK(oparg);
STACK_SHRINK(1);
stack_pointer[-1] = res;
PyObject **args = (stack_pointer - oparg);
PyObject *method = stack_pointer[-(2 + oparg)];
PyObject *res;
- #line 2878 "Python/bytecodes.c"
+ #line 2877 "Python/bytecodes.c"
assert(kwnames == NULL);
int is_meth = method != NULL;
int total_args = oparg;
}
Py_DECREF(callable);
if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; }
- #line 4084 "Python/generated_cases.c.h"
+ #line 4083 "Python/generated_cases.c.h"
STACK_SHRINK(oparg);
STACK_SHRINK(1);
stack_pointer[-1] = res;
PyObject *callargs = stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))];
PyObject *func = stack_pointer[-(2 + ((oparg & 1) ? 1 : 0))];
PyObject *result;
- #line 2909 "Python/bytecodes.c"
+ #line 2908 "Python/bytecodes.c"
if (oparg & 1) {
// DICT_MERGE is called before this opcode if there are kwargs.
// It converts all dict subtypes in kwargs into regular dicts.
assert(PyTuple_CheckExact(callargs));
result = do_call_core(tstate, func, callargs, kwargs, cframe.use_tracing);
- #line 4118 "Python/generated_cases.c.h"
+ #line 4117 "Python/generated_cases.c.h"
Py_DECREF(func);
Py_DECREF(callargs);
Py_XDECREF(kwargs);
- #line 2928 "Python/bytecodes.c"
+ #line 2927 "Python/bytecodes.c"
assert(PEEK(3 + (oparg & 1)) == NULL);
if (result == NULL) { STACK_SHRINK(((oparg & 1) ? 1 : 0)); goto pop_3_error; }
- #line 4126 "Python/generated_cases.c.h"
+ #line 4125 "Python/generated_cases.c.h"
STACK_SHRINK(((oparg & 1) ? 1 : 0));
STACK_SHRINK(2);
stack_pointer[-1] = result;
PyObject *kwdefaults = (oparg & 0x02) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0))] : NULL;
PyObject *defaults = (oparg & 0x01) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x01) ? 1 : 0))] : NULL;
PyObject *func;
- #line 2939 "Python/bytecodes.c"
+ #line 2938 "Python/bytecodes.c"
PyFunctionObject *func_obj = (PyFunctionObject *)
PyFunction_New(codeobj, GLOBALS());
func_obj->func_version = ((PyCodeObject *)codeobj)->co_version;
func = (PyObject *)func_obj;
- #line 4170 "Python/generated_cases.c.h"
+ #line 4169 "Python/generated_cases.c.h"
STACK_SHRINK(((oparg & 0x01) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x08) ? 1 : 0));
stack_pointer[-1] = func;
DISPATCH();
}
TARGET(RETURN_GENERATOR) {
- #line 2970 "Python/bytecodes.c"
+ #line 2969 "Python/bytecodes.c"
assert(PyFunction_Check(frame->f_funcobj));
PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj;
PyGenObject *gen = (PyGenObject *)_Py_MakeCoro(func);
frame = cframe.current_frame = prev;
_PyFrame_StackPush(frame, (PyObject *)gen);
goto resume_frame;
- #line 4198 "Python/generated_cases.c.h"
+ #line 4197 "Python/generated_cases.c.h"
}
TARGET(BUILD_SLICE) {
PyObject *stop = stack_pointer[-(1 + ((oparg == 3) ? 1 : 0))];
PyObject *start = stack_pointer[-(2 + ((oparg == 3) ? 1 : 0))];
PyObject *slice;
- #line 2993 "Python/bytecodes.c"
+ #line 2992 "Python/bytecodes.c"
slice = PySlice_New(start, stop, step);
- #line 4208 "Python/generated_cases.c.h"
+ #line 4207 "Python/generated_cases.c.h"
Py_DECREF(start);
Py_DECREF(stop);
Py_XDECREF(step);
- #line 2995 "Python/bytecodes.c"
+ #line 2994 "Python/bytecodes.c"
if (slice == NULL) { STACK_SHRINK(((oparg == 3) ? 1 : 0)); goto pop_2_error; }
- #line 4214 "Python/generated_cases.c.h"
+ #line 4213 "Python/generated_cases.c.h"
STACK_SHRINK(((oparg == 3) ? 1 : 0));
STACK_SHRINK(1);
stack_pointer[-1] = slice;
PyObject *fmt_spec = ((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? stack_pointer[-((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0))] : NULL;
PyObject *value = stack_pointer[-(1 + (((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0))];
PyObject *result;
- #line 2999 "Python/bytecodes.c"
+ #line 2998 "Python/bytecodes.c"
/* Handles f-string value formatting. */
PyObject *(*conv_fn)(PyObject *);
int which_conversion = oparg & FVC_MASK;
Py_DECREF(value);
Py_XDECREF(fmt_spec);
if (result == NULL) { STACK_SHRINK((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0)); goto pop_1_error; }
- #line 4260 "Python/generated_cases.c.h"
+ #line 4259 "Python/generated_cases.c.h"
STACK_SHRINK((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0));
stack_pointer[-1] = result;
DISPATCH();
TARGET(COPY) {
PyObject *bottom = stack_pointer[-(1 + (oparg-1))];
PyObject *top;
- #line 3036 "Python/bytecodes.c"
+ #line 3035 "Python/bytecodes.c"
assert(oparg > 0);
top = Py_NewRef(bottom);
- #line 4272 "Python/generated_cases.c.h"
+ #line 4271 "Python/generated_cases.c.h"
STACK_GROW(1);
stack_pointer[-1] = top;
DISPATCH();
PyObject *rhs = stack_pointer[-1];
PyObject *lhs = stack_pointer[-2];
PyObject *res;
- #line 3041 "Python/bytecodes.c"
+ #line 3040 "Python/bytecodes.c"
#if ENABLE_SPECIALIZATION
_PyBinaryOpCache *cache = (_PyBinaryOpCache *)next_instr;
if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
assert((unsigned)oparg < Py_ARRAY_LENGTH(binary_ops));
assert(binary_ops[oparg]);
res = binary_ops[oparg](lhs, rhs);
- #line 4300 "Python/generated_cases.c.h"
+ #line 4299 "Python/generated_cases.c.h"
Py_DECREF(lhs);
Py_DECREF(rhs);
- #line 3057 "Python/bytecodes.c"
+ #line 3056 "Python/bytecodes.c"
if (res == NULL) goto pop_2_error;
- #line 4305 "Python/generated_cases.c.h"
+ #line 4304 "Python/generated_cases.c.h"
STACK_SHRINK(1);
stack_pointer[-1] = res;
next_instr += 1;
TARGET(SWAP) {
PyObject *top = stack_pointer[-1];
PyObject *bottom = stack_pointer[-(2 + (oparg-2))];
- #line 3062 "Python/bytecodes.c"
+ #line 3061 "Python/bytecodes.c"
assert(oparg >= 2);
- #line 4317 "Python/generated_cases.c.h"
+ #line 4316 "Python/generated_cases.c.h"
stack_pointer[-1] = bottom;
stack_pointer[-(2 + (oparg-2))] = top;
DISPATCH();
}
TARGET(EXTENDED_ARG) {
- #line 3066 "Python/bytecodes.c"
+ #line 3065 "Python/bytecodes.c"
assert(oparg);
assert(cframe.use_tracing == 0);
opcode = next_instr->op.code;
oparg = oparg << 8 | next_instr->op.arg;
PRE_DISPATCH_GOTO();
DISPATCH_GOTO();
- #line 4331 "Python/generated_cases.c.h"
+ #line 4330 "Python/generated_cases.c.h"
}
TARGET(CACHE) {
- #line 3075 "Python/bytecodes.c"
+ #line 3074 "Python/bytecodes.c"
Py_UNREACHABLE();
- #line 4337 "Python/generated_cases.c.h"
+ #line 4336 "Python/generated_cases.c.h"
}