mirror of
https://github.com/python/cpython.git
synced 2025-10-14 18:59:46 +00:00
gh-115999: Specialize LOAD_ATTR
for instance and class receivers in free-threaded builds (#128164)
Finish specialization for LOAD_ATTR in the free-threaded build by adding support for class and instance receivers.
This commit is contained in:
parent
1c13c56a34
commit
b5ee0258bf
18 changed files with 619 additions and 271 deletions
|
@ -126,7 +126,7 @@ class Emitter:
|
|||
"PyStackRef_AsPyObjectSteal": self.stackref_steal,
|
||||
"DISPATCH": self.dispatch,
|
||||
"INSTRUCTION_SIZE": self.instruction_size,
|
||||
"POP_DEAD_INPUTS": self.pop_dead_inputs,
|
||||
"POP_INPUT": self.pop_input,
|
||||
}
|
||||
self.out = out
|
||||
|
||||
|
@ -423,7 +423,7 @@ class Emitter:
|
|||
self.emit_save(storage)
|
||||
return True
|
||||
|
||||
def pop_dead_inputs(
|
||||
def pop_input(
|
||||
self,
|
||||
tkn: Token,
|
||||
tkn_iter: TokenIterator,
|
||||
|
@ -432,9 +432,18 @@ class Emitter:
|
|||
inst: Instruction | None,
|
||||
) -> bool:
|
||||
next(tkn_iter)
|
||||
name_tkn = next(tkn_iter)
|
||||
name = name_tkn.text
|
||||
next(tkn_iter)
|
||||
next(tkn_iter)
|
||||
storage.pop_dead_inputs(self.out)
|
||||
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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue