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
refactor inference.jl into multiple files for readability/maintainability #25517
Conversation
base/compiler/structs.jl
Outdated
# Optimization* # | ||
################# | ||
|
||
mutable struct OptimizationState |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should go with the optimization code.
base/compiler/structs.jl
Outdated
# This struct contains information about a use of certain value (`SSAValue` or `Slot`) | ||
# This might be a toplevel use for `Slot` in which case the `expr` field is `#undef`, | ||
# and it only happens if the slot might be used before it's defined. | ||
struct ValueUse |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also part of optimization passes.
base/compiler/init.jl
Outdated
# CompilationResult # | ||
##################### | ||
|
||
mutable struct CompilationResult |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name of this should be reverted. It doesn't give you compiled code, just inferred code. Also only used by inference, so it can go in that file.
8b38c4c
to
ca91862
Compare
3267296
to
f610a64
Compare
2e219d7
to
69015e6
Compare
Tests just passed locally! Just waiting on CI now, and any additional review. |
AppVeyor failures are both timeouts. Want me to restart them? Or do we expect this just to timeout again? |
Are AppVeyor timeouts common these days? I have no reason to suspect that this PR to incur AppVeyor timeouts moreso than any other PR, so if you think it's sensible to try again, then sure, thanks! |
Well, you're looking good on Linux and FreeBSD. Let's see how macOS and Windows do... |
👍 Awesome, this is a huge improvement a long time coming. A few detail comments:
|
b6822ce
to
396ffe7
Compare
Done!
Done! Also, there's more work to do splitting out code from
It seems that Now, I've just got to get through a rebase and hope CI stays green, and this should be ready to go. EDIT: rebase complete EDIT 2: tests pass locally on rebased branch |
…lity - the contents of `coreimg.jl`, `inference.jl` and `codevalidation.jl` now live in `base/compiler/` - `Core.Inference` --> `Core.Compiler`, and `Core.InferenceParams` --> `Core.Compiler.Params`, since these refer to more than just type inference at this point - Constants/structs now mostly appear in the file in which they are first used. Non-business logic methods acting on freshly-defined structs are now defined alongside the structs themselves. Non-business logic methods which don't depend on new structs are now in `utilities.jl`. - All non-alias `const` names are now all-caps. Type alias `const`s are camelcase, and function alias `const`s are lowercase. - Inference logic is split into several files (`abstractinterpretation.jl`, `typelattice.jl`, `typeinf.jl`, etc.) - All the tfunc definitions now reside in their own file. - Optimization logic (inlining, DCE, etc.) hasn't been broken up at all yet; it is now in `optimize.jl`. A future PR will be required to break it up. - No semantic changes, at least not on purpose.
396ffe7
to
7113490
Compare
Okay, 64-bit Linux failed on Travis and both 32-bit and 64-bit Windows failed on AppVeyor. None of these look PR-related - Travis failed on Could an AppVeyor wizard restart the AppVeyor builds? Thanks! |
Looks like a kind soul retriggered my AppVeyor build - 64-bit Windows passed and 32-bit simply timed out. I was also informed that I have the power to retrigger AppVeyor myself, so I've just done so. Fingers crossed for all green this time... |
Very nice. I'll merge this now, and Jameson, Keno, and I can rebase around it. |
I would be flabbergasted if this PR passes CI as it is now.Tests now pass locally.This PR does a bulk-refactor of
inference.jl
in order to make the code more readable/maintainable/hackable. One of my long-term motivations here is the development a well-versioned/defined "compiler standard library" - untangling what already exists is the first step.Here's the summary of the changes:
coreimg.jl
,inference.jl
andcodevalidation.jl
now live inbase/compiler/
Core.Inference
-->Core.Compiler
, andCore.InferenceParams
-->Core.Compiler.Params
, since these refer to more than just type inference at this pointutilities.jl
.const
names are now all-caps. Type aliasconst
s are camelcase, and function aliasconst
s are lowercase.abstractinterpretation.jl
,typelattice.jl
,typeinf.jl
, etc.)optimize.jl
. A future PR will be required to break it up.I apologize for not breaking things up into smaller commits...it would've taken forever to do this "properly". May God have mercy on the reviewers' souls.
I also really hope that I made this at the right time...rebasing this against any other non-trivial inference PR would probably break my mind.