-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Unify ConstraintGraph change tracking with SavedTypeVariableBindings #76759
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
Conversation
This messes up the bookkeeping for the trail.
e9dd48b
to
cbaccc8
Compare
@swift-ci Please smoke test |
@swift-ci Please test source compatibility |
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.
Looks great, thank you!
} Update; | ||
}; | ||
|
||
Change() : Kind(ChangeKind::AddedTypeVariable), TypeVar(nullptr) { } |
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.
Do we still need this?
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.
It's needed because eg this calls the default constructor and it won't synthesize one for us because of the unions:
SolverTrail::Change
SolverTrail::Change::addedConstraint(Constraint *constraint) {
Change result;
result.Kind = ChangeKind::AddedConstraint;
result.TheConstraint = constraint;
return result;
}
If there's another way to initialize this without the default constructor I can refactor it later, because I'll be adding lots more Change kinds soon. :)
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.
We have a similar pattern in SyntacticElementTarget
, we just need a fee constructors. No need to change anything in this PR if you are going to follow up anyway!
Previously, retractFromInference() was the last step in unbindTypeVariable(). This doesn't really make sense, because bindTypeVariable() doesn't call introduceToInference(); its two callers do it later. Start untangling this by splitting off introduceToInference() into its own Change, but for now, record this change at the incorrect place to maintain the same behavior as before.
cbaccc8
to
4548880
Compare
@swift-ci Please smoke test |
@swift-ci Please test source compatibility |
I'd like to get rid of all the state that's inside SolverScope today, and instead record a trail of changes to individual data structures. This is a preliminary PR which moves the ConstraintGraph change tracking into a new
CSTrail.cpp
, which defines aSolverTrail
. I also refactored the existing logic for saving and restoring the fixed types of type variables to useSolverTrail
.For now, there's a hack in there to preserve the previous behavior where type variable bindings are restored before all constraint graph changes. Once I untangle some other issues I will streamline this. Next steps after that are converting all other state tracking to use the new mechanism, which will hopefully reduce memory usage and improve performance.