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 #6797

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

Conversation

smillst
Copy link
Member

@smillst smillst commented Sep 12, 2024

This implementation isn't working as expected. In particular, there are unexpected errors in checker/tests/nullness/Issue406.java.
Fixes #406.

@mernst
Copy link
Member

mernst commented Sep 13, 2024

@smillst Could you please add the missing documentation? Also, a test is failing.

@@ -71,6 +73,71 @@ public abstract class CFAbstractStore<V extends CFAbstractValue<V>, S extends CF
/** Information collected about local variables (including method parameters). */
protected final Map<LocalVariable, V> localVariableValues;

/** Stores after boolean variable assignment. */
Copy link
Member

Choose a reason for hiding this comment

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

I wound find this comment more useful if it said more about the semantics, rather than when the field is first set. The map is from boolean local variables, and the mapped-to store indicates facts that are true depending on whether the boolean local variable is true or false.

protected final Map<LocalVariable, BooleanVarStore<V, S>> booleanVarStores;

/**
* An object that contains the then and else store after a boolean variable assignment.
Copy link
Member

Choose a reason for hiding this comment

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

Here too, I think that "after a boolean variable assignment" is not the most important thing to document.
It would be helpful, here, to discuss the goal and the design.

BooleanVarStore(S thenStore, S elseStore) {
this.thenStore = thenStore.copy();
this.elseStore = elseStore.copy();
thenStore.booleanVarStores.clear();
Copy link
Member

Choose a reason for hiding this comment

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

It would be helpful to document the reason that these substores are cleared.

@@ -1186,6 +1286,24 @@ private S upperBound(S other, boolean shouldWiden) {
}
}

for (Map.Entry<LocalVariable, BooleanVarStore<V, S>> e : other.booleanVarStores.entrySet()) {
// If a local variable appears in just one store, then the other store implicitly contains
Copy link
Member

Choose a reason for hiding this comment

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

Here and above, can you remark on whether this is done for correctness, or performance, or as a heuristic?

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.

This pull request looks good overall -- thanks!
However, it needs more documentation, both of its goal and its implementation.

@msridhar
Copy link
Contributor

Linking this comment on the previous PR so it doesn't get lost (regarding overhead):

#6661 (comment)

@mernst mernst removed their assignment Sep 13, 2024
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
3 participants