Import Upstream version 20180207
[hcoop/debian/mlton.git] / doc / guide / localhost / Restore
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>Restore</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>Restore</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="Restore">Restore</a> is a rewrite pass for the <a href="SSA">SSA</a> and <a href="SSA2">SSA2</a>\r
32<a href="IntermediateLanguage">IntermediateLanguage</a>s, invoked from <a href="KnownCase">KnownCase</a> and\r
33<a href="LocalRef">LocalRef</a>.</p></div>\r
34</div>\r
35</div>\r
36<div class="sect1">\r
37<h2 id="_description">Description</h2>\r
38<div class="sectionbody">\r
39<div class="paragraph"><p>This pass restores the SSA condition for a violating <a href="SSA">SSA</a> or\r
40<a href="SSA2">SSA2</a> program; the program must satisfy:</p></div>\r
41<div class="quoteblock">\r
42<div class="content">\r
43<div class="paragraph"><p>Every path from the root to a use of a variable (excluding globals)\r
44passes through a def of that variable.</p></div>\r
45</div>\r
46<div class="attribution">\r
47</div></div>\r
48</div>\r
49</div>\r
50<div class="sect1">\r
51<h2 id="_implementation">Implementation</h2>\r
52<div class="sectionbody">\r
53<div class="ulist"><ul>\r
54<li>\r
55<p>\r
56<a href="https://github.com/MLton/mlton/blob/master/mlton/ssa/restore.sig"><span class="monospaced">restore.sig</span></a>\r
57</p>\r
58</li>\r
59<li>\r
60<p>\r
61<a href="https://github.com/MLton/mlton/blob/master/mlton/ssa/restore.fun"><span class="monospaced">restore.fun</span></a>\r
62</p>\r
63</li>\r
64<li>\r
65<p>\r
66<a href="https://github.com/MLton/mlton/blob/master/mlton/ssa/restore2.sig"><span class="monospaced">restore2.sig</span></a>\r
67</p>\r
68</li>\r
69<li>\r
70<p>\r
71<a href="https://github.com/MLton/mlton/blob/master/mlton/ssa/restore2.fun"><span class="monospaced">restore2.fun</span></a>\r
72</p>\r
73</li>\r
74</ul></div>\r
75</div>\r
76</div>\r
77<div class="sect1">\r
78<h2 id="_details_and_notes">Details and Notes</h2>\r
79<div class="sectionbody">\r
80<div class="paragraph"><p>Based primarily on Section 19.1 of <a href="References#Appel98"> Modern Compiler\r
81Implementation in ML</a>.</p></div>\r
82<div class="paragraph"><p>The main deviation is the calculation of liveness of the violating\r
83variables, which is used to predicate the insertion of phi arguments.\r
84This is due to the algorithm&#8217;s bias towards imperative languages, for\r
85which it makes the assumption that all variables are defined in the\r
86start block and all variables are "used" at exit.</p></div>\r
87<div class="paragraph"><p>This is "optimized" for restoration of functions with small numbers of\r
88violating variables&#8201;&#8212;&#8201;use bool vectors to represent sets of violating\r
89variables.</p></div>\r
90<div class="paragraph"><p>Also, we use a <span class="monospaced">Promise.t</span> to suspend part of the dominance frontier\r
91computation.</p></div>\r
92</div>\r
93</div>\r
94</div>\r
95<div id="footnotes"><hr></div>\r
96<div id="footer">\r
97<div id="footer-text">\r
98</div>\r
99<div id="footer-badges">\r
100</div>\r
101</div>\r
102</body>\r
103</html>\r