aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/bytecodes.c
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2024-10-29 11:15:42 +0000
committerGitHub <noreply@github.com>2024-10-29 11:15:42 +0000
commitfaa3272fb8d63d481a136cc0467a0cba6ed7b264 (patch)
tree474ac9edbff637a8edb280846a1d3d9b113915c4 /Python/bytecodes.c
parent67f5c5bd6fcc956a785edef3be67e8cbe470cd31 (diff)
downloadcpython-faa3272fb8d63d481a136cc0467a0cba6ed7b264.tar.gz
cpython-faa3272fb8d63d481a136cc0467a0cba6ed7b264.zip
GH-125837: Split `LOAD_CONST` into three. (GH-125972)
* Add LOAD_CONST_IMMORTAL opcode * Add LOAD_SMALL_INT opcode * Remove RETURN_CONST opcode
Diffstat (limited to 'Python/bytecodes.c')
-rw-r--r--Python/bytecodes.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/Python/bytecodes.c b/Python/bytecodes.c
index 057ee0a92d9..b7469c2dd8d 100644
--- a/Python/bytecodes.c
+++ b/Python/bytecodes.c
@@ -255,10 +255,26 @@ dummy_func(
value2 = PyStackRef_DUP(GETLOCAL(oparg2));
}
+ family(LOAD_CONST, 0) = {
+ LOAD_CONST_IMMORTAL,
+ };
+
pure inst(LOAD_CONST, (-- value)) {
value = PyStackRef_FromPyObjectNew(GETITEM(FRAME_CO_CONSTS, oparg));
}
+ inst(LOAD_CONST_IMMORTAL, (-- value)) {
+ PyObject *obj = GETITEM(FRAME_CO_CONSTS, oparg);
+ assert(_Py_IsImmortal(obj));
+ value = PyStackRef_FromPyObjectImmortal(obj);
+ }
+
+ replicate(4) inst(LOAD_SMALL_INT, (-- value)) {
+ assert(oparg < _PY_NSMALLPOSINTS);
+ PyObject *obj = (PyObject *)&_PyLong_SMALL_INTS[_PY_NSMALLNEGINTS + oparg];
+ value = PyStackRef_FromPyObjectImmortal(obj);
+ }
+
replicate(8) inst(STORE_FAST, (value --)) {
SETLOCAL(oparg, value);
DEAD(value);
@@ -979,10 +995,9 @@ dummy_func(
return result;
}
- // The stack effect here is ambiguous.
- // We definitely pop the return value off the stack on entry.
- // We also push it onto the stack on exit, but that's a
- // different frame, and it's accounted for by _PUSH_FRAME.
+ // The stack effect here is a bit misleading.
+ // retval is popped from the stack, but res
+ // is pushed to a different frame, the callers' frame.
inst(RETURN_VALUE, (retval -- res)) {
#if TIER_ONE
assert(frame != &entry_frame);
@@ -1013,15 +1028,6 @@ dummy_func(
_RETURN_VALUE_EVENT +
RETURN_VALUE;
- macro(RETURN_CONST) =
- LOAD_CONST +
- RETURN_VALUE;
-
- macro(INSTRUMENTED_RETURN_CONST) =
- LOAD_CONST +
- _RETURN_VALUE_EVENT +
- RETURN_VALUE;
-
inst(GET_AITER, (obj -- iter)) {
unaryfunc getter = NULL;
PyObject *obj_o = PyStackRef_AsPyObjectBorrow(obj);