mirror of
https://github.com/python/cpython.git
synced 2025-09-18 06:30:38 +00:00
Do the int inlining only if the type is really an int, not whenever
PyInt_Check() succeeds. That returns true for subtypes of int, which may override __add__ or __sub__.
This commit is contained in:
parent
13228a6f09
commit
46add98758
1 changed files with 9 additions and 6 deletions
|
@ -548,6 +548,9 @@ eval_frame(PyFrameObject *f)
|
||||||
#define POP() BASIC_POP()
|
#define POP() BASIC_POP()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Strict int check macros */
|
||||||
|
#define ISSTRICTINT(v) ((v)->ob_type == &PyInt_Type)
|
||||||
|
|
||||||
/* Local variable macros */
|
/* Local variable macros */
|
||||||
|
|
||||||
#define GETLOCAL(i) (fastlocals[i])
|
#define GETLOCAL(i) (fastlocals[i])
|
||||||
|
@ -909,7 +912,7 @@ eval_frame(PyFrameObject *f)
|
||||||
case BINARY_ADD:
|
case BINARY_ADD:
|
||||||
w = POP();
|
w = POP();
|
||||||
v = POP();
|
v = POP();
|
||||||
if (PyInt_Check(v) && PyInt_Check(w)) {
|
if (ISSTRICTINT(v) && ISSTRICTINT(w)) {
|
||||||
/* INLINE: int + int */
|
/* INLINE: int + int */
|
||||||
register long a, b, i;
|
register long a, b, i;
|
||||||
a = PyInt_AS_LONG(v);
|
a = PyInt_AS_LONG(v);
|
||||||
|
@ -932,7 +935,7 @@ eval_frame(PyFrameObject *f)
|
||||||
case BINARY_SUBTRACT:
|
case BINARY_SUBTRACT:
|
||||||
w = POP();
|
w = POP();
|
||||||
v = POP();
|
v = POP();
|
||||||
if (PyInt_Check(v) && PyInt_Check(w)) {
|
if (ISSTRICTINT(v) && ISSTRICTINT(w)) {
|
||||||
/* INLINE: int - int */
|
/* INLINE: int - int */
|
||||||
register long a, b, i;
|
register long a, b, i;
|
||||||
a = PyInt_AS_LONG(v);
|
a = PyInt_AS_LONG(v);
|
||||||
|
@ -955,7 +958,7 @@ eval_frame(PyFrameObject *f)
|
||||||
case BINARY_SUBSCR:
|
case BINARY_SUBSCR:
|
||||||
w = POP();
|
w = POP();
|
||||||
v = POP();
|
v = POP();
|
||||||
if (v->ob_type == &PyList_Type && PyInt_Check(w)) {
|
if (v->ob_type == &PyList_Type && ISSTRICTINT(w)) {
|
||||||
/* INLINE: list[int] */
|
/* INLINE: list[int] */
|
||||||
long i = PyInt_AsLong(w);
|
long i = PyInt_AsLong(w);
|
||||||
if (i < 0)
|
if (i < 0)
|
||||||
|
@ -1092,7 +1095,7 @@ eval_frame(PyFrameObject *f)
|
||||||
case INPLACE_ADD:
|
case INPLACE_ADD:
|
||||||
w = POP();
|
w = POP();
|
||||||
v = POP();
|
v = POP();
|
||||||
if (PyInt_Check(v) && PyInt_Check(w)) {
|
if (ISSTRICTINT(v) && ISSTRICTINT(w)) {
|
||||||
/* INLINE: int + int */
|
/* INLINE: int + int */
|
||||||
register long a, b, i;
|
register long a, b, i;
|
||||||
a = PyInt_AS_LONG(v);
|
a = PyInt_AS_LONG(v);
|
||||||
|
@ -1115,7 +1118,7 @@ eval_frame(PyFrameObject *f)
|
||||||
case INPLACE_SUBTRACT:
|
case INPLACE_SUBTRACT:
|
||||||
w = POP();
|
w = POP();
|
||||||
v = POP();
|
v = POP();
|
||||||
if (PyInt_Check(v) && PyInt_Check(w)) {
|
if (ISSTRICTINT(v) && ISSTRICTINT(w)) {
|
||||||
/* INLINE: int - int */
|
/* INLINE: int - int */
|
||||||
register long a, b, i;
|
register long a, b, i;
|
||||||
a = PyInt_AS_LONG(v);
|
a = PyInt_AS_LONG(v);
|
||||||
|
@ -1718,7 +1721,7 @@ eval_frame(PyFrameObject *f)
|
||||||
case COMPARE_OP:
|
case COMPARE_OP:
|
||||||
w = POP();
|
w = POP();
|
||||||
v = POP();
|
v = POP();
|
||||||
if (PyInt_Check(v) && PyInt_Check(w)) {
|
if (ISSTRICTINT(v) && ISSTRICTINT(w)) {
|
||||||
/* INLINE: cmp(int, int) */
|
/* INLINE: cmp(int, int) */
|
||||||
register long a, b;
|
register long a, b;
|
||||||
register int res;
|
register int res;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue