summaryrefslogtreecommitdiffstats
path: root/Python/compile.c
diff options
context:
space:
mode:
authorKen Jin <kenjin4096@gmail.com>2022-06-14 10:36:22 (GMT)
committerGitHub <noreply@github.com>2022-06-14 10:36:22 (GMT)
commitb083450f8896bb4a29ac522e4474d91c056b9f32 (patch)
tree74d923609496e622ec1e99e9381ee3f6c42b829b /Python/compile.c
parentcd543d0bc9aacca1dee02dea7ff4aec8966dcaf8 (diff)
downloadcpython-b083450f8896bb4a29ac522e4474d91c056b9f32.zip
cpython-b083450f8896bb4a29ac522e4474d91c056b9f32.tar.gz
cpython-b083450f8896bb4a29ac522e4474d91c056b9f32.tar.bz2
GH-93429: Merge `LOAD_METHOD` back into `LOAD_ATTR` (GH-93430)
Diffstat (limited to 'Python/compile.c')
-rw-r--r--Python/compile.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/Python/compile.c b/Python/compile.c
index 93aafa7..f36c4aa 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -84,8 +84,9 @@
#define POP_JUMP_IF_TRUE -8
#define POP_JUMP_IF_NONE -9
#define POP_JUMP_IF_NOT_NONE -10
+#define LOAD_METHOD -11
-#define MIN_VIRTUAL_OPCODE -10
+#define MIN_VIRTUAL_OPCODE -11
#define MAX_ALLOWED_OPCODE 254
#define IS_WITHIN_OPCODE_RANGE(opcode) \
@@ -1069,7 +1070,7 @@ stack_effect(int opcode, int oparg, int jump)
case BUILD_CONST_KEY_MAP:
return -oparg;
case LOAD_ATTR:
- return 0;
+ return (oparg & 1);
case COMPARE_OP:
case IS_OP:
case CONTAINS_OP:
@@ -1493,6 +1494,14 @@ compiler_addop_name(struct compiler *c, int opcode, PyObject *dict,
Py_DECREF(mangled);
if (arg < 0)
return 0;
+ if (opcode == LOAD_ATTR) {
+ arg <<= 1;
+ }
+ if (opcode == LOAD_METHOD) {
+ opcode = LOAD_ATTR;
+ arg <<= 1;
+ arg |= 1;
+ }
return compiler_addop_i(c, opcode, arg);
}