8000 GH-98831: Implement basic cache effects by gvanrossum · Pull Request #99313 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

GH-98831: Implement basic cache effects #99313

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Nov 16, 2022
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
9f15c4b
Support simple cache effects
gvanrossum Nov 10, 2022
6189043
More BINARY_OP instructions
gvanrossum Nov 10, 2022
f5e1aed
Merge remote-tracking branch 'origin/main' into cache-effects
gvanrossum Nov 10, 2022
a8d608d
Tweak dummy definitions in bytecodes.c after merge
gvanrossum Nov 10, 2022
4ee85e7
gh-99300: Use Py_NewRef() in Objects/ directory (#99332)
vstinner Nov 10, 2022
873da31
gh-99300: Use Py_NewRef() in Objects/dictobject.c (#99333)
vstinner Nov 10, 2022
e0ab5b8
gh-90110: Update the C-analyzer Tool (gh-99307)
ericsnowcurrently Nov 10, 2022
882fdec
gh-99277: remove older version of `get_write_buffer_limits` (#99280)
csuriano23 Nov 10, 2022
8226fb9
gh-99204: Calculate base_executable by alternate names in POSIX venvs…
vfazio Nov 10, 2022
1aa0124
GH-99298: Don't perform jumps before error handling (GH-99299)
brandtbucher Nov 10, 2022
d094e42
GH-98831: Remove all remaining DISPATCH() calls from bytecodes.c (#99…
gvanrossum Nov 10, 2022
d3d907a
Remaining BINARY_OP family members
gvanrossum Nov 10, 2022
0339a67
Uniformly skip 'unused' effects
gvanrossum Nov 10, 2022
f3e7dd6
Remove superfluous asserts; fix one 'is not'
gvanrossum Nov 10, 2022
e3ff6ac
Make BINARY_OP result unused
gvanrossum Nov 11, 2022
3db443a
Fix parser for family()
gvanrossum Nov 11, 2022
c58a85a
Check family consistency
gvanrossum Nov 11, 2022
756a41b
Add first family (binary_op)
gvanrossum Nov 11, 2022
48400ac
Add assert() to double-check cache struct size
gvanrossum Nov 11, 2022
433243a
Merge commit '00ee6d506e' into cache-effects
gvanrossum Nov 11, 2022
3d51484
Merge commit '694cdb24a6' into cache-effects
gvanrossum Nov 11, 2022
4d42a0a
Merge remote-tracking branch 'origin/main' into cache-effects
gvanrossum Nov 11, 2022
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
Uniformly skip 'unused' effects
  • Loading branch information
gvanrossum committed Nov 10, 2022
commit 0339a670f600b1913300c196829a1a6d94a59e72
9 changes: 5 additions & 4 deletions Tools/cases_generator/generate_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,16 @@ def write_instr(instr: InstDef, predictions: set[str], indent: str, f: TextIO, d
outputs = instr.outputs
cache_offset = 0
for ceffect in cache:
if ceffect.name not in ("unused", "u", "_"):
if ceffect.name != "unused":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this magic name is used in a few places now. Maybe define a constant?

Suggested change
if ceffect.name != "unused":
if ceffect.name != UNUSED:

bits = ceffect.size * 16
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, minor, but the connection between this magic constant and the width of a code unit isn't obvious when reading:

Suggested change
bits = ceffect.size * 16
bits = ceffect.size * CODEUNIT_BITS

f.write(f"{indent} PyObject *{ceffect.name} = read{bits}(next_instr + {cache_offset});\n")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not that it matters yet, but these are almost always fixed-width integer types, not objects (though we'll eventually want handling for objects too):

Suggested change
f.write(f"{indent} PyObject *{ceffect.name} = read{bits}(next_instr + {cache_offset});\n")
f.write(f"{indent} uint{bits}_t {ceffect.name} = read{bits}(next_instr + {cache_offset});\n")

cache_offset += ceffect.size
# TODO: Is it better to count forward or backward?
for i, effect in enumerate(reversed(stack), 1):
f.write(f"{indent} PyObject *{effect.name} = PEEK({i});\n")
if effect.name is not "unused":
f.write(f"{indent} PyObject *{effect.name} = PEEK({i});\n")
for output in instr.outputs:
if output.name not in input_names:
if output.name not in input_names and output.name != "unused":
f.write(f"{indent} PyObject *{output.name};\n")
assert instr.block is not None
blocklines = instr.block.to_text(dedent=dedent).splitlines(True)
Expand Down Expand Up @@ -135,7 +136,7 @@ def write_instr(instr: InstDef, predictions: set[str], indent: str, f: TextIO, d
elif diff < 0:
f.write(f"{indent} STACK_SHRINK({-diff});\n")
for i, output in enumerate(reversed(outputs), 1):
if output.name not in (input_names):
if output.name not in input_names and output.name != "unused":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we checking output.name not in input_names?

f.write(f"{indent} POKE({i}, {output.name});\n")
# Cache effect
if cache_offset:
Expand Down
0