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

Introduce backward analysis to dataflow framework. #3370

Merged
merged 22 commits into from
Jun 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
737e03e
Refactor dataflow framework. Introduce backward analysis.
xingweitian Jun 13, 2020
066c7d3
Resolve comments.
xingweitian Jun 17, 2020
720123f
Merge remote-tracking branch 'typetools/master' into typetools-backwa…
xingweitian Jun 17, 2020
0d8664d
Remove unused import.
xingweitian Jun 17, 2020
741e968
Add a TODO comment for widening support for backward analysis.
xingweitian Jun 17, 2020
9880400
Merge remote-tracking branch 'typetools/master' into typetools-backwa…
xingweitian Jun 21, 2020
247c6d8
Pull latest code from typetools.
xingweitian Jun 25, 2020
ef29c77
Tweaks.
xingweitian Jun 26, 2020
0c2faaf
Revert "Tweaks."
xingweitian Jun 26, 2020
d996fd0
Merge branch 'master' into typetools-backward-analysis
xingweitian Jun 26, 2020
7845428
Add getLastNode() back.
xingweitian Jun 27, 2020
f7298ee
Merge remote-tracking branch 'typetools/master' into typetools-backwa…
xingweitian Jun 27, 2020
c7290ab
Use preconditions instead of asserts.
wmdietl Jun 29, 2020
3c72292
Simplify changelog.
wmdietl Jun 29, 2020
e01fec3
Merge remote-tracking branch 'typetools/master' into typetools-backwa…
xingweitian Jun 29, 2020
01a49af
Resolve comments.
xingweitian Jun 29, 2020
d411396
Tweaks.
xingweitian Jun 29, 2020
3d10dff
Merge remote-tracking branch 'origin/master' into typetools-backward-…
smillst Jun 30, 2020
cbebd6c
Use block instead of bb as parameter name.
smillst Jun 30, 2020
77f50df
Merge pull request #13 from smillst/typetools-backward-analysis
xingweitian Jun 30, 2020
f549ff7
Resolve comment.
xingweitian Jun 30, 2020
5ab4d76
Merge remote-tracking branch 'origin/typetools-backward-analysis' int…
xingweitian Jun 30, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ The Nullness Checker now treats `System.getProperty()` soundly. Use
Add support for class qualifier parameters. See "Class qualifier parameters"
section in the manual.

The Dataflow Framework now also supports backward analysis.

Implementation details:

Changed the types of some fields and methods from array to List:
Expand All @@ -37,6 +39,13 @@ Changed the types of some fields and methods from array to List:
* QualifierDefaults.STANDARD_UNCHECKED_DEFAULTS_TOP
* QualifierDefaults.STANDARD_UNCHECKED_DEFAULTS_BOTTOM

Dataflow Framework: Analysis is now an interface, added AbstractAnalysis,
ForwardAnalysis, ForwardTransferFunction, ForwardAnalysisImpl,
BackwardAnalysis, BackwardTransferFunction, BackwardAnalysisImpl.
Existing code is easy to adapt:
`extends Analysis<V, S, T>` => `extends ForwardAnalysisImpl<V, S, T>`
`implements TransferFunction<V, S>` => `implements ForwardTransferFunction<V, S>`

In AbstractQualifierPolymorphism, use AnnotationMirrors instead of sets of
annotation mirrors.

Expand Down
42 changes: 29 additions & 13 deletions dataflow/manual/content.tex
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,13 @@ \subsubsubsection{TransferFunction}
package org.checkerframework.dataflow.analysis;
interface TransferFunction<V extends AbstractValue<V>,
S extends Store<S>>
extends NodeVisitor<TransferResult<A, S>, TransferInput<A, S>>
extends NodeVisitor<TransferResult<V, S>, TransferInput<V, S>>
interface ForwardTransferFunction<V extends AbstractValue<V>,
S extends Store<S>>
extends TransferFunction<V, S>
interface BackwardTransferFunction<V extends AbstractValue<V>,
S extends Store<S>>
extends TransferFunction<V, S>
\end{verbatim}

The Checker Framework defines a derived class of TransferFunction to
Expand All @@ -392,7 +398,7 @@ \subsubsubsection{TransferFunction}
S extends CFAbstractStore<V, S>,
T extends CFAbstractTransfer<V, S, T>>
extends AbstractNodeVisitor<TransferResult<V, S>, TransferInput<V, S>>
implements TransferFunction<V, S>
implements ForwardTransferFunction<V, S>

class CFTransfer extends CFAbstractTransfer<CFValue, CFStore, CFTransfer>
\end{verbatim}
Expand Down Expand Up @@ -421,14 +427,26 @@ \subsubsection{Analysis}
\label{sec:analysis_classes}

An Analysis performs iterative dataflow analysis over a control flow
graph using a given transfer function. Currently only forward
graph using a given transfer function. Both forward and backward
analyses are supported.

\begin{verbatim}
package org.checkerframework.dataflow.analysis;
class Analysis<V extends AbstractValue<V>,
interface Analysis<V extends AbstractValue<V>,
S extends Store<S>,
T extends TransferFunction<V, S>>
abstract class AbstractAnalysis<V extends AbstractValue<V>,
S extends Store<S>,
T extends TransferFunction<V, S>>
implements Analysis<V, S, T>
interface ForwardAnalysis<V extends AbstractValue<V>,
S extends Store<S>,
T extends TransferFunction<A, S>>
T extends ForwardTransferFunction<V, S>>
extends Analysis<V, S, T>
interface BackwardAnalysis<V extends AbstractValue<V>,
S extends Store<S>,
T extends BackwardTransferFunction<V, S>>
extends Analysis<V, S, T>
\end{verbatim}

The Checker Framework defines a derived class of Analysis for use as
Expand All @@ -441,7 +459,7 @@ \subsubsection{Analysis}
abstract class CFAbstractAnalysis<V extends CFAbstractValue<V>,
S extends CFAbstractStore<V, S>,
T extends CFAbstractTransfer<V, S, T>>
extends Analysis<V, S, T>
extends ForwardAnalysisImpl<V, S, T>

class CFAnalysis extends CFAbstractAnalysis<CFValue, CFStore, CFTransfer>
\end{verbatim}
Expand Down Expand Up @@ -1408,13 +1426,11 @@ \subsection{Overview}
Roughly, a dataflow analysis in the framework works as follows. Given
the abstract syntax tree of a method, the framework computes the
corresponding control-flow graph as described in
\autoref{sec:cfg}. Then, a simple forward iterative algorithm is used
to compute a fix-point, by iteratively applying a set of transfer
functions to the nodes in the CFG\@. (For our initial application,
type-checking, we do not need to support backwards analyses; in the
future, we may wish to do so.) These transfer functions are specific
to the particular analysis and are used to approximate the runtime
behavior of different statements and expressions.
\autoref{sec:cfg}. Then, a simple forward or backward iterative
algorithm is used to compute a fix-point, by iteratively applying a
set of transfer functions to the nodes in the CFG\@. These transfer
functions are specific to the particular analysis and are used to
approximate the runtime behavior of different statements and expressions.

An analysis result contains two parts:

Expand Down
Loading