Import Upstream version 20180207
[hcoop/debian/mlton.git] / doc / guide / localhost / DeepFlatten
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <meta name="generator" content="AsciiDoc 8.6.9">
6 <title>DeepFlatten</title>
7 <link rel="stylesheet" href="./asciidoc.css" type="text/css">
8 <link rel="stylesheet" href="./pygments.css" type="text/css">
9
10
11 <script type="text/javascript" src="./asciidoc.js"></script>
12 <script type="text/javascript">
13 /*<![CDATA[*/
14 asciidoc.install();
15 /*]]>*/
16 </script>
17 <link rel="stylesheet" href="./mlton.css" type="text/css">
18 </head>
19 <body class="article">
20 <div id="banner">
21 <div id="banner-home">
22 <a href="./Home">MLton 20180207</a>
23 </div>
24 </div>
25 <div id="header">
26 <h1>DeepFlatten</h1>
27 </div>
28 <div id="content">
29 <div id="preamble">
30 <div class="sectionbody">
31 <div class="paragraph"><p><a href="DeepFlatten">DeepFlatten</a> is an optimization pass for the <a href="SSA2">SSA2</a>
32 <a href="IntermediateLanguage">IntermediateLanguage</a>, invoked from <a href="SSA2Simplify">SSA2Simplify</a>.</p></div>
33 </div>
34 </div>
35 <div class="sect1">
36 <h2 id="_description">Description</h2>
37 <div class="sectionbody">
38 <div class="paragraph"><p>This pass flattens into mutable fields of objects and into vectors.</p></div>
39 <div class="paragraph"><p>For example, an <span class="monospaced">(int * int) ref</span> is represented by a 2 word
40 object, and an <span class="monospaced">(int * int) array</span> contains pairs of <span class="monospaced">int</span>-s,
41 rather than pointers to pairs of <span class="monospaced">int</span>-s.</p></div>
42 </div>
43 </div>
44 <div class="sect1">
45 <h2 id="_implementation">Implementation</h2>
46 <div class="sectionbody">
47 <div class="ulist"><ul>
48 <li>
49 <p>
50 <a href="https://github.com/MLton/mlton/blob/master/mlton/ssa/deep-flatten.fun"><span class="monospaced">deep-flatten.fun</span></a>
51 </p>
52 </li>
53 </ul></div>
54 </div>
55 </div>
56 <div class="sect1">
57 <h2 id="_details_and_notes">Details and Notes</h2>
58 <div class="sectionbody">
59 <div class="paragraph"><p>There are some performance issues with the deep flatten pass, where it
60 consumes an excessive amount of memory.</p></div>
61 <div class="ulist"><ul>
62 <li>
63 <p>
64 <a href="http://www.mlton.org/pipermail/mlton/2005-April/026990.html">http://www.mlton.org/pipermail/mlton/2005-April/026990.html</a>
65 </p>
66 </li>
67 <li>
68 <p>
69 <a href="http://www.mlton.org/pipermail/mlton-user/2010-June/001626.html">http://www.mlton.org/pipermail/mlton-user/2010-June/001626.html</a>
70 </p>
71 </li>
72 <li>
73 <p>
74 <a href="http://www.mlton.org/pipermail/mlton/2010-December/030876.html">http://www.mlton.org/pipermail/mlton/2010-December/030876.html</a>
75 </p>
76 </li>
77 </ul></div>
78 <div class="paragraph"><p>A number of applications require compilation with
79 <span class="monospaced">-disable-pass deepFlatten</span> to avoid exceeding available memory. It is
80 often asked whether the deep flatten pass usually has a significant
81 impact on performance. The standard benchmark suite was run with and
82 without the deep flatten pass enabled when the pass was first
83 introduced:</p></div>
84 <div class="ulist"><ul>
85 <li>
86 <p>
87 <a href="http://www.mlton.org/pipermail/mlton/2004-August/025760.html">http://www.mlton.org/pipermail/mlton/2004-August/025760.html</a>
88 </p>
89 </li>
90 </ul></div>
91 <div class="paragraph"><p>The conclusion is that it does not have a significant impact.
92 However, these are micro benchmarks; other applications may derive
93 greater benefit from the pass.</p></div>
94 </div>
95 </div>
96 </div>
97 <div id="footnotes"><hr></div>
98 <div id="footer">
99 <div id="footer-text">
100 </div>
101 <div id="footer-badges">
102 </div>
103 </div>
104 </body>
105 </html>