-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
Changes from 1 commit
9f15c4b
6189043
f5e1aed
a8d608d
4ee85e7
873da31
e0ab5b8
882fdec
8226fb9
1aa0124
d094e42
d3d907a
0339a67
f3e7dd6
e3ff6ac
3db443a
c58a85a
756a41b
48400ac
433243a
3d51484
4d42a0a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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": | ||||||
bits = ceffect.size * 16 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
|
||||||
f.write(f"{indent} PyObject *{ceffect.name} = read{bits}(next_instr + {cache_offset});\n") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
|
||||||
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) | ||||||
|
@@ -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": | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are we checking |
||||||
f.write(f"{indent} POKE({i}, {output.name});\n") | ||||||
# Cache effect | ||||||
if cache_offset: | ||||||
|
There was a problem hiding this comment.
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?