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

Compiler: refactor codegen #14760

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ysbaddaden
Copy link
Contributor

@ysbaddaden ysbaddaden commented Jun 27, 2024

Refactors Crystal::Compiler:

  1. extracts #sequential_codegen, #parallel_codegen and #fork_codegen methods;
  2. merges #codegen_many_units into #codegen directly;
  3. stops collecting reused units: #fork_codegen now updates CompilationUnit#reused_compilation_unit? state as reported by the forked processes, and #print_codegen_stats now counts & filters the reused units.

Prerequisite for #14748 that will introduce #mt_codegen.

@ysbaddaden
Copy link
Contributor Author

ysbaddaden commented Jun 27, 2024

AArch64 CI is failing with "fork not implemented" 🤨

EDIT: the issue is the legacy crystal compiler in the images (1.0.0 by default 😱) that doesn't support the has_method? macro outside of methods, so we can't generate different method implementations 😮‍💨

@straight-shoota
Copy link
Member

Actually, I prefer the version with a single def and different bodies, instead of different defs.

@ysbaddaden ysbaddaden changed the title Compiler codegen: small refactor Compiler codegen: small refactor with progress fix Jun 27, 2024
@ysbaddaden ysbaddaden marked this pull request as draft June 27, 2024 12:42
We only need to update unit.reused_compilation_unit? from forked process
then have print_codegen_stats count & filter the units.
@ysbaddaden ysbaddaden force-pushed the refactor/compiler-parallel-codegen branch from 162c8b0 to b17db55 Compare July 2, 2024 10:01
@ysbaddaden ysbaddaden changed the title Compiler codegen: small refactor with progress fix Compiler: refactor codegen Jul 2, 2024
@ysbaddaden
Copy link
Contributor Author

Re-created from master to fix merge conflicts with #14762 and #14763.
Added a patch to stop collecting reused units.

@ysbaddaden ysbaddaden marked this pull request as ready for review July 2, 2024 10:11
@straight-shoota straight-shoota added this to the 1.14.0 milestone Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants