<!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>[207825] trunk</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/207825">207825</a></dd>
<dt>Author</dt> <dd>jfbastien@apple.com</dd>
<dt>Date</dt> <dd>2016-10-25 10:23:53 -0700 (Tue, 25 Oct 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>WebAssembly JS API: implement Module

This implementation allows us to:
 - Syncrhonously create a WebAssembly.Module with a typed array.
 - Creates a compilation plan.
 - Parse the Module and creates corresponding code.
 - Throw WebAssembly.CompileError with mildly helpful [*] error messages on
   failure.

Consult the API documentation for expected behavior: https://github.com/WebAssembly/design/blob/master/JS.md#webassemblymodule-constructor

For now the implementation discards the generated code.

The next steps will be:
 - Expose a Module's exports.
 - Implement WebAssembly.Instance, which allows instantiating and running a
   compiled Module.
 - Beef up the testing infrastructure under JSTests/wasm so that more complex
   modules can be created and tested (instead of writing the bits by hand).

This patch also:
 - Adds assert.instanceof in assert.js.
 - Refactors Wasm::Parser and friends to accept const uint8_t* as well as a
   Vector, to avoid copying when invoked synchronously.
 - Remove useless Structure from some of the wasm constructors: they're already
   on the JSGlobalObject, visited properly and all.
 - Fix off-by-one error in parsing: Parser::parseUInt32 failed if the integer
   was exactly at end of file.

 [*] On error messages while parsing: I filed https://bugs.webkit.org/show_bug.cgi?id=163919

WebAssembly JS API: implement Module
https://bugs.webkit.org/show_bug.cgi?id=163903

Reviewed by Keith Miller.

JSTests:

* wasm/assert.js: use underscore in name, and remove when exporting to avoid clasing with builtin names
(const._notUndef):
(const._isUndef):
(const._eq):
(const._ge):
(const._throws):
* wasm/js-api/test_basic_api.js: test the WebAssembly.Module API
(const.c.in.constructorProperties.switch):

Source/JavaScriptCore:

* runtime/ExceptionHelpers.cpp:
(JSC::defaultSourceAppender): make this public so that WebAssembly can use it: it generates those fancy (evaluating '...') messages at the end
* runtime/ExceptionHelpers.h:
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init): remove the useless Structure from the WebAssembly objects (it's already in this file, no need to hold two references and visit them twice)
* testWasm.cpp:
(runWasmTests): update API
* wasm/WasmB3IRGenerator.cpp:
(JSC::Wasm::parseAndCompile): use updated API
* wasm/WasmB3IRGenerator.h:
* wasm/WasmFunctionParser.h:
(JSC::Wasm::FunctionParser&lt;Context&gt;::FunctionParser): use updated API
(JSC::Wasm::FunctionParser&lt;Context&gt;::parseExpression): use updated API
* wasm/WasmModuleParser.cpp:
(JSC::Wasm::ModuleParser::parse): generate error messages
* wasm/WasmModuleParser.h:
(JSC::Wasm::ModuleParser::ModuleParser):
(JSC::Wasm::ModuleParser::failed):
(JSC::Wasm::ModuleParser::errorMessage):
(JSC::Wasm::ModuleParser::functionInformation):
(JSC::Wasm::ModuleParser::memory):
* wasm/WasmParser.h: use update non-public API
(JSC::Wasm::Parser::parseVarUInt32):
(JSC::Wasm::Parser::parseVarUInt64):
(JSC::Wasm::Parser::source):
(JSC::Wasm::Parser::length):
(JSC::Wasm::Parser::Parser):
(JSC::Wasm::Parser::consumeCharacter):
(JSC::Wasm::Parser::consumeString):
(JSC::Wasm::Parser::parseUInt32):
(JSC::Wasm::Parser::parseUInt7):
* wasm/WasmPlan.cpp:
(JSC::Wasm::Plan::Plan):
(JSC::Wasm::Plan::~Plan):
* wasm/WasmPlan.h:
(JSC::Wasm::Plan::failed):
(JSC::Wasm::Plan::errorMessage):
(JSC::Wasm::Plan::resultSize):
(JSC::Wasm::Plan::result):
(JSC::Wasm::Plan::memory):
* wasm/js/JSWebAssemblyCompileError.cpp:
(JSC::createWebAssemblyCompileError): makes it easier to throw a WebAssembly.CompileError from Module
* wasm/js/JSWebAssemblyCompileError.h:
* wasm/js/WebAssemblyCompileErrorConstructor.cpp:
(JSC::WebAssemblyCompileErrorConstructor::create):
(JSC::WebAssemblyCompileErrorConstructor::finishCreation):
* wasm/js/WebAssemblyCompileErrorConstructor.h:
* wasm/js/WebAssemblyInstanceConstructor.cpp:
(JSC::WebAssemblyInstanceConstructor::create):
(JSC::WebAssemblyInstanceConstructor::finishCreation):
(JSC::WebAssemblyInstanceConstructor::visitChildren):
* wasm/js/WebAssemblyInstanceConstructor.h:
* wasm/js/WebAssemblyMemoryConstructor.cpp:
(JSC::WebAssemblyMemoryConstructor::create):
(JSC::WebAssemblyMemoryConstructor::finishCreation):
(JSC::WebAssemblyMemoryConstructor::visitChildren):
* wasm/js/WebAssemblyMemoryConstructor.h:
* wasm/js/WebAssemblyModuleConstructor.cpp:
(JSC::constructJSWebAssemblyModule):
(JSC::WebAssemblyModuleConstructor::create):
(JSC::WebAssemblyModuleConstructor::finishCreation):
(JSC::WebAssemblyModuleConstructor::visitChildren):
* wasm/js/WebAssemblyModuleConstructor.h:
* wasm/js/WebAssemblyRuntimeErrorConstructor.cpp:
(JSC::WebAssemblyRuntimeErrorConstructor::create):
(JSC::WebAssemblyRuntimeErrorConstructor::finishCreation):
* wasm/js/WebAssemblyRuntimeErrorConstructor.h:
* wasm/js/WebAssemblyTableConstructor.cpp:
(JSC::WebAssemblyTableConstructor::create):
(JSC::WebAssemblyTableConstructor::finishCreation):
(JSC::WebAssemblyTableConstructor::visitChildren):
* wasm/js/WebAssemblyTableConstructor.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkJSTestsChangeLog">trunk/JSTests/ChangeLog</a></li>
<li><a href="#trunkJSTestswasmassertjs">trunk/JSTests/wasm/assert.js</a></li>
<li><a href="#trunkJSTestswasmjsapitest_basic_apijs">trunk/JSTests/wasm/js-api/test_basic_api.js</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeExceptionHelperscpp">trunk/Source/JavaScriptCore/runtime/ExceptionHelpers.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeExceptionHelpersh">trunk/Source/JavaScriptCore/runtime/ExceptionHelpers.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSGlobalObjectcpp">trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp</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="#trunkSourceJavaScriptCorewasmWasmB3IRGeneratorh">trunk/Source/JavaScriptCore/wasm/WasmB3IRGenerator.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="#trunkSourceJavaScriptCorewasmWasmModuleParserh">trunk/Source/JavaScriptCore/wasm/WasmModuleParser.h</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmWasmParserh">trunk/Source/JavaScriptCore/wasm/WasmParser.h</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmWasmPlancpp">trunk/Source/JavaScriptCore/wasm/WasmPlan.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmWasmPlanh">trunk/Source/JavaScriptCore/wasm/WasmPlan.h</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsJSWebAssemblyCompileErrorcpp">trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyCompileError.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsJSWebAssemblyCompileErrorh">trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyCompileError.h</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsWebAssemblyCompileErrorConstructorcpp">trunk/Source/JavaScriptCore/wasm/js/WebAssemblyCompileErrorConstructor.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsWebAssemblyCompileErrorConstructorh">trunk/Source/JavaScriptCore/wasm/js/WebAssemblyCompileErrorConstructor.h</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsWebAssemblyInstanceConstructorcpp">trunk/Source/JavaScriptCore/wasm/js/WebAssemblyInstanceConstructor.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsWebAssemblyInstanceConstructorh">trunk/Source/JavaScriptCore/wasm/js/WebAssemblyInstanceConstructor.h</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsWebAssemblyMemoryConstructorcpp">trunk/Source/JavaScriptCore/wasm/js/WebAssemblyMemoryConstructor.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsWebAssemblyMemoryConstructorh">trunk/Source/JavaScriptCore/wasm/js/WebAssemblyMemoryConstructor.h</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsWebAssemblyModuleConstructorcpp">trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleConstructor.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsWebAssemblyModuleConstructorh">trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleConstructor.h</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsWebAssemblyRuntimeErrorConstructorcpp">trunk/Source/JavaScriptCore/wasm/js/WebAssemblyRuntimeErrorConstructor.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsWebAssemblyRuntimeErrorConstructorh">trunk/Source/JavaScriptCore/wasm/js/WebAssemblyRuntimeErrorConstructor.h</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsWebAssemblyTableConstructorcpp">trunk/Source/JavaScriptCore/wasm/js/WebAssemblyTableConstructor.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsWebAssemblyTableConstructorh">trunk/Source/JavaScriptCore/wasm/js/WebAssemblyTableConstructor.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkJSTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/ChangeLog (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/ChangeLog        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/JSTests/ChangeLog        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -1,3 +1,50 @@
</span><ins>+2016-10-25  JF Bastien  &lt;jfbastien@apple.com&gt;
+
+        WebAssembly JS API: implement Module
+
+        This implementation allows us to:
+         - Syncrhonously create a WebAssembly.Module with a typed array.
+         - Creates a compilation plan.
+         - Parse the Module and creates corresponding code.
+         - Throw WebAssembly.CompileError with mildly helpful [*] error messages on
+           failure.
+
+        Consult the API documentation for expected behavior: https://github.com/WebAssembly/design/blob/master/JS.md#webassemblymodule-constructor
+
+        For now the implementation discards the generated code.
+
+        The next steps will be:
+         - Expose a Module's exports.
+         - Implement WebAssembly.Instance, which allows instantiating and running a
+           compiled Module.
+         - Beef up the testing infrastructure under JSTests/wasm so that more complex
+           modules can be created and tested (instead of writing the bits by hand).
+
+        This patch also:
+         - Adds assert.instanceof in assert.js.
+         - Refactors Wasm::Parser and friends to accept const uint8_t* as well as a
+           Vector, to avoid copying when invoked synchronously.
+         - Remove useless Structure from some of the wasm constructors: they're already
+           on the JSGlobalObject, visited properly and all.
+         - Fix off-by-one error in parsing: Parser::parseUInt32 failed if the integer
+           was exactly at end of file.
+
+         [*] On error messages while parsing: I filed https://bugs.webkit.org/show_bug.cgi?id=163919
+
+        WebAssembly JS API: implement Module
+        https://bugs.webkit.org/show_bug.cgi?id=163903
+
+        Reviewed by Keith Miller.
+
+        * wasm/assert.js: use underscore in name, and remove when exporting to avoid clasing with builtin names
+        (const._notUndef):
+        (const._isUndef):
+        (const._eq):
+        (const._ge):
+        (const._throws):
+        * wasm/js-api/test_basic_api.js: test the WebAssembly.Module API
+        (const.c.in.constructorProperties.switch):
+
</ins><span class="cx"> 2016-10-25  Keith Miller  &lt;keith_miller@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Add trivial Wasm conversion opcodes
</span></span></pre></div>
<a id="trunkJSTestswasmassertjs"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/wasm/assert.js (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/wasm/assert.js        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/JSTests/wasm/assert.js        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -23,29 +23,29 @@
</span><span class="cx">  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</span><span class="cx">  */
</span><span class="cx"> 
</span><del>-export const notUndef = (v) =&gt; {
</del><ins>+const _notUndef = (v) =&gt; {
</ins><span class="cx">     if (typeof v === &quot;undefined&quot;)
</span><span class="cx">         throw new Error(&quot;Shouldn't be undefined&quot;);
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-export const isUndef = (v) =&gt; {
</del><ins>+const _isUndef = (v) =&gt; {
</ins><span class="cx">     if (typeof v !== &quot;undefined&quot;)
</span><span class="cx">         throw new Error(&quot;Should be undefined&quot;);
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-export const eq = (lhs, rhs) =&gt; {
</del><ins>+const _eq = (lhs, rhs) =&gt; {
</ins><span class="cx">     if (lhs !== rhs)
</span><span class="cx">         throw new Error(`Not the same: &quot;${lhs}&quot; and &quot;${rhs}&quot;`);
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-export const ge = (lhs, rhs) =&gt; {
-    notUndef(lhs);
-    notUndef(rhs);
</del><ins>+const _ge = (lhs, rhs) =&gt; {
+    _notUndef(lhs);
+    _notUndef(rhs);
</ins><span class="cx">     if (!(lhs &gt;= rhs))
</span><span class="cx">         throw new Error(`Expected: &quot;${lhs}&quot; &lt; &quot;${rhs}&quot;`);
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-export const throws = (func, type, message, ...args) =&gt; {
</del><ins>+const _throws = (func, type, message, ...args) =&gt; {
</ins><span class="cx">     try {
</span><span class="cx">         func(...args);
</span><span class="cx">     } catch (e) {
</span><span class="lines">@@ -55,3 +55,15 @@
</span><span class="cx">     }
</span><span class="cx">     throw new Error(`Expected to throw a ${type.name} with message &quot;${message}&quot;`);
</span><span class="cx"> };
</span><ins>+
+const _instanceof = (obj, type) =&gt; obj instanceof type;
+
+// Use underscore names to avoid clashing with builtin names.
+export {
+    _notUndef as notUndef,
+    _isUndef as isUndef,
+    _eq as eq,
+    _ge as ge,
+    _throws as throws,
+    _instanceof as instanceof,
+};
</ins></span></pre></div>
<a id="trunkJSTestswasmjsapitest_basic_apijs"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/wasm/js-api/test_basic_api.js (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/wasm/js-api/test_basic_api.js        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/JSTests/wasm/js-api/test_basic_api.js        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -1,6 +1,9 @@
</span><span class="cx"> import * as assert from '../assert.js';
</span><span class="cx"> import * as utilities from '../utilities.js';
</span><span class="cx"> 
</span><ins>+const version = 0xC;
+const emptyModule = Uint8Array.of(0x0, 0x61, 0x73, 0x6d, version, 0x00, 0x00, 0x00);
+
</ins><span class="cx"> const checkOwnPropertyDescriptor = (obj, prop, expect) =&gt; {
</span><span class="cx">     const descriptor = Object.getOwnPropertyDescriptor(obj, prop);
</span><span class="cx">     assert.eq(typeof descriptor.value, expect.typeofvalue);
</span><span class="lines">@@ -14,12 +17,12 @@
</span><span class="cx">     &quot;compile&quot;:  { length: 1 },
</span><span class="cx"> };
</span><span class="cx"> const constructorProperties = {
</span><del>-    &quot;Module&quot;:       { typeofvalue: &quot;function&quot;, writable: true, configurable: true, enumerable: false, length: 1, isError: false },
-    &quot;Instance&quot;:     { typeofvalue: &quot;function&quot;, writable: true, configurable: true, enumerable: false, length: 1, isError: false },
-    &quot;Memory&quot;:       { typeofvalue: &quot;function&quot;, writable: true, configurable: true, enumerable: false, length: 1, isError: false },
-    &quot;Table&quot;:        { typeofvalue: &quot;function&quot;, writable: true, configurable: true, enumerable: false, length: 1, isError: false },
-    &quot;CompileError&quot;: { typeofvalue: &quot;function&quot;, writable: true, configurable: true, enumerable: false, length: 1, isError: true  },
-    &quot;RuntimeError&quot;: { typeofvalue: &quot;function&quot;, writable: true, configurable: true, enumerable: false, length: 1, isError: true  },
</del><ins>+    &quot;Module&quot;:       { typeofvalue: &quot;function&quot;, writable: true, configurable: true, enumerable: false, length: 1 },
+    &quot;Instance&quot;:     { typeofvalue: &quot;function&quot;, writable: true, configurable: true, enumerable: false, length: 1 },
+    &quot;Memory&quot;:       { typeofvalue: &quot;function&quot;, writable: true, configurable: true, enumerable: false, length: 1 },
+    &quot;Table&quot;:        { typeofvalue: &quot;function&quot;, writable: true, configurable: true, enumerable: false, length: 1 },
+    &quot;CompileError&quot;: { typeofvalue: &quot;function&quot;, writable: true, configurable: true, enumerable: false, length: 1 },
+    &quot;RuntimeError&quot;: { typeofvalue: &quot;function&quot;, writable: true, configurable: true, enumerable: false, length: 1 },
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -44,7 +47,30 @@
</span><span class="cx">     checkOwnPropertyDescriptor(WebAssembly, c, constructorProperties[c]);
</span><span class="cx">     checkOwnPropertyDescriptor(WebAssembly[c], &quot;prototype&quot;, { typeofvalue: &quot;object&quot;, writable: false, configurable: false, enumerable: false });
</span><span class="cx">     assert.throws(() =&gt; WebAssembly[c](), TypeError, `calling WebAssembly.${c} constructor without new is invalid`);
</span><del>-    if (constructorProperties[c].isError) {
</del><ins>+    switch (c) {
+    case &quot;Module&quot;:
+        for (const invalid of [undefined, &quot;&quot;, 1, {}, []])
+            assert.throws(() =&gt; new WebAssembly[c](invalid), TypeError, `first argument to WebAssembly.Module must be an ArrayBufferView or an ArrayBuffer (evaluating 'new WebAssembly[c](invalid)')`);
+        for (const buffer of [new ArrayBuffer(), new DataView(new ArrayBuffer()), new Int8Array(), new Uint8Array(), new Uint8ClampedArray(), new Int16Array(), new Uint16Array(), new Int32Array(), new Uint32Array(), new Float32Array(), new Float64Array()])
+            // FIXME the following should be WebAssembly.CompileError. https://bugs.webkit.org/show_bug.cgi?id=163768
+            assert.throws(() =&gt; new WebAssembly[c](buffer), Error, `Module is 0 bytes, expected at least 8 bytes (evaluating 'new WebAssembly[c](buffer)')`);
+        assert.instanceof(new WebAssembly[c](emptyModule), WebAssembly.Module);
+        // FIXME test neutered TypedArray and TypedArrayView. https://bugs.webkit.org/show_bug.cgi?id=163899
+        break;
+    case &quot;Instance&quot;:
+        // FIXME Implement and test these APIs further. For now they just throw. https://bugs.webkit.org/show_bug.cgi?id=159775
+        assert.throws(() =&gt; new WebAssembly[c](), Error, `WebAssembly doesn't yet implement the ${c} constructor property`);
+        break;
+    case &quot;Memory&quot;:
+        // FIXME Implement and test these APIs further. For now they just throw. https://bugs.webkit.org/show_bug.cgi?id=159775
+        assert.throws(() =&gt; new WebAssembly[c](), Error, `WebAssembly doesn't yet implement the ${c} constructor property`);
+        break;
+    case &quot;Table&quot;:
+        // FIXME Implement and test these APIs further. For now they just throw. https://bugs.webkit.org/show_bug.cgi?id=159775
+        assert.throws(() =&gt; new WebAssembly[c](), Error, `WebAssembly doesn't yet implement the ${c} constructor property`);
+        break;
+    case &quot;CompileError&quot;:
+    case &quot;RuntimeError&quot;: {
</ins><span class="cx">         const e = new WebAssembly[c];
</span><span class="cx">         assert.eq(e instanceof WebAssembly[c], true);
</span><span class="cx">         assert.eq(e instanceof Error, true);
</span><span class="lines">@@ -54,16 +80,12 @@
</span><span class="cx">         const sillyString = &quot;uh-oh!&quot;;
</span><span class="cx">         const e2 = new WebAssembly[c](sillyString);
</span><span class="cx">         assert.eq(e2.message, sillyString);
</span><ins>+    } break;
+    default: throw new Error(`Implementation error: unexpected constructor property &quot;${c}&quot;`);
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // FIXME Implement and test these APIs further. For now they just throw. https://bugs.webkit.org/show_bug.cgi?id=159775
</span><del>-
</del><span class="cx"> for (const f in functionProperties) {
</span><span class="cx">     assert.throws(() =&gt; WebAssembly[f](), Error, `WebAssembly doesn't yet implement the ${f} function property`);
</span><span class="cx"> }
</span><del>-
-for (const c in constructorProperties) {
-    if (!constructorProperties[c].isError)
-        assert.throws(() =&gt; new WebAssembly[c](), Error, `WebAssembly doesn't yet implement the ${c} constructor property`);
-}
</del></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -1,3 +1,114 @@
</span><ins>+2016-10-25  JF Bastien  &lt;jfbastien@apple.com&gt;
+
+        WebAssembly JS API: implement Module
+
+        This implementation allows us to:
+         - Syncrhonously create a WebAssembly.Module with a typed array.
+         - Creates a compilation plan.
+         - Parse the Module and creates corresponding code.
+         - Throw WebAssembly.CompileError with mildly helpful [*] error messages on
+           failure.
+
+        Consult the API documentation for expected behavior: https://github.com/WebAssembly/design/blob/master/JS.md#webassemblymodule-constructor
+
+        For now the implementation discards the generated code.
+
+        The next steps will be:
+         - Expose a Module's exports.
+         - Implement WebAssembly.Instance, which allows instantiating and running a
+           compiled Module.
+         - Beef up the testing infrastructure under JSTests/wasm so that more complex
+           modules can be created and tested (instead of writing the bits by hand).
+
+        This patch also:
+         - Adds assert.instanceof in assert.js.
+         - Refactors Wasm::Parser and friends to accept const uint8_t* as well as a
+           Vector, to avoid copying when invoked synchronously.
+         - Remove useless Structure from some of the wasm constructors: they're already
+           on the JSGlobalObject, visited properly and all.
+         - Fix off-by-one error in parsing: Parser::parseUInt32 failed if the integer
+           was exactly at end of file.
+
+         [*] On error messages while parsing: I filed https://bugs.webkit.org/show_bug.cgi?id=163919
+
+        WebAssembly JS API: implement Module
+        https://bugs.webkit.org/show_bug.cgi?id=163903
+
+        Reviewed by Keith Miller.
+
+        * runtime/ExceptionHelpers.cpp:
+        (JSC::defaultSourceAppender): make this public so that WebAssembly can use it: it generates those fancy (evaluating '...') messages at the end
+        * runtime/ExceptionHelpers.h:
+        * runtime/JSGlobalObject.cpp:
+        (JSC::JSGlobalObject::init): remove the useless Structure from the WebAssembly objects (it's already in this file, no need to hold two references and visit them twice)
+        * testWasm.cpp:
+        (runWasmTests): update API
+        * wasm/WasmB3IRGenerator.cpp:
+        (JSC::Wasm::parseAndCompile): use updated API
+        * wasm/WasmB3IRGenerator.h:
+        * wasm/WasmFunctionParser.h:
+        (JSC::Wasm::FunctionParser&lt;Context&gt;::FunctionParser): use updated API
+        (JSC::Wasm::FunctionParser&lt;Context&gt;::parseExpression): use updated API
+        * wasm/WasmModuleParser.cpp:
+        (JSC::Wasm::ModuleParser::parse): generate error messages
+        * wasm/WasmModuleParser.h:
+        (JSC::Wasm::ModuleParser::ModuleParser):
+        (JSC::Wasm::ModuleParser::failed):
+        (JSC::Wasm::ModuleParser::errorMessage):
+        (JSC::Wasm::ModuleParser::functionInformation):
+        (JSC::Wasm::ModuleParser::memory):
+        * wasm/WasmParser.h: use update non-public API
+        (JSC::Wasm::Parser::parseVarUInt32):
+        (JSC::Wasm::Parser::parseVarUInt64):
+        (JSC::Wasm::Parser::source):
+        (JSC::Wasm::Parser::length):
+        (JSC::Wasm::Parser::Parser):
+        (JSC::Wasm::Parser::consumeCharacter):
+        (JSC::Wasm::Parser::consumeString):
+        (JSC::Wasm::Parser::parseUInt32):
+        (JSC::Wasm::Parser::parseUInt7):
+        * wasm/WasmPlan.cpp:
+        (JSC::Wasm::Plan::Plan):
+        (JSC::Wasm::Plan::~Plan):
+        * wasm/WasmPlan.h:
+        (JSC::Wasm::Plan::failed):
+        (JSC::Wasm::Plan::errorMessage):
+        (JSC::Wasm::Plan::resultSize):
+        (JSC::Wasm::Plan::result):
+        (JSC::Wasm::Plan::memory):
+        * wasm/js/JSWebAssemblyCompileError.cpp:
+        (JSC::createWebAssemblyCompileError): makes it easier to throw a WebAssembly.CompileError from Module
+        * wasm/js/JSWebAssemblyCompileError.h:
+        * wasm/js/WebAssemblyCompileErrorConstructor.cpp:
+        (JSC::WebAssemblyCompileErrorConstructor::create):
+        (JSC::WebAssemblyCompileErrorConstructor::finishCreation):
+        * wasm/js/WebAssemblyCompileErrorConstructor.h:
+        * wasm/js/WebAssemblyInstanceConstructor.cpp:
+        (JSC::WebAssemblyInstanceConstructor::create):
+        (JSC::WebAssemblyInstanceConstructor::finishCreation):
+        (JSC::WebAssemblyInstanceConstructor::visitChildren):
+        * wasm/js/WebAssemblyInstanceConstructor.h:
+        * wasm/js/WebAssemblyMemoryConstructor.cpp:
+        (JSC::WebAssemblyMemoryConstructor::create):
+        (JSC::WebAssemblyMemoryConstructor::finishCreation):
+        (JSC::WebAssemblyMemoryConstructor::visitChildren):
+        * wasm/js/WebAssemblyMemoryConstructor.h:
+        * wasm/js/WebAssemblyModuleConstructor.cpp:
+        (JSC::constructJSWebAssemblyModule):
+        (JSC::WebAssemblyModuleConstructor::create):
+        (JSC::WebAssemblyModuleConstructor::finishCreation):
+        (JSC::WebAssemblyModuleConstructor::visitChildren):
+        * wasm/js/WebAssemblyModuleConstructor.h:
+        * wasm/js/WebAssemblyRuntimeErrorConstructor.cpp:
+        (JSC::WebAssemblyRuntimeErrorConstructor::create):
+        (JSC::WebAssemblyRuntimeErrorConstructor::finishCreation):
+        * wasm/js/WebAssemblyRuntimeErrorConstructor.h:
+        * wasm/js/WebAssemblyTableConstructor.cpp:
+        (JSC::WebAssemblyTableConstructor::create):
+        (JSC::WebAssemblyTableConstructor::finishCreation):
+        (JSC::WebAssemblyTableConstructor::visitChildren):
+        * wasm/js/WebAssemblyTableConstructor.h:
+
</ins><span class="cx"> 2016-10-25  Keith Miller  &lt;keith_miller@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Add trivial Wasm conversion opcodes
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeExceptionHelperscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/ExceptionHelpers.cpp (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/ExceptionHelpers.cpp        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/runtime/ExceptionHelpers.cpp        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -101,7 +101,7 @@
</span><span class="cx">     return makeString(originalMessage, &quot; (near '...&quot;, sourceText, &quot;...')&quot;);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static String defaultSourceAppender(const String&amp; originalMessage, const String&amp; sourceText, RuntimeType, ErrorInstance::SourceTextWhereErrorOccurred occurrence)
</del><ins>+String defaultSourceAppender(const String&amp; originalMessage, const String&amp; sourceText, RuntimeType, ErrorInstance::SourceTextWhereErrorOccurred occurrence)
</ins><span class="cx"> {
</span><span class="cx">     if (occurrence == ErrorInstance::FoundApproximateSource)
</span><span class="cx">         return defaultApproximateSourceError(originalMessage, sourceText);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeExceptionHelpersh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/ExceptionHelpers.h (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/ExceptionHelpers.h        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/runtime/ExceptionHelpers.h        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -37,6 +37,8 @@
</span><span class="cx"> 
</span><span class="cx"> typedef JSObject* (*ErrorFactory)(ExecState*, const String&amp;, ErrorInstance::SourceAppender);
</span><span class="cx"> 
</span><ins>+String defaultSourceAppender(const String&amp;, const String&amp;, RuntimeType, ErrorInstance::SourceTextWhereErrorOccurred);
+
</ins><span class="cx"> JSObject* createTerminatedExecutionException(VM*);
</span><span class="cx"> JS_EXPORT_PRIVATE bool isTerminatedExecutionException(Exception*);
</span><span class="cx"> JS_EXPORT_PRIVATE JSObject* createError(ExecState*, JSValue, const String&amp;, ErrorInstance::SourceAppender);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSGlobalObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -832,7 +832,7 @@
</span><span class="cx">         auto* base = m_ ## prototypeBase ## Prototype.get(); \
</span><span class="cx">         auto* prototype = Prototype::create(vm, this, Prototype::createStructure(vm, this, base)); \
</span><span class="cx">         auto* structure = JSObj::createStructure(vm, this, prototype); \
</span><del>-        auto* constructor = Constructor::create(vm, Constructor::createStructure(vm, this, this-&gt;functionPrototype()), prototype, structure); \
</del><ins>+        auto* constructor = Constructor::create(vm, Constructor::createStructure(vm, this, this-&gt;functionPrototype()), prototype); \
</ins><span class="cx">         prototype-&gt;putDirectWithoutTransition(vm, vm.propertyNames-&gt;constructor, constructor, DontEnum); \
</span><span class="cx">         m_ ## lowerName ## Prototype.set(vm, this, prototype); \
</span><span class="cx">         m_ ## properName ## Structure.set(vm, this, structure); \
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretestWasmcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/testWasm.cpp (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/testWasm.cpp        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/testWasm.cpp        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -290,16 +290,16 @@
</span><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         Plan plan(*vm, vector);
</span><del>-        if (plan.result.size() != 2 || !plan.result[0] || !plan.result[1]) {
</del><ins>+        if (plan.failed() || plan.resultSize() != 2 || !plan.result(0) || !plan.result(1)) {
</ins><span class="cx">             dataLogLn(&quot;Module failed to compile correctly.&quot;);
</span><span class="cx">             CRASH();
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // Test this doesn't crash.
</span><del>-        CHECK(isIdentical(invoke&lt;float&gt;(*plan.result[1]-&gt;jsEntryPoint, { boxf(0.0), boxf(1.5) }), -1.5f));
-        CHECK(isIdentical(invoke&lt;float&gt;(*plan.result[1]-&gt;jsEntryPoint, { boxf(100.1234), boxf(12.5) }), 87.6234f));
-        CHECK(isIdentical(invoke&lt;float&gt;(*plan.result[0]-&gt;jsEntryPoint, { boxf(0.0), boxf(1.5) }), -1.5f));
-        CHECK(isIdentical(invoke&lt;float&gt;(*plan.result[0]-&gt;jsEntryPoint, { boxf(100.1234), boxf(12.5) }), 87.6234f));
</del><ins>+        CHECK(isIdentical(invoke&lt;float&gt;(*plan.result(1)-&gt;jsEntryPoint, { boxf(0.0), boxf(1.5) }), -1.5f));
+        CHECK(isIdentical(invoke&lt;float&gt;(*plan.result(1)-&gt;jsEntryPoint, { boxf(100.1234), boxf(12.5) }), 87.6234f));
+        CHECK(isIdentical(invoke&lt;float&gt;(*plan.result(0)-&gt;jsEntryPoint, { boxf(0.0), boxf(1.5) }), -1.5f));
+        CHECK(isIdentical(invoke&lt;float&gt;(*plan.result(0)-&gt;jsEntryPoint, { boxf(100.1234), boxf(12.5) }), 87.6234f));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     {
</span><span class="lines">@@ -319,16 +319,16 @@
</span><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         Plan plan(*vm, vector);
</span><del>-        if (plan.result.size() != 2 || !plan.result[0] || !plan.result[1]) {
</del><ins>+        if (plan.failed() || plan.resultSize() != 2 || !plan.result(0) || !plan.result(1)) {
</ins><span class="cx">             dataLogLn(&quot;Module failed to compile correctly.&quot;);
</span><span class="cx">             CRASH();
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // Test this doesn't crash.
</span><del>-        CHECK(isIdentical(invoke&lt;float&gt;(*plan.result[1]-&gt;jsEntryPoint, { boxf(0.0), boxf(1.5) }), 1.5f));
-        CHECK(isIdentical(invoke&lt;float&gt;(*plan.result[1]-&gt;jsEntryPoint, { boxf(100.1234), boxf(12.5) }), 112.6234f));
-        CHECK(isIdentical(invoke&lt;float&gt;(*plan.result[0]-&gt;jsEntryPoint, { boxf(0.0), boxf(1.5) }), 1.5f));
-        CHECK(isIdentical(invoke&lt;float&gt;(*plan.result[0]-&gt;jsEntryPoint, { boxf(100.1234), boxf(12.5) }), 112.6234f));
</del><ins>+        CHECK(isIdentical(invoke&lt;float&gt;(*plan.result(1)-&gt;jsEntryPoint, { boxf(0.0), boxf(1.5) }), 1.5f));
+        CHECK(isIdentical(invoke&lt;float&gt;(*plan.result(1)-&gt;jsEntryPoint, { boxf(100.1234), boxf(12.5) }), 112.6234f));
+        CHECK(isIdentical(invoke&lt;float&gt;(*plan.result(0)-&gt;jsEntryPoint, { boxf(0.0), boxf(1.5) }), 1.5f));
+        CHECK(isIdentical(invoke&lt;float&gt;(*plan.result(0)-&gt;jsEntryPoint, { boxf(100.1234), boxf(12.5) }), 112.6234f));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     {
</span><span class="lines">@@ -353,17 +353,17 @@
</span><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         Plan plan(*vm, vector);
</span><del>-        if (plan.result.size() != 2 || !plan.result[0] || !plan.result[1]) {
</del><ins>+        if (plan.failed() || plan.resultSize() != 2 || !plan.result(0) || !plan.result(1)) {
</ins><span class="cx">             dataLogLn(&quot;Module failed to compile correctly.&quot;);
</span><span class="cx">             CRASH();
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // Test this doesn't crash.
</span><del>-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[1]-&gt;jsEntryPoint, { box(0) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[1]-&gt;jsEntryPoint, { box(100) }), 1200);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[1]-&gt;jsEntryPoint, { box(1) }), 12);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(1), box(2), box(3), box(4), box(5), box(6), box(7), box(8), box(9), box(10), box(11), box(12) }), 78);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(1), box(2), box(3), box(4), box(5), box(6), box(7), box(8), box(9), box(10), box(11), box(100) }), 166);
</del><ins>+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(1)-&gt;jsEntryPoint, { box(0) }), 0);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(1)-&gt;jsEntryPoint, { box(100) }), 1200);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(1)-&gt;jsEntryPoint, { box(1) }), 12);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(1), box(2), box(3), box(4), box(5), box(6), box(7), box(8), box(9), box(10), box(11), box(12) }), 78);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(1), box(2), box(3), box(4), box(5), box(6), box(7), box(8), box(9), box(10), box(11), box(100) }), 166);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     {
</span><span class="lines">@@ -387,16 +387,16 @@
</span><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         Plan plan(*vm, vector);
</span><del>-        if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx">             dataLogLn(&quot;Module failed to compile correctly.&quot;);
</span><span class="cx">             CRASH();
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // Test this doesn't crash.
</span><del>-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(0) }), 1);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(1) }), 1);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(2) }), 2);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(4) }), 24);
</del><ins>+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(0) }), 1);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(1) }), 1);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(2) }), 2);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(4) }), 24);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     {
</span><span class="lines">@@ -416,18 +416,18 @@
</span><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         Plan plan(*vm, vector);
</span><del>-        if (plan.result.size() != 2 || !plan.result[0] || !plan.result[1]) {
</del><ins>+        if (plan.resultSize() != 2 || !plan.result(0) || !plan.result(1)) {
</ins><span class="cx">             dataLogLn(&quot;Module failed to compile correctly.&quot;);
</span><span class="cx">             CRASH();
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // Test this doesn't crash.
</span><del>-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[1]-&gt;jsEntryPoint, { box(0), box(0) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[1]-&gt;jsEntryPoint, { box(100), box(0) }), 100);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[1]-&gt;jsEntryPoint, { box(1), box(15) }), 16);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(0) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(100) }), 200);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(1) }), 2);
</del><ins>+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(1)-&gt;jsEntryPoint, { box(0), box(0) }), 0);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(1)-&gt;jsEntryPoint, { box(100), box(0) }), 100);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(1)-&gt;jsEntryPoint, { box(1), box(15) }), 16);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(0) }), 0);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(100) }), 200);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(1) }), 2);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     {
</span><span class="lines">@@ -447,18 +447,18 @@
</span><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         Plan plan(*vm, vector);
</span><del>-        if (plan.result.size() != 2 || !plan.result[0] || !plan.result[1]) {
</del><ins>+        if (plan.failed() || plan.resultSize() != 2 || !plan.result(0) || !plan.result(1)) {
</ins><span class="cx">             dataLogLn(&quot;Module failed to compile correctly.&quot;);
</span><span class="cx">             CRASH();
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // Test this doesn't crash.
</span><del>-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[1]-&gt;jsEntryPoint, { box(0) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[1]-&gt;jsEntryPoint, { box(100) }), 100);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[1]-&gt;jsEntryPoint, { box(1) }), 1);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(0) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(100) }), 100);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(1) }), 1);
</del><ins>+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(1)-&gt;jsEntryPoint, { box(0) }), 0);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(1)-&gt;jsEntryPoint, { box(100) }), 100);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(1)-&gt;jsEntryPoint, { box(1) }), 1);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(0) }), 0);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(100) }), 100);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(1) }), 1);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     {
</span><span class="lines">@@ -480,15 +480,15 @@
</span><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         Plan plan(*vm, vector);
</span><del>-        if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx">             dataLogLn(&quot;Module failed to compile correctly.&quot;);
</span><span class="cx">             CRASH();
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // Test this doesn't crash.
</span><del>-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(0), box(10) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(100), box(2) }), 100);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(1), box(100) }), 1);
</del><ins>+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(0), box(10) }), 0);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(100), box(2) }), 100);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(1), box(100) }), 1);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     {
</span><span class="lines">@@ -510,15 +510,15 @@
</span><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         Plan plan(*vm, vector);
</span><del>-        if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx">             dataLogLn(&quot;Module failed to compile correctly.&quot;);
</span><span class="cx">             CRASH();
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // Test this doesn't crash.
</span><del>-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(0), box(10) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(100), box(2) }), 100);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(1), box(100) }), 1);
</del><ins>+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(0), box(10) }), 0);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(100), box(2) }), 100);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(1), box(100) }), 1);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     {
</span><span class="lines">@@ -550,17 +550,17 @@
</span><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         Plan plan(*vm, vector);
</span><del>-        if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx">             dataLogLn(&quot;Module failed to compile correctly.&quot;);
</span><span class="cx">             CRASH();
</span><span class="cx">         }
</span><del>-        ASSERT(plan.memory-&gt;size());
</del><ins>+        ASSERT(plan.memory()-&gt;size());
</ins><span class="cx"> 
</span><span class="cx">         // Test this doesn't crash.
</span><span class="cx">         unsigned length = 5;
</span><span class="cx">         unsigned offset = sizeof(uint32_t);
</span><del>-        uint32_t* memory = static_cast&lt;uint32_t*&gt;(plan.memory-&gt;memory());
-        invoke&lt;void&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(100), box(offset), box(length) });
</del><ins>+        uint32_t* memory = static_cast&lt;uint32_t*&gt;(plan.memory()-&gt;memory());
+        invoke&lt;void&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(100), box(offset), box(length) });
</ins><span class="cx">         offset /= sizeof(uint32_t);
</span><span class="cx">         CHECK_EQ(memory[offset - 1], 0u);
</span><span class="cx">         CHECK_EQ(memory[offset + length], 0u);
</span><span class="lines">@@ -569,7 +569,7 @@
</span><span class="cx"> 
</span><span class="cx">         length = 10;
</span><span class="cx">         offset = 5 * sizeof(uint32_t);
</span><del>-        invoke&lt;void&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(5), box(offset), box(length) });
</del><ins>+        invoke&lt;void&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(5), box(offset), box(length) });
</ins><span class="cx">         offset /= sizeof(uint32_t);
</span><span class="cx">         CHECK_EQ(memory[offset - 1], 100u);
</span><span class="cx">         CHECK_EQ(memory[offset + length], 0u);
</span><span class="lines">@@ -605,17 +605,17 @@
</span><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         Plan plan(*vm, vector);
</span><del>-        if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx">             dataLogLn(&quot;Module failed to compile correctly.&quot;);
</span><span class="cx">             CRASH();
</span><span class="cx">         }
</span><del>-        ASSERT(plan.memory-&gt;size());
</del><ins>+        ASSERT(plan.memory()-&gt;size());
</ins><span class="cx"> 
</span><span class="cx">         // Test this doesn't crash.
</span><span class="cx">         unsigned length = 5;
</span><span class="cx">         unsigned offset = 1;
</span><del>-        uint8_t* memory = static_cast&lt;uint8_t*&gt;(plan.memory-&gt;memory());
-        invoke&lt;void&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(100), box(offset), box(length) });
</del><ins>+        uint8_t* memory = static_cast&lt;uint8_t*&gt;(plan.memory()-&gt;memory());
+        invoke&lt;void&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(100), box(offset), box(length) });
</ins><span class="cx">         CHECK_EQ(memory[offset - 1], 0u);
</span><span class="cx">         CHECK_EQ(memory[offset + length], 0u);
</span><span class="cx">         for (unsigned i = 0; i &lt; length; ++i)
</span><span class="lines">@@ -623,7 +623,7 @@
</span><span class="cx"> 
</span><span class="cx">         length = 10;
</span><span class="cx">         offset = 5;
</span><del>-        invoke&lt;void&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(5), box(offset), box(length) });
</del><ins>+        invoke&lt;void&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(5), box(offset), box(length) });
</ins><span class="cx">         CHECK_EQ(memory[offset - 1], 100u);
</span><span class="cx">         CHECK_EQ(memory[offset + length], 0u);
</span><span class="cx">         for (unsigned i = 0; i &lt; length; ++i)
</span><span class="lines">@@ -649,16 +649,16 @@
</span><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         Plan plan(*vm, vector);
</span><del>-        if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx">             dataLogLn(&quot;Module failed to compile correctly.&quot;);
</span><span class="cx">             CRASH();
</span><span class="cx">         }
</span><del>-        ASSERT(plan.memory-&gt;size());
</del><ins>+        ASSERT(plan.memory()-&gt;size());
</ins><span class="cx"> 
</span><span class="cx">         // Test this doesn't crash.
</span><del>-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(0), box(10) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(100), box(2) }), 100);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(1), box(100) }), 1);
</del><ins>+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(0), box(10) }), 0);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(100), box(2) }), 100);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(1), box(100) }), 1);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     {
</span><span class="lines">@@ -680,15 +680,15 @@
</span><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         Plan plan(*vm, vector);
</span><del>-        if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx">             dataLogLn(&quot;Module failed to compile correctly.&quot;);
</span><span class="cx">             CRASH();
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // Test this doesn't crash.
</span><del>-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(0) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(100) }), 100);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(1) }), 1);
</del><ins>+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(0) }), 0);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(100) }), 100);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(1) }), 1);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     {
</span><span class="lines">@@ -710,16 +710,16 @@
</span><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         Plan plan(*vm, vector);
</span><del>-        if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx">             dataLogLn(&quot;Module failed to compile correctly.&quot;);
</span><span class="cx">             CRASH();
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // Test this doesn't crash.
</span><del>-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(0), box(10) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(100), box(2) }), 100);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(1), box(100) }), 1);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(-12), box(plan.memory-&gt;size() - sizeof(uint64_t)) }), -12);
</del><ins>+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(0), box(10) }), 0);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(100), box(2) }), 100);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(1), box(100) }), 1);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(-12), box(plan.memory()-&gt;size() - sizeof(uint64_t)) }), -12);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     {
</span><span class="lines">@@ -741,15 +741,15 @@
</span><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         Plan plan(*vm, vector);
</span><del>-        if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx">             dataLogLn(&quot;Module failed to compile correctly.&quot;);
</span><span class="cx">             CRASH();
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // Test this doesn't crash.
</span><del>-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(0), box(10) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(100), box(2) }), 100);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(1), box(100) }), 1);
</del><ins>+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(0), box(10) }), 0);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(100), box(2) }), 100);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(1), box(100) }), 1);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     {
</span><span class="lines">@@ -781,17 +781,17 @@
</span><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         Plan plan(*vm, vector);
</span><del>-        if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx">             dataLogLn(&quot;Module failed to compile correctly.&quot;);
</span><span class="cx">             CRASH();
</span><span class="cx">         }
</span><del>-        ASSERT(plan.memory-&gt;size());
</del><ins>+        ASSERT(plan.memory()-&gt;size());
</ins><span class="cx"> 
</span><span class="cx">         // Test this doesn't crash.
</span><span class="cx">         unsigned length = 5;
</span><span class="cx">         unsigned offset = sizeof(uint32_t);
</span><del>-        uint32_t* memory = static_cast&lt;uint32_t*&gt;(plan.memory-&gt;memory());
-        invoke&lt;void&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(100), box(offset), box(length) });
</del><ins>+        uint32_t* memory = static_cast&lt;uint32_t*&gt;(plan.memory()-&gt;memory());
+        invoke&lt;void&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(100), box(offset), box(length) });
</ins><span class="cx">         offset /= sizeof(uint32_t);
</span><span class="cx">         CHECK_EQ(memory[offset - 1], 0u);
</span><span class="cx">         CHECK_EQ(memory[offset + length], 0u);
</span><span class="lines">@@ -800,7 +800,7 @@
</span><span class="cx"> 
</span><span class="cx">         length = 10;
</span><span class="cx">         offset = 5 * sizeof(uint32_t);
</span><del>-        invoke&lt;void&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(5), box(offset), box(length) });
</del><ins>+        invoke&lt;void&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(5), box(offset), box(length) });
</ins><span class="cx">         offset /= sizeof(uint32_t);
</span><span class="cx">         CHECK_EQ(memory[offset - 1], 100u);
</span><span class="cx">         CHECK_EQ(memory[offset + length], 0u);
</span><span class="lines">@@ -836,17 +836,17 @@
</span><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         Plan plan(*vm, vector);
</span><del>-        if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx">             dataLogLn(&quot;Module failed to compile correctly.&quot;);
</span><span class="cx">             CRASH();
</span><span class="cx">         }
</span><del>-        ASSERT(plan.memory-&gt;size());
</del><ins>+        ASSERT(plan.memory()-&gt;size());
</ins><span class="cx"> 
</span><span class="cx">         // Test this doesn't crash.
</span><span class="cx">         unsigned length = 5;
</span><span class="cx">         unsigned offset = 1;
</span><del>-        uint8_t* memory = static_cast&lt;uint8_t*&gt;(plan.memory-&gt;memory());
-        invoke&lt;void&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(100), box(offset), box(length) });
</del><ins>+        uint8_t* memory = static_cast&lt;uint8_t*&gt;(plan.memory()-&gt;memory());
+        invoke&lt;void&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(100), box(offset), box(length) });
</ins><span class="cx">         CHECK_EQ(memory[offset - 1], 0u);
</span><span class="cx">         CHECK_EQ(memory[offset + length], 0u);
</span><span class="cx">         for (unsigned i = 0; i &lt; length; ++i)
</span><span class="lines">@@ -854,7 +854,7 @@
</span><span class="cx"> 
</span><span class="cx">         length = 10;
</span><span class="cx">         offset = 5;
</span><del>-        invoke&lt;void&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(5), box(offset), box(length) });
</del><ins>+        invoke&lt;void&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(5), box(offset), box(length) });
</ins><span class="cx">         CHECK_EQ(memory[offset - 1], 100u);
</span><span class="cx">         CHECK_EQ(memory[offset + length], 0u);
</span><span class="cx">         for (unsigned i = 0; i &lt; length; ++i)
</span><span class="lines">@@ -880,16 +880,16 @@
</span><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         Plan plan(*vm, vector);
</span><del>-        if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx">             dataLogLn(&quot;Module failed to compile correctly.&quot;);
</span><span class="cx">             CRASH();
</span><span class="cx">         }
</span><del>-        ASSERT(plan.memory-&gt;size());
</del><ins>+        ASSERT(plan.memory()-&gt;size());
</ins><span class="cx"> 
</span><span class="cx">         // Test this doesn't crash.
</span><del>-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(0), box(10) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(100), box(2) }), 100);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(1), box(100) }), 1);
</del><ins>+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(0), box(10) }), 0);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(100), box(2) }), 100);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(1), box(100) }), 1);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     {
</span><span class="lines">@@ -911,15 +911,15 @@
</span><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         Plan plan(*vm, vector);
</span><del>-        if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx">             dataLogLn(&quot;Module failed to compile correctly.&quot;);
</span><span class="cx">             CRASH();
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // Test this doesn't crash.
</span><del>-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(0) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(100) }), 100);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(1) }), 1);
</del><ins>+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(0) }), 0);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(100) }), 100);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(1) }), 1);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     {
</span><span class="lines">@@ -941,20 +941,20 @@
</span><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         Plan plan(*vm, vector);
</span><del>-        if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx">             dataLogLn(&quot;Module failed to compile correctly.&quot;);
</span><span class="cx">             CRASH();
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // Test this doesn't crash.
</span><del>-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(0), box(1) }), 1);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(1), box(0) }), 1);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(2), box(1) }), 1);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(1), box(2) }), 1);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(2), box(2) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(1), box(1) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(2), box(6) }), 1);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(100), box(6) }), 1);
</del><ins>+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(0), box(1) }), 1);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(1), box(0) }), 1);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(2), box(1) }), 1);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(1), box(2) }), 1);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(2), box(2) }), 0);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(1), box(1) }), 0);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(2), box(6) }), 1);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(100), box(6) }), 1);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     {
</span><span class="lines">@@ -982,20 +982,20 @@
</span><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         Plan plan(*vm, vector);
</span><del>-        if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx">             dataLogLn(&quot;Module failed to compile correctly.&quot;);
</span><span class="cx">             CRASH();
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // Test this doesn't crash.
</span><del>-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(0), box(1) }), 1);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(1), box(0) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(2), box(1) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(1), box(2) }), 1);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(2), box(2) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(1), box(1) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(2), box(6) }), 1);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(100), box(6) }), 0);
</del><ins>+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(0), box(1) }), 1);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(1), box(0) }), 0);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(2), box(1) }), 0);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(1), box(2) }), 1);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(2), box(2) }), 0);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(1), box(1) }), 0);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(2), box(6) }), 1);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(100), box(6) }), 0);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -1009,13 +1009,13 @@
</span><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         Plan plan(*vm, vector);
</span><del>-        if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx">             dataLogLn(&quot;Module failed to compile correctly.&quot;);
</span><span class="cx">             CRASH();
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // Test this doesn't crash.
</span><del>-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { }), 5);
</del><ins>+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { }), 5);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -1030,13 +1030,13 @@
</span><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         Plan plan(*vm, vector);
</span><del>-        if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx">             dataLogLn(&quot;Module failed to compile correctly.&quot;);
</span><span class="cx">             CRASH();
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // Test this doesn't crash.
</span><del>-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { }), 11);
</del><ins>+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { }), 11);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     {
</span><span class="lines">@@ -1050,13 +1050,13 @@
</span><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         Plan plan(*vm, vector);
</span><del>-        if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx">             dataLogLn(&quot;Module failed to compile correctly.&quot;);
</span><span class="cx">             CRASH();
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // Test this doesn't crash.
</span><del>-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { }), 11);
</del><ins>+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { }), 11);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     {
</span><span class="lines">@@ -1070,13 +1070,13 @@
</span><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         Plan plan(*vm, vector);
</span><del>-        if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx">             dataLogLn(&quot;Module failed to compile correctly.&quot;);
</span><span class="cx">             CRASH();
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // Test this doesn't crash.
</span><del>-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { }), 11);
</del><ins>+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { }), 11);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     {
</span><span class="lines">@@ -1089,16 +1089,16 @@
</span><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         Plan plan(*vm, vector);
</span><del>-        if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx">             dataLogLn(&quot;Module failed to compile correctly.&quot;);
</span><span class="cx">             CRASH();
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // Test this doesn't crash.
</span><del>-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(0), box(1) }), 1);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(100), box(1) }), 101);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(-1), box(1)}), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(std::numeric_limits&lt;int&gt;::max()), box(1) }), std::numeric_limits&lt;int&gt;::min());
</del><ins>+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(0), box(1) }), 1);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(100), box(1) }), 101);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(-1), box(1)}), 0);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(std::numeric_limits&lt;int&gt;::max()), box(1) }), std::numeric_limits&lt;int&gt;::min());
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     {
</span><span class="lines">@@ -1118,14 +1118,14 @@
</span><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         Plan plan(*vm, vector);
</span><del>-        if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx">             dataLogLn(&quot;Module failed to compile correctly.&quot;);
</span><span class="cx">             CRASH();
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // Test this doesn't crash.
</span><del>-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(0) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(10) }), 10);
</del><ins>+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(0) }), 0);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(10) }), 10);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     {
</span><span class="lines">@@ -1154,16 +1154,16 @@
</span><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         Plan plan(*vm, vector);
</span><del>-        if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx">             dataLogLn(&quot;Module failed to compile correctly.&quot;);
</span><span class="cx">             CRASH();
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // Test this doesn't crash.
</span><del>-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(0) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(1) }), 1);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(2)}), 3);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(100) }), 5050);
</del><ins>+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(0) }), 0);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(1) }), 1);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(2)}), 3);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(100) }), 5050);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     {
</span><span class="lines">@@ -1198,20 +1198,20 @@
</span><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         Plan plan(*vm, vector);
</span><del>-        if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx">             dataLogLn(&quot;Module failed to compile correctly.&quot;);
</span><span class="cx">             CRASH();
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // Test this doesn't crash.
</span><del>-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(0), box(1) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(1), box(0) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(2), box(1) }), 2);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(1), box(2) }), 2);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(2), box(2) }), 4);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(2), box(6) }), 12);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(100), box(6) }), 600);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(100), box(100) }), 10000);
</del><ins>+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(0), box(1) }), 0);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(1), box(0) }), 0);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(2), box(1) }), 2);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(1), box(2) }), 2);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(2), box(2) }), 4);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(2), box(6) }), 12);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(100), box(6) }), 600);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(100), box(100) }), 10000);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     {
</span><span class="lines">@@ -1251,20 +1251,20 @@
</span><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         Plan plan(*vm, vector);
</span><del>-        if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx">             dataLogLn(&quot;Module failed to compile correctly.&quot;);
</span><span class="cx">             CRASH();
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // Test this doesn't crash.
</span><del>-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(0), box(1) }), 1);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(1), box(0) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(2), box(1) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(1), box(2) }), 1);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(2), box(2) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(1), box(1) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(2), box(6) }), 1);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.result[0]-&gt;jsEntryPoint, { box(100), box(6) }), 0);
</del><ins>+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(0), box(1) }), 1);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(1), box(0) }), 0);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(2), box(1) }), 0);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(1), box(2) }), 1);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(2), box(2) }), 0);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(1), box(1) }), 0);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(2), box(6) }), 1);
+        CHECK_EQ(invoke&lt;int&gt;(*plan.result(0)-&gt;jsEntryPoint, { box(100), box(6) }), 0);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWasmB3IRGeneratorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -718,13 +718,13 @@
</span><span class="cx">     return std::make_unique&lt;Compilation&gt;(vm, proc);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-std::unique_ptr&lt;FunctionCompilation&gt; parseAndCompile(VM&amp; vm, Vector&lt;uint8_t&gt;&amp; source, Memory* memory, FunctionInformation info, const Vector&lt;FunctionInformation&gt;&amp; functions, unsigned optLevel)
</del><ins>+std::unique_ptr&lt;FunctionCompilation&gt; parseAndCompile(VM&amp; vm, const uint8_t* functionStart, size_t functionLength, Memory* memory, const Signature* signature, const Vector&lt;FunctionInformation&gt;&amp; functions, unsigned optLevel)
</ins><span class="cx"> {
</span><span class="cx">     auto result = std::make_unique&lt;FunctionCompilation&gt;();
</span><span class="cx"> 
</span><span class="cx">     Procedure procedure;
</span><span class="cx">     B3IRGenerator context(memory, procedure, result-&gt;unlinkedCalls);
</span><del>-    FunctionParser&lt;B3IRGenerator&gt; parser(context, source, info, functions);
</del><ins>+    FunctionParser&lt;B3IRGenerator&gt; parser(context, functionStart, functionLength, signature, functions);
</ins><span class="cx">     if (!parser.parse())
</span><span class="cx">         RELEASE_ASSERT_NOT_REACHED();
</span><span class="cx"> 
</span><span class="lines">@@ -736,7 +736,7 @@
</span><span class="cx">         dataLog(&quot;Post SSA: &quot;, procedure);
</span><span class="cx"> 
</span><span class="cx">     result-&gt;code = std::make_unique&lt;Compilation&gt;(vm, procedure, optLevel);
</span><del>-    result-&gt;jsEntryPoint = createJSWrapper(vm, info.signature, result-&gt;code-&gt;code(), memory);
</del><ins>+    result-&gt;jsEntryPoint = createJSWrapper(vm, signature, result-&gt;code-&gt;code(), memory);
</ins><span class="cx">     return result;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWasmB3IRGeneratorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WasmB3IRGenerator.h (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WasmB3IRGenerator.h        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/wasm/WasmB3IRGenerator.h        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -37,7 +37,7 @@
</span><span class="cx"> 
</span><span class="cx"> class Memory;
</span><span class="cx"> 
</span><del>-std::unique_ptr&lt;FunctionCompilation&gt; parseAndCompile(VM&amp;, Vector&lt;uint8_t&gt;&amp;, Memory*, FunctionInformation, const Vector&lt;FunctionInformation&gt;&amp;, unsigned optLevel = 1);
</del><ins>+std::unique_ptr&lt;FunctionCompilation&gt; parseAndCompile(VM&amp;, const uint8_t*, size_t, Memory*, const Signature*, const Vector&lt;FunctionInformation&gt;&amp;, unsigned optLevel = 1);
</ins><span class="cx"> 
</span><span class="cx"> } } // namespace JSC::Wasm
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWasmFunctionParserh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WasmFunctionParser.h (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WasmFunctionParser.h        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/wasm/WasmFunctionParser.h        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -44,7 +44,7 @@
</span><span class="cx">     typedef typename Context::ExpressionType ExpressionType;
</span><span class="cx">     typedef typename Context::ControlType ControlType;
</span><span class="cx"> 
</span><del>-    FunctionParser(Context&amp;, const Vector&lt;uint8_t&gt;&amp; sourceBuffer, const FunctionInformation&amp;, const Vector&lt;FunctionInformation&gt;&amp; functions);
</del><ins>+    FunctionParser(Context&amp;, const uint8_t* functionStart, size_t functionLength, const Signature*, const Vector&lt;FunctionInformation&gt;&amp; functions);
</ins><span class="cx"> 
</span><span class="cx">     bool WARN_UNUSED_RETURN parse();
</span><span class="cx"> 
</span><span class="lines">@@ -59,21 +59,21 @@
</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><del>-    const Signature&amp; m_signature;
</del><ins>+    const Signature* m_signature;
</ins><span class="cx">     const Vector&lt;FunctionInformation&gt;&amp; m_functions;
</span><span class="cx">     unsigned m_unreachableBlocks { 0 };
</span><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> template&lt;typename Context&gt;
</span><del>-FunctionParser&lt;Context&gt;::FunctionParser(Context&amp; context, const Vector&lt;uint8_t&gt;&amp; sourceBuffer, const FunctionInformation&amp; info, const Vector&lt;FunctionInformation&gt;&amp; functions)
-    : Parser(sourceBuffer, info.start, info.end)
</del><ins>+FunctionParser&lt;Context&gt;::FunctionParser(Context&amp; context, const uint8_t* functionStart, size_t functionLength, const Signature* signature, const Vector&lt;FunctionInformation&gt;&amp; functions)
+    : Parser(functionStart, functionLength)
</ins><span class="cx">     , m_context(context)
</span><del>-    , m_signature(*info.signature)
</del><ins>+    , m_signature(signature)
</ins><span class="cx">     , m_functions(functions)
</span><span class="cx"> {
</span><span class="cx">     if (verbose)
</span><del>-        dataLogLn(&quot;Parsing function starting at: &quot;, info.start, &quot; ending at: &quot;, info.end);
-    m_context.addArguments(m_signature.arguments);
</del><ins>+        dataLogLn(&quot;Parsing function starting at: &quot;, (uintptr_t)functionStart, &quot; of length: &quot;, functionLength);
+    m_context.addArguments(m_signature-&gt;arguments);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template&lt;typename Context&gt;
</span><span class="lines">@@ -309,7 +309,7 @@
</span><span class="cx"> 
</span><span class="cx">     case OpType::Return: {
</span><span class="cx">         Vector&lt;ExpressionType, 1&gt; returnValues;
</span><del>-        if (m_signature.returnType != Void)
</del><ins>+        if (m_signature-&gt;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 (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WasmModuleParser.cpp        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/wasm/WasmModuleParser.cpp        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -41,20 +41,29 @@
</span><span class="cx"> 
</span><span class="cx"> bool ModuleParser::parse()
</span><span class="cx"> {
</span><del>-    if (m_sourceLength &lt; 8)
</del><ins>+    const size_t minSize = 8;
+    if (length() &lt; minSize) {
+        m_errorMessage = &quot;Module is &quot; + String::number(length()) + &quot; bytes, expected at least &quot; + String::number(minSize) + &quot; bytes&quot;;
</ins><span class="cx">         return false;
</span><del>-    if (!consumeCharacter(0))
</del><ins>+    }
+    if (!consumeCharacter(0) || !consumeString(&quot;asm&quot;)) {
+        m_errorMessage = &quot;Modules doesn't start with '\\0asm'&quot;;
</ins><span class="cx">         return false;
</span><del>-    if (!consumeString(&quot;asm&quot;))
-        return false;
</del><ins>+    }
</ins><span class="cx"> 
</span><span class="cx">     // Skip the version number for now since we don't do anything with it.
</span><span class="cx">     uint32_t versionNumber;
</span><del>-    if (!parseUInt32(versionNumber))
</del><ins>+    if (!parseUInt32(versionNumber)) {
+        // FIXME improve error message https://bugs.webkit.org/show_bug.cgi?id=163919
+        m_errorMessage = &quot;couldn't parse version number&quot;;
</ins><span class="cx">         return false;
</span><ins>+    }
</ins><span class="cx"> 
</span><del>-    if (versionNumber != magicNumber)
</del><ins>+    if (versionNumber != magicNumber) {
+        // FIXME improve error message https://bugs.webkit.org/show_bug.cgi?id=163919
+        m_errorMessage = &quot;unexpected version number&quot;;
</ins><span class="cx">         return false;
</span><ins>+    }
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     if (verbose)
</span><span class="lines">@@ -61,13 +70,16 @@
</span><span class="cx">         dataLogLn(&quot;Passed processing header.&quot;);
</span><span class="cx"> 
</span><span class="cx">     Sections::Section previousSection = Sections::Unknown;
</span><del>-    while (m_offset &lt; m_sourceLength) {
</del><ins>+    while (m_offset &lt; length()) {
</ins><span class="cx">         if (verbose)
</span><span class="cx">             dataLogLn(&quot;Starting to parse next section at offset: &quot;, m_offset);
</span><span class="cx"> 
</span><span class="cx">         uint8_t sectionByte;
</span><del>-        if (!parseUInt7(sectionByte))
</del><ins>+        if (!parseUInt7(sectionByte)) {
+            // FIXME improve error message https://bugs.webkit.org/show_bug.cgi?id=163919
+            m_errorMessage = &quot;couldn't get section byte&quot;;
</ins><span class="cx">             return false;
</span><ins>+        }
</ins><span class="cx"> 
</span><span class="cx">         if (verbose)
</span><span class="cx">             dataLogLn(&quot;Section byte: &quot;, sectionByte);
</span><span class="lines">@@ -78,12 +90,18 @@
</span><span class="cx">                 section = static_cast&lt;Sections::Section&gt;(sectionByte);
</span><span class="cx">         } else {
</span><span class="cx">             uint32_t sectionNameLength;
</span><del>-            if (!parseVarUInt32(sectionNameLength))
</del><ins>+            if (!parseVarUInt32(sectionNameLength)) {
+                // FIXME improve error message https://bugs.webkit.org/show_bug.cgi?id=163919
+                m_errorMessage = &quot;couldn't get section name length&quot;;
</ins><span class="cx">                 return false;
</span><ins>+            }
</ins><span class="cx"> 
</span><span class="cx">             // Make sure we can read up to the section's size.
</span><del>-            if (m_offset + sectionNameLength + WTF::LEBDecoder::max32BitLEBByteLength &gt;= m_sourceLength)
</del><ins>+            if (m_offset + sectionNameLength + WTF::LEBDecoder::max32BitLEBByteLength &gt;= length()) {
+                // FIXME improve error message https://bugs.webkit.org/show_bug.cgi?id=163919
+                m_errorMessage = &quot;section length is bigger than actual size&quot;;
</ins><span class="cx">                 return false;
</span><ins>+            }
</ins><span class="cx"> 
</span><span class="cx">             // We don't support any custom sections yet.
</span><span class="cx"> 
</span><span class="lines">@@ -90,12 +108,18 @@
</span><span class="cx">             m_offset += sectionNameLength;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (!Sections::validateOrder(previousSection, section))
</del><ins>+        if (!Sections::validateOrder(previousSection, section)) {
+            // FIXME improve error message https://bugs.webkit.org/show_bug.cgi?id=163919
+            m_errorMessage = &quot;invalid section order&quot;;
</ins><span class="cx">             return false;
</span><ins>+        }
</ins><span class="cx"> 
</span><span class="cx">         uint32_t sectionLength;
</span><del>-        if (!parseVarUInt32(sectionLength))
</del><ins>+        if (!parseVarUInt32(sectionLength)) {
+            // FIXME improve error message https://bugs.webkit.org/show_bug.cgi?id=163919
+            m_errorMessage = &quot;couldn't get section length&quot;;
</ins><span class="cx">             return false;
</span><ins>+        }
</ins><span class="cx"> 
</span><span class="cx">         unsigned end = m_offset + sectionLength;
</span><span class="cx"> 
</span><span class="lines">@@ -104,8 +128,11 @@
</span><span class="cx">         case Sections::Memory: {
</span><span class="cx">             if (verbose)
</span><span class="cx">                 dataLogLn(&quot;Parsing Memory.&quot;);
</span><del>-            if (!parseMemory())
</del><ins>+            if (!parseMemory()) {
+                // FIXME improve error message https://bugs.webkit.org/show_bug.cgi?id=163919
+                m_errorMessage = &quot;couldn't parse memory&quot;;
</ins><span class="cx">                 return false;
</span><ins>+            }
</ins><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -112,8 +139,11 @@
</span><span class="cx">         case Sections::FunctionTypes: {
</span><span class="cx">             if (verbose)
</span><span class="cx">                 dataLogLn(&quot;Parsing types.&quot;);
</span><del>-            if (!parseFunctionTypes())
</del><ins>+            if (!parseFunctionTypes()) {
+                // FIXME improve error message https://bugs.webkit.org/show_bug.cgi?id=163919
+                m_errorMessage = &quot;couldn't parse types&quot;;
</ins><span class="cx">                 return false;
</span><ins>+            }
</ins><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -120,8 +150,11 @@
</span><span class="cx">         case Sections::Signatures: {
</span><span class="cx">             if (verbose)
</span><span class="cx">                 dataLogLn(&quot;Parsing function signatures.&quot;);
</span><del>-            if (!parseFunctionSignatures())
</del><ins>+            if (!parseFunctionSignatures()) {
+                // FIXME improve error message https://bugs.webkit.org/show_bug.cgi?id=163919
+                m_errorMessage = &quot;couldn't parse function signatures&quot;;
</ins><span class="cx">                 return false;
</span><ins>+            }
</ins><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -128,8 +161,11 @@
</span><span class="cx">         case Sections::Definitions: {
</span><span class="cx">             if (verbose)
</span><span class="cx">                 dataLogLn(&quot;Parsing function definitions.&quot;);
</span><del>-            if (!parseFunctionDefinitions())
</del><ins>+            if (!parseFunctionDefinitions()) {
+                // FIXME improve error message https://bugs.webkit.org/show_bug.cgi?id=163919
+                m_errorMessage = &quot;couldn't parse function definitions&quot;;
</ins><span class="cx">                 return false;
</span><ins>+            }
</ins><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -146,13 +182,17 @@
</span><span class="cx">         if (verbose)
</span><span class="cx">             dataLogLn(&quot;Finished parsing section.&quot;);
</span><span class="cx"> 
</span><del>-        if (end != m_offset)
</del><ins>+        if (end != m_offset) {
+            // FIXME improve error message https://bugs.webkit.org/show_bug.cgi?id=163919
+            m_errorMessage = &quot;parsing ended before the end of the section&quot;;
</ins><span class="cx">             return false;
</span><ins>+        }
</ins><span class="cx"> 
</span><span class="cx">         previousSection = section;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // TODO
</span><ins>+    m_failed = false;
</ins><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWasmModuleParserh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WasmModuleParser.h (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WasmModuleParser.h        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/wasm/WasmModuleParser.h        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -39,15 +39,33 @@
</span><span class="cx"> 
</span><span class="cx">     static const unsigned magicNumber = 0xc;
</span><span class="cx"> 
</span><ins>+    ModuleParser(const uint8_t* sourceBuffer, size_t sourceLength)
+        : Parser(sourceBuffer, sourceLength)
+    {
+    }
</ins><span class="cx">     ModuleParser(const Vector&lt;uint8_t&gt;&amp; sourceBuffer)
</span><del>-        : Parser(sourceBuffer, 0, sourceBuffer.size())
</del><ins>+        : Parser(sourceBuffer.data(), sourceBuffer.size())
</ins><span class="cx">     {
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     bool WARN_UNUSED_RETURN parse();
</span><ins>+    bool WARN_UNUSED_RETURN failed() const { return m_failed; }
+    const String&amp; errorMessage() const
+    {
+        RELEASE_ASSERT(failed());
+        return m_errorMessage;
+    }
</ins><span class="cx"> 
</span><del>-    const Vector&lt;FunctionInformation&gt;&amp; functionInformation() const { return m_functions; }
-    std::unique_ptr&lt;Memory&gt;&amp; memory() { return m_memory; }
</del><ins>+    const Vector&lt;FunctionInformation&gt;&amp; functionInformation() const
+    {
+        RELEASE_ASSERT(!failed());
+        return m_functions;
+    }
+    std::unique_ptr&lt;Memory&gt;&amp; memory()
+    {
+        RELEASE_ASSERT(!failed());
+        return m_memory;
+    }
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     bool WARN_UNUSED_RETURN parseMemory();
</span><span class="lines">@@ -59,6 +77,8 @@
</span><span class="cx">     Vector&lt;FunctionInformation&gt; m_functions;
</span><span class="cx">     Vector&lt;Signature&gt; m_signatures;
</span><span class="cx">     std::unique_ptr&lt;Memory&gt; m_memory;
</span><ins>+    bool m_failed { true };
+    String m_errorMessage;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } } // namespace JSC::Wasm
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWasmParserh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WasmParser.h (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WasmParser.h        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/wasm/WasmParser.h        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -38,7 +38,7 @@
</span><span class="cx"> 
</span><span class="cx"> class Parser {
</span><span class="cx"> protected:
</span><del>-    Parser(const Vector&lt;uint8_t&gt;&amp;, size_t start, size_t end);
</del><ins>+    Parser(const uint8_t*, size_t);
</ins><span class="cx"> 
</span><span class="cx">     bool WARN_UNUSED_RETURN consumeCharacter(char);
</span><span class="cx">     bool WARN_UNUSED_RETURN consumeString(const char*);
</span><span class="lines">@@ -46,31 +46,32 @@
</span><span class="cx">     bool WARN_UNUSED_RETURN parseVarUInt1(uint8_t&amp; result);
</span><span class="cx">     bool WARN_UNUSED_RETURN parseUInt7(uint8_t&amp; result);
</span><span class="cx">     bool WARN_UNUSED_RETURN parseUInt32(uint32_t&amp; result);
</span><del>-    bool WARN_UNUSED_RETURN parseVarUInt32(uint32_t&amp; result) { return WTF::LEBDecoder::decodeUInt32(m_source.data(), m_sourceLength, m_offset, result); }
-    bool WARN_UNUSED_RETURN parseVarUInt64(uint64_t&amp; result) { return WTF::LEBDecoder::decodeUInt64(m_source.data(), m_sourceLength, m_offset, result); }
</del><ins>+    bool WARN_UNUSED_RETURN parseVarUInt32(uint32_t&amp; result) { return WTF::LEBDecoder::decodeUInt32(m_source, m_sourceLength, m_offset, result); }
+    bool WARN_UNUSED_RETURN parseVarUInt64(uint64_t&amp; result) { return WTF::LEBDecoder::decodeUInt64(m_source, m_sourceLength, m_offset, result); }
</ins><span class="cx"> 
</span><del>-
</del><span class="cx">     bool WARN_UNUSED_RETURN parseValueType(Type&amp; result);
</span><span class="cx"> 
</span><del>-    const Vector&lt;uint8_t&gt;&amp; m_source;
</del><ins>+    const uint8_t* source() const { return m_source; }
+    size_t length() const { return m_sourceLength; }
+
+    size_t m_offset = 0;
+
+private:
+    const uint8_t* m_source;
</ins><span class="cx">     size_t m_sourceLength;
</span><del>-    size_t m_offset;
</del><span class="cx"> };
</span><span class="cx"> 
</span><del>-ALWAYS_INLINE Parser::Parser(const Vector&lt;uint8_t&gt;&amp; sourceBuffer, size_t start, size_t end)
</del><ins>+ALWAYS_INLINE Parser::Parser(const uint8_t* sourceBuffer, size_t sourceLength)
</ins><span class="cx">     : m_source(sourceBuffer)
</span><del>-    , m_sourceLength(end)
-    , m_offset(start)
</del><ins>+    , m_sourceLength(sourceLength)
</ins><span class="cx"> {
</span><del>-    ASSERT(end &lt;= sourceBuffer.size());
-    ASSERT(start &lt; end);
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> ALWAYS_INLINE bool Parser::consumeCharacter(char c)
</span><span class="cx"> {
</span><del>-    if (m_offset &gt;= m_sourceLength)
</del><ins>+    if (m_offset &gt;= length())
</ins><span class="cx">         return false;
</span><del>-    if (c == m_source[m_offset]) {
</del><ins>+    if (c == source()[m_offset]) {
</ins><span class="cx">         m_offset++;
</span><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="lines">@@ -80,9 +81,9 @@
</span><span class="cx"> ALWAYS_INLINE bool Parser::consumeString(const char* str)
</span><span class="cx"> {
</span><span class="cx">     unsigned start = m_offset;
</span><del>-    if (m_offset &gt;= m_sourceLength)
</del><ins>+    if (m_offset &gt;= length())
</ins><span class="cx">         return false;
</span><del>-    for (unsigned i = 0; str[i]; i++) {
</del><ins>+    for (size_t i = 0; str[i]; i++) {
</ins><span class="cx">         if (!consumeCharacter(str[i])) {
</span><span class="cx">             m_offset = start;
</span><span class="cx">             return false;
</span><span class="lines">@@ -93,9 +94,9 @@
</span><span class="cx"> 
</span><span class="cx"> ALWAYS_INLINE bool Parser::parseUInt32(uint32_t&amp; result)
</span><span class="cx"> {
</span><del>-    if (m_sourceLength &lt; 4 || m_offset &gt;= m_sourceLength - 4)
</del><ins>+    if (length() &lt; 4 || m_offset &gt; length() - 4)
</ins><span class="cx">         return false;
</span><del>-    result = *reinterpret_cast&lt;const uint32_t*&gt;(m_source.data() + m_offset);
</del><ins>+    result = *reinterpret_cast&lt;const uint32_t*&gt;(source() + m_offset);
</ins><span class="cx">     m_offset += 4;
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="lines">@@ -102,9 +103,9 @@
</span><span class="cx"> 
</span><span class="cx"> ALWAYS_INLINE bool Parser::parseUInt7(uint8_t&amp; result)
</span><span class="cx"> {
</span><del>-    if (m_offset &gt;= m_sourceLength)
</del><ins>+    if (m_offset &gt;= length())
</ins><span class="cx">         return false;
</span><del>-    result = m_source[m_offset++];
</del><ins>+    result = source()[m_offset++];
</ins><span class="cx">     return result &lt; 0x80;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWasmPlancpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WasmPlan.cpp (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WasmPlan.cpp        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/wasm/WasmPlan.cpp        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -37,14 +37,20 @@
</span><span class="cx"> namespace JSC { namespace Wasm {
</span><span class="cx"> 
</span><span class="cx"> static const bool verbose = false;
</span><del>-
</del><ins>+    
</ins><span class="cx"> Plan::Plan(VM&amp; vm, Vector&lt;uint8_t&gt; source)
</span><ins>+    : Plan(vm, source.data(), source.size())
</ins><span class="cx"> {
</span><ins>+}
+
+Plan::Plan(VM&amp; vm, const uint8_t* source, size_t sourceLength)
+{
</ins><span class="cx">     if (verbose)
</span><span class="cx">         dataLogLn(&quot;Starting plan.&quot;);
</span><del>-    ModuleParser moduleParser(source);
</del><ins>+    ModuleParser moduleParser(source, sourceLength);
</ins><span class="cx">     if (!moduleParser.parse()) {
</span><del>-        dataLogLn(&quot;Parsing module failed.&quot;);
</del><ins>+        dataLogLn(&quot;Parsing module failed: &quot;, moduleParser.errorMessage());
+        m_errorMessage = moduleParser.errorMessage();
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -54,19 +60,25 @@
</span><span class="cx">     for (const FunctionInformation&amp; info : moduleParser.functionInformation()) {
</span><span class="cx">         if (verbose)
</span><span class="cx">             dataLogLn(&quot;Processing funcion starting at: &quot;, info.start, &quot; and ending at: &quot;, info.end);
</span><del>-        result.append(parseAndCompile(vm, source, moduleParser.memory().get(), info, moduleParser.functionInformation()));
</del><ins>+        const uint8_t* functionStart = source + info.start;
+        size_t functionLength = info.end - info.start;
+        ASSERT(functionLength &lt;= sourceLength);
+        m_result.append(parseAndCompile(vm, functionStart, functionLength, moduleParser.memory().get(), info.signature, moduleParser.functionInformation()));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // Patch the call sites for each function.
</span><del>-    for (std::unique_ptr&lt;FunctionCompilation&gt;&amp; functionPtr : result) {
</del><ins>+    for (std::unique_ptr&lt;FunctionCompilation&gt;&amp; functionPtr : m_result) {
</ins><span class="cx">         FunctionCompilation* function = functionPtr.get();
</span><span class="cx">         for (auto&amp; call : function-&gt;unlinkedCalls)
</span><del>-            MacroAssembler::repatchCall(call.callLocation, CodeLocationLabel(result[call.functionIndex]-&gt;code-&gt;code()));
</del><ins>+            MacroAssembler::repatchCall(call.callLocation, CodeLocationLabel(m_result[call.functionIndex]-&gt;code-&gt;code()));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    memory = WTFMove(moduleParser.memory());
</del><ins>+    m_memory = WTFMove(moduleParser.memory());
+    m_failed = false;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+Plan::~Plan() { }
+
</ins><span class="cx"> } } // namespace JSC::Wasm
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(WEBASSEMBLY)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWasmPlanh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WasmPlan.h (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WasmPlan.h        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/wasm/WasmPlan.h        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -36,13 +36,39 @@
</span><span class="cx"> namespace JSC { namespace Wasm {
</span><span class="cx"> class Memory;
</span><span class="cx"> 
</span><del>-// TODO: This should create a Wasm Module not a list of functions.
</del><span class="cx"> class Plan {
</span><span class="cx"> public:
</span><del>-    JS_EXPORT_PRIVATE Plan(VM&amp;, Vector&lt;uint8_t&gt; source);
</del><ins>+    JS_EXPORT_PRIVATE Plan(VM&amp;, Vector&lt;uint8_t&gt;);
+    JS_EXPORT_PRIVATE Plan(VM&amp;, const uint8_t*, size_t);
+    JS_EXPORT_PRIVATE ~Plan();
</ins><span class="cx"> 
</span><del>-    Vector&lt;std::unique_ptr&lt;FunctionCompilation&gt;&gt; result;
-    std::unique_ptr&lt;Memory&gt; memory;
</del><ins>+    bool WARN_UNUSED_RETURN failed() const { return m_failed; }
+    const String&amp; errorMessage() const
+    {
+        RELEASE_ASSERT(failed());
+        return m_errorMessage;
+    }
+    size_t resultSize() const
+    {
+        RELEASE_ASSERT(!failed());
+        return m_result.size();
+    }
+    const FunctionCompilation* result(size_t n) const
+    {
+        RELEASE_ASSERT(!failed());
+        return m_result.at(n).get();
+    }
+    const Memory* memory() const
+    {
+        RELEASE_ASSERT(!failed());
+        return m_memory.get();
+    }
+
+private:
+    Vector&lt;std::unique_ptr&lt;FunctionCompilation&gt;&gt; m_result;
+    std::unique_ptr&lt;Memory&gt; m_memory;
+    bool m_failed { true };
+    String m_errorMessage;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } } // namespace JSC::Wasm
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsJSWebAssemblyCompileErrorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyCompileError.cpp (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyCompileError.cpp        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyCompileError.cpp        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -47,6 +47,14 @@
</span><span class="cx"> 
</span><span class="cx"> const ClassInfo JSWebAssemblyCompileError::s_info = { &quot;WebAssembly.CompileError&quot;, &amp;Base::s_info, 0, CREATE_METHOD_TABLE(JSWebAssemblyCompileError) };
</span><span class="cx"> 
</span><ins>+    
+JSObject* createWebAssemblyCompileError(ExecState* exec, const String&amp; message)
+{
+    ASSERT(!message.isEmpty());
+    JSGlobalObject* globalObject = exec-&gt;lexicalGlobalObject();
+    return ErrorInstance::create(exec, globalObject-&gt;vm(), globalObject-&gt;WebAssemblyCompileErrorStructure(), message, defaultSourceAppender, TypeNothing, true);
+}
+
</ins><span class="cx"> } // namespace JSC
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(WEBASSEMBLY)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsJSWebAssemblyCompileErrorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyCompileError.h (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyCompileError.h        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyCompileError.h        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -47,6 +47,8 @@
</span><span class="cx">     JSWebAssemblyCompileError(VM&amp;, Structure*);
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+JSObject* createWebAssemblyCompileError(ExecState*, const String&amp;);
+
</ins><span class="cx"> } // namespace JSC
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(WEBASSEMBLY)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsWebAssemblyCompileErrorConstructorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/WebAssemblyCompileErrorConstructor.cpp (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/WebAssemblyCompileErrorConstructor.cpp        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/wasm/js/WebAssemblyCompileErrorConstructor.cpp        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -48,7 +48,7 @@
</span><span class="cx"> {
</span><span class="cx">     auto&amp; vm = state-&gt;vm();
</span><span class="cx">     auto scope = DECLARE_THROW_SCOPE(vm);
</span><del>-    JSValue message = state-&gt;argumentCount() ? state-&gt;argument(0) : jsUndefined();
</del><ins>+    JSValue message = state-&gt;argument(0);
</ins><span class="cx">     auto* structure = InternalFunction::createSubclassStructure(state, state-&gt;newTarget(), asInternalFunction(state-&gt;callee())-&gt;globalObject()-&gt;WebAssemblyCompileErrorStructure());
</span><span class="cx">     RETURN_IF_EXCEPTION(scope, encodedJSValue());
</span><span class="cx">     return JSValue::encode(JSWebAssemblyCompileError::create(state, structure, message, false));
</span><span class="lines">@@ -61,10 +61,10 @@
</span><span class="cx">     return JSValue::encode(throwConstructorCannotBeCalledAsFunctionTypeError(state, scope, &quot;WebAssembly.CompileError&quot;));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-WebAssemblyCompileErrorConstructor* WebAssemblyCompileErrorConstructor::create(VM&amp; vm, Structure* structure, WebAssemblyCompileErrorPrototype* thisPrototype, Structure* thisStructure)
</del><ins>+WebAssemblyCompileErrorConstructor* WebAssemblyCompileErrorConstructor::create(VM&amp; vm, Structure* structure, WebAssemblyCompileErrorPrototype* thisPrototype)
</ins><span class="cx"> {
</span><span class="cx">     auto* constructor = new (NotNull, allocateCell&lt;WebAssemblyCompileErrorConstructor&gt;(vm.heap)) WebAssemblyCompileErrorConstructor(vm, structure);
</span><del>-    constructor-&gt;finishCreation(vm, thisPrototype, thisStructure);
</del><ins>+    constructor-&gt;finishCreation(vm, thisPrototype);
</ins><span class="cx">     return constructor;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -73,7 +73,7 @@
</span><span class="cx">     return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebAssemblyCompileErrorConstructor::finishCreation(VM&amp; vm, WebAssemblyCompileErrorPrototype* prototype, Structure*)
</del><ins>+void WebAssemblyCompileErrorConstructor::finishCreation(VM&amp; vm, WebAssemblyCompileErrorPrototype* prototype)
</ins><span class="cx"> {
</span><span class="cx">     Base::finishCreation(vm, ASCIILiteral(&quot;CompileError&quot;));
</span><span class="cx">     putDirectWithoutTransition(vm, vm.propertyNames-&gt;prototype, prototype, ReadOnly | DontEnum | DontDelete);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsWebAssemblyCompileErrorConstructorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/WebAssemblyCompileErrorConstructor.h (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/WebAssemblyCompileErrorConstructor.h        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/wasm/js/WebAssemblyCompileErrorConstructor.h        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -39,13 +39,13 @@
</span><span class="cx">     typedef InternalFunction Base;
</span><span class="cx">     static const unsigned StructureFlags = Base::StructureFlags | HasStaticPropertyTable;
</span><span class="cx"> 
</span><del>-    static WebAssemblyCompileErrorConstructor* create(VM&amp;, Structure*, WebAssemblyCompileErrorPrototype*, Structure*);
</del><ins>+    static WebAssemblyCompileErrorConstructor* create(VM&amp;, Structure*, WebAssemblyCompileErrorPrototype*);
</ins><span class="cx">     static Structure* createStructure(VM&amp;, JSGlobalObject*, JSValue);
</span><span class="cx"> 
</span><span class="cx">     DECLARE_INFO;
</span><span class="cx"> 
</span><span class="cx"> protected:
</span><del>-    void finishCreation(VM&amp;, WebAssemblyCompileErrorPrototype*, Structure*);
</del><ins>+    void finishCreation(VM&amp;, WebAssemblyCompileErrorPrototype*);
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     WebAssemblyCompileErrorConstructor(VM&amp;, Structure*);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsWebAssemblyInstanceConstructorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/WebAssemblyInstanceConstructor.cpp (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/WebAssemblyInstanceConstructor.cpp        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/wasm/js/WebAssemblyInstanceConstructor.cpp        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -57,10 +57,10 @@
</span><span class="cx">     return JSValue::encode(throwConstructorCannotBeCalledAsFunctionTypeError(state, scope, &quot;WebAssembly.Instance&quot;));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-WebAssemblyInstanceConstructor* WebAssemblyInstanceConstructor::create(VM&amp; vm, Structure* structure, WebAssemblyInstancePrototype* thisPrototype, Structure* thisStructure)
</del><ins>+WebAssemblyInstanceConstructor* WebAssemblyInstanceConstructor::create(VM&amp; vm, Structure* structure, WebAssemblyInstancePrototype* thisPrototype)
</ins><span class="cx"> {
</span><span class="cx">     auto* constructor = new (NotNull, allocateCell&lt;WebAssemblyInstanceConstructor&gt;(vm.heap)) WebAssemblyInstanceConstructor(vm, structure);
</span><del>-    constructor-&gt;finishCreation(vm, thisPrototype, thisStructure);
</del><ins>+    constructor-&gt;finishCreation(vm, thisPrototype);
</ins><span class="cx">     return constructor;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -69,12 +69,11 @@
</span><span class="cx">     return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebAssemblyInstanceConstructor::finishCreation(VM&amp; vm, WebAssemblyInstancePrototype* prototype, Structure* structure)
</del><ins>+void WebAssemblyInstanceConstructor::finishCreation(VM&amp; vm, WebAssemblyInstancePrototype* prototype)
</ins><span class="cx"> {
</span><span class="cx">     Base::finishCreation(vm, ASCIILiteral(&quot;Instance&quot;));
</span><span class="cx">     putDirectWithoutTransition(vm, vm.propertyNames-&gt;prototype, prototype, DontEnum | DontDelete | ReadOnly);
</span><span class="cx">     putDirectWithoutTransition(vm, vm.propertyNames-&gt;length, jsNumber(1), ReadOnly | DontEnum | DontDelete);
</span><del>-    m_InstanceStructure.set(vm, this, structure);
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> WebAssemblyInstanceConstructor::WebAssemblyInstanceConstructor(VM&amp; vm, Structure* structure)
</span><span class="lines">@@ -99,7 +98,6 @@
</span><span class="cx">     auto* thisObject = jsCast&lt;WebAssemblyInstanceConstructor*&gt;(cell);
</span><span class="cx">     ASSERT_GC_OBJECT_INHERITS(thisObject, info());
</span><span class="cx">     Base::visitChildren(thisObject, visitor);
</span><del>-    visitor.append(&amp;thisObject-&gt;m_InstanceStructure);
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace JSC
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsWebAssemblyInstanceConstructorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/WebAssemblyInstanceConstructor.h (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/WebAssemblyInstanceConstructor.h        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/wasm/js/WebAssemblyInstanceConstructor.h        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -39,15 +39,13 @@
</span><span class="cx">     typedef InternalFunction Base;
</span><span class="cx">     static const unsigned StructureFlags = Base::StructureFlags | HasStaticPropertyTable;
</span><span class="cx"> 
</span><del>-    static WebAssemblyInstanceConstructor* create(VM&amp;, Structure*, WebAssemblyInstancePrototype*, Structure*);
</del><ins>+    static WebAssemblyInstanceConstructor* create(VM&amp;, Structure*, WebAssemblyInstancePrototype*);
</ins><span class="cx">     static Structure* createStructure(VM&amp;, JSGlobalObject*, JSValue);
</span><span class="cx"> 
</span><span class="cx">     DECLARE_INFO;
</span><span class="cx"> 
</span><del>-    Structure* InstanceStructure() const { return m_InstanceStructure.get(); }
-
</del><span class="cx"> protected:
</span><del>-    void finishCreation(VM&amp;, WebAssemblyInstancePrototype*, Structure*);
</del><ins>+    void finishCreation(VM&amp;, WebAssemblyInstancePrototype*);
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     WebAssemblyInstanceConstructor(VM&amp;, Structure*);
</span><span class="lines">@@ -54,8 +52,6 @@
</span><span class="cx">     static ConstructType getConstructData(JSCell*, ConstructData&amp;);
</span><span class="cx">     static CallType getCallData(JSCell*, CallData&amp;);
</span><span class="cx">     static void visitChildren(JSCell*, SlotVisitor&amp;);
</span><del>-
-    WriteBarrier&lt;Structure&gt; m_InstanceStructure;
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace JSC
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsWebAssemblyMemoryConstructorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/WebAssemblyMemoryConstructor.cpp (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/WebAssemblyMemoryConstructor.cpp        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/wasm/js/WebAssemblyMemoryConstructor.cpp        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -57,10 +57,10 @@
</span><span class="cx">     return JSValue::encode(throwConstructorCannotBeCalledAsFunctionTypeError(state, scope, &quot;WebAssembly.Memory&quot;));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-WebAssemblyMemoryConstructor* WebAssemblyMemoryConstructor::create(VM&amp; vm, Structure* structure, WebAssemblyMemoryPrototype* thisPrototype, Structure* thisStructure)
</del><ins>+WebAssemblyMemoryConstructor* WebAssemblyMemoryConstructor::create(VM&amp; vm, Structure* structure, WebAssemblyMemoryPrototype* thisPrototype)
</ins><span class="cx"> {
</span><span class="cx">     auto* constructor = new (NotNull, allocateCell&lt;WebAssemblyMemoryConstructor&gt;(vm.heap)) WebAssemblyMemoryConstructor(vm, structure);
</span><del>-    constructor-&gt;finishCreation(vm, thisPrototype, thisStructure);
</del><ins>+    constructor-&gt;finishCreation(vm, thisPrototype);
</ins><span class="cx">     return constructor;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -69,12 +69,11 @@
</span><span class="cx">     return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebAssemblyMemoryConstructor::finishCreation(VM&amp; vm, WebAssemblyMemoryPrototype* prototype, Structure* structure)
</del><ins>+void WebAssemblyMemoryConstructor::finishCreation(VM&amp; vm, WebAssemblyMemoryPrototype* prototype)
</ins><span class="cx"> {
</span><span class="cx">     Base::finishCreation(vm, ASCIILiteral(&quot;Memory&quot;));
</span><span class="cx">     putDirectWithoutTransition(vm, vm.propertyNames-&gt;prototype, prototype, DontEnum | DontDelete | ReadOnly);
</span><span class="cx">     putDirectWithoutTransition(vm, vm.propertyNames-&gt;length, jsNumber(1), ReadOnly | DontEnum | DontDelete);
</span><del>-    m_MemoryStructure.set(vm, this, structure);
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> WebAssemblyMemoryConstructor::WebAssemblyMemoryConstructor(VM&amp; vm, Structure* structure)
</span><span class="lines">@@ -99,7 +98,6 @@
</span><span class="cx">     auto* thisObject = jsCast&lt;WebAssemblyMemoryConstructor*&gt;(cell);
</span><span class="cx">     ASSERT_GC_OBJECT_INHERITS(thisObject, info());
</span><span class="cx">     Base::visitChildren(thisObject, visitor);
</span><del>-    visitor.append(&amp;thisObject-&gt;m_MemoryStructure);
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace JSC
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsWebAssemblyMemoryConstructorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/WebAssemblyMemoryConstructor.h (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/WebAssemblyMemoryConstructor.h        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/wasm/js/WebAssemblyMemoryConstructor.h        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -39,15 +39,13 @@
</span><span class="cx">     typedef InternalFunction Base;
</span><span class="cx">     static const unsigned StructureFlags = Base::StructureFlags | HasStaticPropertyTable;
</span><span class="cx"> 
</span><del>-    static WebAssemblyMemoryConstructor* create(VM&amp;, Structure*, WebAssemblyMemoryPrototype*, Structure*);
</del><ins>+    static WebAssemblyMemoryConstructor* create(VM&amp;, Structure*, WebAssemblyMemoryPrototype*);
</ins><span class="cx">     static Structure* createStructure(VM&amp;, JSGlobalObject*, JSValue);
</span><span class="cx"> 
</span><span class="cx">     DECLARE_INFO;
</span><span class="cx"> 
</span><del>-    Structure* MemoryStructure() const { return m_MemoryStructure.get(); }
-
</del><span class="cx"> protected:
</span><del>-    void finishCreation(VM&amp;, WebAssemblyMemoryPrototype*, Structure*);
</del><ins>+    void finishCreation(VM&amp;, WebAssemblyMemoryPrototype*);
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     WebAssemblyMemoryConstructor(VM&amp;, Structure*);
</span><span class="lines">@@ -54,8 +52,6 @@
</span><span class="cx">     static ConstructType getConstructData(JSCell*, ConstructData&amp;);
</span><span class="cx">     static CallType getCallData(JSCell*, CallData&amp;);
</span><span class="cx">     static void visitChildren(JSCell*, SlotVisitor&amp;);
</span><del>-
-    WriteBarrier&lt;Structure&gt; m_MemoryStructure;
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace JSC
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsWebAssemblyModuleConstructorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleConstructor.cpp (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleConstructor.cpp        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleConstructor.cpp        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -28,8 +28,14 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(WEBASSEMBLY)
</span><span class="cx"> 
</span><ins>+#include &quot;ExceptionHelpers.h&quot;
</ins><span class="cx"> #include &quot;FunctionPrototype.h&quot;
</span><ins>+#include &quot;JSArrayBuffer.h&quot;
</ins><span class="cx"> #include &quot;JSCInlines.h&quot;
</span><ins>+#include &quot;JSTypedArrays.h&quot;
+#include &quot;JSWebAssemblyCompileError.h&quot;
+#include &quot;JSWebAssemblyModule.h&quot;
+#include &quot;WasmPlan.h&quot;
</ins><span class="cx"> #include &quot;WebAssemblyModulePrototype.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;WebAssemblyModuleConstructor.lut.h&quot;
</span><span class="lines">@@ -45,9 +51,30 @@
</span><span class="cx"> 
</span><span class="cx"> static EncodedJSValue JSC_HOST_CALL constructJSWebAssemblyModule(ExecState* state)
</span><span class="cx"> {
</span><del>-    VM&amp; vm = state-&gt;vm();
</del><ins>+    auto&amp; vm = state-&gt;vm();
</ins><span class="cx">     auto scope = DECLARE_THROW_SCOPE(vm);
</span><del>-    return JSValue::encode(throwException(state, scope, createError(state, ASCIILiteral(&quot;WebAssembly doesn't yet implement the Module constructor property&quot;))));
</del><ins>+    JSValue val = state-&gt;argument(0);
+    JSArrayBuffer* arrayBuffer = val.getObject() ? jsDynamicCast&lt;JSArrayBuffer*&gt;(val.getObject()) : nullptr;
+    JSArrayBufferView* arrayBufferView = val.getObject() ? jsDynamicCast&lt;JSArrayBufferView*&gt;(val.getObject()) : nullptr;
+    if (!(arrayBuffer || arrayBufferView))
+        return JSValue::encode(throwException(state, scope, createTypeError(state, ASCIILiteral(&quot;first argument to WebAssembly.Module must be an ArrayBufferView or an ArrayBuffer&quot;), defaultSourceAppender, runtimeTypeForValue(val))));
+
+    if (arrayBufferView ? arrayBufferView-&gt;isNeutered() : arrayBuffer-&gt;impl()-&gt;isNeutered())
+        return JSValue::encode(throwException(state, scope, createTypeError(state, ASCIILiteral(&quot;underlying TypedArray has been detatched from the ArrayBuffer&quot;), defaultSourceAppender, runtimeTypeForValue(val))));
+
+    size_t byteOffset = arrayBufferView ? arrayBufferView-&gt;byteOffset() : 0;
+    size_t byteSize = arrayBufferView ? arrayBufferView-&gt;length() : arrayBuffer-&gt;impl()-&gt;byteLength();
+    const auto* base = arrayBufferView ? static_cast&lt;uint8_t*&gt;(arrayBufferView-&gt;vector()) : static_cast&lt;uint8_t*&gt;(arrayBuffer-&gt;impl()-&gt;data());
+
+    Wasm::Plan plan(vm, base + byteOffset, byteSize);
+    if (plan.failed())
+        return JSValue::encode(throwException(state, scope, createWebAssemblyCompileError(state, plan.errorMessage())));
+
+    // FIXME take content from Plan.
+
+    auto* structure = InternalFunction::createSubclassStructure(state, state-&gt;newTarget(), asInternalFunction(state-&gt;callee())-&gt;globalObject()-&gt;WebAssemblyModuleStructure());
+    RETURN_IF_EXCEPTION(scope, encodedJSValue());
+    return JSValue::encode(JSWebAssemblyModule::create(vm, structure));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static EncodedJSValue JSC_HOST_CALL callJSWebAssemblyModule(ExecState* state)
</span><span class="lines">@@ -57,10 +84,10 @@
</span><span class="cx">     return JSValue::encode(throwConstructorCannotBeCalledAsFunctionTypeError(state, scope, &quot;WebAssembly.Module&quot;));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-WebAssemblyModuleConstructor* WebAssemblyModuleConstructor::create(VM&amp; vm, Structure* structure, WebAssemblyModulePrototype* thisPrototype, Structure* thisStructure)
</del><ins>+WebAssemblyModuleConstructor* WebAssemblyModuleConstructor::create(VM&amp; vm, Structure* structure, WebAssemblyModulePrototype* thisPrototype)
</ins><span class="cx"> {
</span><span class="cx">     auto* constructor = new (NotNull, allocateCell&lt;WebAssemblyModuleConstructor&gt;(vm.heap)) WebAssemblyModuleConstructor(vm, structure);
</span><del>-    constructor-&gt;finishCreation(vm, thisPrototype, thisStructure);
</del><ins>+    constructor-&gt;finishCreation(vm, thisPrototype);
</ins><span class="cx">     return constructor;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -69,12 +96,11 @@
</span><span class="cx">     return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebAssemblyModuleConstructor::finishCreation(VM&amp; vm, WebAssemblyModulePrototype* prototype, Structure* structure)
</del><ins>+void WebAssemblyModuleConstructor::finishCreation(VM&amp; vm, WebAssemblyModulePrototype* prototype)
</ins><span class="cx"> {
</span><span class="cx">     Base::finishCreation(vm, ASCIILiteral(&quot;Module&quot;));
</span><span class="cx">     putDirectWithoutTransition(vm, vm.propertyNames-&gt;prototype, prototype, DontEnum | DontDelete | ReadOnly);
</span><span class="cx">     putDirectWithoutTransition(vm, vm.propertyNames-&gt;length, jsNumber(1), ReadOnly | DontEnum | DontDelete);
</span><del>-    m_ModuleStructure.set(vm, this, structure);
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> WebAssemblyModuleConstructor::WebAssemblyModuleConstructor(VM&amp; vm, Structure* structure)
</span><span class="lines">@@ -99,7 +125,6 @@
</span><span class="cx">     auto* thisObject = jsCast&lt;WebAssemblyModuleConstructor*&gt;(cell);
</span><span class="cx">     ASSERT_GC_OBJECT_INHERITS(thisObject, info());
</span><span class="cx">     Base::visitChildren(thisObject, visitor);
</span><del>-    visitor.append(&amp;thisObject-&gt;m_ModuleStructure);
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace JSC
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsWebAssemblyModuleConstructorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleConstructor.h (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleConstructor.h        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleConstructor.h        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -39,15 +39,13 @@
</span><span class="cx">     typedef InternalFunction Base;
</span><span class="cx">     static const unsigned StructureFlags = Base::StructureFlags | HasStaticPropertyTable;
</span><span class="cx"> 
</span><del>-    static WebAssemblyModuleConstructor* create(VM&amp;, Structure*, WebAssemblyModulePrototype*, Structure*);
</del><ins>+    static WebAssemblyModuleConstructor* create(VM&amp;, Structure*, WebAssemblyModulePrototype*);
</ins><span class="cx">     static Structure* createStructure(VM&amp;, JSGlobalObject*, JSValue);
</span><span class="cx"> 
</span><span class="cx">     DECLARE_INFO;
</span><span class="cx"> 
</span><del>-    Structure* ModuleStructure() const { return m_ModuleStructure.get(); }
-
</del><span class="cx"> protected:
</span><del>-    void finishCreation(VM&amp;, WebAssemblyModulePrototype*, Structure*);
</del><ins>+    void finishCreation(VM&amp;, WebAssemblyModulePrototype*);
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     WebAssemblyModuleConstructor(VM&amp;, Structure*);
</span><span class="lines">@@ -54,8 +52,6 @@
</span><span class="cx">     static ConstructType getConstructData(JSCell*, ConstructData&amp;);
</span><span class="cx">     static CallType getCallData(JSCell*, CallData&amp;);
</span><span class="cx">     static void visitChildren(JSCell*, SlotVisitor&amp;);
</span><del>-
-    WriteBarrier&lt;Structure&gt; m_ModuleStructure;
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace JSC
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsWebAssemblyRuntimeErrorConstructorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/WebAssemblyRuntimeErrorConstructor.cpp (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/WebAssemblyRuntimeErrorConstructor.cpp        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/wasm/js/WebAssemblyRuntimeErrorConstructor.cpp        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -61,10 +61,10 @@
</span><span class="cx">     return JSValue::encode(throwConstructorCannotBeCalledAsFunctionTypeError(state, scope, &quot;WebAssembly.RuntimeError&quot;));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-WebAssemblyRuntimeErrorConstructor* WebAssemblyRuntimeErrorConstructor::create(VM&amp; vm, Structure* structure, WebAssemblyRuntimeErrorPrototype* thisPrototype, Structure* thisStructure)
</del><ins>+WebAssemblyRuntimeErrorConstructor* WebAssemblyRuntimeErrorConstructor::create(VM&amp; vm, Structure* structure, WebAssemblyRuntimeErrorPrototype* thisPrototype)
</ins><span class="cx"> {
</span><span class="cx">     auto* constructor = new (NotNull, allocateCell&lt;WebAssemblyRuntimeErrorConstructor&gt;(vm.heap)) WebAssemblyRuntimeErrorConstructor(vm, structure);
</span><del>-    constructor-&gt;finishCreation(vm, thisPrototype, thisStructure);
</del><ins>+    constructor-&gt;finishCreation(vm, thisPrototype);
</ins><span class="cx">     return constructor;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -73,7 +73,7 @@
</span><span class="cx">     return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebAssemblyRuntimeErrorConstructor::finishCreation(VM&amp; vm, WebAssemblyRuntimeErrorPrototype* prototype, Structure*)
</del><ins>+void WebAssemblyRuntimeErrorConstructor::finishCreation(VM&amp; vm, WebAssemblyRuntimeErrorPrototype* prototype)
</ins><span class="cx"> {
</span><span class="cx">     Base::finishCreation(vm, ASCIILiteral(&quot;RuntimeError&quot;));
</span><span class="cx">     putDirectWithoutTransition(vm, vm.propertyNames-&gt;prototype, prototype, ReadOnly | DontEnum | DontDelete);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsWebAssemblyRuntimeErrorConstructorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/WebAssemblyRuntimeErrorConstructor.h (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/WebAssemblyRuntimeErrorConstructor.h        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/wasm/js/WebAssemblyRuntimeErrorConstructor.h        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -39,13 +39,13 @@
</span><span class="cx">     typedef InternalFunction Base;
</span><span class="cx">     static const unsigned StructureFlags = Base::StructureFlags | HasStaticPropertyTable;
</span><span class="cx"> 
</span><del>-    static WebAssemblyRuntimeErrorConstructor* create(VM&amp;, Structure*, WebAssemblyRuntimeErrorPrototype*, Structure*);
</del><ins>+    static WebAssemblyRuntimeErrorConstructor* create(VM&amp;, Structure*, WebAssemblyRuntimeErrorPrototype*);
</ins><span class="cx">     static Structure* createStructure(VM&amp;, JSGlobalObject*, JSValue);
</span><span class="cx"> 
</span><span class="cx">     DECLARE_INFO;
</span><span class="cx"> 
</span><span class="cx"> protected:
</span><del>-    void finishCreation(VM&amp;, WebAssemblyRuntimeErrorPrototype*, Structure*);
</del><ins>+    void finishCreation(VM&amp;, WebAssemblyRuntimeErrorPrototype*);
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     WebAssemblyRuntimeErrorConstructor(VM&amp;, Structure*);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsWebAssemblyTableConstructorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/WebAssemblyTableConstructor.cpp (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/WebAssemblyTableConstructor.cpp        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/wasm/js/WebAssemblyTableConstructor.cpp        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -57,10 +57,10 @@
</span><span class="cx">     return JSValue::encode(throwConstructorCannotBeCalledAsFunctionTypeError(state, scope, &quot;WebAssembly.Table&quot;));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-WebAssemblyTableConstructor* WebAssemblyTableConstructor::create(VM&amp; vm, Structure* structure, WebAssemblyTablePrototype* thisPrototype, Structure* thisStructure)
</del><ins>+WebAssemblyTableConstructor* WebAssemblyTableConstructor::create(VM&amp; vm, Structure* structure, WebAssemblyTablePrototype* thisPrototype)
</ins><span class="cx"> {
</span><span class="cx">     auto* constructor = new (NotNull, allocateCell&lt;WebAssemblyTableConstructor&gt;(vm.heap)) WebAssemblyTableConstructor(vm, structure);
</span><del>-    constructor-&gt;finishCreation(vm, thisPrototype, thisStructure);
</del><ins>+    constructor-&gt;finishCreation(vm, thisPrototype);
</ins><span class="cx">     return constructor;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -69,12 +69,11 @@
</span><span class="cx">     return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebAssemblyTableConstructor::finishCreation(VM&amp; vm, WebAssemblyTablePrototype* prototype, Structure* structure)
</del><ins>+void WebAssemblyTableConstructor::finishCreation(VM&amp; vm, WebAssemblyTablePrototype* prototype)
</ins><span class="cx"> {
</span><span class="cx">     Base::finishCreation(vm, ASCIILiteral(&quot;Table&quot;));
</span><span class="cx">     putDirectWithoutTransition(vm, vm.propertyNames-&gt;prototype, prototype, DontEnum | DontDelete | ReadOnly);
</span><span class="cx">     putDirectWithoutTransition(vm, vm.propertyNames-&gt;length, jsNumber(1), ReadOnly | DontEnum | DontDelete);
</span><del>-    m_TableStructure.set(vm, this, structure);
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> WebAssemblyTableConstructor::WebAssemblyTableConstructor(VM&amp; vm, Structure* structure)
</span><span class="lines">@@ -99,7 +98,6 @@
</span><span class="cx">     auto* thisObject = jsCast&lt;WebAssemblyTableConstructor*&gt;(cell);
</span><span class="cx">     ASSERT_GC_OBJECT_INHERITS(thisObject, info());
</span><span class="cx">     Base::visitChildren(thisObject, visitor);
</span><del>-    visitor.append(&amp;thisObject-&gt;m_TableStructure);
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace JSC
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsWebAssemblyTableConstructorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/WebAssemblyTableConstructor.h (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/WebAssemblyTableConstructor.h        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/wasm/js/WebAssemblyTableConstructor.h        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -39,15 +39,13 @@
</span><span class="cx">     typedef InternalFunction Base;
</span><span class="cx">     static const unsigned StructureFlags = Base::StructureFlags | HasStaticPropertyTable;
</span><span class="cx"> 
</span><del>-    static WebAssemblyTableConstructor* create(VM&amp;, Structure*, WebAssemblyTablePrototype*, Structure*);
</del><ins>+    static WebAssemblyTableConstructor* create(VM&amp;, Structure*, WebAssemblyTablePrototype*);
</ins><span class="cx">     static Structure* createStructure(VM&amp;, JSGlobalObject*, JSValue);
</span><span class="cx"> 
</span><span class="cx">     DECLARE_INFO;
</span><span class="cx"> 
</span><del>-    Structure* TableStructure() const { return m_TableStructure.get(); }
-
</del><span class="cx"> protected:
</span><del>-    void finishCreation(VM&amp;, WebAssemblyTablePrototype*, Structure*);
</del><ins>+    void finishCreation(VM&amp;, WebAssemblyTablePrototype*);
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     WebAssemblyTableConstructor(VM&amp;, Structure*);
</span><span class="lines">@@ -54,8 +52,6 @@
</span><span class="cx">     static ConstructType getConstructData(JSCell*, ConstructData&amp;);
</span><span class="cx">     static CallType getCallData(JSCell*, CallData&amp;);
</span><span class="cx">     static void visitChildren(JSCell*, SlotVisitor&amp;);
</span><del>-
-    WriteBarrier&lt;Structure&gt; m_TableStructure;
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace JSC
</span></span></pre>
</div>
</div>

</body>
</html>