summaryrefslogtreecommitdiffstats
path: root/Python/executor_cases.c.h
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2024-03-11 09:30:15 (GMT)
committerGitHub <noreply@github.com>2024-03-11 09:30:15 (GMT)
commit4e5df2013fc29ed8bdb71572f1d12ff36e7028d5 (patch)
tree7e13e821f19e33133bcebf17225808a68a4efda0 /Python/executor_cases.c.h
parent8d7fde655fbb57e393831b9f30ebba80d6da366f (diff)
downloadcpython-4e5df2013fc29ed8bdb71572f1d12ff36e7028d5.zip
cpython-4e5df2013fc29ed8bdb71572f1d12ff36e7028d5.tar.gz
cpython-4e5df2013fc29ed8bdb71572f1d12ff36e7028d5.tar.bz2
GH-116468: Use constants instead of `oparg` in stack effects when `oparg` is known to be a constant. (GH-116469)
Diffstat (limited to 'Python/executor_cases.c.h')
-rw-r--r--Python/executor_cases.c.h64
1 files changed, 30 insertions, 34 deletions
diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h
index ccd8fb3..42e884c 100644
--- a/Python/executor_cases.c.h
+++ b/Python/executor_cases.c.h
@@ -1061,18 +1061,20 @@
case _UNPACK_SEQUENCE_TWO_TUPLE: {
PyObject *seq;
- PyObject **values;
+ PyObject *val1;
+ PyObject *val0;
oparg = CURRENT_OPARG();
seq = stack_pointer[-1];
- values = &stack_pointer[-1];
+ assert(oparg == 2);
if (!PyTuple_CheckExact(seq)) goto deoptimize;
if (PyTuple_GET_SIZE(seq) != 2) goto deoptimize;
- 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));
+ val0 = Py_NewRef(PyTuple_GET_ITEM(seq, 0));
+ val1 = Py_NewRef(PyTuple_GET_ITEM(seq, 1));
Py_DECREF(seq);
- stack_pointer += -1 + oparg;
+ stack_pointer[-1] = val1;
+ stack_pointer[0] = val0;
+ stack_pointer += 1;
break;
}
@@ -3057,71 +3059,65 @@
/* _CALL_PY_WITH_DEFAULTS is not a viable micro-op for tier 2 */
case _CALL_TYPE_1: {
- PyObject **args;
+ PyObject *arg;
PyObject *null;
PyObject *callable;
PyObject *res;
oparg = CURRENT_OPARG();
- args = &stack_pointer[-oparg];
- null = stack_pointer[-1 - oparg];
- callable = stack_pointer[-2 - oparg];
+ arg = stack_pointer[-1];
+ null = stack_pointer[-2];
+ callable = stack_pointer[-3];
assert(oparg == 1);
if (null != NULL) goto deoptimize;
- PyObject *obj = args[0];
if (callable != (PyObject *)&PyType_Type) goto deoptimize;
STAT_INC(CALL, hit);
- res = Py_NewRef(Py_TYPE(obj));
- Py_DECREF(obj);
- Py_DECREF(&PyType_Type); // I.e., callable
- stack_pointer[-2 - oparg] = res;
- stack_pointer += -1 - oparg;
+ res = Py_NewRef(Py_TYPE(arg));
+ Py_DECREF(arg);
+ stack_pointer[-3] = res;
+ stack_pointer += -2;
break;
}
case _CALL_STR_1: {
- PyObject **args;
+ PyObject *arg;
PyObject *null;
PyObject *callable;
PyObject *res;
oparg = CURRENT_OPARG();
- args = &stack_pointer[-oparg];
- null = stack_pointer[-1 - oparg];
- callable = stack_pointer[-2 - oparg];
+ arg = stack_pointer[-1];
+ null = stack_pointer[-2];
+ callable = stack_pointer[-3];
assert(oparg == 1);
if (null != NULL) goto deoptimize;
if (callable != (PyObject *)&PyUnicode_Type) goto deoptimize;
STAT_INC(CALL, hit);
- PyObject *arg = args[0];
res = PyObject_Str(arg);
Py_DECREF(arg);
- Py_DECREF(&PyUnicode_Type); // I.e., callable
- if (res == NULL) { stack_pointer += -2 - oparg; goto error_tier_two; }
- stack_pointer[-2 - oparg] = res;
- stack_pointer += -1 - oparg;
+ if (res == NULL) goto pop_3_error_tier_two;
+ stack_pointer[-3] = res;
+ stack_pointer += -2;
CHECK_EVAL_BREAKER();
break;
}
case _CALL_TUPLE_1: {
- PyObject **args;
+ PyObject *arg;
PyObject *null;
PyObject *callable;
PyObject *res;
oparg = CURRENT_OPARG();
- args = &stack_pointer[-oparg];
- null = stack_pointer[-1 - oparg];
- callable = stack_pointer[-2 - oparg];
+ arg = stack_pointer[-1];
+ null = stack_pointer[-2];
+ callable = stack_pointer[-3];
assert(oparg == 1);
if (null != NULL) goto deoptimize;
if (callable != (PyObject *)&PyTuple_Type) goto deoptimize;
STAT_INC(CALL, hit);
- PyObject *arg = args[0];
res = PySequence_Tuple(arg);
Py_DECREF(arg);
- Py_DECREF(&PyTuple_Type); // I.e., tuple
- if (res == NULL) { stack_pointer += -2 - oparg; goto error_tier_two; }
- stack_pointer[-2 - oparg] = res;
- stack_pointer += -1 - oparg;
+ if (res == NULL) goto pop_3_error_tier_two;
+ stack_pointer[-3] = res;
+ stack_pointer += -2;
CHECK_EVAL_BREAKER();
break;
}