mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
gh-106290: Fix edge cases around uops (#106319)
- Tweak uops debugging output - Fix the bug from gh-106290 - Rename `SET_IP` to `SAVE_IP` (per https://github.com/faster-cpython/ideas/issues/558) - Add a `SAVE_IP` uop at the start of the trace (ditto) - Allow `unbound_local_error`; this gives us uops for `LOAD_FAST_CHECK`, `LOAD_CLOSURE`, and `DELETE_FAST` - Longer traces - Support `STORE_FAST_LOAD_FAST`, `STORE_FAST_STORE_FAST` - Add deps on pycore_uops.h to Makefile(.pre.in)
This commit is contained in:
parent
58906213cc
commit
2028a4f6d9
7 changed files with 274 additions and 234 deletions
|
@ -308,8 +308,7 @@ class ActiveCacheEffect:
|
|||
|
||||
|
||||
FORBIDDEN_NAMES_IN_UOPS = (
|
||||
"resume_with_error", # Proxy for "goto", which isn't an IDENTIFIER
|
||||
"unbound_local_error",
|
||||
"resume_with_error",
|
||||
"kwnames",
|
||||
"next_instr",
|
||||
"oparg1", # Proxy for super-instructions like LOAD_FAST_LOAD_FAST
|
||||
|
@ -401,20 +400,25 @@ class Instruction:
|
|||
def is_viable_uop(self) -> bool:
|
||||
"""Whether this instruction is viable as a uop."""
|
||||
if self.always_exits:
|
||||
# print(f"Skipping {self.name} because it always exits")
|
||||
return False
|
||||
if self.instr_flags.HAS_ARG_FLAG:
|
||||
# If the instruction uses oparg, it cannot use any caches
|
||||
if self.active_caches:
|
||||
# print(f"Skipping {self.name} because it uses oparg and caches")
|
||||
return False
|
||||
else:
|
||||
# If it doesn't use oparg, it can have one cache entry
|
||||
if len(self.active_caches) > 1:
|
||||
# print(f"Skipping {self.name} because it has >1 cache entries")
|
||||
return False
|
||||
res = True
|
||||
for forbidden in FORBIDDEN_NAMES_IN_UOPS:
|
||||
# TODO: Don't check in '#ifdef ENABLE_SPECIALIZATION' regions
|
||||
if variable_used(self.inst, forbidden):
|
||||
return False
|
||||
return True
|
||||
# print(f"Skipping {self.name} because it uses {forbidden}")
|
||||
res = False
|
||||
return res
|
||||
|
||||
def write(self, out: Formatter, tier: Tiers = TIER_ONE) -> None:
|
||||
"""Write one instruction, sans prologue and epilogue."""
|
||||
|
@ -1323,7 +1327,7 @@ class Analyzer:
|
|||
self.out.emit(make_text(name, counter))
|
||||
counter += 1
|
||||
add("EXIT_TRACE")
|
||||
add("SET_IP")
|
||||
add("SAVE_IP")
|
||||
for instr in self.instrs.values():
|
||||
if instr.kind == "op" and instr.is_viable_uop():
|
||||
add(instr.name)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue