Skip to content

Commit 8b26ff3

Browse files
committed
Merge branch 'proto'
2 parents 7cc06ab + b736f88 commit 8b26ff3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+3457
-80
lines changed

README.md

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,56 @@
22

33
pal -- pointer analysis library for Go
44

5-
## main stub
5+
See [this blog post](https://go-air.github.io/blog/20210729-pal.html)
6+
for an overview.
67

7-
This is a stub/skeleton branch since only toy examples work as of yet.
8+
## status: volatile prototype
9+
10+
pal is in a volatile prototyping stage. We have re-organised
11+
things a few times already, and there are many sizeable holes
12+
still to be coded.
13+
14+
## roadmap
15+
16+
- cli
17+
- [x] analyzer framework stub
18+
- [ ] service
19+
- [ ] memory model
20+
- [x] constraints (load, store, transfer)
21+
- [x] plain serialize
22+
- [ ] indexing
23+
- [ ] integrate types
24+
- [ ] dev.typeparams version
25+
- [ ] types -- represent locatable objects
26+
- [ ] to go types
27+
- [ ] from go types
28+
- [ ] serialize
29+
- [ ] objects -- manage lifecycle of memory model w.r.t. Go things
30+
- [ ] creation
31+
-
32+
- [ ] ssa2pal
33+
- [x] loads
34+
- [x] stores
35+
- [x] map values to memory locations
36+
- [ ] map values to objects
37+
- [ ] indexing arithmetic operations
38+
- [x] structs
39+
- [x] arrays
40+
- [ ] slices
41+
- [x] returns
42+
- [x] phi nodes
43+
- [x] function objects
44+
- [ ] function variadics
45+
- [ ] builtins
46+
- [ ] docs
47+
- [x] statement of purpose
48+
- [ ] design
49+
- [ ] cli
50+
- [ ] service
51+
- [ ] tutorial
52+
- [ ] reference
853

9-
See the branch "proto" if you're interested in a volatile prototyping repo.
1054

11-
See [this blog post](https://go-air.github.io/blog/20210729-pal.html)
12-
for an overview.
1355

1456

1557

docs/design/archi.md

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
# pal architecture
22

3-
The pal architecture is centered around the idea of _persistant modular analysis_.
3+
The pal architecture is centered around the idea of _persistant modular
4+
analysis_.
45

5-
This means that the analysis is bottom-up in the dependency graph, mirroring the Go build system and the go/tools analysis library. However, the
6-
analysis is _persistent_, meaning the results are stored and may be used later to different ends.
6+
This means that the analysis is bottom-up in the dependency graph, mirroring
7+
the Go build system and the go/tools analysis library. However, the analysis
8+
is _persistent_, meaning the results are stored and may be used later to
9+
different ends.
710

8-
In this bottom-up phase, pal constructs executable and queryable memory models for each exported symbol of each package.
11+
In this bottom-up phase, pal constructs executable and queryable memory models
12+
for each exported symbol of each package.
13+
14+
## Applications
15+
16+
### Command line
17+
18+
### Module proxy
919

1020

1121
## Related Work
@@ -31,8 +41,8 @@ between memory locations.
3141

3242
Gillian [5] is also language agnostic, however it is based on modelling full
3343
programs by symbolic execution in a given IR (GIL) whereas pal only
34-
symbolically executes the numeric _Values_ in pointer arithmetic, allowing the
35-
caller to model these values in many different ways.
44+
symbolically executes the numeric _index_ in pointer arithmetic, allowing the
45+
caller to model these index in many different ways.
3646

3747
Golang's pointer analysis [8] is Anderson style with less flexibility,
3848
dependency on an ssa package specific to Go.
@@ -44,4 +54,4 @@ correct pointer analysis in the presence of races or unsafe.Pointer usage.
4454

4555
Rather, pal should provide a small set of basic operations which, taken together,
4656
can be used to model a variety of program behaviors while focusing principally
47-
on usage for which Go guarantees memory safety.
57+
on usage for which Go guarantees memory safety.

docs/design/func.md

Lines changed: 61 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ specific to control flow and/or call flow context. However, pal leaves this
1010
opaque to the user, at least at the level of the memory model.
1111

1212
Sets of locs may or may not support non-constant values for their size. For non-constant
13-
values which occur in the program under analysis, a special Value type is provided and
13+
index which occur in the program under analysis, a special Value type is provided and
1414
detailed below.
1515

1616
Sets of locs must provide an efficient means to determine if two locs 'm', 'n' may overlap
@@ -29,7 +29,7 @@ and/or locations in the program of heap allocations such as `malloc`.
2929

3030
In Go's x/tools/go/pointer, a loc correponds to a node, so for example a
3131
map would would be represented by a node representing a (key, value) pair;
32-
all the values in the map are abstracted to a single pair.
32+
all the index in the map are abstracted to a single pair.
3333

3434
For flow sensitivity, an SSA form in combination with such a representation
3535
can be used. For more flow sensitivity an SSI form can be used. These
@@ -50,18 +50,18 @@ type Constraints interface {
5050
}
5151
```
5252

53-
## Values
53+
## index
5454

5555
Traditional pointer analyses such as Anderson, SteensGaard are independent of
5656
numerical analysis. Often such analysis are useful because they can bootstrap a
5757
numerical analysis and they are usually much faster (albeit less precise) than
5858
methods which combine numerical and points-to analysis.
5959

60-
pal provides opaque support for numerical constraints in a _Values_ type, defined
60+
pal provides opaque support for numerical constraints in a _index_ type, defined
6161
below.
6262

6363
```go
64-
type Values interface {
64+
type index interface {
6565
ToInt(v Value) (int, bool)
6666
FromInt(int) V
6767
Plus(a, b Value) Value
@@ -72,19 +72,19 @@ type Values interface {
7272

7373

7474
The idea is that the pointer operations only use addition and tests for
75-
Values in order to implement the Mems interface; however, Values in programs
75+
index in order to implement the Mems interface; however, index in programs
7676
may be arbitrary expressions in the target language, which, over the
7777
set of all possible executions of the program, may contain any sort of
7878
concrete value.
7979

80-
A client of pal must decide how to model these concrete values, however any such
81-
model will provide the Values interface above.
80+
A client of pal must decide how to model these concrete index, however any such
81+
model will provide the index interface above.
8282

8383
pal will provide some basic models
8484

85-
### Const Values
85+
### Const index
8686

87-
Constant values, corresponding to types\' offsets. In this model, every load or store
87+
Constant index, corresponding to types\' offsets. In this model, every load or store
8888
to a Mem with non-constant offset are collapsed onto a single Mem with zero offset.
8989
This is an abstraction which is simple, efficient, and imprecise for containers
9090
containing lots of pointers.
@@ -96,54 +96,68 @@ generated.
9696

9797
TODO(wsc0)
9898

99-
## Solving
100-
101-
Suppose we have a program or a fragment of a program for which we have created
102-
Mems, Constraints, and Values. We would like to compute the points to set of
103-
Mems
99+
## Modularity
104100

105-
In pal, all these scenarios share a common _Solver_ interface specified below.
101+
Pal follows Go's packages, which form an acyclic dependency graph. Pal
102+
results are stored on a per-package basis.
106103

107104

108-
```go
105+
### Coding
109106

110-
// Construct a solver from Mems (and so with the associated constraints)
111-
// and a modelling of the values. Results are precomputed.
112-
func SolverForAll(ms Mems, vs Values) Solver
113-
// Results are on demand.
114-
func LazySolver(ms Mems, vs Values) Solver
115-
// Results are pre-ordered according to 'perm'
116-
func OrderedSolver(ms Mems, []int perm, vs Values) Solver
107+
This consists of encoding the package into the pal memory model.
108+
Notably, for modularity, we need to keep track of exportable
109+
symbols, opaqueness, param and return index of functions.
117110

118-
// Results are selected from q and PointsTo means transitively to
119-
// things related to q (forward and backward )
120-
func SelectFwdSolver(ms Mems, q []Mem, vs Values) Solver {...}
121-
func SelectBwdSolver(ms Mems, q []Mem, vs Values) Solver {...}
122-
func SelectSolve(ms Mems, q []Mem, vs Values) Solver {...}
111+
### Solving
123112

124-
// project the transitive closue of the points to onto 'on'
125-
func ProjectedSolver(ms Mems, on []Mem, vs Values) Solver
113+
This consists of finding the points-to relation for the package
114+
in terms of how it was coded.
126115

127-
type Solver interface {
116+
### Export
128117

129-
// Overlaps determines complex aliasing.
130-
Overlaps(m Mem, mext Value, n Mem, next Value) AbsTruth
118+
This consists of projecting the memory model onto i/o relations
119+
between exported opaque memory locations (including parameters
120+
and returns of exported functions).
131121

132-
// m == n ?
133-
Equal(m, n Mem) AbsTruth
122+
### Import
134123

135124

136-
// PointsTo place the points to set of m into dst, starting
137-
// at offset from with a max of 'ext',
138-
//
139-
// return the resulting dst.
140-
PointsTo(dst []Mem, m Mem, ext Value) []Mem
125+
### Example
141126

142-
// ReplaceOpaque
143-
// for every Mem in the underlying Mems whose points-to set
144-
// includes the points to set of 't', remove the points-to
145-
// set of 't' and add the PointsTo set of every rep in 'reps'
146-
ReplaceOpaque(t Mem, reps ...Mem)
127+
Below is an example diamond
128+
shaped package dependency graph which we will use to describe how
129+
modular solving works.
147130

148-
}
149131
```
132+
S -> A
133+
S -> B
134+
A -> D
135+
B -> D
136+
```
137+
Below is a list of actions for solving the points-to
138+
incrementally
139+
140+
141+
1. D: Code
142+
1. D: Solve
143+
1. D: Export
144+
1. A: Import D
145+
1. A: Code
146+
1. A: Solve
147+
1. A: Export
148+
1. B: Import D
149+
1. B: Code
150+
1. B: Solve
151+
1. B: Export
152+
1. S: Import A
153+
1. S: Import B
154+
1. S: Code
155+
1. S: Solve
156+
157+
158+
159+
160+
## Solving
161+
162+
163+

docs/design/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ api to meet the most common needs well, and to meet most needs reasonably.
3535
### For different Go IRs
3636

3737
staticcheck [6] has an IR, golang.org/x/tools/go/ssa is a baseline, we are
38-
working on (air)[https://github.com/go-air/air]. We would like pal to be
38+
working on [air](https://github.com/go-air/air). We would like pal to be
3939
retargetable to these different IRs. Perhaps it can be used one day for the Go
4040
gc compiler IR, or other IRs.
4141

@@ -61,7 +61,7 @@ DOI: 10.1561/2500000014 (https://yanniss.github.io/points-to-tutorial15.pdf)
6161
Compositional Analysis by means of bi-abduction
6262
Journal of the ACM Volume 58 Issue 6
6363
December 2011
64-
Article No.: 26pp 1–66https://doi.org/10.1145/2049697.2049700
64+
Article No.: 26pp 1–66 https://doi.org/10.1145/2049697.2049700
6565

6666
[3] Andersen, Lars Ole (1994). Program Analysis and Specialization for the C
6767
Programming Language (PDF) (PhD thesis).

docs/index.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
<<<<<<< HEAD
12
# pal website
23

34
Hello
5+
=======
6+
# pal -- pointer analysis library
7+
8+
pal is a library for doing pointer analysis.
9+
10+
11+
12+
>>>>>>> proto

docs/tutorial/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ As our first IR is "golang.org/x/tools/go/ssa", we recommend taking a look at th
2929

3030
#### github.com/go-air/pal/results
3131

32-
#### github.com/go-air/pal/values
32+
#### github.com/go-air/pal/index
3333

3434
### Memory
3535

3636
### Results
3737

38-
### Working with Values
38+
### Working with index
3939

0 commit comments

Comments
 (0)