diff options
author | Mark Shannon <mark@hotpy.org> | 2024-02-02 12:14:34 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-02 12:14:34 (GMT) |
commit | 0e71a295e9530c939a5efcb45db23cf31e0303b4 (patch) | |
tree | ba3a22d5bece296073aa250a04bc3f4192607281 /Python/bytecodes.c | |
parent | 2091fb2a85c1aa2d9b22c02736b07831bd875c2a (diff) | |
download | cpython-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.c | 24 |
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 */ |