GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GH-98831: Refactor generate_cases.py by gvanrossum · Pull Request #99408 · python/cpython

Conversation

@gvanrossum

@gvanrossum gvanrossum commented Nov 12, 2022 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Consider this after GH-99313.

  • Issue: Generate the interpreter #98831

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
gvanrossum and others added 27 commits November 9, 2022 18:38
@gvanrossum
Support simple cache effects
9f15c4b
Had to refactor the parser a bit for this.
@gvanrossum
More BINARY_OP instructions
6189043
@gvanrossum
Merge remote-tracking branch 'origin/main' into cache-effects
f5e1aed
@gvanrossum
Tweak dummy definitions in bytecodes.c after merge
a8d608d
@vstinner @gvanrossum
pythongh-99300: Use Py_NewRef() in Objects/ directory (python#99332)
4ee85e7
Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and
Py_XNewRef() in C files of the Objects/ directory.
@vstinner @gvanrossum
pythongh-99300: Use Py_NewRef() in Objects/dictobject.c (python#99333)
873da31
Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and
Py_XNewRef() in Objects/dictobject.c.
@ericsnowcurrently @gvanrossum
pythongh-90110: Update the C-analyzer Tool (pythongh-99307)
e0ab5b8
@csuriano23 @kumaraditya303 @gvanrossum
pythongh-99277: remove older version of get_write_buffer_limits (py…
882fdec
…thon#99280)

Co-authored-by: Kumar Aditya <[email protected]>
@vfazio @gvanrossum
pythongh-99204: Calculate base_executable by alternate names in POSIX…
8226fb9
… venvs (pythonGH-99206)

Check to see if `base_executable` exists. If it does not, attempt
to use known alternative names of the python binary to find an
executable in the path specified by `home`.

If no alternative is found, previous behavior is preserved.

Signed-off-by: Vincent Fazio <[email protected]>

Signed-off-by: Vincent Fazio <[email protected]>
@brandtbucher @gvanrossum
pythonGH-99298: Don't perform jumps before error handling (pythonGH-9…
1aa0124
…9299)
@gvanrossum @brandtbucher
pythonGH-98831: Remove all remaining DISPATCH() calls from bytecodes.c (
d094e42
python#99271)

Also mark those opcodes that have no stack effect as such.

Co-authored-by: Brandt Bucher <[email protected]>
@gvanrossum
Remaining BINARY_OP family members
d3d907a
@gvanrossum
Uniformly skip 'unused' effects
0339a67
@gvanrossum
Remove superfluous asserts; fix one 'is not'
f3e7dd6
@gvanrossum
Make BINARY_OP result unused
e3ff6ac
@gvanrossum
Fix parser for family()
3db443a
@gvanrossum
Check family consistency
c58a85a
@gvanrossum
Add first family (binary_op)
756a41b
@gvanrossum
Add assert() to double-check cache struct size
48400ac
@gvanrossum
Merge commit '00ee6d506e' into cache-effects
433243a
@gvanrossum
Merge commit '694cdb24a6' into cache-effects
3d51484
@gvanrossum
Merge remote-tracking branch 'origin/main' into cache-effects
4d42a0a
@gvanrossum
Merge remote-tracking branch 'origin/main' into cache-effects
ff8e0ec
@gvanrossum
Make family() macro variadic
ea16382
@gvanrossum
Merge remote-tracking branch 'origin/main' into cache-effects
8eadf1c
@gvanrossum
Show correct lineno on error; get rid of eopen()
205f12e
@gvanrossum
Kill -q flag
bdba4d2
@bedevere-bot bedevere-bot mentioned this pull request Nov 12, 2022
Generate the interpreter #98831
Closed
@bedevere-bot bedevere-bot added the awaiting core review label Nov 12, 2022
@gvanrossum
Refactor generate_cases.py. Tweak output a teensy bit.
bf10431
@gvanrossum
gvanrossum force-pushed the cases-refactor branch from 8088808 to bf10431 Compare November 12, 2022 05:59
@gvanrossum
Further refactor
4cfcf77
@gvanrossum gvanrossum added the skip news label Nov 12, 2022
gvanrossum added 6 commits November 12, 2022 12:10
@gvanrossum
Merge remote-tracking branch 'origin/main' into cases-refactor
a280167
@gvanrossum
Make {In,Out}putEffect unions instead of classes
382e248
@gvanrossum
Fix some mypy errors
b5c8a9f
@gvanrossum
Move check_overlaps to generate_cases.py
387fbe1
@gvanrossum
Fix cache effect when used
d682118
@gvanrossum
Demonstrate cache effect with BINARY_SUBSCR
14e75f1
This was a bin subtle, esp. BINARY_SUBSCR_DICT (which plays games
with refcounts) and BINARY_SUBSCR_GETITEM (which ends with a goto).
@gvanrossum gvanrossum mentioned this pull request Nov 13, 2022
GH-98831: Implement basic cache effects #99313
Merged
@gvanrossum
Fix test crashes by fiddling DECREF order in BINARY_SUBSCR_DICT
1a5356b
@gvanrossum

gvanrossum commented Nov 14, 2022

Copy link
Copy Markdown
Member Author

My expectation at this point is that converting the majority of instructions to non-legacy form (cache and stack effects) will be a big project, even if we skip opcodes needing arrays or conditional stack effects.

The good news is that it can be parallelized -- each family can be done independently from any others, so anyone who wants to can pick a family and convert it, as long as it doesn't require fixing the generator (it's probably best if I stay on top of that).

I don't know how much we need to do before we can start experimenting with "macro" opcodes (see faster-cpython/ideas#491). Possibly we can start with an example like the one Mark wrote up in the DSL definition.

binbjz reacted with hooray emoji erlend-aasland reacted with eyes emoji
All reactions
  • 🎉 1 reaction
  • 👀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@markshannon

markshannon commented Nov 15, 2022 •
edited by gvanrossum
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

I won't attempt a review of this PR, but a few comments on how I'd like the tool(s) to look.

  • This is a compiler, so it should be built like one: Dumb IR(s) and multiple passes.
  • Any methods on IR classes should be simple query method. Put all processing in the passes.

A possible design:

  • Tokenizer: Tokenize the whole input file, so that locations are correct.
  • Parser: Parse instructions
  • Analyzer: Group and check families, check stack effects. Compute necessary labels and tables, instruction size, etc.
  • Code gen: Generate C code as stream of tokens and strings
  • Formatter: Format resulting C code, inserting #line directives and whitespace where needed.

Then, when we want to generate a trace interpreter, a register interpreter, compiler front-end, etc. we can re-use the tokenizer, parser, and formatter.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gvanrossum

gvanrossum commented Nov 15, 2022

Copy link
Copy Markdown
Member Author

Thanks, I'll try to use that as a north star. In the meantime I am hoping to keep things working the way they were as much as possible to avoid disrupting other work. I have half the analyzer in this refactor, what's missing is a design for the IR to target.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gvanrossum

gvanrossum commented Nov 16, 2022

Copy link
Copy Markdown
Member Author

I'm starting over from scratch now GH-99313 is merged.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gvanrossum gvanrossum closed this Nov 16, 2022
@gvanrossum
gvanrossum deleted the cases-refactor branch November 16, 2022 04:25
This was referenced Nov 16, 2022
We need a design for the DSL-based code generator faster-cpython/ideas#497
Closed
GH-98831: Refactor and fix cases generator #99526
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@markshannon markshannon Awaiting requested review from markshannon markshannon will be requested when the pull request is marked ready for review markshannon is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting core review skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

8 participants

@gvanrossum @markshannon @bedevere-bot @vstinner @ericsnowcurrently @csuriano23 @vfazio @brandtbucher
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.