Skip to content

Conversation

@iritkatriel
Copy link
Member

It might be easier to review the individual commits separately.

The code generation part of the compiler has several functions which are slight variations of each other. Part of this is due to the evolution of the code when accurate line number information was added.

This PR tidies this up to simplify the code. Having just one basicblock_addop function that knows how to handle all the HAS_ARG, !HAS_ARG and JUMP cases is a step towards being able to feed bytecode instruction sequences and turn them into basicblocks (without having to differentiate between the three types).

@iritkatriel iritkatriel requested a review from markshannon as a code owner June 10, 2022 11:06
@iritkatriel iritkatriel added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jun 10, 2022
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @iritkatriel for commit f8a0767 🤖

If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jun 10, 2022
@Fidget-Spinner
Copy link
Member

Sorry but I'm clueless when it comes to the compiler, so I can't give a review.

@Fidget-Spinner Fidget-Spinner removed their request for review June 10, 2022 11:09
Copy link
Member

@markshannon markshannon left a comment

Choose a reason for hiding this comment

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

Seems like a nice improvement in the architecture of the compiler.

@iritkatriel iritkatriel added interpreter-core (Objects, Python, Grammar, and Parser dirs) 🔨 test-with-buildbots Test PR w/ buildbots; report in status section labels Jun 10, 2022
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @iritkatriel for commit 7670a7c 🤖

If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jun 10, 2022
Copy link
Member

@brandtbucher brandtbucher left a comment

Choose a reason for hiding this comment

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

Thanks, this looks nice.

One thing I noticed is that the new design creates lots of temporary location structs (at least one for every instruction emitted by the frontend, I think). Could we instead keep just one struct on the compiler unit, and maybe have a static "no location" struct, and just pass references to those into basicblock_addop instead?

@iritkatriel
Copy link
Member Author

Thanks, this looks nice.

One thing I noticed is that the new design creates lots of temporary location structs (at least one for every instruction emitted by the frontend, I think). Could we instead keep just one struct on the compiler unit, and maybe have a static "no location" struct, and just pass references to those into basicblock_addop instead?

Yeah I guess we could pass them by reference.

I'm now working on replacing the four fields by the struct in the instr and compiler unit structs, will push that in a bit.

@iritkatriel iritkatriel changed the title GH-93678: reduce boilerplate and code repetition in compiler's code-gen stage GH-93678: reduce boilerplate and code repetition in the compiler Jun 10, 2022
@iritkatriel iritkatriel added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jun 10, 2022
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @iritkatriel for commit 9b5dc34 🤖

If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jun 10, 2022
@iritkatriel iritkatriel added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jun 13, 2022
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @iritkatriel for commit 414e26a 🤖

If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again.

Copy link
Member

@markshannon markshannon left a comment

Choose a reason for hiding this comment

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

Nice improvement in clarity.

Copy link
Member

@sweeneyde sweeneyde left a comment

Choose a reason for hiding this comment

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

100 lines shorter 🎉

@iritkatriel iritkatriel merged commit af15cc5 into python:main Jun 14, 2022
@iritkatriel iritkatriel deleted the codegen-reduce-repetition branch June 14, 2022 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

interpreter-core (Objects, Python, Grammar, and Parser dirs)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants