| 1 |
= DeepFlatten |
| 2 |
|
| 3 |
<<DeepFlatten#>> is an optimization pass for the <<SSA2#>> |
| 4 |
<<IntermediateLanguage#>>, invoked from <<SSA2Simplify#>>. |
| 5 |
|
| 6 |
== Description |
| 7 |
|
| 8 |
This pass flattens into mutable fields of objects and into vectors. |
| 9 |
|
| 10 |
For example, an `(int * int) ref` is represented by a 2 word |
| 11 |
object, and an `(int * int) array` contains pairs of `int`-s, |
| 12 |
rather than pointers to pairs of `int`-s. |
| 13 |
|
| 14 |
== Implementation |
| 15 |
|
| 16 |
* https://github.com/MLton/mlton/blob/master/mlton/ssa/deep-flatten.fun[`deep-flatten.fun`] |
| 17 |
|
| 18 |
== Details and Notes |
| 19 |
|
| 20 |
There are some performance issues with the deep flatten pass, where it |
| 21 |
consumes an excessive amount of memory. |
| 22 |
|
| 23 |
* http://www.mlton.org/pipermail/mlton/2005-April/026990.html |
| 24 |
* http://www.mlton.org/pipermail/mlton-user/2010-June/001626.html |
| 25 |
* http://www.mlton.org/pipermail/mlton/2010-December/030876.html |
| 26 |
|
| 27 |
A number of applications require compilation with |
| 28 |
`-disable-pass deepFlatten` to avoid exceeding available memory. It is |
| 29 |
often asked whether the deep flatten pass usually has a significant |
| 30 |
impact on performance. The standard benchmark suite was run with and |
| 31 |
without the deep flatten pass enabled when the pass was first |
| 32 |
introduced: |
| 33 |
|
| 34 |
* http://www.mlton.org/pipermail/mlton/2004-August/025760.html |
| 35 |
|
| 36 |
The conclusion is that it does not have a significant impact. |
| 37 |
However, these are micro benchmarks; other applications may derive |
| 38 |
greater benefit from the pass. |