mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
GH-113710: Add a "globals to constants" pass (GH-114592)
Converts specializations of `LOAD_GLOBAL` into constants during tier 2 optimization.
This commit is contained in:
parent
2091fb2a85
commit
0e71a295e9
16 changed files with 375 additions and 55 deletions
42
Python/executor_cases.c.h
generated
42
Python/executor_cases.c.h
generated
|
@ -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];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue