Skip to content
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

split compiler.c into compiler and codegen #121404

Closed
iritkatriel opened this issue Jul 5, 2024 · 0 comments
Closed

split compiler.c into compiler and codegen #121404

iritkatriel opened this issue Jul 5, 2024 · 0 comments
Assignees
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@iritkatriel
Copy link
Member

iritkatriel commented Jul 5, 2024

compile.c is one of the largest source files in python (at about 8000 lines). Most of the code is code generation functions (the AST traversals). Most of the complexity is in the compiler data structure management.

In this work I will split out the code generation functions into a separate file so that they are independent of the compiler internals (access the compiler through an opaque reference and a well defined API). First I will transform the codegen functions so that they no longer access internals of struct compiler or struct compiler_unit. Then I will rename compile.c to codegen.c (to preserve commit history for the codegen functions) and copy out the compiler implementation code to a new file (compile.c, so the entry point is where people are used to finding it).

The benefits will be that (1) codegen code is simpler (2) the complexity of compile.c is more manageable as it will probably only span 2-3K lines of code (3) it becomes possible to share parts of the compiler with alternative compiler implementation.

Linked PRs

@iritkatriel iritkatriel self-assigned this Jul 5, 2024
@iritkatriel iritkatriel added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Jul 5, 2024
iritkatriel added a commit to iritkatriel/cpython that referenced this issue Jul 5, 2024
iritkatriel added a commit to iritkatriel/cpython that referenced this issue Jul 8, 2024
iritkatriel added a commit to iritkatriel/cpython that referenced this issue Jul 9, 2024
iritkatriel added a commit to iritkatriel/cpython that referenced this issue Jul 9, 2024
noahbkim pushed a commit to hudson-trading/cpython that referenced this issue Jul 11, 2024
noahbkim pushed a commit to hudson-trading/cpython that referenced this issue Jul 11, 2024
estyxx pushed a commit to estyxx/cpython that referenced this issue Jul 17, 2024
estyxx pushed a commit to estyxx/cpython that referenced this issue Jul 17, 2024
iritkatriel added a commit to iritkatriel/cpython that referenced this issue Jul 22, 2024
iritkatriel added a commit that referenced this issue Jul 22, 2024
iritkatriel added a commit to iritkatriel/cpython that referenced this issue Jul 23, 2024
nohlson pushed a commit to nohlson/cpython that referenced this issue Jul 24, 2024
nohlson pushed a commit to nohlson/cpython that referenced this issue Jul 24, 2024
iritkatriel added a commit to iritkatriel/cpython that referenced this issue Aug 14, 2024
iritkatriel added a commit that referenced this issue Aug 15, 2024
iritkatriel added a commit to iritkatriel/cpython that referenced this issue Aug 15, 2024
iritkatriel added a commit to iritkatriel/cpython that referenced this issue Aug 15, 2024
iritkatriel added a commit to iritkatriel/cpython that referenced this issue Aug 15, 2024
iritkatriel added a commit to iritkatriel/cpython that referenced this issue Aug 15, 2024
iritkatriel added a commit to iritkatriel/cpython that referenced this issue Aug 27, 2024
iritkatriel added a commit to iritkatriel/cpython that referenced this issue Aug 27, 2024
iritkatriel added a commit to iritkatriel/cpython that referenced this issue Aug 30, 2024
iritkatriel added a commit that referenced this issue Aug 30, 2024
iritkatriel added a commit to iritkatriel/cpython that referenced this issue Sep 1, 2024
iritkatriel added a commit that referenced this issue Sep 2, 2024
iritkatriel added a commit to iritkatriel/cpython that referenced this issue Sep 3, 2024
iritkatriel added a commit to iritkatriel/cpython that referenced this issue Sep 3, 2024
iritkatriel added a commit to iritkatriel/cpython that referenced this issue Sep 3, 2024
iritkatriel added a commit to iritkatriel/cpython that referenced this issue Sep 15, 2024
savannahostrowski pushed a commit to savannahostrowski/cpython that referenced this issue Sep 22, 2024
efimov-mikhail added a commit to efimov-mikhail/cpython that referenced this issue Oct 8, 2024
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

No branches or pull requests

1 participant