summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chapter10a/README.md28
-rw-r--r--chapter10b/README.md11
2 files changed, 26 insertions, 13 deletions
diff --git a/chapter10a/README.md b/chapter10a/README.md
index 2f25f681..70a09f8d 100644
--- a/chapter10a/README.md
+++ b/chapter10a/README.md
@@ -52,6 +52,13 @@ same `ScopeNode` lookup and update operations as a local variable.
For an `if`, the two branches can finish with different memory values. An
ordinary Phi selects the memory from the branch that executed:
+```java
+struct Point { int x; int y; }
+Point p = new Point;
+if( arg ) p.x = 3; else p.x = 4;
+return p.x;
+```
+
![Whole memory across a branch](docs/example2a.svg)
Loops reuse Chapter 8's lazy Phi construction. Reading or updating `$mem` in a
@@ -59,6 +66,16 @@ loop creates an initially incomplete memory Phi. Closing the loop supplies its
backedge. `break`, `continue`, nested loops, and early returns use the same scope
mechanics as scalar variables.
+```java
+struct Point { int x; int y; }
+Point p = new Point;
+while( arg ) {
+ p.x = arg;
+ arg = arg-1;
+};
+return p.x;
+```
+
![Whole memory around a loop](docs/example2b.svg)
Every Return consumes the current whole-memory value. This keeps stores alive
@@ -97,10 +114,11 @@ The implementation's `$TOP` and `$BOT` names need not appear in the diagram:
| `⊤:struct` | struct top | `TypeStruct.TOP` | `$TOP` |
| `⊥:struct` | struct bottom | `TypeStruct.BOT` | `$BOT` |
-Edges in this diagram show lattice order, with top above bottom. They are not
-the use-to-definition edges of the program graphs elsewhere in the chapter.
-Boxes containing an ellipsis abbreviate further parallel alternatives; they
-are not extra union types. Field and tuple-element type lattices are elided.
+Edges in this diagram show lattice order, with top above bottom. Boxes
+containing an ellipsis abbreviate further parallel alternatives; they are not
+extra union types. Field and tuple-element type lattices are elided in the
+diagram. Field types can be any scalar type (Integer or Pointer), Tuple types
+can be *any* lattice type, including Control and Memory.
Within the type lattice, we now have the following domains:
@@ -169,7 +187,7 @@ We use the following operations on the lattice:
* The join of `1` and `2` is integer top.
As we construct the Sea of Nodes graph, we ensure that values stay inside the
-domain they are created in - that is ptr fields will never contain ints
+domain they are created in - that is pointer fields will never contain integers
(obviously)... nor even the generic `TOP` and `BOT`. There are a couple of
nuances worth highlighting.
diff --git a/chapter10b/README.md b/chapter10b/README.md
index 795d2233..599705f2 100644
--- a/chapter10b/README.md
+++ b/chapter10b/README.md
@@ -27,17 +27,12 @@ load-after-store forwarding turn the return value into 42.
![Independent field dependencies](docs/example1.svg)
-These are schematic dependency graphs, with arrows from uses to their definitions.
-In horizontal diagrams, definitions appear on the left and uses on the right;
-in vertical diagrams, definitions appear above uses.
-Control, pointer, and value edges are omitted when they do not explain memory.
-
## Equivalence-class aliasing
-Each struct field has an integer alias identity. Two different fields receive
+Each struct field has an integer alias identity. Two different fields receive
different identities, even if they have the same spelling in different structs.
-Two instances of the same struct share their field aliases. Thus different
-classes never alias; accesses in the same class **may alias**. Same-class does
+Two instances of the same struct share their field aliases. Thus different
+classes never alias; accesses in the same class **may alias**. Same-class does
not mean same-address: forwarding still checks pointer identity.
The parser assigns field identities at struct declarations, beginning at 2.