summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2023-07-18 18:42:44 (GMT)
committerGitHub <noreply@github.com>2023-07-18 18:42:44 (GMT)
commit40f3f11a773b854c6d94746aa3b1881c8ac71b0f (patch)
treec82e804e0006a9bd35d0b3715afa51bf035ea7db /Python
parent3535ef1eec2563bbd7bff7c830465441fbbf759e (diff)
downloadcpython-40f3f11a773b854c6d94746aa3b1881c8ac71b0f.zip
cpython-40f3f11a773b854c6d94746aa3b1881c8ac71b0f.tar.gz
cpython-40f3f11a773b854c6d94746aa3b1881c8ac71b0f.tar.bz2
gh-105481: Generate the opcode lists in dis from data extracted from bytecodes.c (#106758)
Diffstat (limited to 'Python')
-rw-r--r--Python/bytecodes.c2
-rw-r--r--Python/ceval_macros.h1
-rw-r--r--Python/compile.c18
-rw-r--r--Python/executor_cases.c.h2
-rw-r--r--Python/generated_cases.c.h2
5 files changed, 22 insertions, 3 deletions
diff --git a/Python/bytecodes.c b/Python/bytecodes.c
index 19fb138..ea136a3 100644
--- a/Python/bytecodes.c
+++ b/Python/bytecodes.c
@@ -3604,7 +3604,7 @@ dummy_func(
_PyBinaryOpCache *cache = (_PyBinaryOpCache *)next_instr;
if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
next_instr--;
- _Py_Specialize_BinaryOp(lhs, rhs, next_instr, oparg, &GETLOCAL(0));
+ _Py_Specialize_BinaryOp(lhs, rhs, next_instr, oparg, LOCALS_ARRAY);
DISPATCH_SAME_OPARG();
}
STAT_INC(BINARY_OP, deferred);
diff --git a/Python/ceval_macros.h b/Python/ceval_macros.h
index 874bd45..c2c3233 100644
--- a/Python/ceval_macros.h
+++ b/Python/ceval_macros.h
@@ -234,6 +234,7 @@ GETITEM(PyObject *v, Py_ssize_t i) {
/* Local variable macros */
+#define LOCALS_ARRAY (frame->localsplus)
#define GETLOCAL(i) (frame->localsplus[i])
/* The SETLOCAL() macro must not DECREF the local variable in-place and
diff --git a/Python/compile.c b/Python/compile.c
index 2a73538..d5405b4 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -896,6 +896,24 @@ PyUnstable_OpcodeHasJump(int opcode)
return OPCODE_HAS_JUMP(opcode);
}
+int
+PyUnstable_OpcodeHasFree(int opcode)
+{
+ return OPCODE_HAS_FREE(opcode);
+}
+
+int
+PyUnstable_OpcodeHasLocal(int opcode)
+{
+ return OPCODE_HAS_LOCAL(opcode);
+}
+
+int
+PyUnstable_OpcodeHasExc(int opcode)
+{
+ return IS_BLOCK_PUSH_OPCODE(opcode);
+}
+
static int
codegen_addop_noarg(instr_sequence *seq, int opcode, location loc)
{
diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h
index f492c1f..e1f8b9f 100644
--- a/Python/executor_cases.c.h
+++ b/Python/executor_cases.c.h
@@ -2449,7 +2449,7 @@
_PyBinaryOpCache *cache = (_PyBinaryOpCache *)next_instr;
if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
next_instr--;
- _Py_Specialize_BinaryOp(lhs, rhs, next_instr, oparg, &GETLOCAL(0));
+ _Py_Specialize_BinaryOp(lhs, rhs, next_instr, oparg, LOCALS_ARRAY);
DISPATCH_SAME_OPARG();
}
STAT_INC(BINARY_OP, deferred);
diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h
index 0a8e4da..b2b0aa6 100644
--- a/Python/generated_cases.c.h
+++ b/Python/generated_cases.c.h
@@ -4451,7 +4451,7 @@
_PyBinaryOpCache *cache = (_PyBinaryOpCache *)next_instr;
if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
next_instr--;
- _Py_Specialize_BinaryOp(lhs, rhs, next_instr, oparg, &GETLOCAL(0));
+ _Py_Specialize_BinaryOp(lhs, rhs, next_instr, oparg, LOCALS_ARRAY);
DISPATCH_SAME_OPARG();
}
STAT_INC(BINARY_OP, deferred);