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