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

Boolean variables in dataflow #6661

Closed
wants to merge 26 commits into from
Closed

Conversation

smillst
Copy link
Member

@smillst smillst commented Jun 6, 2024

This is a rough draft of the fix for #406. @jyoo980 can you see if this fixes the error in the case study?
Fixes #406.

mernst
mernst previously approved these changes Jun 6, 2024
Copy link
Member

@mernst mernst left a comment

Choose a reason for hiding this comment

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

LGTM

@mernst mernst removed their assignment Jun 6, 2024
@jyoo980
Copy link
Contributor

jyoo980 commented Jun 6, 2024 via email

@jyoo980
Copy link
Contributor

jyoo980 commented Jun 6, 2024

@smillst @mernst It looks like this eliminates the need for inlining boolean expressions in the case study

@smillst smillst assigned smillst and unassigned jyoo980 Jun 7, 2024
@smillst smillst marked this pull request as ready for review June 7, 2024 19:40
@smillst smillst removed their assignment Aug 8, 2024
azure-pipelines.yml Outdated Show resolved Hide resolved
@@ -1253,6 +1347,32 @@ private V upperBoundOfValues(V otherVal, V thisVal, boolean shouldWiden) {
return shouldWiden ? thisVal.widenUpperBound(otherVal) : thisVal.leastUpperBound(otherVal);
}

/**
* Creates a new store that has all the values from both {@code this} and {@code other}. If a node
* has a value in both stores, then the most specific one is used.
Copy link
Member

Choose a reason for hiding this comment

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

Why is the most specific one used rather than the glb?
It might be helpful to add a comment to the declaration of mostSpecific indicating when it should be called and when glb should be called.

@@ -68,6 +68,12 @@ public abstract class CFAbstractValue<V extends CFAbstractValue<V>> implements A
/** The annotations in this abstract value. */
protected final AnnotationMirrorSet annotations;

/** The then store. */
Copy link
Member

Choose a reason for hiding this comment

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

Please say more here. The pull request doesn't seem to have any comments about the feature being implemented or the purpose of the code, and I think that will make it unnecessarily hard for readers of the code to understand the feature and its implementation.

return analysis.createAbstractValue(mostSpecific, mostSpecifTypeMirror);
V mostSpecificVal = analysis.createAbstractValue(mostSpecific, mostSpecifTypeMirror);
if (this.getThenStore() != null) {
mostSpecificVal.setStores(thenStore, elseStore);
Copy link
Member

Choose a reason for hiding this comment

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

Why is it OK to ignore other's stores if this has a store? Might it have information that should be retained?

@@ -529,7 +574,23 @@ protected V upperBound(@Nullable V other, TypeMirror upperBoundTypeMirror, boole
other.getUnderlyingType(),
other.getAnnotations(),
canBeMissingAnnotations(upperBoundTypeMirror));
return analysis.createAbstractValue(lub, upperBoundTypeMirror);
V upperBound = analysis.createAbstractValue(lub, upperBoundTypeMirror);
if (this.getThenStore() != null && other.getThenStore() != null) {
Copy link
Member

Choose a reason for hiding this comment

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

What if one of this and other has a thenStore, but the other does not? What should be done in that case? The behavior is different than in mostSpecific() above, which always uses exactly one if either one is set.

@mernst mernst assigned smillst and unassigned mernst Aug 19, 2024
@msridhar
Copy link
Contributor

This is a really cool PR! Is there any idea what the performance impact will be? In NullAway, local type inference is one of the most expensive parts of checking, and I imagine the same could be true with the Checker Framework. Might be worth doing some sanity checks on large programs to make sure this doesn't lead to a significant regression.

@smillst
Copy link
Member Author

smillst commented Sep 12, 2024

There are bugs in this implementation that once fixed cause infinite recursion, so I'm closing this pull request in favor of #6797

@smillst smillst closed this Sep 12, 2024
@smillst smillst deleted the issue406 branch September 12, 2024 16:45
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.

Boolean variables aliased to data-flow facts in type refinement
4 participants