GH-130296: Avoid stack transients in four instructions. (GH-130310)

* Combine _GUARD_GLOBALS_VERSION_PUSH_KEYS and _LOAD_GLOBAL_MODULE_FROM_KEYS into _LOAD_GLOBAL_MODULE

* Combine _GUARD_BUILTINS_VERSION_PUSH_KEYS and _LOAD_GLOBAL_BUILTINS_FROM_KEYS into _LOAD_GLOBAL_BUILTINS

* Combine _CHECK_ATTR_MODULE_PUSH_KEYS and _LOAD_ATTR_MODULE_FROM_KEYS into _LOAD_ATTR_MODULE

* Remove stack transient in LOAD_ATTR_WITH_HINT
This commit is contained in:
Mark Shannon 2025-02-28 18:00:38 +00:00 committed by GitHub
parent ab11c09705
commit 54965f3fb2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 615 additions and 1005 deletions

View file

@ -126,7 +126,6 @@ class Emitter:
"PyStackRef_AsPyObjectSteal": self.stackref_steal,
"DISPATCH": self.dispatch,
"INSTRUCTION_SIZE": self.instruction_size,
"POP_INPUT": self.pop_input,
"stack_pointer": self.stack_pointer,
}
self.out = out
@ -421,29 +420,6 @@ class Emitter:
self.emit_save(storage)
return True
def pop_input(
self,
tkn: Token,
tkn_iter: TokenIterator,
uop: CodeSection,
storage: Storage,
inst: Instruction | None,
) -> bool:
next(tkn_iter)
name_tkn = next(tkn_iter)
name = name_tkn.text
next(tkn_iter)
next(tkn_iter)
if not storage.inputs:
raise analysis_error("stack is empty", tkn)
tos = storage.inputs[-1]
if tos.name != name:
raise analysis_error(f"'{name} is not top of stack", name_tkn)
tos.defined = False
storage.clear_dead_inputs()
storage.flush(self.out)
return True
def emit_reload(self, storage: Storage) -> None:
storage.reload(self.out)
self._print_storage(storage)