aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2023-07-17 10:06:05 -0700
committerGitHub <noreply@github.com>2023-07-17 10:06:05 -0700
commitb2b261ab2a2d4ff000c6248dbc52247c78cfa5ab (patch)
tree51ba72743630d842113cc1de9a073ab407e699e6 /Python
parentad95c7253a70e559e7d3f25d53f4772f28bb8b44 (diff)
downloadcpython-b2b261ab2a2d4ff000c6248dbc52247c78cfa5ab.tar.gz
cpython-b2b261ab2a2d4ff000c6248dbc52247c78cfa5ab.zip
gh-106529: Generate uops for POP_JUMP_IF_[NOT_]NONE (#106796)
These aren't automatically translated because (ironically) they are macros deferring to POP_JUMP_IF_{TRUE,FALSE}, which are not viable uops (being manually translated). The hack is that we emit IS_NONE and then set opcode and jump to the POP_JUMP_IF_{TRUE,FALSE} translation code.
Diffstat (limited to 'Python')
-rw-r--r--Python/optimizer.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/Python/optimizer.c b/Python/optimizer.c
index 289b202f806..693ba375971 100644
--- a/Python/optimizer.c
+++ b/Python/optimizer.c
@@ -464,9 +464,26 @@ translate_bytecode_to_trace(
switch (opcode) {
+ case POP_JUMP_IF_NONE:
+ {
+ RESERVE(2, 2);
+ ADD_TO_TRACE(IS_NONE, 0);
+ opcode = POP_JUMP_IF_TRUE;
+ goto pop_jump_if_bool;
+ }
+
+ case POP_JUMP_IF_NOT_NONE:
+ {
+ RESERVE(2, 2);
+ ADD_TO_TRACE(IS_NONE, 0);
+ opcode = POP_JUMP_IF_FALSE;
+ goto pop_jump_if_bool;
+ }
+
case POP_JUMP_IF_FALSE:
case POP_JUMP_IF_TRUE:
{
+pop_jump_if_bool:
// Assume jump unlikely (TODO: handle jump likely case)
RESERVE(1, 2);
_Py_CODEUNIT *target_instr =