summaryrefslogtreecommitdiffstats
path: root/Python/bytecodes.c
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2024-02-02 12:14:34 (GMT)
committerGitHub <noreply@github.com>2024-02-02 12:14:34 (GMT)
commit0e71a295e9530c939a5efcb45db23cf31e0303b4 (patch)
treeba3a22d5bece296073aa250a04bc3f4192607281 /Python/bytecodes.c
parent2091fb2a85c1aa2d9b22c02736b07831bd875c2a (diff)
downloadcpython-0e71a295e9530c939a5efcb45db23cf31e0303b4.zip
cpython-0e71a295e9530c939a5efcb45db23cf31e0303b4.tar.gz
cpython-0e71a295e9530c939a5efcb45db23cf31e0303b4.tar.bz2
GH-113710: Add a "globals to constants" pass (GH-114592)
Converts specializations of `LOAD_GLOBAL` into constants during tier 2 optimization.
Diffstat (limited to 'Python/bytecodes.c')
-rw-r--r--Python/bytecodes.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/Python/bytecodes.c b/Python/bytecodes.c
index ebd5b06..6fb4d71 100644
--- a/Python/bytecodes.c
+++ b/Python/bytecodes.c
@@ -4071,11 +4071,35 @@ dummy_func(
}
op(_LOAD_CONST_INLINE, (ptr/4 -- value)) {
+ TIER_TWO_ONLY
value = Py_NewRef(ptr);
}
op(_LOAD_CONST_INLINE_BORROW, (ptr/4 -- value)) {
+ TIER_TWO_ONLY
+ value = ptr;
+ }
+
+ op(_LOAD_CONST_INLINE_WITH_NULL, (ptr/4 -- value, null)) {
+ TIER_TWO_ONLY
+ value = Py_NewRef(ptr);
+ null = NULL;
+ }
+
+ op(_LOAD_CONST_INLINE_BORROW_WITH_NULL, (ptr/4 -- value, null)) {
+ TIER_TWO_ONLY
value = ptr;
+ null = NULL;
+ }
+
+ op(_CHECK_GLOBALS, (dict/4 -- )) {
+ TIER_TWO_ONLY
+ DEOPT_IF(GLOBALS() != dict);
+ }
+
+ op(_CHECK_BUILTINS, (dict/4 -- )) {
+ TIER_TWO_ONLY
+ DEOPT_IF(BUILTINS() != dict);
}
/* Internal -- for testing executors */