diff options
Diffstat (limited to 'chapter10/README.md')
| -rw-r--r-- | chapter10/README.md | 45 |
1 files changed, 39 insertions, 6 deletions
diff --git a/chapter10/README.md b/chapter10/README.md index c4045513..a25ff011 100644 --- a/chapter10/README.md +++ b/chapter10/README.md @@ -254,12 +254,7 @@ To enable this behaviour, we make following enhancements. ptr. When the input is a `null` we convert to `1` and when is a not `null` ptr value, we convert to `0`. See `NotNode.compute()`. - -## Examples - -We now look at some examples. - -### Example 1 +## Memory Operations Example This is a simple example illustrating how loads and stores are ordered based on aliasing. @@ -279,6 +274,44 @@ The graph from above will have the shape:  +## Additional Peephole Optimizations + +The equivalence aliasing makes it possible to optimize following scenarios: + +* Store followed by another Store to the same field inside an object; the first Store is redundant if there are no other references to the first Store +* Load followed by a Store to a field inside an Object; the Load can be eliminated and the input value of the Store passed through. + +Both of these examples are illustrated in the example below: + +```java +struct Bar { + int a; + int b; +} +struct Foo { + int x; +} +Foo? foo = null; +Bar bar = new Bar; +bar.a = 1; +bar.a = 2; +return bar.a; +``` + +Before the peephole optimizations, we get: + + + +After enabling Store-Store peephole we get: + + + +After load-after-store elision: + + + +Note that at this stage the `bar` object is dead therefore the allocation of bar can be dropped. + [^1]: Diwan A., McKinley K.S., Moss J.E.B. (1998). Type Based Alias Analysis.
\ No newline at end of file |
