Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
56133bb
Split `CALL_PY_EXACT_ARGS` into uops
gvanrossum Aug 5, 2023
907ff95
Fix merge so it works again (I think)
gvanrossum Aug 9, 2023
2c6be6d
Split into finer-grained uops
gvanrossum Aug 9, 2023
6d78ff2
Fix type error in stacking.py
gvanrossum Aug 10, 2023
0d8e66c
Add test
gvanrossum Aug 10, 2023
b75f30e
Add comment explaining _PUSH_FRAME's unused output effect
gvanrossum Aug 10, 2023
61c2822
Make PUSH_FRAME special case a little less myterious
gvanrossum Aug 10, 2023
f73ea90
Rename Instruction.write to write_case_body
gvanrossum Aug 10, 2023
12910fc
Move next_instr update to a more logical place
gvanrossum Aug 10, 2023
2fafa2c
Don't recompute macro cache offset
gvanrossum Aug 10, 2023
2717b07
Fold and refactor long line in stacking.py
gvanrossum Aug 10, 2023
e487908
Fold long lines in generate_cases.py
gvanrossum Aug 10, 2023
1d549af
Don't emit static assert to executor cases
gvanrossum Aug 10, 2023
f40fb1f
Factor away write_case_body (formerly Instruction.write)
gvanrossum Aug 10, 2023
4f6f8f8
Fold long lines
gvanrossum Aug 11, 2023
6facc8d
Make less of a special case of _PUSH_FRAME
gvanrossum Aug 11, 2023
94630d4
Stop special-casing _PUSH_FRAME altogether
gvanrossum Aug 11, 2023
cf8e2c0
Call _Py_EnterRecursivePy in _FRAME_PUSH
gvanrossum Aug 15, 2023
1e62876
Merge remote-tracking branch 'upstream/main' into call-uops
gvanrossum Aug 15, 2023
337a2eb
Add function-by-version cache
gvanrossum Aug 8, 2023
0218222
Trace into function calls
gvanrossum Aug 8, 2023
ab74ef0
Make RESUME a viable uop
gvanrossum Aug 12, 2023
7e6ef78
Clear func_version_cache in interpreter_clear()
gvanrossum Aug 12, 2023
1200014
Add a small essay on function and code versions
gvanrossum Aug 12, 2023
ece96f4
Move function cache clearing earlier in finalization
gvanrossum Aug 12, 2023
b408b2b
Cache borrowed references, cleared in func_dealloc
gvanrossum Aug 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Stop special-casing _PUSH_FRAME altogether
Instead, we special-case SAVE_IP:
- Its Tier 2 expansion sets oparg to the instruction offset
- In Tier 1 it is a no-op (and skipped if present in a macro)
  • Loading branch information
gvanrossum committed Aug 11, 2023
commit 94630d49b3283657953d44b7fbe2a8a36d624721
1 change: 1 addition & 0 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -3005,6 +3005,7 @@ dummy_func(
_CHECK_FUNCTION_EXACT_ARGS +
_CHECK_STACK_SPACE +
_INIT_CALL_PY_EXACT_ARGS +
SAVE_IP + // Tier 2 only; special-cased oparg
_PUSH_FRAME;

inst(CALL_PY_WITH_DEFAULTS, (unused/1, func_version/2, callable, self_or_null, args[oparg] -- unused)) {
Expand Down
12 changes: 4 additions & 8 deletions Tools/cases_generator/generate_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,13 +443,6 @@ def write_macro_expansions(
expansions: list[tuple[str, int, int]] = [] # [(name, size, offset), ...]
for part in parts:
if isinstance(part, Component):
# _PUSH_FRAME is super special; it expands to SAVE_IP(next_instr) + _PUSH_FRAME
if part.instr.name == "_PUSH_FRAME":
expansions.append(
("SAVE_IP", OPARG_SIZES["OPARG_SAVE_IP"], cache_offset)
)
expansions.append(("_PUSH_FRAME", OPARG_SIZES["OPARG_FULL"], 0))
continue
# All component instructions must be viable uops
if not part.instr.is_viable_uop():
# This note just reminds us about macros that cannot
Expand All @@ -463,7 +456,10 @@ def write_macro_expansions(
)
return
if not part.active_caches:
size, offset = OPARG_SIZES["OPARG_FULL"], 0
if part.instr.name == "SAVE_IP":
size, offset = OPARG_SIZES["OPARG_SAVE_IP"], cache_offset
else:
size, offset = OPARG_SIZES["OPARG_FULL"], 0
else:
# If this assert triggers, is_viable_uops() lied
assert len(part.active_caches) == 1, (name, part.instr.name)
Expand Down
16 changes: 14 additions & 2 deletions Tools/cases_generator/stacking.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ class EffectManager:
# Track offsets from stack pointer
min_offset: StackOffset
final_offset: StackOffset
# Link to previous manager
pred: "EffectManager | None" = None

def __init__(
self,
Expand All @@ -168,7 +170,8 @@ def __init__(
self.pokes.append(StackItem(offset=self.final_offset.clone(), effect=eff))
self.final_offset.higher(eff)

if pred:
self.pred = pred
while pred:
# Replace push(x) + pop(y) with copy(x, y).
# Check that the sources and destinations are disjoint.
sources: set[str] = set()
Expand All @@ -193,6 +196,11 @@ def __init__(
sources,
destinations,
)
# See if we can get more copies of a earlier predecessor.
if self.peeks and not pred.pokes and not pred.peeks:
pred = pred.pred
else:
pred = None # Break

def adjust_deeper(self, eff: StackEffect) -> None:
for peek in self.peeks:
Expand Down Expand Up @@ -305,7 +313,11 @@ def write_single_instr(
def write_macro_instr(
mac: MacroInstruction, out: Formatter, family: Family | None
) -> None:
parts = [part for part in mac.parts if isinstance(part, Component)]
parts = [
part
for part in mac.parts
if isinstance(part, Component) and part.instr.name != "SAVE_IP"
]
out.emit("")
with out.block(f"TARGET({mac.name})"):
if mac.predicted:
Expand Down