summaryrefslogtreecommitdiffstats
path: root/Python/executor_cases.c.h
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/executor_cases.c.h
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/executor_cases.c.h')
-rw-r--r--Python/executor_cases.c.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h
index 241b905..2d914b8 100644
--- a/Python/executor_cases.c.h
+++ b/Python/executor_cases.c.h
@@ -3393,6 +3393,7 @@
case _LOAD_CONST_INLINE: {
PyObject *value;
PyObject *ptr = (PyObject *)CURRENT_OPERAND();
+ TIER_TWO_ONLY
value = Py_NewRef(ptr);
stack_pointer[0] = value;
stack_pointer += 1;
@@ -3402,12 +3403,53 @@
case _LOAD_CONST_INLINE_BORROW: {
PyObject *value;
PyObject *ptr = (PyObject *)CURRENT_OPERAND();
+ TIER_TWO_ONLY
value = ptr;
stack_pointer[0] = value;
stack_pointer += 1;
break;
}
+ case _LOAD_CONST_INLINE_WITH_NULL: {
+ PyObject *value;
+ PyObject *null;
+ PyObject *ptr = (PyObject *)CURRENT_OPERAND();
+ TIER_TWO_ONLY
+ value = Py_NewRef(ptr);
+ null = NULL;
+ stack_pointer[0] = value;
+ stack_pointer[1] = null;
+ stack_pointer += 2;
+ break;
+ }
+
+ case _LOAD_CONST_INLINE_BORROW_WITH_NULL: {
+ PyObject *value;
+ PyObject *null;
+ PyObject *ptr = (PyObject *)CURRENT_OPERAND();
+ TIER_TWO_ONLY
+ value = ptr;
+ null = NULL;
+ stack_pointer[0] = value;
+ stack_pointer[1] = null;
+ stack_pointer += 2;
+ break;
+ }
+
+ case _CHECK_GLOBALS: {
+ PyObject *dict = (PyObject *)CURRENT_OPERAND();
+ TIER_TWO_ONLY
+ if (GLOBALS() != dict) goto deoptimize;
+ break;
+ }
+
+ case _CHECK_BUILTINS: {
+ PyObject *dict = (PyObject *)CURRENT_OPERAND();
+ TIER_TWO_ONLY
+ if (BUILTINS() != dict) goto deoptimize;
+ break;
+ }
+
case _INTERNAL_INCREMENT_OPT_COUNTER: {
PyObject *opt;
opt = stack_pointer[-1];