aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/optimizer_cases.c.h
diff options
context:
space:
mode:
authormpage <mpage@meta.com>2025-04-01 10:18:42 -0700
committerGitHub <noreply@github.com>2025-04-01 10:18:42 -0700
commit053c285f6b41f92fbdd1d4ff0c959cceefacd7cd (patch)
treec30af215989dca6fdd8f8ebb74396f29abdca308 /Python/optimizer_cases.c.h
parente9556e100452ed5a92fcf0e333ab75b0da29cf5b (diff)
downloadcpython-053c285f6b41f92fbdd1d4ff0c959cceefacd7cd.tar.gz
cpython-053c285f6b41f92fbdd1d4ff0c959cceefacd7cd.zip
gh-130704: Strength reduce `LOAD_FAST{_LOAD_FAST}` (#130708)
Optimize `LOAD_FAST` opcodes into faster versions that load borrowed references onto the operand stack when we can prove that the lifetime of the local outlives the lifetime of the temporary that is loaded onto the stack.
Diffstat (limited to 'Python/optimizer_cases.c.h')
-rw-r--r--Python/optimizer_cases.c.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/Python/optimizer_cases.c.h b/Python/optimizer_cases.c.h
index 6a8ac75b63e..f1280ba1e40 100644
--- a/Python/optimizer_cases.c.h
+++ b/Python/optimizer_cases.c.h
@@ -47,6 +47,15 @@
break;
}
+ case _LOAD_FAST_BORROW: {
+ JitOptSymbol *value;
+ value = GETLOCAL(oparg);
+ stack_pointer[0] = value;
+ stack_pointer += 1;
+ assert(WITHIN_STACK_BOUNDS());
+ break;
+ }
+
case _LOAD_FAST_AND_CLEAR: {
JitOptSymbol *value;
value = GETLOCAL(oparg);