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">
11 <script type="text/javascript" src="./asciidoc.js"></script>
12 <script type="text/javascript">
17 <link rel="stylesheet" href="./mlton.css" type="text/css">
19 <body class="article">
21 <div id="banner-home">
22 <a href="./Home">MLton 20180207</a>
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>
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>
45 <h2 id="_implementation">Implementation</h2>
46 <div class="sectionbody">
47 <div class="ulist"><ul>
50 <a href="https://github.com/MLton/mlton/blob/master/mlton/ssa/deep-flatten.fun"><span class="monospaced">deep-flatten.fun</span></a>
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>
64 <a href="http://www.mlton.org/pipermail/mlton/2005-April/026990.html">http://www.mlton.org/pipermail/mlton/2005-April/026990.html</a>
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>
74 <a href="http://www.mlton.org/pipermail/mlton/2010-December/030876.html">http://www.mlton.org/pipermail/mlton/2010-December/030876.html</a>
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
84 <div class="ulist"><ul>
87 <a href="http://www.mlton.org/pipermail/mlton/2004-August/025760.html">http://www.mlton.org/pipermail/mlton/2004-August/025760.html</a>
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>
97 <div id="footnotes"><hr></div>
99 <div id="footer-text">
101 <div id="footer-badges">