<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[206110] trunk/Source/JavaScriptCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/206110">206110</a></dd>
<dt>Author</dt> <dd>keith_miller@apple.com</dd>
<dt>Date</dt> <dd>2016-09-19 13:39:55 -0700 (Mon, 19 Sep 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Update WASM towards 0xc
https://bugs.webkit.org/show_bug.cgi?id=162067

Reviewed by Geoffrey Garen.

This patch updates some of the core parts of the WASM frontend to the 0xc standard.
First, it changes the section names from strings to bytecodes. It also adds support
for inline block signatures. This is a change from the old version that used to have
each branch indicate the arity. Finally, this patch updates all the tests and deletes
a duplicate test.

* CMakeLists.txt:
* JavaScriptCore.xcodeproj/project.pbxproj:
* testWASM.cpp:
(runWASMTests):
* wasm/WASMB3IRGenerator.cpp:
* wasm/WASMFormat.h:
* wasm/WASMFunctionParser.h:
(JSC::WASM::FunctionParser&lt;Context&gt;::FunctionParser):
(JSC::WASM::FunctionParser&lt;Context&gt;::parseBlock):
(JSC::WASM::FunctionParser&lt;Context&gt;::parseExpression):
* wasm/WASMModuleParser.cpp:
(JSC::WASM::ModuleParser::parse):
* wasm/WASMSections.cpp: Removed.
(JSC::WASM::Sections::lookup): Deleted.
* wasm/WASMSections.h:
(JSC::WASM::Sections::validateOrder):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreCMakeListstxt">trunk/Source/JavaScriptCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj">trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceJavaScriptCoretestWASMcpp">trunk/Source/JavaScriptCore/testWASM.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmWASMB3IRGeneratorcpp">trunk/Source/JavaScriptCore/wasm/WASMB3IRGenerator.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmWASMFormath">trunk/Source/JavaScriptCore/wasm/WASMFormat.h</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmWASMFunctionParserh">trunk/Source/JavaScriptCore/wasm/WASMFunctionParser.h</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmWASMModuleParsercpp">trunk/Source/JavaScriptCore/wasm/WASMModuleParser.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmWASMSectionsh">trunk/Source/JavaScriptCore/wasm/WASMSections.h</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCorewasmWASMSectionscpp">trunk/Source/JavaScriptCore/wasm/WASMSections.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/CMakeLists.txt (206109 => 206110)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/CMakeLists.txt        2016-09-19 20:35:47 UTC (rev 206109)
+++ trunk/Source/JavaScriptCore/CMakeLists.txt        2016-09-19 20:39:55 UTC (rev 206110)
</span><span class="lines">@@ -854,7 +854,6 @@
</span><span class="cx">     wasm/WASMCallingConvention.cpp
</span><span class="cx">     wasm/WASMModuleParser.cpp
</span><span class="cx">     wasm/WASMPlan.cpp
</span><del>-    wasm/WASMSections.cpp
</del><span class="cx"> 
</span><span class="cx">     yarr/RegularExpression.cpp
</span><span class="cx">     yarr/YarrCanonicalizeUCS2.cpp
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (206109 => 206110)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-09-19 20:35:47 UTC (rev 206109)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-09-19 20:39:55 UTC (rev 206110)
</span><span class="lines">@@ -1,3 +1,33 @@
</span><ins>+2016-09-19  Keith Miller  &lt;keith_miller@apple.com&gt;
+
+        Update WASM towards 0xc
+        https://bugs.webkit.org/show_bug.cgi?id=162067
+
+        Reviewed by Geoffrey Garen.
+
+        This patch updates some of the core parts of the WASM frontend to the 0xc standard.
+        First, it changes the section names from strings to bytecodes. It also adds support
+        for inline block signatures. This is a change from the old version that used to have
+        each branch indicate the arity. Finally, this patch updates all the tests and deletes
+        a duplicate test.
+
+        * CMakeLists.txt:
+        * JavaScriptCore.xcodeproj/project.pbxproj:
+        * testWASM.cpp:
+        (runWASMTests):
+        * wasm/WASMB3IRGenerator.cpp:
+        * wasm/WASMFormat.h:
+        * wasm/WASMFunctionParser.h:
+        (JSC::WASM::FunctionParser&lt;Context&gt;::FunctionParser):
+        (JSC::WASM::FunctionParser&lt;Context&gt;::parseBlock):
+        (JSC::WASM::FunctionParser&lt;Context&gt;::parseExpression):
+        * wasm/WASMModuleParser.cpp:
+        (JSC::WASM::ModuleParser::parse):
+        * wasm/WASMSections.cpp: Removed.
+        (JSC::WASM::Sections::lookup): Deleted.
+        * wasm/WASMSections.h:
+        (JSC::WASM::Sections::validateOrder):
+
</ins><span class="cx"> 2016-09-19  Yusuke Suzuki  &lt;utatane.tea@gmail.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [JSC] Use is_cell_with_type for @isRegExpObject, @isMap, and @isSet
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj (206109 => 206110)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2016-09-19 20:35:47 UTC (rev 206109)
+++ trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2016-09-19 20:39:55 UTC (rev 206110)
</span><span class="lines">@@ -1205,7 +1205,6 @@
</span><span class="cx">                 539EB0811D55608A00C82EF7 /* testWASM.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 539EB0711D553DF800C82EF7 /* testWASM.cpp */; };
</span><span class="cx">                 539FB8BA1C99DA7C00940FA1 /* JSArrayInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = 539FB8B91C99DA7C00940FA1 /* JSArrayInlines.h */; };
</span><span class="cx">                 53F40E851D58F9770099A1B6 /* WASMSections.h in Headers */ = {isa = PBXBuildFile; fileRef = 53F40E841D58F9770099A1B6 /* WASMSections.h */; };
</span><del>-                53F40E871D58F9D60099A1B6 /* WASMSections.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53F40E861D58F9D60099A1B6 /* WASMSections.cpp */; };
</del><span class="cx">                 53F40E8B1D5901BB0099A1B6 /* WASMFunctionParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 53F40E8A1D5901BB0099A1B6 /* WASMFunctionParser.h */; };
</span><span class="cx">                 53F40E8D1D5901F20099A1B6 /* WASMParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 53F40E8C1D5901F20099A1B6 /* WASMParser.h */; };
</span><span class="cx">                 53F40E8F1D5902820099A1B6 /* WASMB3IRGenerator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53F40E8E1D5902820099A1B6 /* WASMB3IRGenerator.cpp */; };
</span><span class="lines">@@ -3414,7 +3413,6 @@
</span><span class="cx">                 539FB8B91C99DA7C00940FA1 /* JSArrayInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSArrayInlines.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 53F256E11B87E28000B4B768 /* JSTypedArrayViewPrototype.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSTypedArrayViewPrototype.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 53F40E841D58F9770099A1B6 /* WASMSections.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WASMSections.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><del>-                53F40E861D58F9D60099A1B6 /* WASMSections.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WASMSections.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</del><span class="cx">                 53F40E8A1D5901BB0099A1B6 /* WASMFunctionParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WASMFunctionParser.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 53F40E8C1D5901F20099A1B6 /* WASMParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WASMParser.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 53F40E8E1D5902820099A1B6 /* WASMB3IRGenerator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WASMB3IRGenerator.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -5605,7 +5603,6 @@
</span><span class="cx">                                 531374BE1D5CE95000AF7A0B /* WASMPlan.cpp */,
</span><span class="cx">                                 531374BC1D5CE67600AF7A0B /* WASMPlan.h */,
</span><span class="cx">                                 53F40E8C1D5901F20099A1B6 /* WASMParser.h */,
</span><del>-                                53F40E861D58F9D60099A1B6 /* WASMSections.cpp */,
</del><span class="cx">                                 53F40E841D58F9770099A1B6 /* WASMSections.h */,
</span><span class="cx">                         );
</span><span class="cx">                         path = wasm;
</span><span class="lines">@@ -9049,7 +9046,6 @@
</span><span class="cx">                                 0FBE0F7216C1DB030082C5E8 /* DFGCPSRethreadingPhase.cpp in Sources */,
</span><span class="cx">                                 A7D89CF517A0B8CC00773AD8 /* DFGCriticalEdgeBreakingPhase.cpp in Sources */,
</span><span class="cx">                                 0F6183291C45BF070072450B /* AirCCallingConvention.cpp in Sources */,
</span><del>-                                53F40E871D58F9D60099A1B6 /* WASMSections.cpp in Sources */,
</del><span class="cx">                                 0FFFC95914EF90A600C72532 /* DFGCSEPhase.cpp in Sources */,
</span><span class="cx">                                 0F2FC77216E12F710038D976 /* DFGDCEPhase.cpp in Sources */,
</span><span class="cx">                                 0F338E121BF0276C0013C88F /* B3OpaqueByproducts.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretestWASMcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/testWASM.cpp (206109 => 206110)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/testWASM.cpp        2016-09-19 20:35:47 UTC (rev 206109)
+++ trunk/Source/JavaScriptCore/testWASM.cpp        2016-09-19 20:39:55 UTC (rev 206110)
</span><span class="lines">@@ -243,7 +243,7 @@
</span><span class="cx">     {
</span><span class="cx">         // Generated from:
</span><span class="cx">         //    (module
</span><del>-        //     (func &quot;dumb-eq&quot; (param $x i32) (param $y i32) (result i32)
</del><ins>+        //     (func (export &quot;dumb-eq&quot;) (param $x i32) (param $y i32) (result i32)
</ins><span class="cx">         //      (if (i32.eq (get_local $x) (get_local $y))
</span><span class="cx">         //       (then (br 0))
</span><span class="cx">         //       (else (return (i32.const 1))))
</span><span class="lines">@@ -251,13 +251,11 @@
</span><span class="cx">         //      )
</span><span class="cx">         //     )
</span><span class="cx">         Vector&lt;uint8_t&gt; vector = {
</span><del>-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x04, 0x74, 0x79, 0x70, 0x65, 0x87, 0x80, 0x80,
-            0x00, 0x01, 0x40, 0x02, 0x01, 0x01, 0x01, 0x01, 0x08, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f,
-            0x6e, 0x82, 0x80, 0x80, 0x00, 0x01, 0x00, 0x06, 0x65, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x91, 0x80,
-            0x80, 0x00, 0x01, 0x00, 0x0e, 0x64, 0x75, 0x6d, 0x62, 0x2d, 0x6c, 0x65, 0x73, 0x73, 0x2d, 0x74,
-            0x68, 0x61, 0x6e, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x97, 0x80, 0x80, 0x00, 0x01, 0x92, 0x80, 0x80,
-            0x00, 0x00, 0x14, 0x00, 0x14, 0x01, 0x4d, 0x03, 0x10, 0x00, 0x09, 0x01, 0x04, 0x10, 0x01, 0x09,
-            0x01, 0x0f, 0x0f
</del><ins>+            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x87, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
+            0x02, 0x01, 0x01, 0x01, 0x01, 0x03, 0x82, 0x80, 0x80, 0x80, 0x00, 0x01, 0x00, 0x07, 0x8b, 0x80,
+            0x80, 0x80, 0x00, 0x01, 0x07, 0x64, 0x75, 0x6d, 0x62, 0x2d, 0x65, 0x71, 0x00, 0x00, 0x0a, 0x99,
+            0x80, 0x80, 0x80, 0x00, 0x01, 0x93, 0x80, 0x80, 0x80, 0x00, 0x00, 0x14, 0x00, 0x14, 0x01, 0x4d,
+            0x03, 0x00, 0x06, 0x00, 0x04, 0x10, 0x01, 0x09, 0x0f, 0x10, 0x00, 0x09, 0x0f
</ins><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         Plan plan(*vm, vector);
</span><span class="lines">@@ -280,7 +278,7 @@
</span><span class="cx">     {
</span><span class="cx">         // Generated from:
</span><span class="cx">         //    (module
</span><del>-        //     (func &quot;dumb-less-than&quot; (param $x i32) (param $y i32) (result i32)
</del><ins>+        //     (func (export &quot;dumb-less-than&quot;) (param $x i32) (param $y i32) (result i32)
</ins><span class="cx">         //      (loop
</span><span class="cx">         //       (if (i32.eq (get_local $x) (get_local $y))
</span><span class="cx">         //        (then (return (i32.const 0)))
</span><span class="lines">@@ -292,14 +290,13 @@
</span><span class="cx">         //      )
</span><span class="cx">         //     )
</span><span class="cx">         Vector&lt;uint8_t&gt; vector = {
</span><del>-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x04, 0x74, 0x79, 0x70, 0x65, 0x87, 0x80, 0x80,
-            0x00, 0x01, 0x40, 0x02, 0x01, 0x01, 0x01, 0x01, 0x08, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f,
-            0x6e, 0x82, 0x80, 0x80, 0x00, 0x01, 0x00, 0x06, 0x65, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x91, 0x80,
-            0x80, 0x00, 0x01, 0x00, 0x0e, 0x64, 0x75, 0x6d, 0x62, 0x2d, 0x6c, 0x65, 0x73, 0x73, 0x2d, 0x74,
-            0x68, 0x61, 0x6e, 0x04, 0x63, 0x6f, 0x64, 0x65, 0xaa, 0x80, 0x80, 0x00, 0x01, 0xa5, 0x80, 0x80,
-            0x00, 0x00, 0x02, 0x14, 0x00, 0x14, 0x01, 0x4d, 0x03, 0x10, 0x00, 0x09, 0x01, 0x04, 0x14, 0x00,
-            0x10, 0x00, 0x4d, 0x03, 0x10, 0x01, 0x09, 0x01, 0x0f, 0x0f, 0x14, 0x00, 0x10, 0x01, 0x41, 0x15,
-            0x00, 0x06, 0x00, 0x00, 0x0f, 0x0f
</del><ins>+            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x87, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
+            0x02, 0x01, 0x01, 0x01, 0x01, 0x03, 0x82, 0x80, 0x80, 0x80, 0x00, 0x01, 0x00, 0x07, 0x92, 0x80,
+            0x80, 0x80, 0x00, 0x01, 0x0e, 0x64, 0x75, 0x6d, 0x62, 0x2d, 0x6c, 0x65, 0x73, 0x73, 0x2d, 0x74,
+            0x68, 0x61, 0x6e, 0x00, 0x00, 0x0a, 0xac, 0x80, 0x80, 0x80, 0x00, 0x01, 0xa6, 0x80, 0x80, 0x80,
+            0x00, 0x00, 0x02, 0x00, 0x14, 0x00, 0x14, 0x01, 0x4d, 0x03, 0x00, 0x10, 0x00, 0x09, 0x04, 0x14,
+            0x00, 0x10, 0x00, 0x4d, 0x03, 0x00, 0x10, 0x01, 0x09, 0x0f, 0x0f, 0x14, 0x00, 0x10, 0x01, 0x41,
+            0x15, 0x00, 0x06, 0x00, 0x0f, 0x00, 0x0f
</ins><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         Plan plan(*vm, vector);
</span><span class="lines">@@ -319,68 +316,14 @@
</span><span class="cx">         CHECK_EQ(invoke&lt;int&gt;(*plan.result[0], { box(100), box(6) }), 0);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    {
-        // Generated from:
-        //    (module
-        //     (func &quot;dumb-less-than&quot; (param $x i32) (param $y i32) (result i32)
-        //      (loop
-        //       (block
-        //        (block
-        //         (br_if 0 (i32.eq (get_local $x) (i32.const 0)))
-        //         (br 1)
-        //         )
-        //        (return (i32.const 1))
-        //        )
-        //       (block
-        //        (block
-        //         (br_if 0 (i32.eq (get_local $x) (get_local $y)))
-        //         (br 1)
-        //         )
-        //        (return (i32.const 0))
-        //        )
-        //       (set_local $x (i32.sub (get_local $x) (i32.const 1)))
-        //       (br 0)
-        //       )
-        //      )
-        //     )
-        Vector&lt;uint8_t&gt; vector = {
-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x04, 0x74, 0x79, 0x70, 0x65, 0x87, 0x80, 0x80,
-            0x00, 0x01, 0x40, 0x02, 0x01, 0x01, 0x01, 0x01, 0x08, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f,
-            0x6e, 0x82, 0x80, 0x80, 0x00, 0x01, 0x00, 0x06, 0x65, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x91, 0x80,
-            0x80, 0x00, 0x01, 0x00, 0x0e, 0x64, 0x75, 0x6d, 0x62, 0x2d, 0x6c, 0x65, 0x73, 0x73, 0x2d, 0x74,
-            0x68, 0x61, 0x6e, 0x04, 0x63, 0x6f, 0x64, 0x65, 0xb9, 0x80, 0x80, 0x00, 0x01, 0xb4, 0x80, 0x80,
-            0x00, 0x00, 0x02, 0x01, 0x01, 0x14, 0x00, 0x14, 0x01, 0x4d, 0x07, 0x00, 0x00, 0x06, 0x00, 0x01,
-            0x0f, 0x10, 0x00, 0x09, 0x01, 0x0f, 0x01, 0x01, 0x14, 0x00, 0x10, 0x00, 0x4d, 0x07, 0x00, 0x00,
-            0x06, 0x00, 0x01, 0x0f, 0x10, 0x01, 0x09, 0x01, 0x0f, 0x14, 0x00, 0x10, 0x01, 0x41, 0x15, 0x00,
-            0x06, 0x00, 0x00, 0x0f, 0x0f
-        };
</del><span class="cx"> 
</span><del>-        Plan plan(*vm, vector);
-        if (plan.result.size() != 1 || !plan.result[0]) {
-            dataLogLn(&quot;Module failed to compile correctly.&quot;);
-            CRASH();
-        }
-
-        // Test this doesn't crash.
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0], { box(0), box(1) }), 1);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0], { box(1), box(0) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0], { box(2), box(1) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0], { box(1), box(2) }), 1);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0], { box(2), box(2) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0], { box(1), box(1) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0], { box(2), box(6) }), 1);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0], { box(100), box(6) }), 0);
-    }
-
</del><span class="cx">     {
</span><del>-        // Generated from: (module (func &quot;return-i32&quot; (result i32) (return (i32.const 5))) )
</del><ins>+        // Generated from: (module (func (export &quot;return-i32&quot;) (result i32) (return (i32.const 5))) )
</ins><span class="cx">         Vector&lt;uint8_t&gt; vector = {
</span><del>-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x04, 0x74, 0x79, 0x70, 0x65, 0x85, 0x80, 0x80,
-            0x00, 0x01, 0x40, 0x00, 0x01, 0x01, 0x08, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x82,
-            0x80, 0x80, 0x00, 0x01, 0x00, 0x06, 0x65, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x8d, 0x80, 0x80, 0x00,
-            0x01, 0x00, 0x0a, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x2d, 0x69, 0x33, 0x32, 0x04, 0x63, 0x6f,
-            0x64, 0x65, 0x8b, 0x80, 0x80, 0x00, 0x01, 0x86, 0x80, 0x80, 0x00, 0x00, 0x10, 0x05, 0x09, 0x01,
-            0x0f
</del><ins>+            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x85, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
+            0x00, 0x01, 0x01, 0x03, 0x82, 0x80, 0x80, 0x80, 0x00, 0x01, 0x00, 0x07, 0x8e, 0x80, 0x80, 0x80,
+            0x00, 0x01, 0x0a, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x2d, 0x69, 0x33, 0x32, 0x00, 0x00, 0x0a,
+            0x8b, 0x80, 0x80, 0x80, 0x00, 0x01, 0x85, 0x80, 0x80, 0x80, 0x00, 0x00, 0x10, 0x05, 0x09, 0x0f
</ins><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         Plan plan(*vm, vector);
</span><span class="lines">@@ -395,14 +338,13 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     {
</span><del>-        // Generated from: (module (func &quot;return-i32&quot; (result i32) (return (i32.add (i32.const 5) (i32.const 6)))) )
</del><ins>+        // Generated from: (module (func (export &quot;return-i32&quot;) (result i32) (return (i32.add (i32.const 5) (i32.const 6)))) )
</ins><span class="cx">         Vector&lt;uint8_t&gt; vector = {
</span><del>-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x04, 0x74, 0x79, 0x70, 0x65, 0x85, 0x80, 0x80,
-            0x00, 0x01, 0x40, 0x00, 0x01, 0x01, 0x08, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x82,
-            0x80, 0x80, 0x00, 0x01, 0x00, 0x06, 0x65, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x8d, 0x80, 0x80, 0x00,
-            0x01, 0x00, 0x0a, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x2d, 0x69, 0x33, 0x32, 0x04, 0x63, 0x6f,
-            0x64, 0x65, 0x8e, 0x80, 0x80, 0x00, 0x01, 0x89, 0x80, 0x80, 0x00, 0x00, 0x10, 0x05, 0x10, 0x06,
-            0x40, 0x09, 0x01, 0x0f
</del><ins>+            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x85, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
+            0x00, 0x01, 0x01, 0x03, 0x82, 0x80, 0x80, 0x80, 0x00, 0x01, 0x00, 0x07, 0x8e, 0x80, 0x80, 0x80,
+            0x00, 0x01, 0x0a, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x2d, 0x69, 0x33, 0x32, 0x00, 0x00, 0x0a,
+            0x8e, 0x80, 0x80, 0x80, 0x00, 0x01, 0x88, 0x80, 0x80, 0x80, 0x00, 0x00, 0x10, 0x05, 0x10, 0x06,
+            0x40, 0x09, 0x0f
</ins><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         Plan plan(*vm, vector);
</span><span class="lines">@@ -414,16 +356,15 @@
</span><span class="cx">         // Test this doesn't crash.
</span><span class="cx">         CHECK_EQ(invoke&lt;int&gt;(*plan.result[0], { }), 11);
</span><span class="cx">     }
</span><del>-    
</del><ins>+
</ins><span class="cx">     {
</span><del>-        // Generated from: (module (func &quot;return-i32&quot; (result i32) (return (i32.add (i32.add (i32.const 5) (i32.const 3)) (i32.const 3)))) )
</del><ins>+        // Generated from: (module (func (export &quot;return-i32&quot;) (result i32) (return (i32.add (i32.add (i32.const 5) (i32.const 3)) (i32.const 3)))) )
</ins><span class="cx">         Vector&lt;uint8_t&gt; vector = {
</span><del>-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x04, 0x74, 0x79, 0x70, 0x65, 0x85, 0x80, 0x80,
-            0x00, 0x01, 0x40, 0x00, 0x01, 0x01, 0x08, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x82,
-            0x80, 0x80, 0x00, 0x01, 0x00, 0x06, 0x65, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x8d, 0x80, 0x80, 0x00,
-            0x01, 0x00, 0x0a, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x2d, 0x69, 0x33, 0x32, 0x04, 0x63, 0x6f,
-            0x64, 0x65, 0x91, 0x80, 0x80, 0x00, 0x01, 0x8c, 0x80, 0x80, 0x00, 0x00, 0x10, 0x05, 0x10, 0x03,
-            0x40, 0x10, 0x03, 0x40, 0x09, 0x01, 0x0f
</del><ins>+            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x85, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
+            0x00, 0x01, 0x01, 0x03, 0x82, 0x80, 0x80, 0x80, 0x00, 0x01, 0x00, 0x07, 0x8e, 0x80, 0x80, 0x80,
+            0x00, 0x01, 0x0a, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x2d, 0x69, 0x33, 0x32, 0x00, 0x00, 0x0a,
+            0x91, 0x80, 0x80, 0x80, 0x00, 0x01, 0x8b, 0x80, 0x80, 0x80, 0x00, 0x00, 0x10, 0x05, 0x10, 0x03,
+            0x40, 0x10, 0x03, 0x40, 0x09, 0x0f
</ins><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         Plan plan(*vm, vector);
</span><span class="lines">@@ -437,14 +378,13 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     {
</span><del>-        // Generated from: (module (func &quot;return-i32&quot; (result i32) (block (return (i32.add (i32.add (i32.const 5) (i32.const 3)) (i32.const 3))))) )
</del><ins>+        // Generated from: (module (func (export &quot;return-i32&quot;) (result i32) (block (return (i32.add (i32.add (i32.const 5) (i32.const 3)) (i32.const 3)))) (unreachable)) )
</ins><span class="cx">         Vector&lt;uint8_t&gt; vector = {
</span><del>-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x04, 0x74, 0x79, 0x70, 0x65, 0x85, 0x80, 0x80,
-            0x00, 0x01, 0x40, 0x00, 0x01, 0x01, 0x08, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x82,
-            0x80, 0x80, 0x00, 0x01, 0x00, 0x06, 0x65, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x8d, 0x80, 0x80, 0x00,
-            0x01, 0x00, 0x0a, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x2d, 0x69, 0x33, 0x32, 0x04, 0x63, 0x6f,
-            0x64, 0x65, 0x93, 0x80, 0x80, 0x00, 0x01, 0x8e, 0x80, 0x80, 0x00, 0x00, 0x01, 0x10, 0x05, 0x10,
-            0x03, 0x40, 0x10, 0x03, 0x40, 0x09, 0x01, 0x0f, 0x0f
</del><ins>+            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x85, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
+            0x00, 0x01, 0x01, 0x03, 0x82, 0x80, 0x80, 0x80, 0x00, 0x01, 0x00, 0x07, 0x8e, 0x80, 0x80, 0x80,
+            0x00, 0x01, 0x0a, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x2d, 0x69, 0x33, 0x32, 0x00, 0x00, 0x0a,
+            0x95, 0x80, 0x80, 0x80, 0x00, 0x01, 0x8f, 0x80, 0x80, 0x80, 0x00, 0x00, 0x01, 0x00, 0x10, 0x05,
+            0x10, 0x03, 0x40, 0x10, 0x03, 0x40, 0x09, 0x0f, 0x00, 0x0f
</ins><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         Plan plan(*vm, vector);
</span><span class="lines">@@ -458,12 +398,12 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     {
</span><del>-        // Generated from: (module (func $add (param $x i32) (param $y i32) (result i32) (return (i32.add (get_local $x) (get_local $y)))) )
</del><ins>+        // Generated from: (module (func (export &quot;add&quot;) (param $x i32) (param $y i32) (result i32) (return (i32.add (get_local $x) (get_local $y)))) )
</ins><span class="cx">         Vector&lt;uint8_t&gt; vector = {
</span><del>-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x04, 0x74, 0x79, 0x70, 0x65, 0x87, 0x80, 0x80,
-            0x00, 0x01, 0x40, 0x02, 0x01, 0x01, 0x01, 0x01, 0x08, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f,
-            0x6e, 0x82, 0x80, 0x80, 0x00, 0x01, 0x00, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x8e, 0x80, 0x80, 0x00,
-            0x01, 0x89, 0x80, 0x80, 0x00, 0x00, 0x14, 0x00, 0x14, 0x01, 0x40, 0x09, 0x01, 0x0f
</del><ins>+            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x87, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
+            0x02, 0x01, 0x01, 0x01, 0x01, 0x03, 0x82, 0x80, 0x80, 0x80, 0x00, 0x01, 0x00, 0x07, 0x87, 0x80,
+            0x80, 0x80, 0x00, 0x01, 0x03, 0x61, 0x64, 0x64, 0x00, 0x00, 0x0a, 0x8e, 0x80, 0x80, 0x80, 0x00,
+            0x01, 0x88, 0x80, 0x80, 0x80, 0x00, 0x00, 0x14, 0x00, 0x14, 0x01, 0x40, 0x09, 0x0f
</ins><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         Plan plan(*vm, vector);
</span><span class="lines">@@ -482,18 +422,17 @@
</span><span class="cx">     {
</span><span class="cx">         // Generated from:
</span><span class="cx">         //    (module
</span><del>-        //     (func &quot;locals&quot; (param $x i32) (result i32) (local $num i32)
</del><ins>+        //     (func (export &quot;locals&quot;) (param $x i32) (result i32) (local $num i32)
</ins><span class="cx">         //      (set_local $num (get_local $x))
</span><span class="cx">         //      (return (get_local $num))
</span><span class="cx">         //      )
</span><span class="cx">         //     )
</span><span class="cx">         Vector&lt;uint8_t&gt; vector = {
</span><del>-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x04, 0x74, 0x79, 0x70, 0x65, 0x86, 0x80, 0x80,
-            0x00, 0x01, 0x40, 0x01, 0x01, 0x01, 0x01, 0x08, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e,
-            0x82, 0x80, 0x80, 0x00, 0x01, 0x00, 0x06, 0x65, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x89, 0x80, 0x80,
-            0x00, 0x01, 0x00, 0x06, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x73, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x91,
-            0x80, 0x80, 0x00, 0x01, 0x8c, 0x80, 0x80, 0x00, 0x01, 0x01, 0x01, 0x14, 0x00, 0x15, 0x01, 0x14,
-            0x01, 0x09, 0x01, 0x0f
</del><ins>+            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x86, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
+            0x01, 0x01, 0x01, 0x01, 0x03, 0x82, 0x80, 0x80, 0x80, 0x00, 0x01, 0x00, 0x07, 0x8a, 0x80, 0x80,
+            0x80, 0x00, 0x01, 0x06, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x73, 0x00, 0x00, 0x0a, 0x91, 0x80, 0x80,
+            0x80, 0x00, 0x01, 0x8b, 0x80, 0x80, 0x80, 0x00, 0x01, 0x01, 0x01, 0x14, 0x00, 0x15, 0x01, 0x14,
+            0x01, 0x09, 0x0f
</ins><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         Plan plan(*vm, vector);
</span><span class="lines">@@ -510,33 +449,26 @@
</span><span class="cx">     {
</span><span class="cx">         // Generated from:
</span><span class="cx">         //    (module
</span><del>-        //     (func &quot;dumb-mult&quot; (param $x i32) (param $y i32) (result i32) (local $total i32) (local $i i32) (local $j i32)
-        //      (set_local $total (i32.const 0))
-        //      (set_local $i (i32.const 0))
-        //      (block
-        //       (loop
-        //        (br_if 1 (i32.eq (get_local $i) (get_local $x)))
-        //        (set_local $j (i32.const 0))
-        //        (set_local $i (i32.add (get_local $i) (i32.const 1)))
-        //        (loop
-        //         (br_if 1 (i32.eq (get_local $j) (get_local $y)))
-        //         (set_local $total (i32.add (get_local $total) (i32.const 1)))
-        //         (set_local $j (i32.add (get_local $j) (i32.const 1)))
-        //         (br 0)
-        //         )
</del><ins>+        //     (func (export &quot;sum&quot;) (param $x i32) (result i32) (local $y i32)
+        //      (set_local $y (i32.const 0))
+        //      (loop
+        //       (block
+        //        (br_if 0 (i32.eq (get_local $x) (i32.const 0)))
+        //        (set_local $y (i32.add (get_local $x) (get_local $y)))
+        //        (set_local $x (i32.sub (get_local $x) (i32.const 1)))
+        //        (br 1)
</ins><span class="cx">         //        )
</span><span class="cx">         //       )
</span><del>-        //      (return (get_local $total))
</del><ins>+        //      (return (get_local $y))
</ins><span class="cx">         //      )
</span><span class="cx">         //     )
</span><span class="cx">         Vector&lt;uint8_t&gt; vector = {
</span><del>-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x04, 0x74, 0x79, 0x70, 0x65, 0x86, 0x80, 0x80,
-            0x00, 0x01, 0x40, 0x01, 0x01, 0x01, 0x01, 0x08, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e,
-            0x82, 0x80, 0x80, 0x00, 0x01, 0x00, 0x06, 0x65, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x86, 0x80, 0x80,
-            0x00, 0x01, 0x00, 0x03, 0x73, 0x75, 0x6d, 0x04, 0x63, 0x6f, 0x64, 0x65, 0xae, 0x80, 0x80, 0x00,
-            0x01, 0xa9, 0x80, 0x80, 0x00, 0x01, 0x01, 0x01, 0x10, 0x00, 0x15, 0x01, 0x02, 0x01, 0x14, 0x00,
-            0x10, 0x00, 0x4d, 0x07, 0x00, 0x00, 0x14, 0x00, 0x14, 0x01, 0x40, 0x15, 0x01, 0x14, 0x00, 0x10,
-            0x01, 0x41, 0x15, 0x00, 0x06, 0x00, 0x01, 0x0f, 0x0f, 0x14, 0x01, 0x09, 0x01, 0x0f
</del><ins>+            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x86, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
+            0x01, 0x01, 0x01, 0x01, 0x03, 0x82, 0x80, 0x80, 0x80, 0x00, 0x01, 0x00, 0x07, 0x87, 0x80, 0x80,
+            0x80, 0x00, 0x01, 0x03, 0x73, 0x75, 0x6d, 0x00, 0x00, 0x0a, 0xae, 0x80, 0x80, 0x80, 0x00, 0x01,
+            0xa8, 0x80, 0x80, 0x80, 0x00, 0x01, 0x01, 0x01, 0x10, 0x00, 0x15, 0x01, 0x02, 0x00, 0x01, 0x00,
+            0x14, 0x00, 0x10, 0x00, 0x4d, 0x07, 0x00, 0x14, 0x00, 0x14, 0x01, 0x40, 0x15, 0x01, 0x14, 0x00,
+            0x10, 0x01, 0x41, 0x15, 0x00, 0x06, 0x01, 0x0f, 0x0f, 0x14, 0x01, 0x09, 0x0f
</ins><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         Plan plan(*vm, vector);
</span><span class="lines">@@ -555,7 +487,7 @@
</span><span class="cx">     {
</span><span class="cx">         // Generated from:
</span><span class="cx">         //    (module
</span><del>-        //     (func &quot;dumb-mult&quot; (param $x i32) (param $y i32) (result i32) (local $total i32) (local $i i32) (local $j i32)
</del><ins>+        //     (func (export &quot;dumb-mult&quot;) (param $x i32) (param $y i32) (result i32) (local $total i32) (local $i i32) (local $j i32)
</ins><span class="cx">         //      (set_local $total (i32.const 0))
</span><span class="cx">         //      (set_local $i (i32.const 0))
</span><span class="cx">         //      (block (loop
</span><span class="lines">@@ -573,15 +505,14 @@
</span><span class="cx">         //      )
</span><span class="cx">         //     )
</span><span class="cx">         Vector&lt;uint8_t&gt; vector = {
</span><del>-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x04, 0x74, 0x79, 0x70, 0x65, 0x87, 0x80, 0x80,
-            0x00, 0x01, 0x40, 0x02, 0x01, 0x01, 0x01, 0x01, 0x08, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f,
-            0x6e, 0x82, 0x80, 0x80, 0x00, 0x01, 0x00, 0x06, 0x65, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x8c, 0x80,
-            0x80, 0x00, 0x01, 0x00, 0x09, 0x64, 0x75, 0x6d, 0x62, 0x2d, 0x6d, 0x75, 0x6c, 0x74, 0x04, 0x63,
-            0x6f, 0x64, 0x65, 0xc7, 0x80, 0x80, 0x00, 0x01, 0xc2, 0x80, 0x80, 0x00, 0x01, 0x03, 0x01, 0x10,
-            0x00, 0x15, 0x02, 0x10, 0x00, 0x15, 0x03, 0x01, 0x02, 0x14, 0x03, 0x14, 0x00, 0x4d, 0x07, 0x00,
-            0x01, 0x10, 0x00, 0x15, 0x04, 0x14, 0x03, 0x10, 0x01, 0x40, 0x15, 0x03, 0x02, 0x14, 0x04, 0x14,
-            0x01, 0x4d, 0x07, 0x00, 0x01, 0x14, 0x02, 0x10, 0x01, 0x40, 0x15, 0x02, 0x14, 0x04, 0x10, 0x01,
-            0x40, 0x15, 0x04, 0x06, 0x00, 0x00, 0x0f, 0x0f, 0x0f, 0x14, 0x02, 0x09, 0x01, 0x0f
</del><ins>+            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x87, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
+            0x02, 0x01, 0x01, 0x01, 0x01, 0x03, 0x82, 0x80, 0x80, 0x80, 0x00, 0x01, 0x00, 0x07, 0x8d, 0x80,
+            0x80, 0x80, 0x00, 0x01, 0x09, 0x64, 0x75, 0x6d, 0x62, 0x2d, 0x6d, 0x75, 0x6c, 0x74, 0x00, 0x00,
+            0x0a, 0xc7, 0x80, 0x80, 0x80, 0x00, 0x01, 0xc1, 0x80, 0x80, 0x80, 0x00, 0x01, 0x03, 0x01, 0x10,
+            0x00, 0x15, 0x02, 0x10, 0x00, 0x15, 0x03, 0x01, 0x00, 0x02, 0x00, 0x14, 0x03, 0x14, 0x00, 0x4d,
+            0x07, 0x01, 0x10, 0x00, 0x15, 0x04, 0x14, 0x03, 0x10, 0x01, 0x40, 0x15, 0x03, 0x02, 0x00, 0x14,
+            0x04, 0x14, 0x01, 0x4d, 0x07, 0x01, 0x14, 0x02, 0x10, 0x01, 0x40, 0x15, 0x02, 0x14, 0x04, 0x10,
+            0x01, 0x40, 0x15, 0x04, 0x06, 0x00, 0x0f, 0x0f, 0x0f, 0x14, 0x02, 0x09, 0x0f
</ins><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         Plan plan(*vm, vector);
</span><span class="lines">@@ -608,33 +539,33 @@
</span><span class="cx">         //      (loop
</span><span class="cx">         //       (block
</span><span class="cx">         //        (block
</span><del>-        //         (br_if 0 (i32.eq (get_local $x) (i32.const 0)))
</del><ins>+        //         (br_if 0 (i32.eq (get_local $x) (get_local $y)))
</ins><span class="cx">         //         (br 1)
</span><span class="cx">         //         )
</span><del>-        //        (return (i32.const 1))
</del><ins>+        //        (return (i32.const 0))
</ins><span class="cx">         //        )
</span><span class="cx">         //       (block
</span><span class="cx">         //        (block
</span><del>-        //         (br_if 0 (i32.eq (get_local $x) (get_local $y)))
</del><ins>+        //         (br_if 0 (i32.eq (get_local $x) (i32.const 0)))
</ins><span class="cx">         //         (br 1)
</span><span class="cx">         //         )
</span><del>-        //        (return (i32.const 0))
</del><ins>+        //        (return (i32.const 1))
</ins><span class="cx">         //        )
</span><span class="cx">         //       (set_local $x (i32.sub (get_local $x) (i32.const 1)))
</span><span class="cx">         //       (br 0)
</span><span class="cx">         //       )
</span><ins>+        //       (unreachable)
</ins><span class="cx">         //      )
</span><span class="cx">         //     )
</span><span class="cx">         Vector&lt;uint8_t&gt; vector = {
</span><del>-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x04, 0x74, 0x79, 0x70, 0x65, 0x87, 0x80, 0x80,
-            0x00, 0x01, 0x40, 0x02, 0x01, 0x01, 0x01, 0x01, 0x08, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f,
-            0x6e, 0x82, 0x80, 0x80, 0x00, 0x01, 0x00, 0x06, 0x65, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x91, 0x80,
-            0x80, 0x00, 0x01, 0x00, 0x0e, 0x64, 0x75, 0x6d, 0x62, 0x2d, 0x6c, 0x65, 0x73, 0x73, 0x2d, 0x74,
-            0x68, 0x61, 0x6e, 0x04, 0x63, 0x6f, 0x64, 0x65, 0xb9, 0x80, 0x80, 0x00, 0x01, 0xb4, 0x80, 0x80,
-            0x00, 0x00, 0x02, 0x01, 0x01, 0x14, 0x00, 0x14, 0x01, 0x4d, 0x07, 0x00, 0x00, 0x06, 0x00, 0x01,
-            0x0f, 0x10, 0x00, 0x09, 0x01, 0x0f, 0x01, 0x01, 0x14, 0x00, 0x10, 0x00, 0x4d, 0x07, 0x00, 0x00,
-            0x06, 0x00, 0x01, 0x0f, 0x10, 0x01, 0x09, 0x01, 0x0f, 0x14, 0x00, 0x10, 0x01, 0x41, 0x15, 0x00,
-            0x06, 0x00, 0x00, 0x0f, 0x0f
</del><ins>+            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x87, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
+            0x02, 0x01, 0x01, 0x01, 0x01, 0x03, 0x82, 0x80, 0x80, 0x80, 0x00, 0x01, 0x00, 0x07, 0x92, 0x80,
+            0x80, 0x80, 0x00, 0x01, 0x0e, 0x64, 0x75, 0x6d, 0x62, 0x2d, 0x6c, 0x65, 0x73, 0x73, 0x2d, 0x74,
+            0x68, 0x61, 0x6e, 0x00, 0x00, 0x0a, 0xb9, 0x80, 0x80, 0x80, 0x00, 0x01, 0xb3, 0x80, 0x80, 0x80,
+            0x00, 0x00, 0x02, 0x00, 0x01, 0x00, 0x01, 0x00, 0x14, 0x00, 0x14, 0x01, 0x4d, 0x07, 0x00, 0x06,
+            0x01, 0x0f, 0x10, 0x00, 0x09, 0x0f, 0x01, 0x00, 0x01, 0x00, 0x14, 0x00, 0x10, 0x00, 0x4d, 0x07,
+            0x00, 0x06, 0x01, 0x0f, 0x10, 0x01, 0x09, 0x0f, 0x14, 0x00, 0x10, 0x01, 0x41, 0x15, 0x00, 0x06,
+            0x00, 0x0f, 0x00, 0x0f
</ins><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         Plan plan(*vm, vector);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWASMB3IRGeneratorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WASMB3IRGenerator.cpp (206109 => 206110)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WASMB3IRGenerator.cpp        2016-09-19 20:35:47 UTC (rev 206109)
+++ trunk/Source/JavaScriptCore/wasm/WASMB3IRGenerator.cpp        2016-09-19 20:39:55 UTC (rev 206110)
</span><span class="lines">@@ -105,11 +105,12 @@
</span><span class="cx"> 
</span><span class="cx"> public:
</span><span class="cx">     struct ControlData {
</span><del>-        ControlData(Optional&lt;Vector&lt;Variable*&gt;&gt;&amp;&amp; stack, BasicBlock* special = nullptr, BasicBlock* continuation = nullptr)
</del><ins>+        ControlData(Procedure&amp; proc, Type signature, BasicBlock* special = nullptr, BasicBlock* continuation = nullptr)
</ins><span class="cx">             : continuation(continuation)
</span><span class="cx">             , special(special)
</span><del>-            , stack(stack)
</del><span class="cx">         {
</span><ins>+            if (signature != Void)
+                result.append(proc.addVariable(toB3Type(signature)));
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         void dump(PrintStream&amp; out) const
</span><span class="lines">@@ -143,7 +144,7 @@
</span><span class="cx"> 
</span><span class="cx">         BasicBlock* targetBlockForBranch(Procedure&amp; proc)
</span><span class="cx">         {
</span><del>-            if (special)
</del><ins>+            if (type() == BlockType::Loop)
</ins><span class="cx">                 return special;
</span><span class="cx">             return continuation.get(proc);
</span><span class="cx">         }
</span><span class="lines">@@ -155,11 +156,13 @@
</span><span class="cx">         // that example, if we eagerly allocate a BasicBlock for the continuation it will never be reachable.
</span><span class="cx">         LazyBlock continuation;
</span><span class="cx">         BasicBlock* special;
</span><del>-        Optional&lt;Vector&lt;Variable*&gt;&gt; stack;
</del><ins>+        Vector&lt;Variable*, 1&gt; result;
</ins><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx">     typedef Value* ExpressionType;
</span><span class="cx">     typedef ControlData ControlType;
</span><ins>+    typedef Vector&lt;ExpressionType, 1&gt; ExpressionList;
+    typedef Vector&lt;Variable*, 1&gt; ResultList;
</ins><span class="cx">     static constexpr ExpressionType emptyExpression = nullptr;
</span><span class="cx"> 
</span><span class="cx">     B3IRGenerator(Procedure&amp;);
</span><span class="lines">@@ -174,23 +177,22 @@
</span><span class="cx">     bool WARN_UNUSED_RETURN binaryOp(BinaryOpType, ExpressionType left, ExpressionType right, ExpressionType&amp; result);
</span><span class="cx">     bool WARN_UNUSED_RETURN unaryOp(UnaryOpType, ExpressionType arg, ExpressionType&amp; result);
</span><span class="cx"> 
</span><del>-    ControlData WARN_UNUSED_RETURN addBlock();
-    ControlData WARN_UNUSED_RETURN addLoop();
-    ControlData WARN_UNUSED_RETURN addIf(ExpressionType condition);
</del><ins>+    ControlData WARN_UNUSED_RETURN addBlock(Type signature);
+    ControlData WARN_UNUSED_RETURN addLoop(Type signature);
+    ControlData WARN_UNUSED_RETURN addIf(ExpressionType condition, Type signature);
</ins><span class="cx">     bool WARN_UNUSED_RETURN addElse(ControlData&amp;);
</span><span class="cx"> 
</span><del>-    bool WARN_UNUSED_RETURN addReturn(const Vector&lt;ExpressionType, 1&gt;&amp; returnValues);
-    bool WARN_UNUSED_RETURN addBranch(ControlData&amp;, ExpressionType condition, const Vector&lt;ExpressionType, 1&gt;&amp; returnValues);
-    bool WARN_UNUSED_RETURN endBlock(ControlData&amp;, Vector&lt;ExpressionType, 1&gt;&amp; expressionStack);
</del><ins>+    bool WARN_UNUSED_RETURN addReturn(const ExpressionList&amp; returnValues);
+    bool WARN_UNUSED_RETURN addBranch(ControlData&amp;, ExpressionType condition, const ExpressionList&amp; returnValues);
+    bool WARN_UNUSED_RETURN endBlock(ControlData&amp;, ExpressionList&amp; expressionStack);
</ins><span class="cx"> 
</span><span class="cx">     bool isContinuationReachable(ControlData&amp;);
</span><span class="cx"> 
</span><del>-    void dump(const Vector&lt;ControlType&gt;&amp; controlStack, const Vector&lt;ExpressionType, 1&gt;&amp; expressionStack);
</del><ins>+    void dump(const Vector&lt;ControlType&gt;&amp; controlStack, const ExpressionList&amp; expressionStack);
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     void unify(Variable* target, const ExpressionType source);
</span><del>-    Vector&lt;Variable*&gt; initializeIncommingTypes(BasicBlock*, const Vector&lt;ExpressionType, 1&gt;&amp;);
-    void unifyValuesWithBlock(const Vector&lt;ExpressionType, 1&gt;&amp; resultStack, Optional&lt;Vector&lt;Variable*&gt;&gt;&amp; stack, BasicBlock* target);
</del><ins>+    void unifyValuesWithBlock(const ExpressionList&amp; resultStack, ResultList&amp; stack);
</ins><span class="cx"> 
</span><span class="cx">     Procedure&amp; m_proc;
</span><span class="cx">     BasicBlock* m_currentBlock;
</span><span class="lines">@@ -265,21 +267,21 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-B3IRGenerator::ControlData B3IRGenerator::addBlock()
</del><ins>+B3IRGenerator::ControlData B3IRGenerator::addBlock(Type signature)
</ins><span class="cx"> {
</span><del>-    return ControlData(Nullopt);
</del><ins>+    return ControlData(m_proc, signature);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-B3IRGenerator::ControlData B3IRGenerator::addLoop()
</del><ins>+B3IRGenerator::ControlData B3IRGenerator::addLoop(Type signature)
</ins><span class="cx"> {
</span><span class="cx">     BasicBlock* body = m_proc.addBlock();
</span><span class="cx">     m_currentBlock-&gt;appendNewControlValue(m_proc, Jump, Origin(), body);
</span><span class="cx">     body-&gt;addPredecessor(m_currentBlock);
</span><span class="cx">     m_currentBlock = body;
</span><del>-    return ControlData(Vector&lt;Variable*&gt;(), body);
</del><ins>+    return ControlData(m_proc, signature, body);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-B3IRGenerator::ControlData B3IRGenerator::addIf(ExpressionType condition)
</del><ins>+B3IRGenerator::ControlData B3IRGenerator::addIf(ExpressionType condition, Type signature)
</ins><span class="cx"> {
</span><span class="cx">     // FIXME: This needs to do some kind of stack passing.
</span><span class="cx"> 
</span><span class="lines">@@ -293,7 +295,7 @@
</span><span class="cx">     notTaken-&gt;addPredecessor(m_currentBlock);
</span><span class="cx"> 
</span><span class="cx">     m_currentBlock = taken;
</span><del>-    return ControlData(Nullopt, notTaken, continuation);
</del><ins>+    return ControlData(m_proc, signature, notTaken, continuation);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool B3IRGenerator::addElse(ControlData&amp; data)
</span><span class="lines">@@ -306,7 +308,7 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool B3IRGenerator::addReturn(const Vector&lt;ExpressionType, 1&gt;&amp; returnValues)
</del><ins>+bool B3IRGenerator::addReturn(const ExpressionList&amp; returnValues)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(returnValues.size() &lt;= 1);
</span><span class="cx">     if (returnValues.size())
</span><span class="lines">@@ -316,10 +318,10 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool B3IRGenerator::addBranch(ControlData&amp; data, ExpressionType condition, const Vector&lt;ExpressionType, 1&gt;&amp; returnValues)
</del><ins>+bool B3IRGenerator::addBranch(ControlData&amp; data, ExpressionType condition, const ExpressionList&amp; returnValues)
</ins><span class="cx"> {
</span><span class="cx">     BasicBlock* target = data.targetBlockForBranch(m_proc);
</span><del>-    unifyValuesWithBlock(returnValues, data.stack, target);
</del><ins>+    unifyValuesWithBlock(returnValues, data.result);
</ins><span class="cx">     if (condition) {
</span><span class="cx">         BasicBlock* continuation = m_proc.addBlock();
</span><span class="cx">         m_currentBlock-&gt;appendNew&lt;Value&gt;(m_proc, B3::Branch, Origin(), condition);
</span><span class="lines">@@ -335,7 +337,7 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool B3IRGenerator::endBlock(ControlData&amp; data, Vector&lt;ExpressionType, 1&gt;&amp; expressionStack)
</del><ins>+bool B3IRGenerator::endBlock(ControlData&amp; data, ExpressionList&amp; expressionStack)
</ins><span class="cx"> {
</span><span class="cx">     if (!data.continuation)
</span><span class="cx">         return true;
</span><span class="lines">@@ -349,7 +351,7 @@
</span><span class="cx">         continuation-&gt;addPredecessor(data.special);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    unifyValuesWithBlock(expressionStack, data.stack, continuation);
</del><ins>+    unifyValuesWithBlock(expressionStack, data.result);
</ins><span class="cx">     m_currentBlock-&gt;appendNewControlValue(m_proc, Jump, Origin(), continuation);
</span><span class="cx">     continuation-&gt;addPredecessor(m_currentBlock);
</span><span class="cx">     m_currentBlock = continuation;
</span><span class="lines">@@ -377,34 +379,15 @@
</span><span class="cx">     m_currentBlock-&gt;appendNew&lt;VariableValue&gt;(m_proc, Set, Origin(), variable, source);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-Vector&lt;Variable*&gt; B3IRGenerator::initializeIncommingTypes(BasicBlock* block, const Vector&lt;ExpressionType, 1&gt;&amp; source)
</del><ins>+void B3IRGenerator::unifyValuesWithBlock(const ExpressionList&amp; resultStack, ResultList&amp; result)
</ins><span class="cx"> {
</span><del>-    Vector&lt;Variable*&gt; result;
-    result.reserveInitialCapacity(source.size());
-    for (ExpressionType expr : source) {
-        ASSERT(expr-&gt;type() != B3::Void);
-        Variable* var = m_proc.addVariable(expr-&gt;type());
-        result.append(var);
-        block-&gt;appendNew&lt;VariableValue&gt;(m_proc, B3::Get, Origin(), var);
-    }
</del><ins>+    ASSERT(result.size() &gt;= resultStack.size());
</ins><span class="cx"> 
</span><del>-    return result;
-}
-
-void B3IRGenerator::unifyValuesWithBlock(const Vector&lt;ExpressionType, 1&gt;&amp; resultStack, Optional&lt;Vector&lt;Variable*&gt;&gt;&amp; stack, BasicBlock* target)
-{
-    if (!stack) {
-        stack = initializeIncommingTypes(target, resultStack);
-        return;
-    }
-
-    ASSERT(stack.value().size() == resultStack.size());
-
</del><span class="cx">     for (size_t i = 0; i &lt; resultStack.size(); ++i)
</span><del>-        unify(stack.value()[i], resultStack[i]);
</del><ins>+        unify(result[i], resultStack[i]);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void B3IRGenerator::dump(const Vector&lt;ControlType&gt;&amp; controlStack, const Vector&lt;ExpressionType, 1&gt;&amp; expressionStack)
</del><ins>+void B3IRGenerator::dump(const Vector&lt;ControlType&gt;&amp; controlStack, const ExpressionList&amp; expressionStack)
</ins><span class="cx"> {
</span><span class="cx">     dataLogLn(&quot;Processing Graph:&quot;);
</span><span class="cx">     dataLog(m_proc);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWASMFormath"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WASMFormat.h (206109 => 206110)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WASMFormat.h        2016-09-19 20:35:47 UTC (rev 206109)
+++ trunk/Source/JavaScriptCore/wasm/WASMFormat.h        2016-09-19 20:39:55 UTC (rev 206110)
</span><span class="lines">@@ -55,12 +55,12 @@
</span><span class="cx"> namespace WASM {
</span><span class="cx"> 
</span><span class="cx"> enum Type : uint8_t {
</span><del>-    I32 = 1,
</del><ins>+    Void,
+    I32,
</ins><span class="cx">     I64,
</span><span class="cx">     F32,
</span><span class="cx">     F64,
</span><span class="cx">     LastValueType = F64,
</span><del>-    Void
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> static_assert(I32 == 1, &quot;WASM needs I32 to have the value 1&quot;);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWASMFunctionParserh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WASMFunctionParser.h (206109 => 206110)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WASMFunctionParser.h        2016-09-19 20:35:47 UTC (rev 206109)
+++ trunk/Source/JavaScriptCore/wasm/WASMFunctionParser.h        2016-09-19 20:39:55 UTC (rev 206110)
</span><span class="lines">@@ -59,6 +59,7 @@
</span><span class="cx">     Context&amp; m_context;
</span><span class="cx">     Vector&lt;ExpressionType, 1&gt; m_expressionStack;
</span><span class="cx">     Vector&lt;ControlType&gt; m_controlStack;
</span><ins>+    const Signature&amp; m_signature;
</ins><span class="cx">     unsigned m_unreachableBlocks { 0 };
</span><span class="cx"> };
</span><span class="cx"> 
</span><span class="lines">@@ -66,8 +67,11 @@
</span><span class="cx"> FunctionParser&lt;Context&gt;::FunctionParser(Context&amp; context, const Vector&lt;uint8_t&gt;&amp; sourceBuffer, const FunctionInformation&amp; info)
</span><span class="cx">     : Parser(sourceBuffer, info.start, info.end)
</span><span class="cx">     , m_context(context)
</span><ins>+    , m_signature(*info.signature)
</ins><span class="cx"> {
</span><del>-    m_context.addArguments(info.signature-&gt;arguments);
</del><ins>+    if (verbose)
+        dataLogLn(&quot;Parsing function starting at: &quot;, info.start, &quot; ending at: &quot;, info.end);
+    m_context.addArguments(m_signature.arguments);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template&lt;typename Context&gt;
</span><span class="lines">@@ -101,7 +105,7 @@
</span><span class="cx">             return false;
</span><span class="cx"> 
</span><span class="cx">         if (verbose) {
</span><del>-            dataLogLn(&quot;processing op (&quot;, m_unreachableBlocks, &quot;): &quot;,  RawPointer(reinterpret_cast&lt;void*&gt;(op)));
</del><ins>+            dataLogLn(&quot;processing op (&quot;, m_unreachableBlocks, &quot;): &quot;,  RawPointer(reinterpret_cast&lt;void*&gt;(op)), &quot; at offset: &quot;, RawPointer(reinterpret_cast&lt;void*&gt;(m_offset)));
</ins><span class="cx">             m_context.dump(m_controlStack, m_expressionStack);
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -179,18 +183,30 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     case OpType::Block: {
</span><del>-        m_controlStack.append(m_context.addBlock());
</del><ins>+        Type inlineSignature;
+        if (!parseValueType(inlineSignature))
+            return false;
+
+        m_controlStack.append(m_context.addBlock(inlineSignature));
</ins><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     case OpType::Loop: {
</span><del>-        m_controlStack.append(m_context.addLoop());
</del><ins>+        Type inlineSignature;
+        if (!parseValueType(inlineSignature))
+            return false;
+
+        m_controlStack.append(m_context.addLoop(inlineSignature));
</ins><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     case OpType::If: {
</span><ins>+        Type inlineSignature;
+        if (!parseValueType(inlineSignature))
+            return false;
+
</ins><span class="cx">         ExpressionType condition = m_expressionStack.takeLast();
</span><del>-        m_controlStack.append(m_context.addIf(condition));
</del><ins>+        m_controlStack.append(m_context.addIf(condition, inlineSignature));
</ins><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -200,12 +216,8 @@
</span><span class="cx"> 
</span><span class="cx">     case OpType::Branch:
</span><span class="cx">     case OpType::BranchIf: {
</span><del>-        uint32_t arity;
-        if (!parseVarUInt32(arity) || arity &gt; m_expressionStack.size())
-            return false;
-
</del><span class="cx">         uint32_t target;
</span><del>-        if (!parseVarUInt32(target))
</del><ins>+        if (!parseVarUInt32(target) || target &gt;= m_controlStack.size())
</ins><span class="cx">             return false;
</span><span class="cx"> 
</span><span class="cx">         ExpressionType condition = Context::emptyExpression;
</span><span class="lines">@@ -214,23 +226,14 @@
</span><span class="cx">         else
</span><span class="cx">             m_unreachableBlocks = 1;
</span><span class="cx"> 
</span><del>-        Vector&lt;ExpressionType, 1&gt; values(arity);
-        for (unsigned i = arity; i; i--)
-            values[i-1] = m_expressionStack.takeLast();
-
-        if (target &gt;= m_controlStack.size())
-            return false;
</del><span class="cx">         ControlType&amp; data = m_controlStack[m_controlStack.size() - 1 - target];
</span><span class="cx"> 
</span><del>-        return m_context.addBranch(data, condition, values);
</del><ins>+        return m_context.addBranch(data, condition, m_expressionStack);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     case OpType::Return: {
</span><del>-        uint8_t returnCount;
-        if (!parseVarUInt1(returnCount))
-            return false;
</del><span class="cx">         Vector&lt;ExpressionType, 1&gt; returnValues;
</span><del>-        if (returnCount)
</del><ins>+        if (m_signature.returnType != Void)
</ins><span class="cx">             returnValues.append(m_expressionStack.takeLast());
</span><span class="cx"> 
</span><span class="cx">         m_unreachableBlocks = 1;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWASMModuleParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WASMModuleParser.cpp (206109 => 206110)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WASMModuleParser.cpp        2016-09-19 20:35:47 UTC (rev 206109)
+++ trunk/Source/JavaScriptCore/wasm/WASMModuleParser.cpp        2016-09-19 20:39:55 UTC (rev 206110)
</span><span class="lines">@@ -61,18 +61,33 @@
</span><span class="cx">     while (m_offset &lt; m_sourceLength) {
</span><span class="cx">         if (verbose)
</span><span class="cx">             dataLogLn(&quot;Starting to parse next section at offset: &quot;, m_offset);
</span><del>-        uint32_t sectionNameLength;
-        if (!parseVarUInt32(sectionNameLength))
-            return false;
</del><span class="cx"> 
</span><del>-        // Make sure we can read up to the section's size.
-        if (m_offset + sectionNameLength + maxLEBByteLength &gt;= m_sourceLength)
</del><ins>+        Sections::Section section = Sections::Unknown;
+        uint8_t sectionByte;
+        if (!parseUInt7(sectionByte))
</ins><span class="cx">             return false;
</span><span class="cx"> 
</span><del>-        Sections::Section section = Sections::lookup(m_source.data() + m_offset, sectionNameLength);
</del><ins>+        if (sectionByte) {
+            if (sectionByte &gt;= Sections::Unknown)
+                section = Sections::Unknown;
+            else
+                section = static_cast&lt;Sections::Section&gt;(sectionByte);
+        } else {
+            uint32_t sectionNameLength;
+            if (!parseVarUInt32(sectionNameLength))
+                return false;
+
+            // Make sure we can read up to the section's size.
+            if (m_offset + sectionNameLength + maxLEBByteLength &gt;= m_sourceLength)
+                return false;
+
+            // We don't support any custom sections yet.
+
+            m_offset += sectionNameLength;
+        }
+
</ins><span class="cx">         if (!Sections::validateOrder(previousSection, section))
</span><span class="cx">             return false;
</span><del>-        m_offset += sectionNameLength;
</del><span class="cx"> 
</span><span class="cx">         uint32_t sectionLength;
</span><span class="cx">         if (!parseVarUInt32(sectionLength))
</span><span class="lines">@@ -81,9 +96,6 @@
</span><span class="cx">         unsigned end = m_offset + sectionLength;
</span><span class="cx"> 
</span><span class="cx">         switch (section) {
</span><del>-        case Sections::End:
-            return true;
-
</del><span class="cx">         case Sections::FunctionTypes: {
</span><span class="cx">             if (verbose)
</span><span class="cx">                 dataLogLn(&quot;Parsing types.&quot;);
</span><span class="lines">@@ -108,7 +120,9 @@
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        case Sections::Unknown: {
</del><ins>+        case Sections::Unknown:
+        // FIXME: Delete this when we support all the sections.
+        default: {
</ins><span class="cx">             if (verbose)
</span><span class="cx">                 dataLogLn(&quot;Unknown section, skipping.&quot;);
</span><span class="cx">             m_offset += sectionLength;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWASMSectionscpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/JavaScriptCore/wasm/WASMSections.cpp (206109 => 206110)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WASMSections.cpp        2016-09-19 20:35:47 UTC (rev 206109)
+++ trunk/Source/JavaScriptCore/wasm/WASMSections.cpp        2016-09-19 20:39:55 UTC (rev 206110)
</span><span class="lines">@@ -1,65 +0,0 @@
</span><del>-/*
- * Copyright (C) 2016 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include &quot;config.h&quot;
-#include &quot;WASMSections.h&quot;
-
-#if ENABLE(WEBASSEMBLY)
-
-#include &lt;wtf/DataLog.h&gt;
-#include &lt;wtf/text/WTFString.h&gt;
-
-namespace JSC { namespace WASM {
-
-struct SectionData {
-    unsigned length;
-    const char* name;
-};
-
-static const bool verbose = false;
-
-static const unsigned sectionDataLength = static_cast&lt;unsigned&gt;(Sections::Unknown);
-static const SectionData sectionData[sectionDataLength] {
-#define CREATE_SECTION_DATA(name, str) { sizeof(str) - 1, str },
-    FOR_EACH_WASM_SECTION_TYPE(CREATE_SECTION_DATA)
-#undef CREATE_SECTION_DATA
-};
-
-Sections::Section Sections::lookup(const uint8_t* name, unsigned length)
-{
-    if (verbose)
-        dataLogLn(&quot;Decoding section with name: &quot;, String(name, length));
-    for (unsigned i = 0; i &lt; sectionDataLength; ++i) {
-        if (sectionData[i].length != length)
-            continue;
-        if (!memcmp(name, sectionData[i].name, length))
-            return static_cast&lt;Sections::Section&gt;(i);
-    }
-    return Sections::Unknown;
-}
-
-} } // namespace JSC::WASM
-
-#endif // ENABLE(WEBASSEMBLY)
</del></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWASMSectionsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WASMSections.h (206109 => 206110)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WASMSections.h        2016-09-19 20:35:47 UTC (rev 206109)
+++ trunk/Source/JavaScriptCore/wasm/WASMSections.h        2016-09-19 20:39:55 UTC (rev 206110)
</span><span class="lines">@@ -29,25 +29,15 @@
</span><span class="cx"> 
</span><span class="cx"> namespace JSC { namespace WASM {
</span><span class="cx"> 
</span><del>-// These should be in the order that we expect them to be in the binary.
-#define FOR_EACH_WASM_SECTION_TYPE(macro) \
-    macro(FunctionTypes, &quot;type&quot;) \
-    macro(Signatures, &quot;function&quot;) \
-    macro(Definitions, &quot;code&quot;) \
-    macro(End, &quot;end&quot;)
-
</del><span class="cx"> struct Sections {
</span><del>-    enum Section {
-#define CREATE_SECTION_ENUM(name, str) name,
-        FOR_EACH_WASM_SECTION_TYPE(CREATE_SECTION_ENUM)
-#undef CREATE_SECTION_ENUM
</del><ins>+    enum Section : uint8_t {
+        FunctionTypes = 1,
+        Signatures = 3,
+        Definitions = 10,
</ins><span class="cx">         Unknown
</span><span class="cx">     };
</span><del>-    static Section lookup(const uint8_t*, unsigned);
</del><span class="cx">     static bool validateOrder(Section previous, Section next)
</span><span class="cx">     {
</span><del>-        // This allows unknown sections after End, which I doubt will ever be supported but
-        // there is no reason to potentially break backwards compatability.
</del><span class="cx">         if (previous == Unknown)
</span><span class="cx">             return true;
</span><span class="cx">         return previous &lt; next;
</span></span></pre>
</div>
</div>

</body>
</html>