Skip to content

[ConstraintSystem] Add BindingProducer base type #19132

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

Merged
merged 5 commits into from
Sep 6, 2018

Conversation

xedin
Copy link
Contributor

@xedin xedin commented Sep 5, 2018

Introduce a base BindingProducer type which can produce bindings
for both type variables and disjunctions.

It required some cleanup in the solver:

  • Introduce more common functionality into TypeBinding such as getIndex, isDisabled etc.
  • Extract logic for attempting individual choices into solveForDisjunctionChoice
  • Remove all of the unnecessary information from DisjunctionChoice
  • Convert auxiliary logic to operate on TypeBinding instead of DisjunctionChoice

Add all of the important information to the `TypeBinding` which covers
both type variable and disjunction choices.
…nding`

* Extract logic for attempting individual choices into `solveForDisjunctionChoice`
* Remove all of the unnecessary information from `DisjunctionChoice`
* Convert auxiliary logic to operate on `TypeBinding` instead of `DisjunctionChoice`
@xedin xedin requested a review from rudkx September 5, 2018 05:31

return TypeVariableBinding(TypeVar, Bindings[Index++]);
unsigned currIndex = Index++;
return llvm::make_unique<TypeVariableBinding>(currIndex, TypeVar,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rudkx For some reason solver would just crash when I tried to do new (CS.getAllocator()), I also tried to call

void *mem = CS.getAllocator().Allocate(sizeof(TypeVariableBinding), alignof(TypeVariableBinding)); 
auto *binding = new (mem) ...

which didn't help either... It seems to work fine with new though... Any ideas?

Copy link
Contributor

Choose a reason for hiding this comment

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

Does it crash when allocating, or later?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Later, when it’s trying to access fields I think

Introduce a base `BindingProducer` type which can produce bindings
for both type variables and disjunctions.
@xedin xedin force-pushed the add-binding-producer branch from c2d1012 to 2acfff0 Compare September 5, 2018 07:13
@xedin
Copy link
Contributor Author

xedin commented Sep 5, 2018

@rudkx I have changed the interface of the BindingProducer to accept template parameter, I think I should be able to make that work with my "step" abstraction, if not I'll change it back to allocate unique pointers later, WDYT?

/// Position of this binding in the chain.
unsigned getIndex() const { return Index; }

virtual bool isDisabled() const { return false; }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually let me try to convert this into flags of the binding, so I don't have to create so many virtual methods...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, all done!

@xedin
Copy link
Contributor Author

xedin commented Sep 5, 2018

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented Sep 5, 2018

Build failed
Swift Test OS X Platform
Git Sha - 2acfff0

@swift-ci
Copy link
Contributor

swift-ci commented Sep 5, 2018

Build failed
Swift Test Linux Platform
Git Sha - 2acfff0

@xedin
Copy link
Contributor Author

xedin commented Sep 6, 2018

If nobody objects I'm going to merge tonight, since this is mostly NFC.

Copy link
Contributor

@rudkx rudkx left a comment

Choose a reason for hiding this comment

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

I only had a chance to do a quick look, but seems okay.

@xedin
Copy link
Contributor Author

xedin commented Sep 6, 2018

@swift-ci please ASAN test

@xedin xedin merged commit 3e7e9f3 into swiftlang:master Sep 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants