-
-
Notifications
You must be signed in to change notification settings - Fork 35k
gh-107557: Setup abstract interpretation #107847
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 5 commits
d20fbb8
2aeea51
1a728ab
17fccbc
a1da69d
b458e17
f81f888
0020320
1f93072
dac63e3
e62e015
a7f654c
f4040b8
ec58145
4292767
fdcca90
5110fb9
9f443a2
7632ed1
0d0c4c4
4c8953e
3bd36fa
229097f
ca0fab7
68c684f
46c5777
b839ee4
6ecf3d2
b6eeb25
d5cceb9
8c0d65f
95db909
1e05ef8
d7d8b52
4d7abc7
3d76f9a
e81def2
9a5a3f7
df490d0
1e4fc94
6de77a7
a11fc80
c61015b
56c62eb
3c08ebe
d5f16be
1e61c49
6c24b49
2be404d
29e255d
3c44117
b758b47
80c7f18
6a2b204
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3743,13 +3743,12 @@ dummy_func( | |
| return frame; | ||
| } | ||
|
|
||
| op(INSERT, (--)) { | ||
| op(INSERT, (stuff[oparg], top -- top, stuff[oparg])) { | ||
|
Fidget-Spinner marked this conversation as resolved.
Outdated
|
||
| // Inserts TOS at position specified by oparg | ||
| PyObject *tos = TOP(); | ||
| for (int i = 1; i < oparg + 1; i++) { | ||
| stack_pointer[i] = stack_pointer[i - 1]; | ||
|
Member
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. Hm, doesn't this repeat the first stack element over and over? Maybe
Member
Author
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. Woops yeah thanks for catching this! Forgot to negate the indexes. |
||
| } | ||
| POKE(oparg, tos); | ||
| } | ||
|
|
||
|
|
||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,7 +61,7 @@ | |
|
|
||
| INSTR_FMT_PREFIX = "INSTR_FMT_" | ||
|
|
||
| # @TODO generate all these after updating the DSL | ||
| # TODO: generate all these after updating the DSL | ||
| SPECIALLY_HANDLED_ABSTRACT_INSTR = { | ||
| "LOAD_FAST", | ||
| "LOAD_FAST_CHECK", | ||
|
|
@@ -135,7 +135,7 @@ def effect_str(effects: list[StackEffect]) -> str: | |
| pushed: str | None | ||
| match thing: | ||
| case parsing.InstDef(): | ||
| if thing.kind != "op" or (thing.kind != "inst" and self.instrs[thing.name].is_viable_uop()): | ||
| if thing.kind != "op" or self.instrs[thing.name].is_viable_uop(): | ||
| instr = self.instrs[thing.name] | ||
| popped = effect_str(instr.input_effects) | ||
| pushed = effect_str(instr.output_effects) | ||
|
|
@@ -641,17 +641,14 @@ def write_abstract_interpreter_instructions( | |
| for thing in self.everything: | ||
| match thing: | ||
| case OverriddenInstructionPlaceHolder(): | ||
| # TODO: Is this helpful? | ||
| self.write_overridden_instr_place_holder(thing) | ||
| pass | ||
| case parsing.InstDef(): | ||
| instr = AbstractInstruction(self.instrs[thing.name].inst) | ||
| if instr.is_viable_uop() and instr.name not in SPECIALLY_HANDLED_ABSTRACT_INSTR: | ||
| self.out.emit("") | ||
| with self.out.block(f"case {thing.name}:"): | ||
| instr.write(self.out, tier=TIER_TWO) | ||
|
Member
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. Note that in gh-107760 I'm removing
Comment on lines
645
to
650
Member
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. I wonder if you even need the
Member
Author
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. I was thinking of how we might need to expand on it more in the future, so a separate class might be better.
Member
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. When that happens in the future you can refactor the code. Until then, I recommend less code. As you may have noticed this code gets refactored a lot. :-) It's easy because the generator is not a public API -- all we care about is whether it generates a handful of files correctly from bytecodes.c at build time. But I worry about copying and pasting code, because that's harder to refactor. |
||
| self.out.emit("break;") | ||
| # elif instr.kind != "op": | ||
| # print(f"NOTE: {thing.name} is not a viable uop") | ||
| case parsing.Macro(): | ||
| pass | ||
| case parsing.Pseudo(): | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.