summaryrefslogtreecommitdiffstats
path: root/Python/optimizer.c
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2024-02-20 10:50:59 (GMT)
committerGitHub <noreply@github.com>2024-02-20 10:50:59 (GMT)
commit626c414995bad1dab51c7222a6f7bf388255eb9e (patch)
treedd89add10cfb1bb71ca3a2709b10414652d07031 /Python/optimizer.c
parent7b21403ccd16c480812a1e857c0ee2deca592be0 (diff)
downloadcpython-626c414995bad1dab51c7222a6f7bf388255eb9e.zip
cpython-626c414995bad1dab51c7222a6f7bf388255eb9e.tar.gz
cpython-626c414995bad1dab51c7222a6f7bf388255eb9e.tar.bz2
GH-115457: Support splitting and replication of micro ops. (GH-115558)
Diffstat (limited to 'Python/optimizer.c')
-rw-r--r--Python/optimizer.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/Python/optimizer.c b/Python/optimizer.c
index acc1d54..df8f0ed 100644
--- a/Python/optimizer.c
+++ b/Python/optimizer.c
@@ -963,6 +963,21 @@ uop_optimize(
}
}
assert(err == 1);
+ /* Fix up */
+ for (int pc = 0; pc < UOP_MAX_TRACE_LENGTH; pc++) {
+ int opcode = buffer[pc].opcode;
+ int oparg = buffer[pc].oparg;
+ if (_PyUop_Flags[opcode] & HAS_OPARG_AND_1_FLAG) {
+ buffer[pc].opcode = opcode + 1 + (oparg & 1);
+ }
+ else if (oparg < _PyUop_Replication[opcode]) {
+ buffer[pc].opcode = opcode + oparg + 1;
+ }
+ else if (opcode == _JUMP_TO_TOP || opcode == _EXIT_TRACE) {
+ break;
+ }
+ assert(_PyOpcode_uop_name[buffer[pc].opcode]);
+ }
_PyExecutorObject *executor = make_executor_from_uops(buffer, &dependencies);
if (executor == NULL) {
return -1;