gh-121459: Deferred LOAD_GLOBAL (GH-123128)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Sam Gross <655866+colesbury@users.noreply.github.com>
This commit is contained in:
Ken Jin 2024-09-14 00:23:51 +08:00 committed by GitHub
parent 74330d992b
commit 8810e286fa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 108 additions and 29 deletions

View file

@ -1661,15 +1661,14 @@
}
case _LOAD_GLOBAL: {
_PyStackRef res;
_PyStackRef *res;
_PyStackRef null = PyStackRef_NULL;
oparg = CURRENT_OPARG();
res = &stack_pointer[0];
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg>>1);
PyObject *res_o = _PyEval_LoadGlobal(GLOBALS(), BUILTINS(), name);
if (res_o == NULL) JUMP_TO_ERROR();
_PyEval_LoadGlobalStackRef(GLOBALS(), BUILTINS(), name, res);
if (PyStackRef_IsNull(*res)) JUMP_TO_ERROR();
null = PyStackRef_NULL;
res = PyStackRef_FromPyObjectSteal(res_o);
stack_pointer[0] = res;
if (oparg & 1) stack_pointer[1] = null;
stack_pointer += 1 + (oparg & 1);
assert(WITHIN_STACK_BOUNDS());