| 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>Zone</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 |
| 14 | asciidoc.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>Zone</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="Zone">Zone</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 breaks large <a href="SSA2">SSA2</a> functions into zones, which are\r |
| 39 | connected subgraphs of the dominator tree. For each zone, at the node\r |
| 40 | that dominates the zone (the "zone root"), it places a tuple\r |
| 41 | collecting all of the live variables at that node. It replaces any\r |
| 42 | variables used in that zone with offsets from the tuple. The goal is\r |
| 43 | to decrease the liveness information in large <a href="SSA">SSA</a> functions.</p></div>\r |
| 44 | </div>\r |
| 45 | </div>\r |
| 46 | <div class="sect1">\r |
| 47 | <h2 id="_implementation">Implementation</h2>\r |
| 48 | <div class="sectionbody">\r |
| 49 | <div class="ulist"><ul>\r |
| 50 | <li>\r |
| 51 | <p>\r |
| 52 | <a href="https://github.com/MLton/mlton/blob/master/mlton/ssa/zone.fun"><span class="monospaced">zone.fun</span></a>\r |
| 53 | </p>\r |
| 54 | </li>\r |
| 55 | </ul></div>\r |
| 56 | </div>\r |
| 57 | </div>\r |
| 58 | <div class="sect1">\r |
| 59 | <h2 id="_details_and_notes">Details and Notes</h2>\r |
| 60 | <div class="sectionbody">\r |
| 61 | <div class="paragraph"><p>Compute strongly-connected components to avoid put tuple constructions\r |
| 62 | in loops.</p></div>\r |
| 63 | <div class="paragraph"><p>There are two (expert) flags that govern the use of this pass</p></div>\r |
| 64 | <div class="ulist"><ul>\r |
| 65 | <li>\r |
| 66 | <p>\r |
| 67 | <span class="monospaced">-max-function-size <n></span>\r |
| 68 | </p>\r |
| 69 | </li>\r |
| 70 | <li>\r |
| 71 | <p>\r |
| 72 | <span class="monospaced">-zone-cut-depth <n></span>\r |
| 73 | </p>\r |
| 74 | </li>\r |
| 75 | </ul></div>\r |
| 76 | <div class="paragraph"><p>Zone splitting only works when the number of basic blocks in a\r |
| 77 | function is greater than <span class="monospaced">n</span>. The <span class="monospaced">n</span> used to cut the dominator tree\r |
| 78 | is set by <span class="monospaced">-zone-cut-depth</span>.</p></div>\r |
| 79 | <div class="paragraph"><p>There is currently no attempt to be safe-for-space. That is, the\r |
| 80 | tuples are not restricted to containing only "small" values.</p></div>\r |
| 81 | <div class="paragraph"><p>In the <span class="monospaced">HOL</span> program, the particular problem is the main function,\r |
| 82 | which has 161,783 blocks and 257,519 variables — the product of those\r |
| 83 | two numbers being about 41 billion. Now, we’re not likely going to\r |
| 84 | need that much space since we use a sparse representation. But even\r |
| 85 | 1/100th would really hurt. And of course this rules out bit vectors.</p></div>\r |
| 86 | </div>\r |
| 87 | </div>\r |
| 88 | </div>\r |
| 89 | <div id="footnotes"><hr></div>\r |
| 90 | <div id="footer">\r |
| 91 | <div id="footer-text">\r |
| 92 | </div>\r |
| 93 | <div id="footer-badges">\r |
| 94 | </div>\r |
| 95 | </div>\r |
| 96 | </body>\r |
| 97 | </html>\r |