<!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>[209630] 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/209630">209630</a></dd>
<dt>Author</dt> <dd>sbarati@apple.com</dd>
<dt>Date</dt> <dd>2016-12-09 14:38:39 -0800 (Fri, 09 Dec 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>WebAssembly JS API: implement importing and defining Memory
https://bugs.webkit.org/show_bug.cgi?id=164134

Reviewed by Keith Miller.

JSTests:

* wasm/Builder.js:
(const._importMemoryContinuation.section):
(const._importMemoryContinuation.assert):
(const._importMemoryContinuation):
(const._exportFunctionContinuation.const): Deleted.
(const._exportFunctionContinuation): Deleted.
* wasm/Builder_WebAssemblyBinary.js:
(const.emitters.Import):
* wasm/js-api/test_basic_api.js:
(const.c.in.constructorProperties.switch):
* wasm/js-api/test_memory.js: Added.
(assert):
(binaryShouldNotParse):
(test):
(test.testMemImportError):
* wasm/js-api/test_memory_constructor.js: Added.
(assert):
(throw.new.Error):
(testInvalidSize):
(assert.testInvalidInitial):
(testInvalidInitial.testInvalidMaximum):
(testInvalidInitial):
(testInvalidMaximum):
* wasm/self-test/test_BuilderJSON.js:

Source/JavaScriptCore:

This patch implements the WebAssembly.Memory object. It refactors
the code to now associate a Memory with the instance instead of
the Module.

* CMakeLists.txt:
* JavaScriptCore.xcodeproj/project.pbxproj:
* jsc.cpp:
(functionTestWasmModuleFunctions):
* runtime/VM.h:
* shell/CMakeLists.txt:
* testWasm.cpp: Removed.
This has bitrotted. I'm removing it.

* wasm/WasmB3IRGenerator.cpp:
(JSC::Wasm::B3IRGenerator::B3IRGenerator):
(JSC::Wasm::sizeOfLoadOp):
(JSC::Wasm::createJSToWasmWrapper):
(JSC::Wasm::parseAndCompile):
* wasm/WasmB3IRGenerator.h:
* wasm/WasmFormat.cpp:
(JSC::Wasm::ModuleInformation::~ModuleInformation): Deleted.
* wasm/WasmFormat.h:
* wasm/WasmMemory.cpp:
(JSC::Wasm::Memory::Memory):
* wasm/WasmMemory.h:
(JSC::Wasm::Memory::size):
(JSC::Wasm::Memory::initial):
(JSC::Wasm::Memory::maximum):
(JSC::Wasm::Memory::pinnedRegisters): Deleted.
* wasm/WasmMemoryInformation.cpp: Added.
(JSC::Wasm::MemoryInformation::MemoryInformation):
* wasm/WasmMemoryInformation.h: Added.
(JSC::Wasm::MemoryInformation::MemoryInformation):
(JSC::Wasm::MemoryInformation::pinnedRegisters):
(JSC::Wasm::MemoryInformation::initial):
(JSC::Wasm::MemoryInformation::maximum):
(JSC::Wasm::MemoryInformation::isImport):
(JSC::Wasm::MemoryInformation::operator bool):
* wasm/WasmModuleParser.cpp:
(JSC::Wasm::ModuleParser::parseImport):
(JSC::Wasm::ModuleParser::parseMemoryHelper):
(JSC::Wasm::ModuleParser::parseMemory):
(JSC::Wasm::ModuleParser::parseExport):
* wasm/WasmModuleParser.h:
* wasm/WasmPageCount.h: Added. Implement a new way of describing Wasm
pages and then asking for how many bytes a quantity of pages is. This
class also makes it clear when we're talking about bytes or pages.

(JSC::Wasm::PageCount::PageCount):
(JSC::Wasm::PageCount::bytes):
(JSC::Wasm::PageCount::isValid):
(JSC::Wasm::PageCount::max):
(JSC::Wasm::PageCount::operator bool):
(JSC::Wasm::PageCount::operator&lt;):
(JSC::Wasm::PageCount::operator&gt;):
(JSC::Wasm::PageCount::operator&gt;=):
* wasm/WasmPlan.cpp:
(JSC::Wasm::Plan::run):
* wasm/WasmPlan.h:
(JSC::Wasm::Plan::memory): Deleted.
* wasm/WasmValidate.cpp:
(JSC::Wasm::Validate::hasMemory):
(JSC::Wasm::Validate::Validate):
(JSC::Wasm::validateFunction):
* wasm/WasmValidate.h:
* wasm/generateWasmValidateInlinesHeader.py:
* wasm/js/JSWebAssemblyInstance.cpp:
(JSC::JSWebAssemblyInstance::visitChildren):
* wasm/js/JSWebAssemblyInstance.h:
(JSC::JSWebAssemblyInstance::memory):
(JSC::JSWebAssemblyInstance::setMemory):
(JSC::JSWebAssemblyInstance::offsetOfImportFunctions):
(JSC::JSWebAssemblyInstance::allocationSize):
* wasm/js/JSWebAssemblyMemory.cpp:
(JSC::JSWebAssemblyMemory::create):
(JSC::JSWebAssemblyMemory::JSWebAssemblyMemory):
(JSC::JSWebAssemblyMemory::buffer):
(JSC::JSWebAssemblyMemory::visitChildren):
* wasm/js/JSWebAssemblyMemory.h:
(JSC::JSWebAssemblyMemory::memory):
* wasm/js/WebAssemblyFunction.cpp:
(JSC::callWebAssemblyFunction):
* wasm/js/WebAssemblyInstanceConstructor.cpp:
Handle importing and creating of memory according
to the spec. This also does the needed validation
of making sure the memory defined in the module
is compatible with the imported memory.

(JSC::constructJSWebAssemblyInstance):
* wasm/js/WebAssemblyMemoryConstructor.cpp:
(JSC::constructJSWebAssemblyMemory):
(JSC::callJSWebAssemblyMemory):
* wasm/js/WebAssemblyMemoryPrototype.cpp:
(JSC::webAssemblyMemoryProtoFuncBuffer):
(JSC::WebAssemblyMemoryPrototype::create):
(JSC::WebAssemblyMemoryPrototype::finishCreation):
* wasm/js/WebAssemblyMemoryPrototype.h:
* wasm/js/WebAssemblyModuleRecord.cpp:
(JSC::WebAssemblyModuleRecord::finishCreation):
(JSC::WebAssemblyModuleRecord::link):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkJSTestsChangeLog">trunk/JSTests/ChangeLog</a></li>
<li><a href="#trunkJSTestswasmBuilderjs">trunk/JSTests/wasm/Builder.js</a></li>
<li><a href="#trunkJSTestswasmBuilder_WebAssemblyBinaryjs">trunk/JSTests/wasm/Builder_WebAssemblyBinary.js</a></li>
<li><a href="#trunkJSTestswasmjsapitest_basic_apijs">trunk/JSTests/wasm/js-api/test_basic_api.js</a></li>
<li><a href="#trunkJSTestswasmselftesttest_BuilderJSONjs">trunk/JSTests/wasm/self-test/test_BuilderJSON.js</a></li>
<li><a href="#trunkSourceJavaScriptCoreCMakeListstxt">trunk/Source/JavaScriptCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj">trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceJavaScriptCorejsccpp">trunk/Source/JavaScriptCore/jsc.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeVMh">trunk/Source/JavaScriptCore/runtime/VM.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreshellCMakeListstxt">trunk/Source/JavaScriptCore/shell/CMakeLists.txt</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="#trunkSourceJavaScriptCorewasmWasmFormatcpp">trunk/Source/JavaScriptCore/wasm/WasmFormat.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmWasmFormath">trunk/Source/JavaScriptCore/wasm/WasmFormat.h</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmWasmMemorycpp">trunk/Source/JavaScriptCore/wasm/WasmMemory.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmWasmMemoryh">trunk/Source/JavaScriptCore/wasm/WasmMemory.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="#trunkSourceJavaScriptCorewasmWasmPlancpp">trunk/Source/JavaScriptCore/wasm/WasmPlan.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmWasmPlanh">trunk/Source/JavaScriptCore/wasm/WasmPlan.h</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmWasmValidatecpp">trunk/Source/JavaScriptCore/wasm/WasmValidate.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmWasmValidateh">trunk/Source/JavaScriptCore/wasm/WasmValidate.h</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmgenerateWasmValidateInlinesHeaderpy">trunk/Source/JavaScriptCore/wasm/generateWasmValidateInlinesHeader.py</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsJSWebAssemblyInstancecpp">trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsJSWebAssemblyInstanceh">trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.h</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsJSWebAssemblyMemorycpp">trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyMemory.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsJSWebAssemblyMemoryh">trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyMemory.h</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsWebAssemblyFunctioncpp">trunk/Source/JavaScriptCore/wasm/js/WebAssemblyFunction.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsWebAssemblyInstanceConstructorcpp">trunk/Source/JavaScriptCore/wasm/js/WebAssemblyInstanceConstructor.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsWebAssemblyMemoryConstructorcpp">trunk/Source/JavaScriptCore/wasm/js/WebAssemblyMemoryConstructor.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsWebAssemblyMemoryPrototypecpp">trunk/Source/JavaScriptCore/wasm/js/WebAssemblyMemoryPrototype.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsWebAssemblyMemoryPrototypeh">trunk/Source/JavaScriptCore/wasm/js/WebAssemblyMemoryPrototype.h</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsWebAssemblyModuleRecordcpp">trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkJSTestswasmjsapitest_memoryjs">trunk/JSTests/wasm/js-api/test_memory.js</a></li>
<li><a href="#trunkJSTestswasmjsapitest_memory_constructorjs">trunk/JSTests/wasm/js-api/test_memory_constructor.js</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmWasmMemoryInformationcpp">trunk/Source/JavaScriptCore/wasm/WasmMemoryInformation.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmWasmMemoryInformationh">trunk/Source/JavaScriptCore/wasm/WasmMemoryInformation.h</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmWasmPageCounth">trunk/Source/JavaScriptCore/wasm/WasmPageCount.h</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoretestWasmcpp">trunk/Source/JavaScriptCore/testWasm.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkJSTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/ChangeLog (209629 => 209630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/ChangeLog        2016-12-09 22:12:08 UTC (rev 209629)
+++ trunk/JSTests/ChangeLog        2016-12-09 22:38:39 UTC (rev 209630)
</span><span class="lines">@@ -1,3 +1,35 @@
</span><ins>+2016-12-09  Saam Barati  &lt;sbarati@apple.com&gt;
+
+        WebAssembly JS API: implement importing and defining Memory
+        https://bugs.webkit.org/show_bug.cgi?id=164134
+
+        Reviewed by Keith Miller.
+
+        * wasm/Builder.js:
+        (const._importMemoryContinuation.section):
+        (const._importMemoryContinuation.assert):
+        (const._importMemoryContinuation):
+        (const._exportFunctionContinuation.const): Deleted.
+        (const._exportFunctionContinuation): Deleted.
+        * wasm/Builder_WebAssemblyBinary.js:
+        (const.emitters.Import):
+        * wasm/js-api/test_basic_api.js:
+        (const.c.in.constructorProperties.switch):
+        * wasm/js-api/test_memory.js: Added.
+        (assert):
+        (binaryShouldNotParse):
+        (test):
+        (test.testMemImportError):
+        * wasm/js-api/test_memory_constructor.js: Added.
+        (assert):
+        (throw.new.Error):
+        (testInvalidSize):
+        (assert.testInvalidInitial):
+        (testInvalidInitial.testInvalidMaximum):
+        (testInvalidInitial):
+        (testInvalidMaximum):
+        * wasm/self-test/test_BuilderJSON.js:
+
</ins><span class="cx"> 2016-12-08  JF Bastien  &lt;jfbastien@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         WebAssembly: JSC::link* shouldn't need a CodeBlock
</span></span></pre></div>
<a id="trunkJSTestswasmBuilderjs"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/wasm/Builder.js (209629 => 209630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/wasm/Builder.js        2016-12-09 22:12:08 UTC (rev 209629)
+++ trunk/JSTests/wasm/Builder.js        2016-12-09 22:38:39 UTC (rev 209630)
</span><span class="lines">@@ -102,6 +102,15 @@
</span><span class="cx">     };
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+const _importMemoryContinuation = (builder, section, nextBuilder) =&gt; {
+    return (module, field, memoryDescription) =&gt; {
+        assert.isString(module, `Import function module should be a string, got &quot;${module}&quot;`);
+        assert.isString(field, `Import function field should be a string, got &quot;${field}&quot;`);
+        section.data.push({module, field, kind: &quot;Memory&quot;, memoryDescription});
+        return nextBuilder;
+    };
+};
+
</ins><span class="cx"> const _exportFunctionContinuation = (builder, section, nextBuilder) =&gt; {
</span><span class="cx">     return (field, index, type) =&gt; {
</span><span class="cx">         assert.isString(field, `Export function field should be a string, got &quot;${field}&quot;`);
</span><span class="lines">@@ -110,6 +119,7 @@
</span><span class="cx">             // Exports can leave the type unspecified, letting the Code builder patch them up later.
</span><span class="cx">             type = _maybeRegisterType(builder, type);
</span><span class="cx">         }
</span><ins>+
</ins><span class="cx">         // We can't check much about &quot;index&quot; here because the Code section succeeds the Export section. More work is done at Code().End() time.
</span><span class="cx">         switch (typeof(index)) {
</span><span class="cx">         case &quot;string&quot;: break; // Assume it's a function name which will be revealed in the Code section.
</span><span class="lines">@@ -125,6 +135,7 @@
</span><span class="cx">             break;
</span><span class="cx">         default: throw new Error(`Export section's index must be a string or a number, got ${index}`);
</span><span class="cx">         }
</span><ins>+
</ins><span class="cx">         const correspondingImport = builder._getFunctionFromIndexSpace(index);
</span><span class="cx">         const importSection = builder._getSection(&quot;Import&quot;);
</span><span class="cx">         if (typeof(index) === &quot;object&quot;) {
</span><span class="lines">@@ -368,10 +379,10 @@
</span><span class="cx">                     const importBuilder = {
</span><span class="cx">                         End: () =&gt; this,
</span><span class="cx">                         Table: () =&gt; { throw new Error(`Unimplemented: import table`); },
</span><del>-                        Memory: () =&gt; { throw new Error(`Unimplemented: import memory`); },
</del><span class="cx">                         Global: () =&gt; { throw new Error(`Unimplemented: import global`); },
</span><span class="cx">                     };
</span><span class="cx">                     importBuilder.Function = _importFunctionContinuation(this, s, importBuilder);
</span><ins>+                    importBuilder.Memory = _importMemoryContinuation(this, s, importBuilder);
</ins><span class="cx">                     return importBuilder;
</span><span class="cx">                 };
</span><span class="cx">                 break;
</span><span class="lines">@@ -465,7 +476,13 @@
</span><span class="cx">                                     }
</span><span class="cx">                                     if (typeof(e.type) === &quot;undefined&quot;) {
</span><span class="cx">                                         // This must be a function export from the Code section (re-exports were handled earlier).
</span><del>-                                        const functionIndexSpaceOffset = importSection ? importSection.data.length : 0;
</del><ins>+                                        let functionIndexSpaceOffset = 0;
+                                        if (importSection) {
+                                            for (const {kind} of importSection.data) {
+                                                if (kind === &quot;Function&quot;)
+                                                    ++functionIndexSpaceOffset;
+                                            }
+                                        }
</ins><span class="cx">                                         const functionIndex = e.index - functionIndexSpaceOffset;
</span><span class="cx">                                         e.type = codeSection.data[functionIndex].type;
</span><span class="cx">                                     }
</span></span></pre></div>
<a id="trunkJSTestswasmBuilder_WebAssemblyBinaryjs"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/wasm/Builder_WebAssemblyBinary.js (209629 => 209630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/wasm/Builder_WebAssemblyBinary.js        2016-12-09 22:12:08 UTC (rev 209629)
+++ trunk/JSTests/wasm/Builder_WebAssemblyBinary.js        2016-12-09 22:38:39 UTC (rev 209630)
</span><span class="lines">@@ -53,9 +53,29 @@
</span><span class="cx">             put(bin, &quot;uint8&quot;, WASM.externalKindValue[entry.kind]);
</span><span class="cx">             switch (entry.kind) {
</span><span class="cx">             default: throw new Error(`Implementation problem: unexpected kind ${entry.kind}`);
</span><del>-            case &quot;Function&quot;: put(bin, &quot;varuint32&quot;, entry.type); break;
</del><ins>+            case &quot;Function&quot;: {
+                put(bin, &quot;varuint32&quot;, entry.type);
+                break;
+            }
</ins><span class="cx">             case &quot;Table&quot;: throw new Error(`Not yet implemented`);
</span><del>-            case &quot;Memory&quot;: throw new Error(`Not yet implemented`);
</del><ins>+            case &quot;Memory&quot;: {
+                let {initial, maximum} = entry.memoryDescription;
+                assert.truthy(typeof initial === &quot;number&quot;, &quot;We expect 'initial' to be a number&quot;);
+                initial |= 0;
+                let hasMaximum = 0;
+                if (typeof maximum === &quot;number&quot;) {
+                    maximum |= 0;
+                    hasMaximum = 1;
+                } else {
+                    assert.truthy(typeof maximum === &quot;undefined&quot;, &quot;We expect 'maximum' to be a number if it's defined&quot;);
+                }
+
+                put(bin, &quot;varuint1&quot;, hasMaximum);
+                put(bin, &quot;varuint32&quot;, initial);
+                if (hasMaximum)
+                    put(bin, &quot;varuint32&quot;, maximum);
+                break;
+            };
</ins><span class="cx">             case &quot;Global&quot;: throw new Error(`Not yet implemented`);
</span><span class="cx">             }
</span><span class="cx">         }
</span></span></pre></div>
<a id="trunkJSTestswasmjsapitest_basic_apijs"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/wasm/js-api/test_basic_api.js (209629 => 209630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/wasm/js-api/test_basic_api.js        2016-12-09 22:12:08 UTC (rev 209629)
+++ trunk/JSTests/wasm/js-api/test_basic_api.js        2016-12-09 22:38:39 UTC (rev 209630)
</span><span class="lines">@@ -75,8 +75,7 @@
</span><span class="cx">         // assert.eq(Symbol.toStringTag in instance.exports, true);
</span><span class="cx">         break;
</span><span class="cx">     case &quot;Memory&quot;:
</span><del>-        // 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`);
</del><ins>+        new WebAssembly.Memory({initial: 20});
</ins><span class="cx">         break;
</span><span class="cx">     case &quot;Table&quot;:
</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></span></pre></div>
<a id="trunkJSTestswasmjsapitest_memoryjs"></a>
<div class="addfile"><h4>Added: trunk/JSTests/wasm/js-api/test_memory.js (0 => 209630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/wasm/js-api/test_memory.js                                (rev 0)
+++ trunk/JSTests/wasm/js-api/test_memory.js        2016-12-09 22:38:39 UTC (rev 209630)
</span><span class="lines">@@ -0,0 +1,385 @@
</span><ins>+// FIXME: use the assert library: https://bugs.webkit.org/show_bug.cgi?id=165684
+import Builder from '../Builder.js';
+
+function assert(b) {
+    if (!b) {
+        throw new Error(&quot;Bad assertion&quot;);
+    }
+}
+
+const pageSize = 64 * 1024;
+const maxPageCount = (2**32) / pageSize;
+
+function binaryShouldNotParse(builder) {
+    const bin = builder.WebAssembly().get();
+    let threw = false;
+    try {
+        const module = new WebAssembly.Module(bin);
+    } catch(e) {
+        threw = true;
+    }
+    assert(threw);
+}
+
+{
+    // Can't declare more than one memory.
+    const builder = (new Builder())
+        .Type().End()
+        .Import().Memory(&quot;imp&quot;, &quot;memory&quot;, {initial: 20}).End()
+        .Function().End()
+        .Memory().InitialMaxPages(1, 1).End()
+        .Export().End()
+        .Code()
+        .End();
+    binaryShouldNotParse(builder);
+}
+
+{
+    // Can't declare more than one memory.
+    const builder = (new Builder())
+        .Type().End()
+        .Import()
+            .Memory(&quot;imp&quot;, &quot;memory&quot;, {initial: 20})
+            .Memory(&quot;imp&quot;, &quot;memory&quot;, {initial: 30})
+        .End()
+        .Function().End()
+        .Export().End()
+        .Code()
+        .End();
+    binaryShouldNotParse(builder);
+}
+
+{
+    // initial must be &lt;= maximum.
+    const builder = (new Builder())
+        .Type().End()
+        .Import()
+            .Memory(&quot;imp&quot;, &quot;memory&quot;, {initial: 20, maximum: 19})
+        .End()
+        .Function().End()
+        .Export().End()
+        .Code()
+        .End();
+    binaryShouldNotParse(builder);
+}
+
+{
+    // No loads when no memory defined.
+    const builder = (new Builder())
+        .Type().End()
+        .Import().End()
+        .Function().End()
+        .Export().Function(&quot;foo&quot;).End()
+        .Code()
+            .Function(&quot;foo&quot;, { params: [&quot;i32&quot;], ret: &quot;i32&quot; })
+                .GetLocal(0)
+                .I32Load(2, 0)
+                .Return()
+            .End()
+        .End();
+
+    binaryShouldNotParse(builder);
+}
+
+{
+    // No stores when no memory defined.
+    const builder = (new Builder())
+        .Type().End()
+        .Import()
+        .End()
+        .Function().End()
+        .Export().Function(&quot;foo&quot;).End()
+        .Code()
+            .Function(&quot;foo&quot;, { params: [&quot;i32&quot;] })
+                .GetLocal(0)
+                .GetLocal(0)
+                .I32Store(2, 0)
+                .Return()
+            .End()
+        .End();
+
+    binaryShouldNotParse(builder);
+}
+
+{
+    let threw = false;
+    try {
+        new WebAssembly.Memory(20);
+    } catch(e) {
+        assert(e instanceof TypeError);
+        assert(e.message === &quot;WebAssembly.Memory expects its first argument to be an object&quot;);
+        threw = true;
+    }
+    assert(threw);
+}
+
+{
+    let threw = false;
+    try {
+        new WebAssembly.Memory({}, {});
+    } catch(e) {
+        assert(e instanceof TypeError);
+        assert(e.message === &quot;WebAssembly.Memory expects exactly one argument&quot;);
+        threw = true;
+    }
+    assert(threw);
+}
+
+function test(f) {
+    noInline(f);
+    for (let i = 0; i &lt; 2; i++) {
+        f(i);
+    }
+}
+
+test(function() {
+    const memoryDescription = {initial: 20, maximum: 20};
+    const builder = (new Builder())
+        .Type().End()
+        .Import().Memory(&quot;imp&quot;, &quot;memory&quot;, memoryDescription).End()
+        .Function().End()
+        .Export()
+            .Function(&quot;foo&quot;)
+        .End()
+        .Code()
+            .Function(&quot;foo&quot;, { params: [&quot;i32&quot;, &quot;i32&quot;], ret: &quot;i32&quot; })
+                .GetLocal(1)
+                .GetLocal(0)
+                .I32Store(2, 0)
+                .GetLocal(1)
+                .I32Load(2, 0)
+                .Return()
+            .End()
+        .End();
+
+    const bin = builder.WebAssembly().get();
+    const module = new WebAssembly.Module(bin);
+    const memory = new WebAssembly.Memory(memoryDescription);
+    const instance = new WebAssembly.Instance(module, { imp: { memory: memory } });
+    const foo = instance.exports.foo;
+    // foo(value, address)
+
+    const bytes = memoryDescription.initial * pageSize;
+    for (let i = 0; i &lt; (bytes/4); i++) {
+        let value = i + 1;
+        let address = i * 4;
+        let result = foo(value, address);
+        assert(result === value);
+        let arrayBuffer = memory.buffer;
+        let buffer = new Uint32Array(arrayBuffer);
+        assert(buffer[i] === value);
+    }
+});
+
+test(function() {
+    const memoryDescription = {initial: 20, maximum: 20};
+    const builder = (new Builder())
+        .Type().End()
+        .Import().Memory(&quot;imp&quot;, &quot;memory&quot;, memoryDescription).End()
+        .Function().End()
+        .Export()
+            .Function(&quot;foo&quot;)
+        .End()
+        .Code()
+            .Function(&quot;foo&quot;, { params: [&quot;i32&quot;, &quot;i32&quot;], ret: &quot;i32&quot;})
+                .GetLocal(1)
+                .GetLocal(0)
+                .I32Store8(0, 0)
+                .GetLocal(1)
+                .I32Load8U(0, 0)
+                .Return()
+            .End()
+        .End();
+
+    const bin = builder.WebAssembly().get();
+    const module = new WebAssembly.Module(bin);
+    const memory = new WebAssembly.Memory(memoryDescription);
+    const instance = new WebAssembly.Instance(module, { imp: { memory: memory } });
+    const foo = instance.exports.foo;
+    // foo(value, address)
+
+    const bytes = memoryDescription.initial * pageSize;
+    for (let i = 0; i &lt; bytes; i++) {
+        let value = (i + 1);
+        let address = i;
+        let result = foo(value, address);
+        let expectedValue = (value &amp; ((2**8) - 1)); 
+        assert(result === expectedValue);
+        let arrayBuffer = memory.buffer;
+        let buffer = new Uint8Array(arrayBuffer);
+        assert(buffer[i] === expectedValue);
+    }
+});
+
+test(function() {
+    const memoryDescription = {initial: 20, maximum: 20};
+    const builder = (new Builder())
+        .Type().End()
+        .Import().Memory(&quot;imp&quot;, &quot;memory&quot;, memoryDescription).End()
+        .Function().End()
+        .Export()
+            .Function(&quot;foo&quot;)
+        .End()
+        .Code()
+            .Function(&quot;foo&quot;, { params: [&quot;f32&quot;, &quot;i32&quot;], ret: &quot;f32&quot;})
+                .GetLocal(1)
+                .GetLocal(0)
+                .F32Store(2, 0)
+                .GetLocal(1)
+                .F32Load(2, 0)
+                .Return()
+            .End()
+        .End();
+
+    const bin = builder.WebAssembly().get();
+    const module = new WebAssembly.Module(bin);
+    const memory = new WebAssembly.Memory(memoryDescription);
+    const instance = new WebAssembly.Instance(module, { imp: { memory: memory } });
+    const foo = instance.exports.foo;
+    // foo(value, address)
+
+    const bytes = memoryDescription.initial * pageSize;
+    for (let i = 0; i &lt; (bytes/4); i++) {
+        let value = i + 1 + .0128213781289;
+        assert(value !== Math.fround(value));
+        let address = i * 4;
+        let result = foo(value, address);
+        let expectedValue = Math.fround(result);
+        assert(result === expectedValue);
+        let arrayBuffer = memory.buffer;
+        let buffer = new Float32Array(arrayBuffer);
+        assert(buffer[i] === expectedValue);
+    }
+});
+
+test(function() {
+    const memoryDescription = {initial: 20, maximum: 20};
+    const builder = (new Builder())
+        .Type().End()
+        .Import().Memory(&quot;imp&quot;, &quot;memory&quot;, memoryDescription).End()
+        .Function().End()
+        .Export()
+            .Function(&quot;foo&quot;)
+        .End()
+        .Code()
+            .Function(&quot;foo&quot;, { params: [&quot;f64&quot;, &quot;i32&quot;], ret: &quot;f64&quot;})
+                .GetLocal(1)
+                .GetLocal(0)
+                .F64Store(3, 0)
+                .GetLocal(1)
+                .F64Load(3, 0)
+                .Return()
+            .End()
+        .End();
+
+    const bin = builder.WebAssembly().get();
+    const module = new WebAssembly.Module(bin);
+    const memory = new WebAssembly.Memory(memoryDescription);
+    const instance = new WebAssembly.Instance(module, { imp: { memory: memory } });
+    const foo = instance.exports.foo;
+    // foo(value, address)
+
+    const bytes = memoryDescription.initial * pageSize;
+    for (let i = 0; i &lt; (bytes/8); i++) {
+        let value = i + 1 + .0128213781289;
+        let address = i * 8;
+        let result = foo(value, address);
+        let expectedValue = result;
+        assert(result === expectedValue);
+        let arrayBuffer = memory.buffer;
+        let buffer = new Float64Array(arrayBuffer);
+        assert(buffer[i] === expectedValue);
+    }
+});
+
+test(function() {
+    const memoryDescription = {initial: 20, maximum: 25};
+    const builder = (new Builder())
+        .Type().End()
+        .Import().Memory(&quot;imp&quot;, &quot;memory&quot;, memoryDescription).End()
+        .Function().End()
+        .Export()
+            .Function(&quot;foo&quot;)
+        .End()
+        .Code()
+            .Function(&quot;foo&quot;, { params: [&quot;f64&quot;, &quot;i32&quot;], ret: &quot;f64&quot;})
+                .GetLocal(1)
+                .GetLocal(0)
+                .F64Store(3, 0)
+                .GetLocal(1)
+                .F64Load(3, 0)
+                .Return()
+            .End()
+        .End();
+
+    const bin = builder.WebAssembly().get();
+    const module = new WebAssembly.Module(bin);
+
+    function testMemImportError(instanceObj, expectedError) {
+        let threw = false;
+        try {
+            new WebAssembly.Instance(module, instanceObj);
+        } catch(e) {
+            assert(e instanceof TypeError);
+            threw = true;
+            if (expectedError) {
+                assert(e.message === expectedError);
+            }
+        }
+        assert(threw);
+    }
+
+    testMemImportError(20);
+    testMemImportError({ });
+    testMemImportError({imp: { } });
+    testMemImportError({imp: { memory: 20 } });
+    testMemImportError({imp: { memory: [] } });
+    testMemImportError({imp: { memory: new WebAssembly.Memory({initial: 19, maximum: 25}) } }, &quot;Memory import provided an 'initial' that is too small&quot;);
+    testMemImportError({imp: { memory: new WebAssembly.Memory({initial: 20}) } }, &quot;Memory import did not have a 'maximum' but the module requires that it does&quot;);
+    testMemImportError({imp: { memory: new WebAssembly.Memory({initial: 20, maximum: 26}) } }, &quot;Memory imports 'maximum' is larger than the module's expected 'maximum&quot;);
+});
+
+test(function() {
+    const memoryDescription = {initial: 20};
+    const builder = (new Builder())
+        .Type().End()
+        .Import().Memory(&quot;imp&quot;, &quot;memory&quot;, memoryDescription).End()
+        .Function().End()
+        .Export()
+            .Function(&quot;foo&quot;)
+        .End()
+        .Code()
+            .Function(&quot;foo&quot;, { params: [&quot;f64&quot;, &quot;i32&quot;], ret: &quot;f64&quot;})
+                .GetLocal(1)
+                .GetLocal(0)
+                .F64Store(3, 0)
+                .GetLocal(1)
+                .F64Load(3, 0)
+                .Return()
+            .End()
+        .End();
+
+    const bin = builder.WebAssembly().get();
+    const module = new WebAssembly.Module(bin);
+
+    function testMemImportError(instanceObj, expectedError) {
+        let threw = false;
+        try {
+            new WebAssembly.Instance(module, instanceObj);
+        } catch(e) {
+            assert(e instanceof TypeError);
+            threw = true;
+            if (expectedError) {
+                assert(e.message === expectedError);
+            }
+        }
+        assert(threw);
+    }
+
+    testMemImportError({imp: { memory: new WebAssembly.Memory({initial: 19, maximum: 25}) } }, &quot;Memory import provided an 'initial' that is too small&quot;);
+    testMemImportError({imp: { memory: new WebAssembly.Memory({initial: 19}) } }, &quot;Memory import provided an 'initial' that is too small&quot;);
+
+    // This should not throw.
+    new WebAssembly.Instance(module, {imp: {memory: new WebAssembly.Memory({initial:20})}});
+    new WebAssembly.Instance(module, {imp: {memory: new WebAssembly.Memory({initial:20, maximum:20})}});
+});
</ins></span></pre></div>
<a id="trunkJSTestswasmjsapitest_memory_constructorjs"></a>
<div class="addfile"><h4>Added: trunk/JSTests/wasm/js-api/test_memory_constructor.js (0 => 209630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/wasm/js-api/test_memory_constructor.js                                (rev 0)
+++ trunk/JSTests/wasm/js-api/test_memory_constructor.js        2016-12-09 22:38:39 UTC (rev 209630)
</span><span class="lines">@@ -0,0 +1,79 @@
</span><ins>+// FIXME: use the assert library: https://bugs.webkit.org/show_bug.cgi?id=165684
+import Builder from '../Builder.js';
+
+function assert(b) {
+    if (!b) {
+        throw new Error(&quot;Bad assertion&quot;);
+    }
+}
+
+{
+    let threw = false;
+    try {
+        new WebAssembly.Memory({initial: 20, maximum: 19});
+    } catch(e) {
+        assert(e instanceof RangeError);
+        assert(e.message === &quot;'maximum' page count must be than greater than or equal to the 'initial' page count&quot;);
+        threw = true;
+    }
+    assert(threw);
+}
+
+const pageSize = 64 * 1024;
+const maxPageCount = (2**32) / pageSize;
+
+function testInvalidSize(description, propName) {
+    let threw = false;
+    try {
+        new WebAssembly.Memory(description);
+    } catch(e) {
+        threw = true;
+        assert(e instanceof RangeError);
+        assert(e.message === `WebAssembly.Memory '${propName}' page count is too large`);
+    }
+    assert(threw);
+}
+
+{
+    function testInvalidInitial(v) {
+        testInvalidSize({initial: v}, &quot;initial&quot;);
+    }
+
+    // These should not throw.
+    new WebAssembly.Memory({initial: maxPageCount});
+    new WebAssembly.Memory({initial: maxPageCount, maximum: maxPageCount});
+
+    testInvalidInitial(2**31);
+    testInvalidInitial(maxPageCount + 1);
+}
+
+{
+    function testInvalidMaximum(v) {
+        testInvalidSize({initial: 1, maximum: v}, &quot;maximum&quot;);
+    }
+
+    testInvalidMaximum(2**31);
+    testInvalidMaximum(maxPageCount + 1);
+}
+
+{
+    for (let i = 0; i &lt; 5; i++) {
+        let x = Math.random() * (2**10);
+        x |= 0;
+        const mem = new WebAssembly.Memory({initial: x, maximum: x + 100});
+        assert(mem.buffer.byteLength === x * pageSize);
+    }
+}
+
+{
+    let bufferGetter = Object.getOwnPropertyDescriptor((new WebAssembly.Memory({initial:1})).__proto__, &quot;buffer&quot;).get;
+    let threw = false;
+    try {
+        bufferGetter.call({});
+    } catch(e) {
+        assert(e instanceof TypeError);
+        assert(e.message === &quot;WebAssembly.Memory.prototype.buffer getter called with non WebAssembly.Memory |this| value&quot;);
+        threw = true;
+    }
+    assert(threw);
+}
</ins></span></pre></div>
<a id="trunkJSTestswasmselftesttest_BuilderJSONjs"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/wasm/self-test/test_BuilderJSON.js (209629 => 209630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/wasm/self-test/test_BuilderJSON.js        2016-12-09 22:12:08 UTC (rev 209629)
+++ trunk/JSTests/wasm/self-test/test_BuilderJSON.js        2016-12-09 22:38:39 UTC (rev 209630)
</span><span class="lines">@@ -569,4 +569,23 @@
</span><span class="cx">     assert.eq(j.section[1].data[0].code[3].name, &quot;select&quot;);
</span><span class="cx"> })();
</span><span class="cx"> 
</span><ins>+(function MemoryImport() {
+    const builder = (new Builder())
+        .Type().End()
+        .Import()
+            .Memory(&quot;__module__&quot;, &quot;__field__&quot;, {initial: 30, maximum: 31})
+        .End()
+        .Code().End();
+
+    const json = JSON.parse(builder.json());
+    assert.eq(json.section.length, 3);
+    assert.eq(json.section[1].name, &quot;Import&quot;);
+    assert.eq(json.section[1].data.length, 1);
+    assert.eq(json.section[1].data[0].module, &quot;__module__&quot;);
+    assert.eq(json.section[1].data[0].field, &quot;__field__&quot;);
+    assert.eq(json.section[1].data[0].kind, &quot;Memory&quot;);
+    assert.eq(json.section[1].data[0].memoryDescription.initial, 30);
+    assert.eq(json.section[1].data[0].memoryDescription.maximum, 31);
+})();
+
</ins><span class="cx"> // FIXME test type mismatch with select. https://bugs.webkit.org/show_bug.cgi?id=163267
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/CMakeLists.txt (209629 => 209630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/CMakeLists.txt        2016-12-09 22:12:08 UTC (rev 209629)
+++ trunk/Source/JavaScriptCore/CMakeLists.txt        2016-12-09 22:38:39 UTC (rev 209630)
</span><span class="lines">@@ -902,6 +902,7 @@
</span><span class="cx">     wasm/WasmCallingConvention.cpp
</span><span class="cx">     wasm/WasmFormat.cpp
</span><span class="cx">     wasm/WasmMemory.cpp
</span><ins>+    wasm/WasmMemoryInformation.cpp
</ins><span class="cx">     wasm/WasmModuleParser.cpp
</span><span class="cx">     wasm/WasmPlan.cpp
</span><span class="cx">     wasm/WasmValidate.cpp
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (209629 => 209630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-12-09 22:12:08 UTC (rev 209629)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-12-09 22:38:39 UTC (rev 209630)
</span><span class="lines">@@ -1,3 +1,111 @@
</span><ins>+2016-12-09  Saam Barati  &lt;sbarati@apple.com&gt;
+
+        WebAssembly JS API: implement importing and defining Memory
+        https://bugs.webkit.org/show_bug.cgi?id=164134
+
+        Reviewed by Keith Miller.
+
+        This patch implements the WebAssembly.Memory object. It refactors
+        the code to now associate a Memory with the instance instead of
+        the Module.
+
+        * CMakeLists.txt:
+        * JavaScriptCore.xcodeproj/project.pbxproj:
+        * jsc.cpp:
+        (functionTestWasmModuleFunctions):
+        * runtime/VM.h:
+        * shell/CMakeLists.txt:
+        * testWasm.cpp: Removed.
+        This has bitrotted. I'm removing it.
+
+        * wasm/WasmB3IRGenerator.cpp:
+        (JSC::Wasm::B3IRGenerator::B3IRGenerator):
+        (JSC::Wasm::sizeOfLoadOp):
+        (JSC::Wasm::createJSToWasmWrapper):
+        (JSC::Wasm::parseAndCompile):
+        * wasm/WasmB3IRGenerator.h:
+        * wasm/WasmFormat.cpp:
+        (JSC::Wasm::ModuleInformation::~ModuleInformation): Deleted.
+        * wasm/WasmFormat.h:
+        * wasm/WasmMemory.cpp:
+        (JSC::Wasm::Memory::Memory):
+        * wasm/WasmMemory.h:
+        (JSC::Wasm::Memory::size):
+        (JSC::Wasm::Memory::initial):
+        (JSC::Wasm::Memory::maximum):
+        (JSC::Wasm::Memory::pinnedRegisters): Deleted.
+        * wasm/WasmMemoryInformation.cpp: Added.
+        (JSC::Wasm::MemoryInformation::MemoryInformation):
+        * wasm/WasmMemoryInformation.h: Added.
+        (JSC::Wasm::MemoryInformation::MemoryInformation):
+        (JSC::Wasm::MemoryInformation::pinnedRegisters):
+        (JSC::Wasm::MemoryInformation::initial):
+        (JSC::Wasm::MemoryInformation::maximum):
+        (JSC::Wasm::MemoryInformation::isImport):
+        (JSC::Wasm::MemoryInformation::operator bool):
+        * wasm/WasmModuleParser.cpp:
+        (JSC::Wasm::ModuleParser::parseImport):
+        (JSC::Wasm::ModuleParser::parseMemoryHelper):
+        (JSC::Wasm::ModuleParser::parseMemory):
+        (JSC::Wasm::ModuleParser::parseExport):
+        * wasm/WasmModuleParser.h:
+        * wasm/WasmPageCount.h: Added. Implement a new way of describing Wasm
+        pages and then asking for how many bytes a quantity of pages is. This
+        class also makes it clear when we're talking about bytes or pages.
+
+        (JSC::Wasm::PageCount::PageCount):
+        (JSC::Wasm::PageCount::bytes):
+        (JSC::Wasm::PageCount::isValid):
+        (JSC::Wasm::PageCount::max):
+        (JSC::Wasm::PageCount::operator bool):
+        (JSC::Wasm::PageCount::operator&lt;):
+        (JSC::Wasm::PageCount::operator&gt;):
+        (JSC::Wasm::PageCount::operator&gt;=):
+        * wasm/WasmPlan.cpp:
+        (JSC::Wasm::Plan::run):
+        * wasm/WasmPlan.h:
+        (JSC::Wasm::Plan::memory): Deleted.
+        * wasm/WasmValidate.cpp:
+        (JSC::Wasm::Validate::hasMemory):
+        (JSC::Wasm::Validate::Validate):
+        (JSC::Wasm::validateFunction):
+        * wasm/WasmValidate.h:
+        * wasm/generateWasmValidateInlinesHeader.py:
+        * wasm/js/JSWebAssemblyInstance.cpp:
+        (JSC::JSWebAssemblyInstance::visitChildren):
+        * wasm/js/JSWebAssemblyInstance.h:
+        (JSC::JSWebAssemblyInstance::memory):
+        (JSC::JSWebAssemblyInstance::setMemory):
+        (JSC::JSWebAssemblyInstance::offsetOfImportFunctions):
+        (JSC::JSWebAssemblyInstance::allocationSize):
+        * wasm/js/JSWebAssemblyMemory.cpp:
+        (JSC::JSWebAssemblyMemory::create):
+        (JSC::JSWebAssemblyMemory::JSWebAssemblyMemory):
+        (JSC::JSWebAssemblyMemory::buffer):
+        (JSC::JSWebAssemblyMemory::visitChildren):
+        * wasm/js/JSWebAssemblyMemory.h:
+        (JSC::JSWebAssemblyMemory::memory):
+        * wasm/js/WebAssemblyFunction.cpp:
+        (JSC::callWebAssemblyFunction):
+        * wasm/js/WebAssemblyInstanceConstructor.cpp:
+        Handle importing and creating of memory according
+        to the spec. This also does the needed validation
+        of making sure the memory defined in the module
+        is compatible with the imported memory.
+
+        (JSC::constructJSWebAssemblyInstance):
+        * wasm/js/WebAssemblyMemoryConstructor.cpp:
+        (JSC::constructJSWebAssemblyMemory):
+        (JSC::callJSWebAssemblyMemory):
+        * wasm/js/WebAssemblyMemoryPrototype.cpp:
+        (JSC::webAssemblyMemoryProtoFuncBuffer):
+        (JSC::WebAssemblyMemoryPrototype::create):
+        (JSC::WebAssemblyMemoryPrototype::finishCreation):
+        * wasm/js/WebAssemblyMemoryPrototype.h:
+        * wasm/js/WebAssemblyModuleRecord.cpp:
+        (JSC::WebAssemblyModuleRecord::finishCreation):
+        (JSC::WebAssemblyModuleRecord::link):
+
</ins><span class="cx"> 2016-12-09  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Web Inspector: Some resources fetched via Fetch API do not have data
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj (209629 => 209630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2016-12-09 22:12:08 UTC (rev 209629)
+++ trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2016-12-09 22:38:39 UTC (rev 209630)
</span><span class="lines">@@ -25,7 +25,6 @@
</span><span class="cx">                         buildPhases = (
</span><span class="cx">                         );
</span><span class="cx">                         dependencies = (
</span><del>-                                539EB0831D5560F400C82EF7 /* PBXTargetDependency */,
</del><span class="cx">                                 0F6183471C45F67A0072450B /* PBXTargetDependency */,
</span><span class="cx">                                 0F93275D1C20BF3A00CF6564 /* PBXTargetDependency */,
</span><span class="cx">                                 0FEC85B11BDB5D8F0080FF74 /* PBXTargetDependency */,
</span><span class="lines">@@ -1287,9 +1286,6 @@
</span><span class="cx">                 5370B4F51BF26202005C40FC /* AdaptiveInferredPropertyValueWatchpointBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5370B4F31BF25EA2005C40FC /* AdaptiveInferredPropertyValueWatchpointBase.cpp */; };
</span><span class="cx">                 5370B4F61BF26205005C40FC /* AdaptiveInferredPropertyValueWatchpointBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 5370B4F41BF25EA2005C40FC /* AdaptiveInferredPropertyValueWatchpointBase.h */; };
</span><span class="cx">                 53917E7B1B7906FA000EBD33 /* JSGenericTypedArrayViewPrototypeFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = 53917E7A1B7906E4000EBD33 /* JSGenericTypedArrayViewPrototypeFunctions.h */; };
</span><del>-                539EB0791D55607000C82EF7 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 51F0EB6105C86C6B00E6DF1B /* Foundation.framework */; };
-                539EB07A1D55607000C82EF7 /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 932F5BD90822A1C700736975 /* JavaScriptCore.framework */; };
-                539EB0811D55608A00C82EF7 /* testWasm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 539EB0711D553DF800C82EF7 /* testWasm.cpp */; };
</del><span class="cx">                 539FB8BA1C99DA7C00940FA1 /* JSArrayInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = 539FB8B91C99DA7C00940FA1 /* JSArrayInlines.h */; };
</span><span class="cx">                 53D444DC1DAF08AB00B92784 /* B3WasmAddressValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 53D444DB1DAF08AB00B92784 /* B3WasmAddressValue.h */; };
</span><span class="cx">                 53D444DE1DAF09A000B92784 /* B3WasmAddressValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53D444DD1DAF09A000B92784 /* B3WasmAddressValue.cpp */; };
</span><span class="lines">@@ -1429,6 +1425,9 @@
</span><span class="cx">                 79B00CBE1C6AB07E0088C65D /* ProxyObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 79B00CBA1C6AB07E0088C65D /* ProxyObject.cpp */; settings = {COMPILER_FLAGS = &quot;-fno-optimize-sibling-calls&quot;; }; };
</span><span class="cx">                 79B00CBF1C6AB07E0088C65D /* ProxyObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 79B00CBB1C6AB07E0088C65D /* ProxyObject.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 79B1788E1D399B8000B1A567 /* JITMathICForwards.h in Headers */ = {isa = PBXBuildFile; fileRef = 79A899FE1D38612E00D18C73 /* JITMathICForwards.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+                79B759741DFA4C600052174C /* WasmMemoryInformation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 79B759711DFA4C600052174C /* WasmMemoryInformation.cpp */; };
+                79B759751DFA4C600052174C /* WasmMemoryInformation.h in Headers */ = {isa = PBXBuildFile; fileRef = 79B759721DFA4C600052174C /* WasmMemoryInformation.h */; settings = {ATTRIBUTES = (Private, ); }; };
+                79B759761DFA4C600052174C /* WasmPageCount.h in Headers */ = {isa = PBXBuildFile; fileRef = 79B759731DFA4C600052174C /* WasmPageCount.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 79B819931DD25CF500DDC714 /* JSGlobalObjectInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = 79B819921DD25CF500DDC714 /* JSGlobalObjectInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 79C4B15D1BA2158F00FD592E /* DFGLiveCatchVariablePreservationPhase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 79C4B15B1BA2158F00FD592E /* DFGLiveCatchVariablePreservationPhase.cpp */; };
</span><span class="cx">                 79C4B15E1BA2158F00FD592E /* DFGLiveCatchVariablePreservationPhase.h in Headers */ = {isa = PBXBuildFile; fileRef = 79C4B15C1BA2158F00FD592E /* DFGLiveCatchVariablePreservationPhase.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -2379,13 +2378,6 @@
</span><span class="cx">                         remoteGlobalIDString = 0F4680A914BA7FD900BFE272;
</span><span class="cx">                         remoteInfo = &quot;LLInt Offsets&quot;;
</span><span class="cx">                 };
</span><del>-                539EB0821D5560F400C82EF7 /* PBXContainerItemProxy */ = {
-                        isa = PBXContainerItemProxy;
-                        containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
-                        proxyType = 1;
-                        remoteGlobalIDString = 539EB0751D55607000C82EF7;
-                        remoteInfo = testWASM;
-                };
</del><span class="cx">                 5D69E911152BE5470028D720 /* PBXContainerItemProxy */ = {
</span><span class="cx">                         isa = PBXContainerItemProxy;
</span><span class="cx">                         containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
</span><span class="lines">@@ -3683,7 +3675,6 @@
</span><span class="cx">                 53917E7C1B791106000EBD33 /* JSTypedArrayViewPrototype.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSTypedArrayViewPrototype.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 53917E831B791CB8000EBD33 /* TypedArrayPrototype.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = TypedArrayPrototype.js; path = builtins/TypedArrayPrototype.js; sourceTree = SOURCE_ROOT; };
</span><span class="cx">                 539EB0711D553DF800C82EF7 /* testWasm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = testWasm.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><del>-                539EB0801D55607000C82EF7 /* testWASM */ = {isa = PBXFileReference; explicitFileType = &quot;compiled.mach-o.executable&quot;; includeInIndex = 0; path = testWASM; sourceTree = BUILT_PRODUCTS_DIR; };
</del><span class="cx">                 539FB8B91C99DA7C00940FA1 /* JSArrayInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSArrayInlines.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 53D444DB1DAF08AB00B92784 /* B3WasmAddressValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = B3WasmAddressValue.h; path = b3/B3WasmAddressValue.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 53D444DD1DAF09A000B92784 /* B3WasmAddressValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = B3WasmAddressValue.cpp; path = b3/B3WasmAddressValue.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -3860,6 +3851,9 @@
</span><span class="cx">                 79B00CB91C6AB07E0088C65D /* ProxyConstructor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProxyConstructor.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 79B00CBA1C6AB07E0088C65D /* ProxyObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ProxyObject.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 79B00CBB1C6AB07E0088C65D /* ProxyObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProxyObject.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                79B759711DFA4C600052174C /* WasmMemoryInformation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WasmMemoryInformation.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                79B759721DFA4C600052174C /* WasmMemoryInformation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmMemoryInformation.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                79B759731DFA4C600052174C /* WasmPageCount.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmPageCount.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 79B819921DD25CF500DDC714 /* JSGlobalObjectInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSGlobalObjectInlines.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 79C4B15B1BA2158F00FD592E /* DFGLiveCatchVariablePreservationPhase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGLiveCatchVariablePreservationPhase.cpp; path = dfg/DFGLiveCatchVariablePreservationPhase.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 79C4B15C1BA2158F00FD592E /* DFGLiveCatchVariablePreservationPhase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGLiveCatchVariablePreservationPhase.h; path = dfg/DFGLiveCatchVariablePreservationPhase.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -4911,15 +4905,6 @@
</span><span class="cx">                         );
</span><span class="cx">                         runOnlyForDeploymentPostprocessing = 0;
</span><span class="cx">                 };
</span><del>-                539EB0781D55607000C82EF7 /* Frameworks */ = {
-                        isa = PBXFrameworksBuildPhase;
-                        buildActionMask = 2147483647;
-                        files = (
-                                539EB0791D55607000C82EF7 /* Foundation.framework in Frameworks */,
-                                539EB07A1D55607000C82EF7 /* JavaScriptCore.framework in Frameworks */,
-                        );
-                        runOnlyForDeploymentPostprocessing = 0;
-                };
</del><span class="cx">                 651122FC14046A4C002B101D /* Frameworks */ = {
</span><span class="cx">                         isa = PBXFrameworksBuildPhase;
</span><span class="cx">                         buildActionMask = 2147483647;
</span><span class="lines">@@ -4967,7 +4952,6 @@
</span><span class="cx">                                 6511230514046A4C002B101D /* testRegExp */,
</span><span class="cx">                                 0F9327591C20BCBA00CF6564 /* dynbench */,
</span><span class="cx">                                 0F6183431C45F62A0072450B /* testair */,
</span><del>-                                539EB0801D55607000C82EF7 /* testWASM */,
</del><span class="cx">                         );
</span><span class="cx">                         name = Products;
</span><span class="cx">                         sourceTree = &quot;&lt;group&gt;&quot;;
</span><span class="lines">@@ -6024,8 +6008,11 @@
</span><span class="cx">                                 53F40E8A1D5901BB0099A1B6 /* WasmFunctionParser.h */,
</span><span class="cx">                                 535557151D9DFA32006D583B /* WasmMemory.cpp */,
</span><span class="cx">                                 535557131D9D9EA5006D583B /* WasmMemory.h */,
</span><ins>+                                79B759711DFA4C600052174C /* WasmMemoryInformation.cpp */,
+                                79B759721DFA4C600052174C /* WasmMemoryInformation.h */,
</ins><span class="cx">                                 53F40E961D5A7BEC0099A1B6 /* WasmModuleParser.cpp */,
</span><span class="cx">                                 53F40E941D5A7AEF0099A1B6 /* WasmModuleParser.h */,
</span><ins>+                                79B759731DFA4C600052174C /* WasmPageCount.h */,
</ins><span class="cx">                                 53F40E8C1D5901F20099A1B6 /* WasmParser.h */,
</span><span class="cx">                                 531374BE1D5CE95000AF7A0B /* WasmPlan.cpp */,
</span><span class="cx">                                 531374BC1D5CE67600AF7A0B /* WasmPlan.h */,
</span><span class="lines">@@ -7983,6 +7970,7 @@
</span><span class="cx">                                 0F18D3D01B55A6E0002C5C9F /* DFGAdaptiveStructureWatchpoint.h in Headers */,
</span><span class="cx">                                 998ED6751BED768C00DD8017 /* RemoteControllableTarget.h in Headers */,
</span><span class="cx">                                 0F33FCF81C136E2500323F67 /* B3StackmapGenerationParams.h in Headers */,
</span><ins>+                                79B759761DFA4C600052174C /* WasmPageCount.h in Headers */,
</ins><span class="cx">                                 0F66E16B14DF3F1600B7B2E4 /* DFGAdjacencyList.h in Headers */,
</span><span class="cx">                                 0FFB921816D02EB20055A5DB /* DFGAllocator.h in Headers */,
</span><span class="cx">                                 0F1E3A461534CBAF000F9456 /* DFGArgumentPosition.h in Headers */,
</span><span class="lines">@@ -8222,6 +8210,7 @@
</span><span class="cx">                                 BC02E98D0E183E38000F9297 /* ErrorInstance.h in Headers */,
</span><span class="cx">                                 BC02E90F0E1839DB000F9297 /* ErrorPrototype.h in Headers */,
</span><span class="cx">                                 996B731B1BDA08D100331B84 /* ErrorPrototype.lut.h in Headers */,
</span><ins>+                                79B759751DFA4C600052174C /* WasmMemoryInformation.h in Headers */,
</ins><span class="cx">                                 969A07980ED1D3AE00F1F681 /* DirectEvalCodeCache.h in Headers */,
</span><span class="cx">                                 A54982041891D0B00081E5B8 /* EventLoop.h in Headers */,
</span><span class="cx">                                 FE1C0FFD1B193E9800B53FCA /* Exception.h in Headers */,
</span><span class="lines">@@ -9146,22 +9135,6 @@
</span><span class="cx">                         productReference = 14BD59BF0A3E8F9000BAF59C /* testapi */;
</span><span class="cx">                         productType = &quot;com.apple.product-type.tool&quot;;
</span><span class="cx">                 };
</span><del>-                539EB0751D55607000C82EF7 /* testWASM */ = {
-                        isa = PBXNativeTarget;
-                        buildConfigurationList = 539EB07B1D55607000C82EF7 /* Build configuration list for PBXNativeTarget &quot;testWASM&quot; */;
-                        buildPhases = (
-                                539EB0761D55607000C82EF7 /* Sources */,
-                                539EB0781D55607000C82EF7 /* Frameworks */,
-                        );
-                        buildRules = (
-                        );
-                        dependencies = (
-                        );
-                        name = testWASM;
-                        productName = testapi;
-                        productReference = 539EB0801D55607000C82EF7 /* testWASM */;
-                        productType = &quot;com.apple.product-type.tool&quot;;
-                };
</del><span class="cx">                 651122F714046A4C002B101D /* testRegExp */ = {
</span><span class="cx">                         isa = PBXNativeTarget;
</span><span class="cx">                         buildConfigurationList = 6511230014046A4C002B101D /* Build configuration list for PBXNativeTarget &quot;testRegExp&quot; */;
</span><span class="lines">@@ -9263,7 +9236,6 @@
</span><span class="cx">                                 5D6B2A47152B9E17005231DE /* Test Tools */,
</span><span class="cx">                                 0F93274E1C20BCBA00CF6564 /* dynbench */,
</span><span class="cx">                                 0F6183381C45F62A0072450B /* testair */,
</span><del>-                                539EB0751D55607000C82EF7 /* testWASM */,
</del><span class="cx">                         );
</span><span class="cx">                 };
</span><span class="cx"> /* End PBXProject section */
</span><span class="lines">@@ -9534,14 +9506,6 @@
</span><span class="cx">                         );
</span><span class="cx">                         runOnlyForDeploymentPostprocessing = 0;
</span><span class="cx">                 };
</span><del>-                539EB0761D55607000C82EF7 /* Sources */ = {
-                        isa = PBXSourcesBuildPhase;
-                        buildActionMask = 2147483647;
-                        files = (
-                                539EB0811D55608A00C82EF7 /* testWasm.cpp in Sources */,
-                        );
-                        runOnlyForDeploymentPostprocessing = 0;
-                };
</del><span class="cx">                 651122FA14046A4C002B101D /* Sources */ = {
</span><span class="cx">                         isa = PBXSourcesBuildPhase;
</span><span class="cx">                         buildActionMask = 2147483647;
</span><span class="lines">@@ -9647,6 +9611,7 @@
</span><span class="cx">                                 C2FCAE1017A9C24E0034C735 /* BytecodeBasicBlock.cpp in Sources */,
</span><span class="cx">                                 148F21AA107EC53A0042EC2C /* BytecodeGenerator.cpp in Sources */,
</span><span class="cx">                                 7094C4DE1AE439530041A2EE /* BytecodeIntrinsicRegistry.cpp in Sources */,
</span><ins>+                                79B759741DFA4C600052174C /* WasmMemoryInformation.cpp in Sources */,
</ins><span class="cx">                                 C2FCAE1217A9C24E0034C735 /* BytecodeLivenessAnalysis.cpp in Sources */,
</span><span class="cx">                                 0F338E0D1BF0276C0013C88F /* B3DataSection.cpp in Sources */,
</span><span class="cx">                                 65B8392F1BACAD6A0044E824 /* CachedRecovery.cpp in Sources */,
</span><span class="lines">@@ -10471,11 +10436,6 @@
</span><span class="cx">                         target = 0F4680A914BA7FD900BFE272 /* LLInt Offsets */;
</span><span class="cx">                         targetProxy = 0FF922D214F46B2F0041A24E /* PBXContainerItemProxy */;
</span><span class="cx">                 };
</span><del>-                539EB0831D5560F400C82EF7 /* PBXTargetDependency */ = {
-                        isa = PBXTargetDependency;
-                        target = 539EB0751D55607000C82EF7 /* testWASM */;
-                        targetProxy = 539EB0821D5560F400C82EF7 /* PBXContainerItemProxy */;
-                };
</del><span class="cx">                 5D69E912152BE5470028D720 /* PBXTargetDependency */ = {
</span><span class="cx">                         isa = PBXTargetDependency;
</span><span class="cx">                         target = 932F5BDA0822A1C700736975 /* jsc */;
</span><span class="lines">@@ -10811,38 +10771,6 @@
</span><span class="cx">                         };
</span><span class="cx">                         name = Production;
</span><span class="cx">                 };
</span><del>-                539EB07C1D55607000C82EF7 /* Debug */ = {
-                        isa = XCBuildConfiguration;
-                        baseConfigurationReference = BC021BF2136900C300FC5467 /* ToolExecutable.xcconfig */;
-                        buildSettings = {
-                                PRODUCT_NAME = &quot;$(TARGET_NAME)&quot;;
-                        };
-                        name = Debug;
-                };
-                539EB07D1D55607000C82EF7 /* Release */ = {
-                        isa = XCBuildConfiguration;
-                        baseConfigurationReference = BC021BF2136900C300FC5467 /* ToolExecutable.xcconfig */;
-                        buildSettings = {
-                                PRODUCT_NAME = &quot;$(TARGET_NAME)&quot;;
-                        };
-                        name = Release;
-                };
-                539EB07E1D55607000C82EF7 /* Profiling */ = {
-                        isa = XCBuildConfiguration;
-                        baseConfigurationReference = BC021BF2136900C300FC5467 /* ToolExecutable.xcconfig */;
-                        buildSettings = {
-                                PRODUCT_NAME = &quot;$(TARGET_NAME)&quot;;
-                        };
-                        name = Profiling;
-                };
-                539EB07F1D55607000C82EF7 /* Production */ = {
-                        isa = XCBuildConfiguration;
-                        baseConfigurationReference = BC021BF2136900C300FC5467 /* ToolExecutable.xcconfig */;
-                        buildSettings = {
-                                PRODUCT_NAME = &quot;$(TARGET_NAME)&quot;;
-                        };
-                        name = Production;
-                };
</del><span class="cx">                 5D6B2A48152B9E17005231DE /* Debug */ = {
</span><span class="cx">                         isa = XCBuildConfiguration;
</span><span class="cx">                         buildSettings = {
</span><span class="lines">@@ -11134,17 +11062,6 @@
</span><span class="cx">                         defaultConfigurationIsVisible = 0;
</span><span class="cx">                         defaultConfigurationName = Production;
</span><span class="cx">                 };
</span><del>-                539EB07B1D55607000C82EF7 /* Build configuration list for PBXNativeTarget &quot;testWASM&quot; */ = {
-                        isa = XCConfigurationList;
-                        buildConfigurations = (
-                                539EB07C1D55607000C82EF7 /* Debug */,
-                                539EB07D1D55607000C82EF7 /* Release */,
-                                539EB07E1D55607000C82EF7 /* Profiling */,
-                                539EB07F1D55607000C82EF7 /* Production */,
-                        );
-                        defaultConfigurationIsVisible = 0;
-                        defaultConfigurationName = Production;
-                };
</del><span class="cx">                 5D6B2A4C152B9E17005231DE /* Build configuration list for PBXAggregateTarget &quot;Test Tools&quot; */ = {
</span><span class="cx">                         isa = XCConfigurationList;
</span><span class="cx">                         buildConfigurations = (
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejsccpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jsc.cpp (209629 => 209630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jsc.cpp        2016-12-09 22:12:08 UTC (rev 209629)
+++ trunk/Source/JavaScriptCore/jsc.cpp        2016-12-09 22:38:39 UTC (rev 209630)
</span><span class="lines">@@ -69,6 +69,7 @@
</span><span class="cx"> #include &quot;TestRunnerUtils.h&quot;
</span><span class="cx"> #include &quot;TypeProfilerLog.h&quot;
</span><span class="cx"> #include &quot;WasmPlan.h&quot;
</span><ins>+#include &quot;WasmMemory.h&quot;
</ins><span class="cx"> #include &lt;locale.h&gt;
</span><span class="cx"> #include &lt;math.h&gt;
</span><span class="cx"> #include &lt;stdio.h&gt;
</span><span class="lines">@@ -2632,6 +2633,19 @@
</span><span class="cx">             });
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    void* memoryBytes = nullptr;
+    uint32_t memorySize = 0;
+    std::unique_ptr&lt;Wasm::Memory&gt; memory;
+    std::unique_ptr&lt;Wasm::ModuleInformation&gt; moduleInformation = plan.takeModuleInformation();
+
+    if (!!moduleInformation-&gt;memory) {
+        memory = std::make_unique&lt;Wasm::Memory&gt;(moduleInformation-&gt;memory.initial(), moduleInformation-&gt;memory.maximum());
+        memoryBytes = memory-&gt;memory();
+        memorySize = memory-&gt;size();
+    }
+    vm.topWasmMemoryPointer = memoryBytes;
+    vm.topWasmMemorySize = memorySize;
+
</ins><span class="cx">     for (uint32_t i = 0; i &lt; functionCount; ++i) {
</span><span class="cx">         JSArray* testCases = jsCast&lt;JSArray*&gt;(exec-&gt;argument(i + 2));
</span><span class="cx">         for (unsigned testIndex = 0; testIndex &lt; testCases-&gt;length(); ++testIndex) {
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeVMh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/VM.h (209629 => 209630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/VM.h        2016-12-09 22:12:08 UTC (rev 209629)
+++ trunk/Source/JavaScriptCore/runtime/VM.h        2016-12-09 22:38:39 UTC (rev 209630)
</span><span class="lines">@@ -296,6 +296,8 @@
</span><span class="cx">     // https://bugs.webkit.org/show_bug.cgi?id=160441
</span><span class="cx">     ExecState* topCallFrame;
</span><span class="cx">     JSWebAssemblyInstance* topJSWebAssemblyInstance;
</span><ins>+    void* topWasmMemoryPointer;
+    uint32_t topWasmMemorySize;
</ins><span class="cx">     Strong&lt;Structure&gt; structureStructure;
</span><span class="cx">     Strong&lt;Structure&gt; structureRareDataStructure;
</span><span class="cx">     Strong&lt;Structure&gt; terminatedExecutionErrorStructure;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreshellCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/shell/CMakeLists.txt (209629 => 209630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/shell/CMakeLists.txt        2016-12-09 22:12:08 UTC (rev 209629)
+++ trunk/Source/JavaScriptCore/shell/CMakeLists.txt        2016-12-09 22:38:39 UTC (rev 209630)
</span><span class="lines">@@ -49,10 +49,6 @@
</span><span class="cx">         ../b3/air/testair.cpp
</span><span class="cx">     )
</span><span class="cx"> 
</span><del>-    set(TESTWASM_SOURCES
-        ../testWasm.cpp
-    )
-
</del><span class="cx">     add_executable(testb3 ${TESTB3_SOURCES})
</span><span class="cx">     target_link_libraries(testb3 ${JSC_LIBRARIES})
</span><span class="cx"> 
</span><span class="lines">@@ -59,7 +55,4 @@
</span><span class="cx">     add_executable(testair ${TESTAIR_SOURCES})
</span><span class="cx">     target_link_libraries(testair ${JSC_LIBRARIES})
</span><span class="cx"> 
</span><del>-    add_executable(testWASM ${TESTWASM_SOURCES})
-    target_link_libraries(testWASM ${JSC_LIBRARIES})
-
</del><span class="cx"> endif ()
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretestWasmcpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/JavaScriptCore/testWasm.cpp (209629 => 209630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/testWasm.cpp        2016-12-09 22:12:08 UTC (rev 209629)
+++ trunk/Source/JavaScriptCore/testWasm.cpp        2016-12-09 22:38:39 UTC (rev 209630)
</span><span class="lines">@@ -1,1344 +0,0 @@
</span><del>-/*
- * Copyright (C) 2016 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include &quot;config.h&quot;
-
-#include &quot;B3Common.h&quot;
-#include &quot;B3Compilation.h&quot;
-#include &quot;InitializeThreading.h&quot;
-#include &quot;JSCJSValueInlines.h&quot;
-#include &quot;JSString.h&quot;
-#include &quot;LLIntThunks.h&quot;
-#include &quot;ProtoCallFrame.h&quot;
-#include &quot;VM.h&quot;
-#include &quot;WasmMemory.h&quot;
-#include &quot;WasmPlan.h&quot;
-
-#include &lt;wtf/DataLog.h&gt;
-#include &lt;wtf/LEBDecoder.h&gt;
-
-class CommandLine {
-public:
-    CommandLine(int argc, char** argv)
-    {
-        parseArguments(argc, argv);
-    }
-
-    bool m_runWasmTests { false };
-
-    void parseArguments(int, char**);
-};
-
-static NO_RETURN void printUsageStatement(bool help = false)
-{
-    fprintf(stderr, &quot;Usage: testWasm [options]\n&quot;);
-    fprintf(stderr, &quot;  -h|--help  Prints this help message\n&quot;);
-    fprintf(stderr, &quot;  -w|--web   Run the Wasm tests\n&quot;);
-    fprintf(stderr, &quot;\n&quot;);
-
-    exit(help ? EXIT_SUCCESS : EXIT_FAILURE);
-}
-
-void CommandLine::parseArguments(int argc, char** argv)
-{
-    int i = 1;
-
-    if (argc == i)
-        printUsageStatement(false);
-
-    for (; i &lt; argc; ++i) {
-        const char* arg = argv[i];
-
-        if (!strcmp(arg, &quot;-h&quot;) || !strcmp(arg, &quot;--help&quot;)) {
-            printUsageStatement(true);
-            RELEASE_ASSERT_NOT_REACHED();
-        }
-
-        if (!strcmp(arg, &quot;-w&quot;) || !strcmp(arg, &quot;--web&quot;)) {
-            m_runWasmTests = true;
-            continue;
-        }
-
-        fprintf(stderr, &quot;Unknown option %s\n&quot;, arg);
-        printUsageStatement(false);
-    }
-}
-
-StaticLock crashLock;
-
-#define CHECK_EQ(x, y) do { \
-        auto __x = (x); \
-        auto __y = (y); \
-        if (__x == __y) \
-        break; \
-        crashLock.lock(); \
-        WTFReportAssertionFailure(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, toCString(#x &quot; == &quot; #y, &quot; (&quot; #x &quot; == &quot;, __x, &quot;, &quot; #y &quot; == &quot;, __y, &quot;)&quot;).data()); \
-        CRASH(); \
-    } while (false)
-
-#define CHECK(x) CHECK_EQ(x, true)
-
-#if ENABLE(WEBASSEMBLY)
-
-static JSC::VM* vm;
-
-using namespace JSC;
-using namespace Wasm;
-using namespace B3;
-
-template&lt;typename T&gt;
-T cast(EncodedJSValue value)
-{
-    return static_cast&lt;T&gt;(value);
-}
-
-template&lt;&gt;
-double cast(EncodedJSValue value)
-{
-    return bitwise_cast&lt;double&gt;(value);
-}
-
-template&lt;&gt;
-float cast(EncodedJSValue value)
-{
-    return bitwise_cast&lt;float&gt;(static_cast&lt;int&gt;(value));
-}
-
-template&lt;typename T&gt;
-T invoke(MacroAssemblerCodePtr ptr, std::initializer_list&lt;JSValue&gt; args)
-{
-    JSValue firstArgument;
-    // Since vmEntryToJavaScript expects a this value we claim there is one... there isn't.
-    int argCount = 1;
-    JSValue* remainingArguments = nullptr;
-    if (args.size()) {
-        remainingArguments = const_cast&lt;JSValue*&gt;(args.begin());
-        firstArgument = *remainingArguments;
-        remainingArguments++;
-        argCount = args.size();
-    }
-
-    ProtoCallFrame protoCallFrame;
-    protoCallFrame.init(nullptr, nullptr, firstArgument, argCount, remainingArguments);
-
-    return cast&lt;T&gt;(vmEntryToWasm(ptr.executableAddress(), vm, &amp;protoCallFrame));
-}
-
-template&lt;typename T&gt;
-T invoke(const Compilation&amp; code, std::initializer_list&lt;JSValue&gt; args)
-{
-    return invoke&lt;T&gt;(code.code(), args);
-}
-
-inline JSValue box(uint64_t value)
-{
-    return JSValue::decode(value);
-}
-
-inline JSValue boxf(float value)
-{
-    return box(bitwise_cast&lt;uint32_t&gt;(value));
-}
-
-inline JSValue boxd(double value)
-{
-    return box(bitwise_cast&lt;uint64_t&gt;(value));
-}
-
-static void checkPlan(Plan&amp; plan, unsigned expectedNumberOfFunctions)
-{
-    plan.run();
-    if (plan.failed()) {
-        dataLogLn(&quot;Module failed to compile with error: &quot;, plan.errorMessage());
-        CRASH();
-    }
-
-    if (plan.internalFunctionCount() != expectedNumberOfFunctions) {
-        dataLogLn(&quot;Incorrect number of functions&quot;);
-        CRASH();
-    }
-
-    for (unsigned i = 0; i &lt; expectedNumberOfFunctions; ++i) {
-        if (!plan.jsToWasmEntryPointForFunction(i)) {
-            dataLogLn(&quot;Function at index, &quot; , i, &quot; failed to compile correctly&quot;);
-            CRASH();
-        }
-    }
-
-}
-
-// For now we inline the test files.
-static void runWasmTests()
-{
-    {
-        // Generated from:
-        //    (module
-        //     (func (export &quot;br_table-with-loop&quot;) (param $x i32) (result i32)
-        //      (local $i i32)
-        //      (loop
-        //       (block
-        //        (get_local $x)
-        //        (set_local $i (i32.add (get_local $i) (i32.const 1)))
-        //        (set_local $x (i32.sub (get_local $x) (i32.const 1)))
-        //        (br_table 0 1)
-        //        )
-        //       )
-        //      (get_local $i)
-        //      )
-        //     )
-        Vector&lt;uint8_t&gt; vector = {
-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x86, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
-            0x01, 0x01, 0x01, 0x01, 0x03, 0x82, 0x80, 0x80, 0x80, 0x00, 0x01, 0x00, 0x07, 0x96, 0x80, 0x80,
-            0x80, 0x00, 0x01, 0x12, 0x62, 0x72, 0x5f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x2d, 0x77, 0x69, 0x74,
-            0x68, 0x2d, 0x6c, 0x6f, 0x6f, 0x70, 0x00, 0x00, 0x0a, 0xa6, 0x80, 0x80, 0x80, 0x00, 0x01, 0xa0,
-            0x80, 0x80, 0x80, 0x00, 0x01, 0x01, 0x01, 0x02, 0x00, 0x01, 0x00, 0x14, 0x00, 0x14, 0x01, 0x10,
-            0x01, 0x40, 0x15, 0x01, 0x14, 0x00, 0x10, 0x01, 0x41, 0x15, 0x00, 0x08, 0x01, 0x00, 0x01, 0x0f,
-            0x0f, 0x14, 0x01, 0x0f
-        };
-
-        Plan plan(vm, vector);
-        checkPlan(plan, 1);
-
-        // Test this doesn't crash.
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(0) }), 1);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(1) }), 2);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(100) }), 101);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(122) }), 123);
-    }
-
-    {
-        // Generated from:
-        //    (module
-        //     (func (export &quot;multiple-value&quot;) (param i32) (result i32)
-        //      (local i32)
-        //      (set_local 1 (block i32
-        //        (set_local 1 (block i32
-        //          (set_local 1 (block i32
-        //            (set_local 1 (block i32
-        //              (set_local 1 (block i32
-        //                (br_table 3 2 1 0 4 (i32.const 200) (get_local 0))
-        //                (return (i32.add (get_local 1) (i32.const 99)))
-        //                ))
-        //              (return (i32.add (get_local 1) (i32.const 10)))
-        //              ))
-        //            (return (i32.add (get_local 1) (i32.const 11)))
-        //            ))
-        //          (return (i32.add (get_local 1) (i32.const 12)))
-        //          ))
-        //        (return (i32.add (get_local 1) (i32.const 13)))
-        //        ))
-        //      (i32.add (get_local 1) (i32.const 14))
-        //      )
-        //     )
-        Vector&lt;uint8_t&gt; vector = {
-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x86, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
-            0x01, 0x01, 0x01, 0x01, 0x03, 0x82, 0x80, 0x80, 0x80, 0x00, 0x01, 0x00, 0x07, 0x92, 0x80, 0x80,
-            0x80, 0x00, 0x01, 0x0e, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x2d, 0x76, 0x61, 0x6c,
-            0x75, 0x65, 0x00, 0x00, 0x0a, 0xd3, 0x80, 0x80, 0x80, 0x00, 0x01, 0xcd, 0x80, 0x80, 0x80, 0x00,
-            0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x10, 0xc8, 0x01,
-            0x14, 0x00, 0x08, 0x04, 0x03, 0x02, 0x01, 0x00, 0x04, 0x14, 0x01, 0x10, 0xe3, 0x00, 0x40, 0x09,
-            0x0f, 0x15, 0x01, 0x14, 0x01, 0x10, 0x0a, 0x40, 0x09, 0x0f, 0x15, 0x01, 0x14, 0x01, 0x10, 0x0b,
-            0x40, 0x09, 0x0f, 0x15, 0x01, 0x14, 0x01, 0x10, 0x0c, 0x40, 0x09, 0x0f, 0x15, 0x01, 0x14, 0x01,
-            0x10, 0x0d, 0x40, 0x09, 0x0f, 0x15, 0x01, 0x14, 0x01, 0x10, 0x0e, 0x40, 0x0f
-        };
-
-        Plan plan(vm, vector);
-        checkPlan(plan, 1);
-
-        // Test this doesn't crash.
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(0) }), 213);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(1) }), 212);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(2) }), 211);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(3) }), 210);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(3) }), 210);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(4) }), 214);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(5) }), 214);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(-1) }), 214);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(-1000) }), 214);
-    }
-
-    {
-        // Generated from:
-        //    (module
-        //     (func (export &quot;singleton&quot;) (param i32) (result i32)
-        //      (block
-        //       (block
-        //        (br_table 1 0 (get_local 0))
-        //        (return (i32.const 21))
-        //        )
-        //       (return (i32.const 20))
-        //       )
-        //      (i32.const 22)
-        //      )
-        //     )
-        Vector&lt;uint8_t&gt; vector = {
-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x86, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
-            0x01, 0x01, 0x01, 0x01, 0x03, 0x82, 0x80, 0x80, 0x80, 0x00, 0x01, 0x00, 0x07, 0x8d, 0x80, 0x80,
-            0x80, 0x00, 0x01, 0x09, 0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x74, 0x6f, 0x6e, 0x00, 0x00, 0x0a,
-            0x9c, 0x80, 0x80, 0x80, 0x00, 0x01, 0x96, 0x80, 0x80, 0x80, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00,
-            0x14, 0x00, 0x08, 0x01, 0x01, 0x00, 0x10, 0x15, 0x09, 0x0f, 0x10, 0x14, 0x09, 0x0f, 0x10, 0x16,
-            0x0f
-        };
-
-        Plan plan(vm, vector);
-        checkPlan(plan, 1);
-
-        // Test this doesn't crash.
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(0) }), 22);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(1) }), 20);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(11) }), 20);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(-100) }), 20);
-    }
-
-    {
-        // Generated from:
-        //    (module
-        //     (func (export &quot;if-then-both-fallthrough&quot;) (param $x i32) (param $y i32) (result i32)
-        //      (block $block i32
-        //       (if i32 (i32.eq (get_local $x) (i32.const 0))
-        //        (then (i32.const 1))
-        //        (else
-        //         (i32.const 2)
-        //         (br $block))
-        //        )
-        //       )
-        //      )
-        //     )
-        Vector&lt;uint8_t&gt; vector = {
-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x87, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
-            0x02, 0x01, 0x01, 0x01, 0x01, 0x03, 0x82, 0x80, 0x80, 0x80, 0x00, 0x01, 0x00, 0x07, 0x9c, 0x80,
-            0x80, 0x80, 0x00, 0x01, 0x18, 0x69, 0x66, 0x2d, 0x74, 0x68, 0x65, 0x6e, 0x2d, 0x62, 0x6f, 0x74,
-            0x68, 0x2d, 0x66, 0x61, 0x6c, 0x6c, 0x74, 0x68, 0x72, 0x6f, 0x75, 0x67, 0x68, 0x00, 0x00, 0x0a,
-            0x9a, 0x80, 0x80, 0x80, 0x00, 0x01, 0x94, 0x80, 0x80, 0x80, 0x00, 0x00, 0x01, 0x01, 0x14, 0x00,
-            0x10, 0x00, 0x4d, 0x03, 0x01, 0x10, 0x01, 0x04, 0x10, 0x02, 0x06, 0x01, 0x0f, 0x0f, 0x0f
-        };
-
-        Plan plan(vm, vector);
-        checkPlan(plan, 1);
-
-        // Test this doesn't crash.
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(0), box(32) }), 1);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(1), box(32) }), 2);
-    }
-
-    {
-        // Generated from:
-        //    (module
-        //     (func (export &quot;if-then-both-fallthrough&quot;) (param $x i32) (param $y i32) (result i32)
-        //      (if i32 (i32.eq (get_local $x) (i32.const 0))
-        //       (then (i32.const 1))
-        //       (else (i32.const 2))
-        //       )
-        //      )
-        //     )
-        Vector&lt;uint8_t&gt; vector = {
-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x87, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
-            0x02, 0x01, 0x01, 0x01, 0x01, 0x03, 0x82, 0x80, 0x80, 0x80, 0x00, 0x01, 0x00, 0x07, 0x9c, 0x80,
-            0x80, 0x80, 0x00, 0x01, 0x18, 0x69, 0x66, 0x2d, 0x74, 0x68, 0x65, 0x6e, 0x2d, 0x62, 0x6f, 0x74,
-            0x68, 0x2d, 0x66, 0x61, 0x6c, 0x6c, 0x74, 0x68, 0x72, 0x6f, 0x75, 0x67, 0x68, 0x00, 0x00, 0x0a,
-            0x95, 0x80, 0x80, 0x80, 0x00, 0x01, 0x8f, 0x80, 0x80, 0x80, 0x00, 0x00, 0x14, 0x00, 0x10, 0x00,
-            0x4d, 0x03, 0x01, 0x10, 0x01, 0x04, 0x10, 0x02, 0x0f, 0x0f
-        };
-
-        Plan plan(vm, vector);
-        checkPlan(plan, 1);
-
-        // Test this doesn't crash.
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(0), box(32) }), 1);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(1), box(32) }), 2);
-    }
-
-    {
-        // Generated from:
-        //    (module
-        //     (func (export &quot;dumb-less-than&quot;) (param $x i32) (param $y i32) (result i32)
-        //      (loop $loop i32
-        //       (i32.eq (get_local $x) (get_local $y))
-        //       (if i32
-        //        (then (return (i32.const 0)))
-        //        (else
-        //         (get_local $x)
-        //         (set_local $x (i32.sub (get_local $x) (i32.const 1)))
-        //         (i32.const 0)
-        //         (i32.ne)
-        //         (br_if $loop)
-        //         (i32.const 1)
-        //         )
-        //        )
-        //       )
-        //      )
-        //     )
-        Vector&lt;uint8_t&gt; vector = {
-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x87, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
-            0x02, 0x01, 0x01, 0x01, 0x01, 0x03, 0x82, 0x80, 0x80, 0x80, 0x00, 0x01, 0x00, 0x07, 0x92, 0x80,
-            0x80, 0x80, 0x00, 0x01, 0x0e, 0x64, 0x75, 0x6d, 0x62, 0x2d, 0x6c, 0x65, 0x73, 0x73, 0x2d, 0x74,
-            0x68, 0x61, 0x6e, 0x00, 0x00, 0x0a, 0xa7, 0x80, 0x80, 0x80, 0x00, 0x01, 0xa1, 0x80, 0x80, 0x80,
-            0x00, 0x00, 0x02, 0x01, 0x14, 0x00, 0x14, 0x01, 0x4d, 0x03, 0x01, 0x10, 0x00, 0x09, 0x04, 0x14,
-            0x00, 0x14, 0x00, 0x10, 0x01, 0x41, 0x15, 0x00, 0x10, 0x00, 0x4e, 0x07, 0x01, 0x10, 0x01, 0x0f,
-            0x0f, 0x0f
-        };
-
-        Plan plan(vm, vector);
-        checkPlan(plan, 1);
-
-        // Test this doesn't crash.
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(0), box(1) }), 1);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(1), box(0) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(2), box(1) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(1), box(2) }), 1);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(2), box(2) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(1), box(1) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(2), box(6) }), 1);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(100), box(6) }), 0);
-    }
-
-    {
-        // Generated from:
-        //    (module
-        //     (func $f32-sub (export &quot;f32-sub&quot;) (param f32) (param f32) (result f32) (return (f32.sub (get_local 0) (get_local 1))))
-        //     (func (export &quot;indirect-f32-sub&quot;) (param f32) (param f32) (result f32) (return (call $f32-sub (get_local 0) (get_local 1))))
-        //     )
-        Vector&lt;uint8_t&gt; vector = {
-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x87, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
-            0x02, 0x03, 0x03, 0x01, 0x03, 0x03, 0x83, 0x80, 0x80, 0x80, 0x00, 0x02, 0x00, 0x00, 0x07, 0x9e,
-            0x80, 0x80, 0x80, 0x00, 0x02, 0x07, 0x66, 0x33, 0x32, 0x2d, 0x73, 0x75, 0x62, 0x00, 0x00, 0x10,
-            0x69, 0x6e, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x2d, 0x66, 0x33, 0x32, 0x2d, 0x73, 0x75, 0x62,
-            0x00, 0x01, 0x0a, 0x9c, 0x80, 0x80, 0x80, 0x00, 0x02, 0x88, 0x80, 0x80, 0x80, 0x00, 0x00, 0x14,
-            0x00, 0x14, 0x01, 0x76, 0x09, 0x0f, 0x89, 0x80, 0x80, 0x80, 0x00, 0x00, 0x14, 0x00, 0x14, 0x01,
-            0x16, 0x00, 0x09, 0x0f
-        };
-
-        Plan plan(vm, vector);
-        checkPlan(plan, 2);
-
-        // Test this doesn't crash.
-        CHECK(isIdentical(invoke&lt;float&gt;(*plan.jsToWasmEntryPointForFunction(1), { boxf(0.0), boxf(1.5) }), -1.5f));
-        CHECK(isIdentical(invoke&lt;float&gt;(*plan.jsToWasmEntryPointForFunction(1), { boxf(100.1234), boxf(12.5) }), 87.6234f));
-        CHECK(isIdentical(invoke&lt;float&gt;(*plan.jsToWasmEntryPointForFunction(0), { boxf(0.0), boxf(1.5) }), -1.5f));
-        CHECK(isIdentical(invoke&lt;float&gt;(*plan.jsToWasmEntryPointForFunction(0), { boxf(100.1234), boxf(12.5) }), 87.6234f));
-    }
-
-    {
-        // Generated from:
-        //    (module
-        //     (func $f32-add (export &quot;f32-add&quot;) (param f32) (param f32) (result f32) (return (f32.add (get_local 0) (get_local 1))))
-        //     (func (export &quot;indirect-f32-add&quot;) (param f32) (param f32) (result f32) (return (call $f32-add (get_local 0) (get_local 1))))
-        //     )
-        Vector&lt;uint8_t&gt; vector = {
-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x87, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
-            0x02, 0x03, 0x03, 0x01, 0x03, 0x03, 0x83, 0x80, 0x80, 0x80, 0x00, 0x02, 0x00, 0x00, 0x07, 0x9e,
-            0x80, 0x80, 0x80, 0x00, 0x02, 0x07, 0x66, 0x33, 0x32, 0x2d, 0x61, 0x64, 0x64, 0x00, 0x00, 0x10,
-            0x69, 0x6e, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x2d, 0x66, 0x33, 0x32, 0x2d, 0x61, 0x64, 0x64,
-            0x00, 0x01, 0x0a, 0x9c, 0x80, 0x80, 0x80, 0x00, 0x02, 0x88, 0x80, 0x80, 0x80, 0x00, 0x00, 0x14,
-            0x00, 0x14, 0x01, 0x75, 0x09, 0x0f, 0x89, 0x80, 0x80, 0x80, 0x00, 0x00, 0x14, 0x00, 0x14, 0x01,
-            0x16, 0x00, 0x09, 0x0f
-        };
-
-        Plan plan(vm, vector);
-        checkPlan(plan, 2);
-
-        // Test this doesn't crash.
-        CHECK(isIdentical(invoke&lt;float&gt;(*plan.jsToWasmEntryPointForFunction(1), { boxf(0.0), boxf(1.5) }), 1.5f));
-        CHECK(isIdentical(invoke&lt;float&gt;(*plan.jsToWasmEntryPointForFunction(1), { boxf(100.1234), boxf(12.5) }), 112.6234f));
-        CHECK(isIdentical(invoke&lt;float&gt;(*plan.jsToWasmEntryPointForFunction(0), { boxf(0.0), boxf(1.5) }), 1.5f));
-        CHECK(isIdentical(invoke&lt;float&gt;(*plan.jsToWasmEntryPointForFunction(0), { boxf(100.1234), boxf(12.5) }), 112.6234f));
-    }
-
-    {
-        // Generated from:
-        //    (module
-        //     (memory 1)
-        //     (func $sum12 (param i32) (param i32) (param i32) (param i32) (param i32) (param i32) (param i32) (param i32) (param i32) (param i32) (param i32) (param i32) (result i32) (return (i32.add (get_local 0) (i32.add (get_local 1) (i32.add (get_local 2) (i32.add (get_local 3) (i32.add (get_local 4) (i32.add (get_local 5) (i32.add (get_local 6) (i32.add (get_local 7) (i32.add (get_local 8) (i32.add (get_local 9) (i32.add (get_local 10) (get_local 11))))))))))))))
-        //     (func (export &quot;mult12&quot;) (param i32) (result i32) (return (call $sum12 (get_local 0) (get_local 0) (get_local 0) (get_local 0) (get_local 0) (get_local 0) (get_local 0) (get_local 0) (get_local 0) (get_local 0) (get_local 0) (get_local 0))))
-        //     )
-
-        Vector&lt;uint8_t&gt; vector = {
-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x96, 0x80, 0x80, 0x80, 0x00, 0x02, 0x40,
-            0x0c, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x40,
-            0x01, 0x01, 0x01, 0x01, 0x03, 0x83, 0x80, 0x80, 0x80, 0x00, 0x02, 0x00, 0x01, 0x05, 0x83, 0x80,
-            0x80, 0x80, 0x00, 0x01, 0x00, 0x01, 0x07, 0x8a, 0x80, 0x80, 0x80, 0x00, 0x01, 0x06, 0x6d, 0x75,
-            0x6c, 0x74, 0x31, 0x32, 0x00, 0x01, 0x0a, 0xce, 0x80, 0x80, 0x80, 0x00, 0x02, 0xa6, 0x80, 0x80,
-            0x80, 0x00, 0x00, 0x14, 0x00, 0x14, 0x01, 0x14, 0x02, 0x14, 0x03, 0x14, 0x04, 0x14, 0x05, 0x14,
-            0x06, 0x14, 0x07, 0x14, 0x08, 0x14, 0x09, 0x14, 0x0a, 0x14, 0x0b, 0x40, 0x40, 0x40, 0x40, 0x40,
-            0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x09, 0x0f, 0x9d, 0x80, 0x80, 0x80, 0x00, 0x00, 0x14, 0x00,
-            0x14, 0x00, 0x14, 0x00, 0x14, 0x00, 0x14, 0x00, 0x14, 0x00, 0x14, 0x00, 0x14, 0x00, 0x14, 0x00,
-            0x14, 0x00, 0x14, 0x00, 0x14, 0x00, 0x16, 0x00, 0x09, 0x0f
-        };
-
-        Plan plan(vm, vector);
-        checkPlan(plan, 2);
-
-        // Test this doesn't crash.
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(1), { box(0) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(1), { box(100) }), 1200);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(1), { box(1) }), 12);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { 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.jsToWasmEntryPointForFunction(0), { 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);
-    }
-
-    {
-        // Generated from:
-        //    (module
-        //     (memory 1)
-        //     (func $fac (export &quot;fac&quot;) (param i64) (result i64)
-        //      (if (i64.eqz (get_local 0))
-        //       (return (i64.const 1))
-        //       )
-        //      (return (i64.mul (get_local 0) (call $fac (i64.sub (get_local 0) (i64.const 1)))))
-        //      )
-        //     )
-        Vector&lt;uint8_t&gt; vector = {
-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x86, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
-            0x01, 0x02, 0x01, 0x02, 0x03, 0x82, 0x80, 0x80, 0x80, 0x00, 0x01, 0x00, 0x05, 0x83, 0x80, 0x80,
-            0x80, 0x00, 0x01, 0x00, 0x01, 0x07, 0x87, 0x80, 0x80, 0x80, 0x00, 0x01, 0x03, 0x66, 0x61, 0x63,
-            0x00, 0x00, 0x0a, 0x9e, 0x80, 0x80, 0x80, 0x00, 0x01, 0x98, 0x80, 0x80, 0x80, 0x00, 0x00, 0x14,
-            0x00, 0x11, 0x00, 0x68, 0x03, 0x00, 0x11, 0x01, 0x09, 0x0f, 0x14, 0x00, 0x14, 0x00, 0x11, 0x01,
-            0x5c, 0x16, 0x00, 0x5d, 0x09, 0x0f
-        };
-
-        Plan plan(vm, vector);
-        checkPlan(plan, 1);
-
-        // Test this doesn't crash.
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(0) }), 1);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(1) }), 1);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(2) }), 2);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(4) }), 24);
-    }
-
-    {
-        // Generated from:
-        //    (module
-        //     (memory 1)
-        //     (func (export &quot;double&quot;) (param i64) (result i64) (return (call 1 (get_local 0) (get_local 0))))
-        //     (func $sum (param i64) (param i64) (result i64) (return (i64.add (get_local 0) (get_local 1))))
-        //     )
-        Vector&lt;uint8_t&gt; vector = {
-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x8c, 0x80, 0x80, 0x80, 0x00, 0x02, 0x40,
-            0x01, 0x02, 0x01, 0x02, 0x40, 0x02, 0x02, 0x02, 0x01, 0x02, 0x03, 0x83, 0x80, 0x80, 0x80, 0x00,
-            0x02, 0x00, 0x01, 0x05, 0x83, 0x80, 0x80, 0x80, 0x00, 0x01, 0x00, 0x01, 0x07, 0x8a, 0x80, 0x80,
-            0x80, 0x00, 0x01, 0x06, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x00, 0x00, 0x0a, 0x9c, 0x80, 0x80,
-            0x80, 0x00, 0x02, 0x89, 0x80, 0x80, 0x80, 0x00, 0x00, 0x14, 0x00, 0x14, 0x00, 0x16, 0x01, 0x09,
-            0x0f, 0x88, 0x80, 0x80, 0x80, 0x00, 0x00, 0x14, 0x00, 0x14, 0x01, 0x5b, 0x09, 0x0f
-        };
-
-        Plan plan(vm, vector);
-        checkPlan(plan, 2);
-
-        // Test this doesn't crash.
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(1), { box(0), box(0) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(1), { box(100), box(0) }), 100);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(1), { box(1), box(15) }), 16);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(0) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(100) }), 200);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(1) }), 2);
-    }
-
-    {
-        // Generated from:
-        //    (module
-        //     (memory 1)
-        //     (func $id (param $value i32) (result i32) (return (get_local $value)))
-        //     (func (export &quot;id-call&quot;) (param $value i32) (result i32) (return (call $id (get_local $value))))
-        //     )
-        Vector&lt;uint8_t&gt; vector = {
-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x86, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
-            0x01, 0x01, 0x01, 0x01, 0x03, 0x83, 0x80, 0x80, 0x80, 0x00, 0x02, 0x00, 0x00, 0x05, 0x83, 0x80,
-            0x80, 0x80, 0x00, 0x01, 0x01, 0x01, 0x07, 0x8b, 0x80, 0x80, 0x80, 0x00, 0x01, 0x07, 0x69, 0x64,
-            0x2d, 0x63, 0x61, 0x6c, 0x6c, 0x00, 0x01, 0x0a, 0x97, 0x80, 0x80, 0x80, 0x00, 0x02, 0x85, 0x80,
-            0x80, 0x80, 0x00, 0x00, 0x14, 0x00, 0x09, 0x0f, 0x87, 0x80, 0x80, 0x80, 0x00, 0x00, 0x14, 0x00,
-            0x16, 0x00, 0x09, 0x0f
-        };
-
-        Plan plan(vm, vector);
-        checkPlan(plan, 2);
-
-        // Test this doesn't crash.
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(1), { box(0) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(1), { box(100) }), 100);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(1), { box(1) }), 1);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(0) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(100) }), 100);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(1) }), 1);
-    }
-
-    {
-        // Generated from:
-        //    (module
-        //     (memory 1)
-        //     (func (export &quot;i64&quot;) (param $i i64) (param $ptr i32) (result i64)
-        //      (i64.store (get_local $ptr) (get_local $i))
-        //      (return (i64.load (get_local $ptr)))
-        //      )
-        //     )
-        Vector&lt;uint8_t&gt; vector = {
-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x87, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
-            0x02, 0x02, 0x01, 0x01, 0x02, 0x03, 0x82, 0x80, 0x80, 0x80, 0x00, 0x01, 0x00, 0x05, 0x83, 0x80,
-            0x80, 0x80, 0x00, 0x01, 0x01, 0x01, 0x07, 0x87, 0x80, 0x80, 0x80, 0x00, 0x01, 0x03, 0x69, 0x36,
-            0x34, 0x00, 0x00, 0x0a, 0x95, 0x80, 0x80, 0x80, 0x00, 0x01, 0x8f, 0x80, 0x80, 0x80, 0x00, 0x00,
-            0x14, 0x01, 0x14, 0x00, 0x34, 0x03, 0x00, 0x14, 0x01, 0x2b, 0x03, 0x00, 0x09, 0x0f
-        };
-
-        Plan plan(vm, vector);
-        checkPlan(plan, 1);
-
-        // Test this doesn't crash.
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(0), box(10) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(100), box(2) }), 100);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(1), box(100) }), 1);
-    }
-
-    {
-        // Generated from:
-        // (module
-        //  (memory 1)
-        //  (func (export &quot;i32_load8_s&quot;) (param $i i32) (param $ptr i32) (result i32)
-        //   (i32.store (get_local $ptr) (get_local $i))
-        //   (return (i32.load (get_local $ptr)))
-        //   )
-        //  )
-        Vector&lt;uint8_t&gt; vector = {
-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x87, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
-            0x02, 0x01, 0x01, 0x01, 0x01, 0x03, 0x82, 0x80, 0x80, 0x80, 0x00, 0x01, 0x00, 0x05, 0x83, 0x80,
-            0x80, 0x80, 0x00, 0x01, 0x01, 0x01, 0x07, 0x8f, 0x80, 0x80, 0x80, 0x00, 0x01, 0x0b, 0x69, 0x33,
-            0x32, 0x5f, 0x6c, 0x6f, 0x61, 0x64, 0x38, 0x5f, 0x73, 0x00, 0x00, 0x0a, 0x95, 0x80, 0x80, 0x80,
-            0x00, 0x01, 0x8f, 0x80, 0x80, 0x80, 0x00, 0x00, 0x14, 0x01, 0x14, 0x00, 0x33, 0x02, 0x00, 0x14,
-            0x01, 0x2a, 0x02, 0x00, 0x09, 0x0f
-        };
-
-        Plan plan(vm, vector);
-        checkPlan(plan, 1);
-
-        // Test this doesn't crash.
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(0), box(10) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(100), box(2) }), 100);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(1), box(100) }), 1);
-    }
-
-    {
-        // Generated from:
-        //    (module
-        //     (memory 1)
-        //     (func (export &quot;write_array&quot;) (param $x i32) (param $p i32) (param $length i32) (local $i i32)
-        //      (set_local $i (i32.const 0))
-        //      (block
-        //       (loop
-        //        (br_if 1 (i32.ge_u (get_local $i) (get_local $length)))
-        //        (i32.store (i32.add (get_local $p) (i32.mul (get_local $i) (i32.const 4))) (get_local $x))
-        //        (set_local $i (i32.add (i32.const 1) (get_local $i)))
-        //        (br 0)
-        //        )
-        //       )
-        //      (return)
-        //      )
-        //     )
-        Vector&lt;uint8_t&gt; vector = {
-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x87, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
-            0x03, 0x01, 0x01, 0x01, 0x00, 0x03, 0x82, 0x80, 0x80, 0x80, 0x00, 0x01, 0x00, 0x05, 0x83, 0x80,
-            0x80, 0x80, 0x00, 0x01, 0x01, 0x01, 0x07, 0x8f, 0x80, 0x80, 0x80, 0x00, 0x01, 0x0b, 0x77, 0x72,
-            0x69, 0x74, 0x65, 0x5f, 0x61, 0x72, 0x72, 0x61, 0x79, 0x00, 0x00, 0x0a, 0xb2, 0x80, 0x80, 0x80,
-            0x00, 0x01, 0xac, 0x80, 0x80, 0x80, 0x00, 0x01, 0x01, 0x01, 0x10, 0x00, 0x15, 0x03, 0x01, 0x00,
-            0x02, 0x00, 0x14, 0x03, 0x14, 0x02, 0x56, 0x07, 0x01, 0x14, 0x01, 0x14, 0x03, 0x10, 0x04, 0x42,
-            0x40, 0x14, 0x00, 0x33, 0x02, 0x00, 0x10, 0x01, 0x14, 0x03, 0x40, 0x15, 0x03, 0x06, 0x00, 0x0f,
-            0x0f, 0x09, 0x0f
-        };
-
-        Plan plan(vm, vector);
-        checkPlan(plan, 1);
-        ASSERT(plan.memory()-&gt;size());
-
-        // Test this doesn't crash.
-        unsigned length = 5;
-        unsigned offset = sizeof(uint32_t);
-        uint32_t* memory = static_cast&lt;uint32_t*&gt;(plan.memory()-&gt;memory());
-        invoke&lt;void&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(100), box(offset), box(length) });
-        offset /= sizeof(uint32_t);
-        CHECK_EQ(memory[offset - 1], 0u);
-        CHECK_EQ(memory[offset + length], 0u);
-        for (unsigned i = 0; i &lt; length; ++i)
-            CHECK_EQ(memory[i + offset], 100u);
-
-        length = 10;
-        offset = 5 * sizeof(uint32_t);
-        invoke&lt;void&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(5), box(offset), box(length) });
-        offset /= sizeof(uint32_t);
-        CHECK_EQ(memory[offset - 1], 100u);
-        CHECK_EQ(memory[offset + length], 0u);
-        for (unsigned i = 0; i &lt; length; ++i)
-            CHECK_EQ(memory[i + offset], 5u);
-    }
-
-    {
-        // Generated from:
-        //    (module
-        //     (memory 1)
-        //     (func (export &quot;write_array&quot;) (param $x i32) (param $p i32) (param $length i32) (local $i i32)
-        //      (set_local $i (i32.const 0))
-        //      (block
-        //       (loop
-        //        (br_if 1 (i32.ge_u (get_local $i) (get_local $length)))
-        //        (i32.store8 (i32.add (get_local $p) (get_local $i)) (get_local $x))
-        //        (set_local $i (i32.add (i32.const 1) (get_local $i)))
-        //        (br 0)
-        //        )
-        //       )
-        //      (return)
-        //      )
-        //     )
-        Vector&lt;uint8_t&gt; vector = {
-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x87, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
-            0x03, 0x01, 0x01, 0x01, 0x00, 0x03, 0x82, 0x80, 0x80, 0x80, 0x00, 0x01, 0x00, 0x05, 0x83, 0x80,
-            0x80, 0x80, 0x00, 0x01, 0x01, 0x01, 0x07, 0x8f, 0x80, 0x80, 0x80, 0x00, 0x01, 0x0b, 0x77, 0x72,
-            0x69, 0x74, 0x65, 0x5f, 0x61, 0x72, 0x72, 0x61, 0x79, 0x00, 0x00, 0x0a, 0xaf, 0x80, 0x80, 0x80,
-            0x00, 0x01, 0xa9, 0x80, 0x80, 0x80, 0x00, 0x01, 0x01, 0x01, 0x10, 0x00, 0x15, 0x03, 0x01, 0x00,
-            0x02, 0x00, 0x14, 0x03, 0x14, 0x02, 0x56, 0x07, 0x01, 0x14, 0x01, 0x14, 0x03, 0x40, 0x14, 0x00,
-            0x2e, 0x00, 0x00, 0x10, 0x01, 0x14, 0x03, 0x40, 0x15, 0x03, 0x06, 0x00, 0x0f, 0x0f, 0x09, 0x0f
-        };
-
-        Plan plan(vm, vector);
-        checkPlan(plan, 1);
-        ASSERT(plan.memory()-&gt;size());
-
-        // Test this doesn't crash.
-        unsigned length = 5;
-        unsigned offset = 1;
-        uint8_t* memory = static_cast&lt;uint8_t*&gt;(plan.memory()-&gt;memory());
-        invoke&lt;void&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(100), box(offset), box(length) });
-        CHECK_EQ(memory[offset - 1], 0u);
-        CHECK_EQ(memory[offset + length], 0u);
-        for (unsigned i = 0; i &lt; length; ++i)
-            CHECK_EQ(memory[i + offset], 100u);
-
-        length = 10;
-        offset = 5;
-        invoke&lt;void&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(5), box(offset), box(length) });
-        CHECK_EQ(memory[offset - 1], 100u);
-        CHECK_EQ(memory[offset + length], 0u);
-        for (unsigned i = 0; i &lt; length; ++i)
-            CHECK_EQ(memory[i + offset], 5u);
-    }
-
-    {
-        // Generated from:
-        //    (module
-        //     (memory 1)
-        //     (func (export &quot;i32_load8_s&quot;) (param $i i32) (param $ptr i32) (result i32)
-        //      (i32.store8 (get_local $ptr) (get_local $i))
-        //      (return (i32.load8_s (get_local $ptr)))
-        //      )
-        //     )
-        Vector&lt;uint8_t&gt; vector = {
-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x87, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
-            0x02, 0x01, 0x01, 0x01, 0x01, 0x03, 0x82, 0x80, 0x80, 0x80, 0x00, 0x01, 0x00, 0x05, 0x83, 0x80,
-            0x80, 0x80, 0x00, 0x01, 0x01, 0x01, 0x07, 0x8f, 0x80, 0x80, 0x80, 0x00, 0x01, 0x0b, 0x69, 0x33,
-            0x32, 0x5f, 0x6c, 0x6f, 0x61, 0x64, 0x38, 0x5f, 0x73, 0x00, 0x00, 0x0a, 0x95, 0x80, 0x80, 0x80,
-            0x00, 0x01, 0x8f, 0x80, 0x80, 0x80, 0x00, 0x00, 0x14, 0x01, 0x14, 0x00, 0x2e, 0x00, 0x00, 0x14,
-            0x01, 0x20, 0x00, 0x00, 0x09, 0x0f
-        };
-
-        Plan plan(vm, vector);
-        checkPlan(plan, 1);
-        ASSERT(plan.memory()-&gt;size());
-
-        // Test this doesn't crash.
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(0), box(10) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(100), box(2) }), 100);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(1), box(100) }), 1);
-    }
-
-    {
-        // Generated from:
-        //    (module
-        //     (memory 1)
-        //     (func (export &quot;i32_load8_s&quot;) (param $i i32) (result i32)
-        //      (i32.store8 (i32.const 8) (get_local $i))
-        //      (return (i32.load8_s (i32.const 8)))
-        //      )
-        //     )
-        Vector&lt;uint8_t&gt; vector = {
-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x86, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
-            0x01, 0x01, 0x01, 0x01, 0x03, 0x82, 0x80, 0x80, 0x80, 0x00, 0x01, 0x00, 0x05, 0x83, 0x80, 0x80,
-            0x80, 0x00, 0x01, 0x01, 0x01, 0x07, 0x8f, 0x80, 0x80, 0x80, 0x00, 0x01, 0x0b, 0x69, 0x33, 0x32,
-            0x5f, 0x6c, 0x6f, 0x61, 0x64, 0x38, 0x5f, 0x73, 0x00, 0x00, 0x0a, 0x95, 0x80, 0x80, 0x80, 0x00,
-            0x01, 0x8f, 0x80, 0x80, 0x80, 0x00, 0x00, 0x10, 0x08, 0x14, 0x00, 0x2e, 0x00, 0x00, 0x10, 0x08,
-            0x20, 0x00, 0x00, 0x09, 0x0f
-        };
-
-        Plan plan(vm, vector);
-        checkPlan(plan, 1);
-
-        // Test this doesn't crash.
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(0) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(100) }), 100);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(1) }), 1);
-    }
-
-    {
-        // Generated from:
-        // (module
-        //  (memory 1)
-        //  (func (export &quot;i32_load8_s&quot;) (param $i i32) (param $ptr i32) (result i32)
-        //   (i32.store (get_local $ptr) (get_local $i))
-        //   (return (i32.load (get_local $ptr)))
-        //   )
-        //  )
-        Vector&lt;uint8_t&gt; vector = {
-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x87, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
-            0x02, 0x02, 0x01, 0x01, 0x02, 0x03, 0x82, 0x80, 0x80, 0x80, 0x00, 0x01, 0x00, 0x05, 0x83, 0x80,
-            0x80, 0x80, 0x00, 0x01, 0x01, 0x01, 0x07, 0x8f, 0x80, 0x80, 0x80, 0x00, 0x01, 0x0b, 0x69, 0x33,
-            0x32, 0x5f, 0x6c, 0x6f, 0x61, 0x64, 0x38, 0x5f, 0x73, 0x00, 0x00, 0x0a, 0x95, 0x80, 0x80, 0x80,
-            0x00, 0x01, 0x8f, 0x80, 0x80, 0x80, 0x00, 0x00, 0x14, 0x01, 0x14, 0x00, 0x34, 0x03, 0x00, 0x14,
-            0x01, 0x2b, 0x03, 0x00, 0x09, 0x0f
-        };
-
-        Plan plan(vm, vector);
-        checkPlan(plan, 1);
-
-        // Test this doesn't crash.
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(0), box(10) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(100), box(2) }), 100);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(1), box(100) }), 1);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(-12), box(plan.memory()-&gt;size() - sizeof(uint64_t)) }), -12);
-    }
-
-    {
-        // Generated from:
-        // (module
-        //  (memory 1)
-        //  (func (export &quot;i32_load8_s&quot;) (param $i i32) (param $ptr i32) (result i32)
-        //   (i32.store (get_local $ptr) (get_local $i))
-        //   (return (i32.load (get_local $ptr)))
-        //   )
-        //  )
-        Vector&lt;uint8_t&gt; vector = {
-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x87, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
-            0x02, 0x01, 0x01, 0x01, 0x01, 0x03, 0x82, 0x80, 0x80, 0x80, 0x00, 0x01, 0x00, 0x05, 0x83, 0x80,
-            0x80, 0x80, 0x00, 0x01, 0x01, 0x01, 0x07, 0x8f, 0x80, 0x80, 0x80, 0x00, 0x01, 0x0b, 0x69, 0x33,
-            0x32, 0x5f, 0x6c, 0x6f, 0x61, 0x64, 0x38, 0x5f, 0x73, 0x00, 0x00, 0x0a, 0x95, 0x80, 0x80, 0x80,
-            0x00, 0x01, 0x8f, 0x80, 0x80, 0x80, 0x00, 0x00, 0x14, 0x01, 0x14, 0x00, 0x33, 0x02, 0x00, 0x14,
-            0x01, 0x2a, 0x02, 0x00, 0x09, 0x0f
-        };
-
-        Plan plan(vm, vector);
-        checkPlan(plan, 1);
-
-        // Test this doesn't crash.
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(0), box(10) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(100), box(2) }), 100);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(1), box(100) }), 1);
-    }
-
-    {
-        // Generated from:
-        //    (module
-        //     (memory 1)
-        //     (func (export &quot;write_array&quot;) (param $x i32) (param $p i32) (param $length i32) (local $i i32)
-        //      (set_local $i (i32.const 0))
-        //      (block
-        //       (loop
-        //        (br_if 1 (i32.ge_u (get_local $i) (get_local $length)))
-        //        (i32.store (i32.add (get_local $p) (i32.mul (get_local $i) (i32.const 4))) (get_local $x))
-        //        (set_local $i (i32.add (i32.const 1) (get_local $i)))
-        //        (br 0)
-        //        )
-        //       )
-        //      (return)
-        //      )
-        //     )
-        Vector&lt;uint8_t&gt; vector = {
-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x87, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
-            0x03, 0x01, 0x01, 0x01, 0x00, 0x03, 0x82, 0x80, 0x80, 0x80, 0x00, 0x01, 0x00, 0x05, 0x83, 0x80,
-            0x80, 0x80, 0x00, 0x01, 0x01, 0x01, 0x07, 0x8f, 0x80, 0x80, 0x80, 0x00, 0x01, 0x0b, 0x77, 0x72,
-            0x69, 0x74, 0x65, 0x5f, 0x61, 0x72, 0x72, 0x61, 0x79, 0x00, 0x00, 0x0a, 0xb2, 0x80, 0x80, 0x80,
-            0x00, 0x01, 0xac, 0x80, 0x80, 0x80, 0x00, 0x01, 0x01, 0x01, 0x10, 0x00, 0x15, 0x03, 0x01, 0x00,
-            0x02, 0x00, 0x14, 0x03, 0x14, 0x02, 0x56, 0x07, 0x01, 0x14, 0x01, 0x14, 0x03, 0x10, 0x04, 0x42,
-            0x40, 0x14, 0x00, 0x33, 0x02, 0x00, 0x10, 0x01, 0x14, 0x03, 0x40, 0x15, 0x03, 0x06, 0x00, 0x0f,
-            0x0f, 0x09, 0x0f
-        };
-
-        Plan plan(vm, vector);
-        checkPlan(plan, 1);
-        ASSERT(plan.memory()-&gt;size());
-
-        // Test this doesn't crash.
-        unsigned length = 5;
-        unsigned offset = sizeof(uint32_t);
-        uint32_t* memory = static_cast&lt;uint32_t*&gt;(plan.memory()-&gt;memory());
-        invoke&lt;void&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(100), box(offset), box(length) });
-        offset /= sizeof(uint32_t);
-        CHECK_EQ(memory[offset - 1], 0u);
-        CHECK_EQ(memory[offset + length], 0u);
-        for (unsigned i = 0; i &lt; length; ++i)
-            CHECK_EQ(memory[i + offset], 100u);
-
-        length = 10;
-        offset = 5 * sizeof(uint32_t);
-        invoke&lt;void&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(5), box(offset), box(length) });
-        offset /= sizeof(uint32_t);
-        CHECK_EQ(memory[offset - 1], 100u);
-        CHECK_EQ(memory[offset + length], 0u);
-        for (unsigned i = 0; i &lt; length; ++i)
-            CHECK_EQ(memory[i + offset], 5u);
-    }
-
-    {
-        // Generated from:
-        //    (module
-        //     (memory 1)
-        //     (func (export &quot;write_array&quot;) (param $x i32) (param $p i32) (param $length i32) (local $i i32)
-        //      (set_local $i (i32.const 0))
-        //      (block
-        //       (loop
-        //        (br_if 1 (i32.ge_u (get_local $i) (get_local $length)))
-        //        (i32.store8 (i32.add (get_local $p) (get_local $i)) (get_local $x))
-        //        (set_local $i (i32.add (i32.const 1) (get_local $i)))
-        //        (br 0)
-        //        )
-        //       )
-        //      (return)
-        //      )
-        //     )
-        Vector&lt;uint8_t&gt; vector = {
-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x87, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
-            0x03, 0x01, 0x01, 0x01, 0x00, 0x03, 0x82, 0x80, 0x80, 0x80, 0x00, 0x01, 0x00, 0x05, 0x83, 0x80,
-            0x80, 0x80, 0x00, 0x01, 0x01, 0x01, 0x07, 0x8f, 0x80, 0x80, 0x80, 0x00, 0x01, 0x0b, 0x77, 0x72,
-            0x69, 0x74, 0x65, 0x5f, 0x61, 0x72, 0x72, 0x61, 0x79, 0x00, 0x00, 0x0a, 0xaf, 0x80, 0x80, 0x80,
-            0x00, 0x01, 0xa9, 0x80, 0x80, 0x80, 0x00, 0x01, 0x01, 0x01, 0x10, 0x00, 0x15, 0x03, 0x01, 0x00,
-            0x02, 0x00, 0x14, 0x03, 0x14, 0x02, 0x56, 0x07, 0x01, 0x14, 0x01, 0x14, 0x03, 0x40, 0x14, 0x00,
-            0x2e, 0x00, 0x00, 0x10, 0x01, 0x14, 0x03, 0x40, 0x15, 0x03, 0x06, 0x00, 0x0f, 0x0f, 0x09, 0x0f
-        };
-
-        Plan plan(vm, vector);
-        checkPlan(plan, 1);
-        ASSERT(plan.memory()-&gt;size());
-
-        // Test this doesn't crash.
-        unsigned length = 5;
-        unsigned offset = 1;
-        uint8_t* memory = static_cast&lt;uint8_t*&gt;(plan.memory()-&gt;memory());
-        invoke&lt;void&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(100), box(offset), box(length) });
-        CHECK_EQ(memory[offset - 1], 0u);
-        CHECK_EQ(memory[offset + length], 0u);
-        for (unsigned i = 0; i &lt; length; ++i)
-            CHECK_EQ(memory[i + offset], 100u);
-
-        length = 10;
-        offset = 5;
-        invoke&lt;void&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(5), box(offset), box(length) });
-        CHECK_EQ(memory[offset - 1], 100u);
-        CHECK_EQ(memory[offset + length], 0u);
-        for (unsigned i = 0; i &lt; length; ++i)
-            CHECK_EQ(memory[i + offset], 5u);
-    }
-
-    {
-        // Generated from:
-        //    (module
-        //     (memory 1)
-        //     (func (export &quot;i32_load8_s&quot;) (param $i i32) (param $ptr i32) (result i32)
-        //      (i32.store8 (get_local $ptr) (get_local $i))
-        //      (return (i32.load8_s (get_local $ptr)))
-        //      )
-        //     )
-        Vector&lt;uint8_t&gt; vector = {
-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x87, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
-            0x02, 0x01, 0x01, 0x01, 0x01, 0x03, 0x82, 0x80, 0x80, 0x80, 0x00, 0x01, 0x00, 0x05, 0x83, 0x80,
-            0x80, 0x80, 0x00, 0x01, 0x01, 0x01, 0x07, 0x8f, 0x80, 0x80, 0x80, 0x00, 0x01, 0x0b, 0x69, 0x33,
-            0x32, 0x5f, 0x6c, 0x6f, 0x61, 0x64, 0x38, 0x5f, 0x73, 0x00, 0x00, 0x0a, 0x95, 0x80, 0x80, 0x80,
-            0x00, 0x01, 0x8f, 0x80, 0x80, 0x80, 0x00, 0x00, 0x14, 0x01, 0x14, 0x00, 0x2e, 0x00, 0x00, 0x14,
-            0x01, 0x20, 0x00, 0x00, 0x09, 0x0f
-        };
-
-        Plan plan(vm, vector);
-        checkPlan(plan, 1);
-        ASSERT(plan.memory()-&gt;size());
-
-        // Test this doesn't crash.
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(0), box(10) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(100), box(2) }), 100);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(1), box(100) }), 1);
-    }
-
-    {
-        // Generated from:
-        //    (module
-        //     (memory 1)
-        //     (func (export &quot;i32_load8_s&quot;) (param $i i32) (result i32)
-        //      (i32.store8 (i32.const 8) (get_local $i))
-        //      (return (i32.load8_s (i32.const 8)))
-        //      )
-        //     )
-        Vector&lt;uint8_t&gt; vector = {
-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x86, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
-            0x01, 0x01, 0x01, 0x01, 0x03, 0x82, 0x80, 0x80, 0x80, 0x00, 0x01, 0x00, 0x05, 0x83, 0x80, 0x80,
-            0x80, 0x00, 0x01, 0x01, 0x01, 0x07, 0x8f, 0x80, 0x80, 0x80, 0x00, 0x01, 0x0b, 0x69, 0x33, 0x32,
-            0x5f, 0x6c, 0x6f, 0x61, 0x64, 0x38, 0x5f, 0x73, 0x00, 0x00, 0x0a, 0x95, 0x80, 0x80, 0x80, 0x00,
-            0x01, 0x8f, 0x80, 0x80, 0x80, 0x00, 0x00, 0x10, 0x08, 0x14, 0x00, 0x2e, 0x00, 0x00, 0x10, 0x08,
-            0x20, 0x00, 0x00, 0x09, 0x0f
-        };
-
-        Plan plan(vm, vector);
-        checkPlan(plan, 1);
-
-        // Test this doesn't crash.
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(0) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(100) }), 100);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(1) }), 1);
-    }
-
-    {
-        // Generated from:
-        //    (module
-        //     (func &quot;dumb-eq&quot; (param $x i32) (param $y i32) (result i32)
-        //      (if (i32.eq (get_local $x) (get_local $y))
-        //       (then (br 0))
-        //       (else (return (i32.const 1))))
-        //      (return (i32.const 0))
-        //      )
-        //     )
-        Vector&lt;uint8_t&gt; vector = {
-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x87, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
-            0x02, 0x01, 0x01, 0x01, 0x01, 0x03, 0x82, 0x80, 0x80, 0x80, 0x00, 0x01, 0x00, 0x07, 0x8b, 0x80,
-            0x80, 0x80, 0x00, 0x01, 0x07, 0x64, 0x75, 0x6d, 0x62, 0x2d, 0x65, 0x71, 0x00, 0x00, 0x0a, 0x99,
-            0x80, 0x80, 0x80, 0x00, 0x01, 0x93, 0x80, 0x80, 0x80, 0x00, 0x00, 0x14, 0x00, 0x14, 0x01, 0x4d,
-            0x03, 0x00, 0x06, 0x00, 0x04, 0x10, 0x01, 0x09, 0x0f, 0x10, 0x00, 0x09, 0x0f
-        };
-
-        Plan plan(vm, vector);
-        checkPlan(plan, 1);
-
-        // Test this doesn't crash.
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(0), box(1) }), 1);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(1), box(0) }), 1);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(2), box(1) }), 1);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(1), box(2) }), 1);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(2), box(2) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(1), box(1) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(2), box(6) }), 1);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(100), box(6) }), 1);
-    }
-
-    {
-        // Generated from:
-        //    (module
-        //     (func (export &quot;dumb-less-than&quot;) (param $x i32) (param $y i32) (result i32)
-        //      (loop
-        //       (if (i32.eq (get_local $x) (get_local $y))
-        //        (then (return (i32.const 0)))
-        //        (else (if (i32.eq (get_local $x) (i32.const 0))
-        //               (return (i32.const 1)))))
-        //       (set_local $x (i32.sub (get_local $x) (i32.const 1)))
-        //       (br 0)
-        //       )
-        //      )
-        //     )
-        Vector&lt;uint8_t&gt; vector = {
-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x87, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
-            0x02, 0x01, 0x01, 0x01, 0x01, 0x03, 0x82, 0x80, 0x80, 0x80, 0x00, 0x01, 0x00, 0x07, 0x92, 0x80,
-            0x80, 0x80, 0x00, 0x01, 0x0e, 0x64, 0x75, 0x6d, 0x62, 0x2d, 0x6c, 0x65, 0x73, 0x73, 0x2d, 0x74,
-            0x68, 0x61, 0x6e, 0x00, 0x00, 0x0a, 0xac, 0x80, 0x80, 0x80, 0x00, 0x01, 0xa6, 0x80, 0x80, 0x80,
-            0x00, 0x00, 0x02, 0x00, 0x14, 0x00, 0x14, 0x01, 0x4d, 0x03, 0x00, 0x10, 0x00, 0x09, 0x04, 0x14,
-            0x00, 0x10, 0x00, 0x4d, 0x03, 0x00, 0x10, 0x01, 0x09, 0x0f, 0x0f, 0x14, 0x00, 0x10, 0x01, 0x41,
-            0x15, 0x00, 0x06, 0x00, 0x0f, 0x00, 0x0f
-        };
-
-        Plan plan(vm, vector);
-        checkPlan(plan, 1);
-
-        // Test this doesn't crash.
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(0), box(1) }), 1);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(1), box(0) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(2), box(1) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(1), box(2) }), 1);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(2), box(2) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(1), box(1) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(2), box(6) }), 1);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(100), box(6) }), 0);
-    }
-
-
-    {
-        // Generated from: (module (func (export &quot;return-i32&quot;) (result i32) (return (i32.const 5))) )
-        Vector&lt;uint8_t&gt; vector = {
-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x85, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
-            0x00, 0x01, 0x01, 0x03, 0x82, 0x80, 0x80, 0x80, 0x00, 0x01, 0x00, 0x07, 0x8e, 0x80, 0x80, 0x80,
-            0x00, 0x01, 0x0a, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x2d, 0x69, 0x33, 0x32, 0x00, 0x00, 0x0a,
-            0x8b, 0x80, 0x80, 0x80, 0x00, 0x01, 0x85, 0x80, 0x80, 0x80, 0x00, 0x00, 0x10, 0x05, 0x09, 0x0f
-        };
-
-        Plan plan(vm, vector);
-        checkPlan(plan, 1);
-
-        // Test this doesn't crash.
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { }), 5);
-    }
-
-
-    {
-        // Generated from: (module (func (export &quot;return-i32&quot;) (result i32) (return (i32.add (i32.const 5) (i32.const 6)))) )
-        Vector&lt;uint8_t&gt; vector = {
-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x85, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
-            0x00, 0x01, 0x01, 0x03, 0x82, 0x80, 0x80, 0x80, 0x00, 0x01, 0x00, 0x07, 0x8e, 0x80, 0x80, 0x80,
-            0x00, 0x01, 0x0a, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x2d, 0x69, 0x33, 0x32, 0x00, 0x00, 0x0a,
-            0x8e, 0x80, 0x80, 0x80, 0x00, 0x01, 0x88, 0x80, 0x80, 0x80, 0x00, 0x00, 0x10, 0x05, 0x10, 0x06,
-            0x40, 0x09, 0x0f
-        };
-
-        Plan plan(vm, vector);
-        checkPlan(plan, 1);
-
-        // Test this doesn't crash.
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { }), 11);
-    }
-
-    {
-        // Generated from: (module (func (export &quot;return-i32&quot;) (result i32) (return (i32.add (i32.add (i32.const 5) (i32.const 3)) (i32.const 3)))) )
-        Vector&lt;uint8_t&gt; vector = {
-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x85, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
-            0x00, 0x01, 0x01, 0x03, 0x82, 0x80, 0x80, 0x80, 0x00, 0x01, 0x00, 0x07, 0x8e, 0x80, 0x80, 0x80,
-            0x00, 0x01, 0x0a, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x2d, 0x69, 0x33, 0x32, 0x00, 0x00, 0x0a,
-            0x91, 0x80, 0x80, 0x80, 0x00, 0x01, 0x8b, 0x80, 0x80, 0x80, 0x00, 0x00, 0x10, 0x05, 0x10, 0x03,
-            0x40, 0x10, 0x03, 0x40, 0x09, 0x0f
-        };
-
-        Plan plan(vm, vector);
-        checkPlan(plan, 1);
-
-        // Test this doesn't crash.
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { }), 11);
-    }
-
-    {
-        // Generated from: (module (func (export &quot;return-i32&quot;) (result i32) (block (return (i32.add (i32.add (i32.const 5) (i32.const 3)) (i32.const 3)))) (unreachable)) )
-        Vector&lt;uint8_t&gt; vector = {
-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x85, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
-            0x00, 0x01, 0x01, 0x03, 0x82, 0x80, 0x80, 0x80, 0x00, 0x01, 0x00, 0x07, 0x8e, 0x80, 0x80, 0x80,
-            0x00, 0x01, 0x0a, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x2d, 0x69, 0x33, 0x32, 0x00, 0x00, 0x0a,
-            0x95, 0x80, 0x80, 0x80, 0x00, 0x01, 0x8f, 0x80, 0x80, 0x80, 0x00, 0x00, 0x01, 0x00, 0x10, 0x05,
-            0x10, 0x03, 0x40, 0x10, 0x03, 0x40, 0x09, 0x0f, 0x00, 0x0f
-        };
-
-        Plan plan(vm, vector);
-        checkPlan(plan, 1);
-
-        // Test this doesn't crash.
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { }), 11);
-    }
-
-    {
-        // Generated from: (module (func (export &quot;add&quot;) (param $x i32) (param $y i32) (result i32) (return (i32.add (get_local $x) (get_local $y)))) )
-        Vector&lt;uint8_t&gt; vector = {
-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x87, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
-            0x02, 0x01, 0x01, 0x01, 0x01, 0x03, 0x82, 0x80, 0x80, 0x80, 0x00, 0x01, 0x00, 0x07, 0x87, 0x80,
-            0x80, 0x80, 0x00, 0x01, 0x03, 0x61, 0x64, 0x64, 0x00, 0x00, 0x0a, 0x8e, 0x80, 0x80, 0x80, 0x00,
-            0x01, 0x88, 0x80, 0x80, 0x80, 0x00, 0x00, 0x14, 0x00, 0x14, 0x01, 0x40, 0x09, 0x0f
-        };
-
-        Plan plan(vm, vector);
-        checkPlan(plan, 1);
-
-        // Test this doesn't crash.
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(0), box(1) }), 1);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(100), box(1) }), 101);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(-1), box(1)}), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(std::numeric_limits&lt;int&gt;::max()), box(1) }), std::numeric_limits&lt;int&gt;::min());
-    }
-
-    {
-        // Generated from:
-        //    (module
-        //     (func (export &quot;locals&quot;) (param $x i32) (result i32) (local $num i32)
-        //      (set_local $num (get_local $x))
-        //      (return (get_local $num))
-        //      )
-        //     )
-        Vector&lt;uint8_t&gt; vector = {
-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x86, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
-            0x01, 0x01, 0x01, 0x01, 0x03, 0x82, 0x80, 0x80, 0x80, 0x00, 0x01, 0x00, 0x07, 0x8a, 0x80, 0x80,
-            0x80, 0x00, 0x01, 0x06, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x73, 0x00, 0x00, 0x0a, 0x91, 0x80, 0x80,
-            0x80, 0x00, 0x01, 0x8b, 0x80, 0x80, 0x80, 0x00, 0x01, 0x01, 0x01, 0x14, 0x00, 0x15, 0x01, 0x14,
-            0x01, 0x09, 0x0f
-        };
-
-        Plan plan(vm, vector);
-        checkPlan(plan, 1);
-
-        // Test this doesn't crash.
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(0) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(10) }), 10);
-    }
-
-    {
-        // Generated from:
-        //    (module
-        //     (func (export &quot;sum&quot;) (param $x i32) (result i32) (local $y i32)
-        //      (set_local $y (i32.const 0))
-        //      (loop
-        //       (block
-        //        (br_if 0 (i32.eq (get_local $x) (i32.const 0)))
-        //        (set_local $y (i32.add (get_local $x) (get_local $y)))
-        //        (set_local $x (i32.sub (get_local $x) (i32.const 1)))
-        //        (br 1)
-        //        )
-        //       )
-        //      (return (get_local $y))
-        //      )
-        //     )
-        Vector&lt;uint8_t&gt; vector = {
-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x86, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
-            0x01, 0x01, 0x01, 0x01, 0x03, 0x82, 0x80, 0x80, 0x80, 0x00, 0x01, 0x00, 0x07, 0x87, 0x80, 0x80,
-            0x80, 0x00, 0x01, 0x03, 0x73, 0x75, 0x6d, 0x00, 0x00, 0x0a, 0xae, 0x80, 0x80, 0x80, 0x00, 0x01,
-            0xa8, 0x80, 0x80, 0x80, 0x00, 0x01, 0x01, 0x01, 0x10, 0x00, 0x15, 0x01, 0x02, 0x00, 0x01, 0x00,
-            0x14, 0x00, 0x10, 0x00, 0x4d, 0x07, 0x00, 0x14, 0x00, 0x14, 0x01, 0x40, 0x15, 0x01, 0x14, 0x00,
-            0x10, 0x01, 0x41, 0x15, 0x00, 0x06, 0x01, 0x0f, 0x0f, 0x14, 0x01, 0x09, 0x0f
-        };
-
-        Plan plan(vm, vector);
-        checkPlan(plan, 1);
-
-        // Test this doesn't crash.
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(0) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(1) }), 1);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(2)}), 3);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(100) }), 5050);
-    }
-
-    {
-        // Generated from:
-        //    (module
-        //     (func (export &quot;dumb-mult&quot;) (param $x i32) (param $y i32) (result i32) (local $total i32) (local $i i32) (local $j i32)
-        //      (set_local $total (i32.const 0))
-        //      (set_local $i (i32.const 0))
-        //      (block (loop
-        //              (br_if 1 (i32.eq (get_local $i) (get_local $x)))
-        //              (set_local $j (i32.const 0))
-        //              (set_local $i (i32.add (get_local $i) (i32.const 1)))
-        //              (loop
-        //               (br_if 1 (i32.eq (get_local $j) (get_local $y)))
-        //               (set_local $total (i32.add (get_local $total) (i32.const 1)))
-        //               (set_local $j (i32.add (get_local $j) (i32.const 1)))
-        //               (br 0)
-        //               )
-        //              ))
-        //      (return (get_local $total))
-        //      )
-        //     )
-        Vector&lt;uint8_t&gt; vector = {
-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x87, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
-            0x02, 0x01, 0x01, 0x01, 0x01, 0x03, 0x82, 0x80, 0x80, 0x80, 0x00, 0x01, 0x00, 0x07, 0x8d, 0x80,
-            0x80, 0x80, 0x00, 0x01, 0x09, 0x64, 0x75, 0x6d, 0x62, 0x2d, 0x6d, 0x75, 0x6c, 0x74, 0x00, 0x00,
-            0x0a, 0xc7, 0x80, 0x80, 0x80, 0x00, 0x01, 0xc1, 0x80, 0x80, 0x80, 0x00, 0x01, 0x03, 0x01, 0x10,
-            0x00, 0x15, 0x02, 0x10, 0x00, 0x15, 0x03, 0x01, 0x00, 0x02, 0x00, 0x14, 0x03, 0x14, 0x00, 0x4d,
-            0x07, 0x01, 0x10, 0x00, 0x15, 0x04, 0x14, 0x03, 0x10, 0x01, 0x40, 0x15, 0x03, 0x02, 0x00, 0x14,
-            0x04, 0x14, 0x01, 0x4d, 0x07, 0x01, 0x14, 0x02, 0x10, 0x01, 0x40, 0x15, 0x02, 0x14, 0x04, 0x10,
-            0x01, 0x40, 0x15, 0x04, 0x06, 0x00, 0x0f, 0x0f, 0x0f, 0x14, 0x02, 0x09, 0x0f
-        };
-
-        Plan plan(vm, vector);
-        checkPlan(plan, 1);
-
-        // Test this doesn't crash.
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(0), box(1) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(1), box(0) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(2), box(1) }), 2);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(1), box(2) }), 2);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(2), box(2) }), 4);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(2), box(6) }), 12);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(100), box(6) }), 600);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(100), box(100) }), 10000);
-    }
-
-    {
-        // Generated from:
-        //    (module
-        //     (func &quot;dumb-less-than&quot; (param $x i32) (param $y i32) (result i32)
-        //      (loop
-        //       (block
-        //        (block
-        //         (br_if 0 (i32.eq (get_local $x) (get_local $y)))
-        //         (br 1)
-        //         )
-        //        (return (i32.const 0))
-        //        )
-        //       (block
-        //        (block
-        //         (br_if 0 (i32.eq (get_local $x) (i32.const 0)))
-        //         (br 1)
-        //         )
-        //        (return (i32.const 1))
-        //        )
-        //       (set_local $x (i32.sub (get_local $x) (i32.const 1)))
-        //       (br 0)
-        //       )
-        //       (unreachable)
-        //      )
-        //     )
-        Vector&lt;uint8_t&gt; vector = {
-            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x87, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
-            0x02, 0x01, 0x01, 0x01, 0x01, 0x03, 0x82, 0x80, 0x80, 0x80, 0x00, 0x01, 0x00, 0x07, 0x92, 0x80,
-            0x80, 0x80, 0x00, 0x01, 0x0e, 0x64, 0x75, 0x6d, 0x62, 0x2d, 0x6c, 0x65, 0x73, 0x73, 0x2d, 0x74,
-            0x68, 0x61, 0x6e, 0x00, 0x00, 0x0a, 0xb9, 0x80, 0x80, 0x80, 0x00, 0x01, 0xb3, 0x80, 0x80, 0x80,
-            0x00, 0x00, 0x02, 0x00, 0x01, 0x00, 0x01, 0x00, 0x14, 0x00, 0x14, 0x01, 0x4d, 0x07, 0x00, 0x06,
-            0x01, 0x0f, 0x10, 0x00, 0x09, 0x0f, 0x01, 0x00, 0x01, 0x00, 0x14, 0x00, 0x10, 0x00, 0x4d, 0x07,
-            0x00, 0x06, 0x01, 0x0f, 0x10, 0x01, 0x09, 0x0f, 0x14, 0x00, 0x10, 0x01, 0x41, 0x15, 0x00, 0x06,
-            0x00, 0x0f, 0x00, 0x0f
-        };
-
-        Plan plan(vm, vector);
-        checkPlan(plan, 1);
-
-        // Test this doesn't crash.
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(0), box(1) }), 1);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(1), box(0) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(2), box(1) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(1), box(2) }), 1);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(2), box(2) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(1), box(1) }), 0);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(2), box(6) }), 1);
-        CHECK_EQ(invoke&lt;int&gt;(*plan.jsToWasmEntryPointForFunction(0), { box(100), box(6) }), 0);
-    }
-
-}
-
-#endif // ENABLE(WEBASSEMBLY)
-
-int main(int argc, char** argv)
-{
-    CommandLine options(argc, argv);
-
-    if (options.m_runWasmTests) {
-#if ENABLE(WEBASSEMBLY)
-        JSC::initializeThreading();
-        vm = &amp;JSC::VM::create(JSC::LargeHeap).leakRef();
-        runWasmTests();
-#else
-        dataLogLn(&quot;Wasm is not enabled!&quot;);
-        return EXIT_FAILURE;
-#endif // ENABLE(WEBASSEMBLY)
-    }
-
-    return EXIT_SUCCESS;
-}
-
</del></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWasmB3IRGeneratorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp (209629 => 209630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp        2016-12-09 22:12:08 UTC (rev 209629)
+++ trunk/Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp        2016-12-09 22:38:39 UTC (rev 209630)
</span><span class="lines">@@ -130,7 +130,7 @@
</span><span class="cx"> 
</span><span class="cx">     static constexpr ExpressionType emptyExpression = nullptr;
</span><span class="cx"> 
</span><del>-    B3IRGenerator(Memory*, Procedure&amp;, WasmInternalFunction*, Vector&lt;UnlinkedWasmToWasmCall&gt;&amp;);
</del><ins>+    B3IRGenerator(MemoryInformation&amp;, Procedure&amp;, WasmInternalFunction*, Vector&lt;UnlinkedWasmToWasmCall&gt;&amp;);
</ins><span class="cx"> 
</span><span class="cx">     bool WARN_UNUSED_RETURN addArguments(const Vector&lt;Type&gt;&amp;);
</span><span class="cx">     bool WARN_UNUSED_RETURN addLocal(Type, uint32_t);
</span><span class="lines">@@ -179,7 +179,6 @@
</span><span class="cx">     void unifyValuesWithBlock(const ExpressionList&amp; resultStack, ResultList&amp; stack);
</span><span class="cx">     Value* zeroForType(Type);
</span><span class="cx"> 
</span><del>-    Memory* m_memory;
</del><span class="cx">     Procedure&amp; m_proc;
</span><span class="cx">     BasicBlock* m_currentBlock;
</span><span class="cx">     Vector&lt;Variable*&gt; m_locals;
</span><span class="lines">@@ -189,9 +188,8 @@
</span><span class="cx">     Value* m_zeroValues[numTypes];
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-B3IRGenerator::B3IRGenerator(Memory* memory, Procedure&amp; procedure, WasmInternalFunction* compilation, Vector&lt;UnlinkedWasmToWasmCall&gt;&amp; unlinkedWasmToWasmCalls)
-    : m_memory(memory)
-    , m_proc(procedure)
</del><ins>+B3IRGenerator::B3IRGenerator(MemoryInformation&amp; memory, Procedure&amp; procedure, WasmInternalFunction* compilation, Vector&lt;UnlinkedWasmToWasmCall&gt;&amp; unlinkedWasmToWasmCalls)
+    : m_proc(procedure)
</ins><span class="cx">     , m_unlinkedWasmToWasmCalls(unlinkedWasmToWasmCalls)
</span><span class="cx"> {
</span><span class="cx">     m_currentBlock = m_proc.addBlock();
</span><span class="lines">@@ -210,12 +208,12 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (m_memory) {
-        m_memoryBaseGPR = m_memory-&gt;pinnedRegisters().baseMemoryPointer;
</del><ins>+    if (!!memory) {
+        m_memoryBaseGPR = memory.pinnedRegisters().baseMemoryPointer;
</ins><span class="cx">         m_proc.pinRegister(m_memoryBaseGPR);
</span><del>-        ASSERT(!m_memory-&gt;pinnedRegisters().sizeRegisters[0].sizeOffset);
-        m_memorySizeGPR = m_memory-&gt;pinnedRegisters().sizeRegisters[0].sizeRegister;
-        for (const PinnedSizeRegisterInfo&amp; info : m_memory-&gt;pinnedRegisters().sizeRegisters)
</del><ins>+        ASSERT(!memory.pinnedRegisters().sizeRegisters[0].sizeOffset);
+        m_memorySizeGPR = memory.pinnedRegisters().sizeRegisters[0].sizeRegister;
+        for (const PinnedSizeRegisterInfo&amp; info : memory.pinnedRegisters().sizeRegisters)
</ins><span class="cx">             m_proc.pinRegister(info.sizeRegister);
</span><span class="cx"> 
</span><span class="cx">         m_proc.setWasmBoundsCheckGenerator([=] (CCallHelpers&amp; jit, GPRReg pinnedGPR, unsigned) {
</span><span class="lines">@@ -302,13 +300,13 @@
</span><span class="cx">     case LoadOpType::I32Load:
</span><span class="cx">     case LoadOpType::I64Load32S:
</span><span class="cx">     case LoadOpType::I64Load32U:
</span><ins>+    case LoadOpType::F32Load:
</ins><span class="cx">         return 4;
</span><span class="cx">     case LoadOpType::I64Load:
</span><ins>+    case LoadOpType::F64Load:
</ins><span class="cx">         return 8;
</span><span class="cx">     case LoadOpType::I32Load16U:
</span><span class="cx">     case LoadOpType::I64Load16U:
</span><del>-    case LoadOpType::F32Load:
-    case LoadOpType::F64Load:
</del><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx">     RELEASE_ASSERT_NOT_REACHED();
</span><span class="lines">@@ -659,7 +657,7 @@
</span><span class="cx">     dataLogLn(&quot;\n&quot;);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static std::unique_ptr&lt;Compilation&gt; createJSToWasmWrapper(VM&amp; vm, const Signature* signature, MacroAssemblerCodePtr mainFunction, Memory* memory)
</del><ins>+static std::unique_ptr&lt;Compilation&gt; createJSToWasmWrapper(VM&amp; vm, const Signature* signature, MacroAssemblerCodePtr mainFunction, MemoryInformation&amp; memory)
</ins><span class="cx"> {
</span><span class="cx">     Procedure proc;
</span><span class="cx">     BasicBlock* block = proc.addBlock();
</span><span class="lines">@@ -681,12 +679,13 @@
</span><span class="cx">     // Move memory values to the approriate places, if needed.
</span><span class="cx">     Value* baseMemory = nullptr;
</span><span class="cx">     Vector&lt;Value*&gt; sizes;
</span><del>-    if (memory) {
-        baseMemory = block-&gt;appendNew&lt;ConstPtrValue&gt;(proc, Origin(), memory-&gt;memory());
</del><ins>+    if (!!memory) {
+        baseMemory = block-&gt;appendNew&lt;MemoryValue&gt;(proc, Load, Int64, Origin(),
+            block-&gt;appendNew&lt;ConstPtrValue&gt;(proc, Origin(), &amp;vm.topWasmMemoryPointer));
</ins><span class="cx">         Value* size = block-&gt;appendNew&lt;MemoryValue&gt;(proc, Load, Int32, Origin(),
</span><del>-            block-&gt;appendNew&lt;ConstPtrValue&gt;(proc, Origin(), bitwise_cast&lt;char*&gt;(memory) + Memory::offsetOfSize()));
-        sizes.reserveCapacity(memory-&gt;pinnedRegisters().sizeRegisters.size());
-        for (auto info : memory-&gt;pinnedRegisters().sizeRegisters) {
</del><ins>+            block-&gt;appendNew&lt;ConstPtrValue&gt;(proc, Origin(), &amp;vm.topWasmMemorySize));
+        sizes.reserveCapacity(memory.pinnedRegisters().sizeRegisters.size());
+        for (auto info : memory.pinnedRegisters().sizeRegisters) {
</ins><span class="cx">             sizes.append(block-&gt;appendNew&lt;Value&gt;(proc, Sub, Origin(), size,
</span><span class="cx">                 block-&gt;appendNew&lt;Const32Value&gt;(proc, Origin(), info.sizeOffset)));
</span><span class="cx">         }
</span><span class="lines">@@ -700,11 +699,11 @@
</span><span class="cx"> 
</span><span class="cx">     // Move the arguments into place.
</span><span class="cx">     Value* result = wasmCallingConvention().setupCall(proc, block, Origin(), arguments, toB3Type(signature-&gt;returnType), [&amp;] (PatchpointValue* patchpoint) {
</span><del>-        if (memory) {
-            ASSERT(sizes.size() == memory-&gt;pinnedRegisters().sizeRegisters.size());
-            patchpoint-&gt;append(ConstrainedValue(baseMemory, ValueRep::reg(memory-&gt;pinnedRegisters().baseMemoryPointer)));
</del><ins>+        if (!!memory) {
+            ASSERT(sizes.size() == memory.pinnedRegisters().sizeRegisters.size());
+            patchpoint-&gt;append(ConstrainedValue(baseMemory, ValueRep::reg(memory.pinnedRegisters().baseMemoryPointer)));
</ins><span class="cx">             for (unsigned i = 0; i &lt; sizes.size(); ++i)
</span><del>-                patchpoint-&gt;append(ConstrainedValue(sizes[i], ValueRep::reg(memory-&gt;pinnedRegisters().sizeRegisters[i].sizeRegister)));
</del><ins>+                patchpoint-&gt;append(ConstrainedValue(sizes[i], ValueRep::reg(memory.pinnedRegisters().sizeRegisters[i].sizeRegister)));
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         patchpoint-&gt;setGenerator([=] (CCallHelpers&amp; jit, const B3::StackmapGenerationParams&amp;) {
</span><span class="lines">@@ -738,7 +737,7 @@
</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;WasmInternalFunction&gt; parseAndCompile(VM&amp; vm, const uint8_t* functionStart, size_t functionLength, Memory* memory, const Signature* signature, Vector&lt;UnlinkedWasmToWasmCall&gt;&amp; unlinkedWasmToWasmCalls, const FunctionIndexSpace&amp; functionIndexSpace, unsigned optLevel)
</del><ins>+std::unique_ptr&lt;WasmInternalFunction&gt; parseAndCompile(VM&amp; vm, const uint8_t* functionStart, size_t functionLength, MemoryInformation&amp; memory, const Signature* signature, Vector&lt;UnlinkedWasmToWasmCall&gt;&amp; unlinkedWasmToWasmCalls, const FunctionIndexSpace&amp; functionIndexSpace, unsigned optLevel)
</ins><span class="cx"> {
</span><span class="cx">     auto result = std::make_unique&lt;WasmInternalFunction&gt;();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWasmB3IRGeneratorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WasmB3IRGenerator.h (209629 => 209630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WasmB3IRGenerator.h        2016-12-09 22:12:08 UTC (rev 209629)
+++ trunk/Source/JavaScriptCore/wasm/WasmB3IRGenerator.h        2016-12-09 22:38:39 UTC (rev 209630)
</span><span class="lines">@@ -35,9 +35,9 @@
</span><span class="cx"> 
</span><span class="cx"> namespace JSC { namespace Wasm {
</span><span class="cx"> 
</span><del>-class Memory;
</del><ins>+class MemoryInformation;
</ins><span class="cx"> 
</span><del>-std::unique_ptr&lt;WasmInternalFunction&gt; parseAndCompile(VM&amp;, const uint8_t*, size_t, Memory*, const Signature*, Vector&lt;UnlinkedWasmToWasmCall&gt;&amp;, const FunctionIndexSpace&amp;, unsigned optLevel = 1);
</del><ins>+std::unique_ptr&lt;WasmInternalFunction&gt; parseAndCompile(VM&amp;, const uint8_t*, size_t, MemoryInformation&amp;, const Signature*, Vector&lt;UnlinkedWasmToWasmCall&gt;&amp;, const FunctionIndexSpace&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="trunkSourceJavaScriptCorewasmWasmFormatcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WasmFormat.cpp (209629 => 209630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WasmFormat.cpp        2016-12-09 22:12:08 UTC (rev 209629)
+++ trunk/Source/JavaScriptCore/wasm/WasmFormat.cpp        2016-12-09 22:38:39 UTC (rev 209630)
</span><span class="lines">@@ -33,8 +33,6 @@
</span><span class="cx"> 
</span><span class="cx"> namespace JSC { namespace Wasm {
</span><span class="cx"> 
</span><del>-ModuleInformation::~ModuleInformation() { }
-
</del><span class="cx"> } } // namespace JSC::Wasm
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(WEBASSEMBLY)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWasmFormath"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WasmFormat.h (209629 => 209630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WasmFormat.h        2016-12-09 22:12:08 UTC (rev 209629)
+++ trunk/Source/JavaScriptCore/wasm/WasmFormat.h        2016-12-09 22:38:39 UTC (rev 209630)
</span><span class="lines">@@ -32,7 +32,9 @@
</span><span class="cx"> #include &quot;CodeLocation.h&quot;
</span><span class="cx"> #include &quot;Identifier.h&quot;
</span><span class="cx"> #include &quot;MacroAssemblerCodeRef.h&quot;
</span><ins>+#include &quot;WasmMemoryInformation.h&quot;
</ins><span class="cx"> #include &quot;WasmOps.h&quot;
</span><ins>+#include &quot;WasmPageCount.h&quot;
</ins><span class="cx"> #include &lt;wtf/Vector.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace JSC {
</span><span class="lines">@@ -95,8 +97,6 @@
</span><span class="cx">     unsigned kindIndex; // Index in the vector of the corresponding kind.
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-class Memory;
-
</del><span class="cx"> struct Export {
</span><span class="cx">     Identifier field;
</span><span class="cx">     External::Kind kind;
</span><span class="lines">@@ -103,7 +103,7 @@
</span><span class="cx">     union {
</span><span class="cx">         uint32_t functionIndex;
</span><span class="cx">         // FIXME implement Table https://bugs.webkit.org/show_bug.cgi?id=164135
</span><del>-        // FIXME implement Memory https://bugs.webkit.org/show_bug.cgi?id=164134
</del><ins>+        // FIXME implement Memory https://bugs.webkit.org/show_bug.cgi?id=165671
</ins><span class="cx">         // FIXME implement Global https://bugs.webkit.org/show_bug.cgi?id=164133
</span><span class="cx">     };
</span><span class="cx"> };
</span><span class="lines">@@ -119,13 +119,10 @@
</span><span class="cx">     Vector&lt;Import&gt; imports;
</span><span class="cx">     Vector&lt;Signature*&gt; importFunctions;
</span><span class="cx">     // FIXME implement import Table https://bugs.webkit.org/show_bug.cgi?id=164135
</span><del>-    // FIXME implement import Memory https://bugs.webkit.org/show_bug.cgi?id=164134
</del><span class="cx">     // FIXME implement import Global https://bugs.webkit.org/show_bug.cgi?id=164133
</span><span class="cx">     Vector&lt;Signature*&gt; internalFunctionSignatures;
</span><del>-    std::unique_ptr&lt;Memory&gt; memory;
</del><ins>+    MemoryInformation memory;
</ins><span class="cx">     Vector&lt;Export&gt; exports;
</span><del>-
-    ~ModuleInformation();
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> struct UnlinkedWasmToWasmCall {
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWasmMemorycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WasmMemory.cpp (209629 => 209630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WasmMemory.cpp        2016-12-09 22:12:08 UTC (rev 209629)
+++ trunk/Source/JavaScriptCore/wasm/WasmMemory.cpp        2016-12-09 22:38:39 UTC (rev 209630)
</span><span class="lines">@@ -30,15 +30,17 @@
</span><span class="cx"> 
</span><span class="cx"> namespace JSC { namespace Wasm {
</span><span class="cx"> 
</span><del>-Memory::Memory(uint32_t startingSize, uint32_t capacity, const Vector&lt;unsigned&gt;&amp; pinnedSizeRegisters)
</del><ins>+Memory::Memory(PageCount initial, PageCount maximum)
</ins><span class="cx">     : m_mode(Mode::BoundsChecking)
</span><del>-    , m_size(startingSize)
-    , m_capacity(capacity)
</del><ins>+    , m_size(initial.bytes())
+    , m_capacity(maximum ? maximum.bytes() : PageCount::max().bytes())
+    , m_initial(initial)
+    , m_maximum(maximum)
</ins><span class="cx">     // FIXME: If we add signal based bounds checking then we need extra space for overflow on load.
</span><span class="cx">     // see: https://bugs.webkit.org/show_bug.cgi?id=162693
</span><del>-    , m_mappedCapacity(static_cast&lt;uint64_t&gt;(maxPageCount) * static_cast&lt;uint64_t&gt;(pageSize))
</del><ins>+    , m_mappedCapacity(PageCount::max().bytes())
</ins><span class="cx"> {
</span><del>-    ASSERT(pinnedSizeRegisters.size() &gt; 0);
</del><ins>+    RELEASE_ASSERT(!maximum || maximum &gt;= initial); // This should be guaranteed by our caller.
</ins><span class="cx"> 
</span><span class="cx">     // FIXME: It would be nice if we had a VM tag for wasm memory. https://bugs.webkit.org/show_bug.cgi?id=163600
</span><span class="cx">     void* result = mmap(nullptr, m_mappedCapacity, PROT_NONE, MAP_PRIVATE | MAP_ANON, -1, 0);
</span><span class="lines">@@ -50,25 +52,12 @@
</span><span class="cx">             return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    ASSERT(startingSize &lt;= m_mappedCapacity);
-    if (mprotect(result, startingSize, PROT_READ | PROT_WRITE)) {
</del><ins>+    ASSERT(m_size &lt;= m_mappedCapacity);
+    if (mprotect(result, m_size, PROT_READ | PROT_WRITE)) {
</ins><span class="cx">         munmap(result, m_mappedCapacity);
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    unsigned remainingPinnedRegisters = pinnedSizeRegisters.size() + 1;
-    jscCallingConvention().m_calleeSaveRegisters.forEach([&amp;] (Reg reg) {
-        GPRReg gpr = reg.gpr();
-        if (!remainingPinnedRegisters || RegisterSet::stackRegisters().get(reg))
-            return;
-        if (remainingPinnedRegisters == 1) {
-            m_pinnedRegisters.baseMemoryPointer = gpr;
-            remainingPinnedRegisters--;
-        } else
-            m_pinnedRegisters.sizeRegisters.append({ gpr, pinnedSizeRegisters[--remainingPinnedRegisters - 1] });
-    });
-
-    ASSERT(!remainingPinnedRegisters);
</del><span class="cx">     m_memory = result;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWasmMemoryh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WasmMemory.h (209629 => 209630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WasmMemory.h        2016-12-09 22:12:08 UTC (rev 209629)
+++ trunk/Source/JavaScriptCore/wasm/WasmMemory.h        2016-12-09 22:38:39 UTC (rev 209630)
</span><span class="lines">@@ -28,27 +28,12 @@
</span><span class="cx"> #if ENABLE(WEBASSEMBLY)
</span><span class="cx"> 
</span><span class="cx"> #include &quot;WasmCallingConvention.h&quot;
</span><ins>+#include &quot;WasmPageCount.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> #include &lt;wtf/Vector.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace JSC { namespace Wasm {
</span><span class="cx"> 
</span><del>-struct PinnedSizeRegisterInfo {
-    GPRReg sizeRegister;
-    unsigned sizeOffset;
-};
-
-// FIXME: We should support more than one memory size register. Right now we take a vector with only one
-// entry. Specifically an entry where the sizeOffset == 0. If we have more than one size register,
-// we can have one for each load size class. see: https://bugs.webkit.org/show_bug.cgi?id=162952
-struct PinnedRegisterInfo {
-    Vector&lt;PinnedSizeRegisterInfo&gt; sizeRegisters;
-    GPRReg baseMemoryPointer;
-};
-
-constexpr uint32_t pageSize = 64 * KB;
-constexpr uint32_t maxPageCount = static_cast&lt;uint32_t&gt;((1ull &lt;&lt; 32) / pageSize);
-
</del><span class="cx"> class Memory {
</span><span class="cx">     WTF_MAKE_NONCOPYABLE(Memory);
</span><span class="cx">     WTF_MAKE_FAST_ALLOCATED;
</span><span class="lines">@@ -59,8 +44,7 @@
</span><span class="cx">         BoundsChecking
</span><span class="cx">     };
</span><span class="cx"> 
</span><del>-    Memory() = default;
-    Memory(uint32_t startingSize, uint32_t capacity, const Vector&lt;unsigned&gt;&amp; pinnedSizeRegisters);
</del><ins>+    JS_EXPORT_PRIVATE Memory(PageCount initial, PageCount maximum);
</ins><span class="cx"> 
</span><span class="cx">     ~Memory()
</span><span class="cx">     {
</span><span class="lines">@@ -70,10 +54,12 @@
</span><span class="cx"> 
</span><span class="cx">     void* memory() const { return m_memory; }
</span><span class="cx">     uint32_t size() const { return m_size; }
</span><del>-    const PinnedRegisterInfo&amp; pinnedRegisters() const { return m_pinnedRegisters; }
</del><span class="cx"> 
</span><span class="cx">     Mode mode() const { return m_mode; }
</span><span class="cx"> 
</span><ins>+    PageCount initial() const { return m_initial; }
+    PageCount maximum() const { return m_maximum; }
+
</ins><span class="cx">     bool grow(uint32_t newSize)
</span><span class="cx">     {
</span><span class="cx">         ASSERT(m_memory);
</span><span class="lines">@@ -84,13 +70,15 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     static ptrdiff_t offsetOfSize() { return OBJECT_OFFSETOF(Memory, m_size); }
</span><ins>+
</ins><span class="cx">     
</span><span class="cx"> private:
</span><span class="cx">     void* m_memory { nullptr };
</span><del>-    PinnedRegisterInfo m_pinnedRegisters;
</del><span class="cx">     Mode m_mode;
</span><span class="cx">     uint32_t m_size { 0 };
</span><span class="cx">     uint32_t m_capacity { 0 };
</span><ins>+    PageCount m_initial;
+    PageCount m_maximum;
</ins><span class="cx">     uint64_t m_mappedCapacity { 0 };
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWasmMemoryInformationcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/wasm/WasmMemoryInformation.cpp (0 => 209630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WasmMemoryInformation.cpp                                (rev 0)
+++ trunk/Source/JavaScriptCore/wasm/WasmMemoryInformation.cpp        2016-12-09 22:38:39 UTC (rev 209630)
</span><span class="lines">@@ -0,0 +1,61 @@
</span><ins>+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;WasmMemoryInformation.h&quot;
+
+#include &quot;WasmCallingConvention.h&quot;
+
+#if ENABLE(WEBASSEMBLY)
+
+namespace JSC { namespace Wasm {
+
+MemoryInformation::MemoryInformation(PageCount initial, PageCount maximum,  const Vector&lt;unsigned&gt;&amp; pinnedSizeRegisters, bool isImport)
+    : m_initial(initial)
+    , m_maximum(maximum)
+    , m_isImport(isImport)
+{
+    RELEASE_ASSERT(!!m_initial);
+    RELEASE_ASSERT(!m_maximum || m_maximum &gt;= m_initial);
+    ASSERT(!!*this);
+
+    unsigned remainingPinnedRegisters = pinnedSizeRegisters.size() + 1;
+    jscCallingConvention().m_calleeSaveRegisters.forEach([&amp;] (Reg reg) {
+        GPRReg gpr = reg.gpr();
+        if (!remainingPinnedRegisters || RegisterSet::stackRegisters().get(reg))
+            return;
+        if (remainingPinnedRegisters == 1) {
+            m_pinnedRegisters.baseMemoryPointer = gpr;
+            remainingPinnedRegisters--;
+        } else
+            m_pinnedRegisters.sizeRegisters.append({ gpr, pinnedSizeRegisters[--remainingPinnedRegisters - 1] });
+    });
+
+    ASSERT(!remainingPinnedRegisters);
+}
+
+} } // namespace JSC::Wasm
+
+#endif // ENABLE(WEBASSEMBLY)
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWasmMemoryInformationh"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/wasm/WasmMemoryInformation.h (0 => 209630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WasmMemoryInformation.h                                (rev 0)
+++ trunk/Source/JavaScriptCore/wasm/WasmMemoryInformation.h        2016-12-09 22:38:39 UTC (rev 209630)
</span><span class="lines">@@ -0,0 +1,74 @@
</span><ins>+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(WEBASSEMBLY)
+
+#include &quot;GPRInfo.h&quot;
+#include &quot;WasmPageCount.h&quot;
+#include &lt;wtf/Vector.h&gt;
+
+namespace JSC { namespace Wasm {
+
+struct PinnedSizeRegisterInfo {
+    GPRReg sizeRegister;
+    unsigned sizeOffset;
+};
+
+// FIXME: We should support more than one memory size register. Right now we take a vector with only one
+// entry. Specifically an entry where the sizeOffset == 0. If we have more than one size register,
+// we can have one for each load size class. see: https://bugs.webkit.org/show_bug.cgi?id=162952
+struct PinnedRegisterInfo {
+    Vector&lt;PinnedSizeRegisterInfo&gt; sizeRegisters;
+    GPRReg baseMemoryPointer;
+};
+
+class MemoryInformation {
+public:
+    MemoryInformation()
+    {
+        ASSERT(!*this);
+    }
+
+    MemoryInformation(PageCount initial, PageCount maximum, const Vector&lt;unsigned&gt;&amp; pinnedSizeRegisters, bool isImport);
+
+    const PinnedRegisterInfo&amp; pinnedRegisters() const { return m_pinnedRegisters; }
+    PageCount initial() const { return m_initial; }
+    PageCount maximum() const { return m_maximum; }
+    bool isImport() const { return m_isImport; }
+
+    explicit operator bool() const { return !!m_initial; }
+
+private:
+    PageCount m_initial { };
+    PageCount m_maximum { };
+    PinnedRegisterInfo m_pinnedRegisters { };
+    bool m_isImport { false };
+};
+
+} } // namespace JSC::Wasm
+
+#endif // ENABLE(WASM)
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWasmModuleParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WasmModuleParser.cpp (209629 => 209630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WasmModuleParser.cpp        2016-12-09 22:12:08 UTC (rev 209629)
+++ trunk/Source/JavaScriptCore/wasm/WasmModuleParser.cpp        2016-12-09 22:38:39 UTC (rev 209630)
</span><span class="lines">@@ -30,7 +30,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;IdentifierInlines.h&quot;
</span><span class="cx"> #include &quot;WasmFormat.h&quot;
</span><del>-#include &quot;WasmMemory.h&quot;
</del><ins>+#include &quot;WasmMemoryInformation.h&quot;
</ins><span class="cx"> #include &quot;WasmOps.h&quot;
</span><span class="cx"> #include &quot;WasmSections.h&quot;
</span><span class="cx"> 
</span><span class="lines">@@ -256,7 +256,9 @@
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         case External::Memory: {
</span><del>-            // FIXME https://bugs.webkit.org/show_bug.cgi?id=164134
</del><ins>+            bool isImport = true;
+            if (!parseMemoryHelper(isImport))
+                return false;
</ins><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         case External::Global: {
</span><span class="lines">@@ -305,38 +307,61 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ModuleParser::parseMemory()
</del><ins>+bool ModuleParser::parseMemoryHelper(bool isImport)
</ins><span class="cx"> {
</span><del>-    uint8_t count;
-    if (!parseVarUInt1(count))
</del><ins>+    // We don't allow redeclaring memory. Either via import or definition.
+    if (m_module-&gt;memory)
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    if (!count)
-        return true;
-
</del><span class="cx">     uint8_t flags;
</span><del>-    uint32_t size;
-    if (!parseVarUInt1(flags)
-        || !parseVarUInt32(size)
-        || size &gt; maxPageCount)
</del><ins>+    if (!parseVarUInt1(flags))
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    uint32_t capacity = maxPageCount;
</del><ins>+    uint32_t initial;
+    if (!parseVarUInt32(initial))
+        return false;
+
+    if (!PageCount::isValid(initial))
+        return false;
+
+    PageCount initialPageCount(initial);
+
+    PageCount maximumPageCount;
</ins><span class="cx">     if (flags) {
</span><del>-        if (!parseVarUInt32(capacity)
-            || size &gt; capacity
-            || capacity &gt; maxPageCount)
</del><ins>+        uint32_t maximum;
+        if (!parseVarUInt32(maximum))
</ins><span class="cx">             return false;
</span><ins>+
+        if (!PageCount::isValid(maximum))
+            return false;
+
+        maximumPageCount = PageCount(maximum);
+        if (initialPageCount &gt; maximumPageCount)
+            return false;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    capacity *= pageSize;
-    size *= pageSize;
-
</del><span class="cx">     Vector&lt;unsigned&gt; pinnedSizes = { 0 };
</span><del>-    m_module-&gt;memory = std::make_unique&lt;Memory&gt;(size, capacity, pinnedSizes);
-    return m_module-&gt;memory-&gt;memory();
</del><ins>+    m_module-&gt;memory = MemoryInformation(initialPageCount, maximumPageCount, pinnedSizes, isImport);
+    return true;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool ModuleParser::parseMemory()
+{
+    uint8_t count;
+    if (!parseVarUInt1(count))
+        return false;
+
+    if (!count)
+        return true;
+
+    // We only allow one memory for now.
+    if (count != 1)
+        return false;
+
+    bool isImport = false;
+    return parseMemoryHelper(isImport);
+}
+
</ins><span class="cx"> bool ModuleParser::parseGlobal()
</span><span class="cx"> {
</span><span class="cx">     // FIXME https://bugs.webkit.org/show_bug.cgi?id=164133
</span><span class="lines">@@ -372,7 +397,7 @@
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         case External::Memory: {
</span><del>-            // FIXME https://bugs.webkit.org/show_bug.cgi?id=164134
</del><ins>+            // FIXME: https://bugs.webkit.org/show_bug.cgi?id=165671
</ins><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         case External::Global: {
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWasmModuleParserh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WasmModuleParser.h (209629 => 209630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WasmModuleParser.h        2016-12-09 22:12:08 UTC (rev 209629)
+++ trunk/Source/JavaScriptCore/wasm/WasmModuleParser.h        2016-12-09 22:38:39 UTC (rev 209630)
</span><span class="lines">@@ -78,6 +78,8 @@
</span><span class="cx">     FOR_EACH_WASM_SECTION(WASM_SECTION_DECLARE_PARSER)
</span><span class="cx"> #undef WASM_SECTION_DECLARE_PARSER
</span><span class="cx"> 
</span><ins>+    bool WARN_UNUSED_RETURN parseMemoryHelper(bool isImport);
+
</ins><span class="cx">     VM* m_vm;
</span><span class="cx">     std::unique_ptr&lt;ModuleInformation&gt; m_module;
</span><span class="cx">     FunctionIndexSpace m_functionIndexSpace;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWasmPageCounth"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/wasm/WasmPageCount.h (0 => 209630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WasmPageCount.h                                (rev 0)
+++ trunk/Source/JavaScriptCore/wasm/WasmPageCount.h        2016-12-09 22:38:39 UTC (rev 209630)
</span><span class="lines">@@ -0,0 +1,75 @@
</span><ins>+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(WEBASSEMBLY)
+
+namespace JSC { namespace Wasm {
+
+class PageCount {
+
+public:
+    PageCount()
+        : m_pageCount(UINT_MAX)
+    {
+        static_assert(maxPageCount &lt; UINT_MAX, &quot;We rely on this here.&quot;);
+    }
+
+    PageCount(uint32_t pageCount)
+        : m_pageCount(pageCount)
+    { }
+
+    size_t bytes() { return m_pageCount * pageSize; }
+
+    static bool isValid(uint32_t pageCount)
+    {
+        return pageCount &lt;= maxPageCount;
+    }
+
+    static PageCount max()
+    {
+        return PageCount(maxPageCount);
+    }
+
+    explicit operator bool() const
+    {
+        return m_pageCount != UINT_MAX;
+    }
+
+    bool operator&lt;(const PageCount&amp; other) const { return m_pageCount &lt; other.m_pageCount; }
+    bool operator&gt;(const PageCount&amp; other) const { return m_pageCount &gt; other.m_pageCount; }
+    bool operator&gt;=(const PageCount&amp; other) const { return m_pageCount &gt;= other.m_pageCount; }
+
+private:
+    static constexpr uint32_t pageSize = 64 * KB;
+    static constexpr uint32_t maxPageCount = static_cast&lt;uint32_t&gt;((1ull &lt;&lt; 32) / pageSize);
+
+    uint32_t m_pageCount;
+};
+
+} } // namespace JSC::Wasm
+
+#endif // ENABLE(WASM)
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWasmPlancpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WasmPlan.cpp (209629 => 209630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WasmPlan.cpp        2016-12-09 22:12:08 UTC (rev 209629)
+++ trunk/Source/JavaScriptCore/wasm/WasmPlan.cpp        2016-12-09 22:38:39 UTC (rev 209630)
</span><span class="lines">@@ -116,7 +116,7 @@
</span><span class="cx">         unsigned functionIndexSpace = m_wasmToJSStubs.size() + functionIndex;
</span><span class="cx">         ASSERT(m_functionIndexSpace[functionIndexSpace].signature == signature);
</span><span class="cx"> 
</span><del>-        String error = validateFunction(functionStart, functionLength, signature, m_functionIndexSpace);
</del><ins>+        String error = validateFunction(functionStart, functionLength, signature, m_functionIndexSpace, m_moduleInformation-&gt;memory);
</ins><span class="cx">         if (!error.isNull()) {
</span><span class="cx">             if (verbose) {
</span><span class="cx">                 for (unsigned i = 0; i &lt; functionLength; ++i)
</span><span class="lines">@@ -128,7 +128,7 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         unlinkedWasmToWasmCalls.uncheckedAppend(Vector&lt;UnlinkedWasmToWasmCall&gt;());
</span><del>-        m_wasmInternalFunctions.uncheckedAppend(parseAndCompile(*m_vm, functionStart, functionLength, m_moduleInformation-&gt;memory.get(), signature, unlinkedWasmToWasmCalls.at(functionIndex), m_functionIndexSpace));
</del><ins>+        m_wasmInternalFunctions.uncheckedAppend(parseAndCompile(*m_vm, functionStart, functionLength, m_moduleInformation-&gt;memory, signature, unlinkedWasmToWasmCalls.at(functionIndex), m_functionIndexSpace));
</ins><span class="cx">         m_functionIndexSpace[functionIndexSpace].code = m_wasmInternalFunctions[functionIndex]-&gt;code-&gt;code().executableAddress();
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWasmPlanh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WasmPlan.h (209629 => 209630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WasmPlan.h        2016-12-09 22:12:08 UTC (rev 209629)
+++ trunk/Source/JavaScriptCore/wasm/WasmPlan.h        2016-12-09 22:38:39 UTC (rev 209630)
</span><span class="lines">@@ -42,8 +42,6 @@
</span><span class="cx"> 
</span><span class="cx"> namespace Wasm {
</span><span class="cx"> 
</span><del>-class Memory;
-
</del><span class="cx"> class Plan {
</span><span class="cx"> public:
</span><span class="cx">     JS_EXPORT_PRIVATE Plan(VM*, Vector&lt;uint8_t&gt;);
</span><span class="lines">@@ -67,17 +65,12 @@
</span><span class="cx">         return m_moduleInformation-&gt;exports;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    const Memory* memory() const
-    {
-        RELEASE_ASSERT(!failed());
-        return m_moduleInformation-&gt;memory.get();
-    }
-
</del><span class="cx">     size_t internalFunctionCount() const
</span><span class="cx">     {
</span><span class="cx">         RELEASE_ASSERT(!failed());
</span><span class="cx">         return m_wasmInternalFunctions.size();
</span><span class="cx">     }
</span><ins>+
</ins><span class="cx">     B3::Compilation* jsToWasmEntryPointForFunction(size_t i) const
</span><span class="cx">     {
</span><span class="cx">         ASSERT(i &gt; m_wasmToJSStubs.size());
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWasmValidatecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WasmValidate.cpp (209629 => 209630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WasmValidate.cpp        2016-12-09 22:12:08 UTC (rev 209629)
+++ trunk/Source/JavaScriptCore/wasm/WasmValidate.cpp        2016-12-09 22:38:39 UTC (rev 209630)
</span><span class="lines">@@ -115,10 +115,13 @@
</span><span class="cx"> 
</span><span class="cx">     void dump(const Vector&lt;ControlEntry&gt;&amp; controlStack, const ExpressionList&amp; expressionStack);
</span><span class="cx"> 
</span><ins>+    bool hasMemory() const { return !!m_memory; }
+
</ins><span class="cx">     void setErrorMessage(String&amp;&amp; message) { ASSERT(m_errorMessage.isNull()); m_errorMessage = WTFMove(message); }
</span><span class="cx">     String errorMessage() const { return m_errorMessage; }
</span><del>-    Validate(ExpressionType returnType)
</del><ins>+    Validate(ExpressionType returnType, const MemoryInformation&amp; memory)
</ins><span class="cx">         : m_returnType(returnType)
</span><ins>+        , m_memory(memory)
</ins><span class="cx">     {
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -131,6 +134,7 @@
</span><span class="cx">     ExpressionType m_returnType;
</span><span class="cx">     Vector&lt;Type&gt; m_locals;
</span><span class="cx">     String m_errorMessage;
</span><ins>+    const MemoryInformation&amp; m_memory;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> bool Validate::addArguments(const Vector&lt;Type&gt;&amp; args)
</span><span class="lines">@@ -367,9 +371,9 @@
</span><span class="cx">     // Think of this as penance for the sin of bad error messages.
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-String validateFunction(const uint8_t* source, size_t length, const Signature* signature, const FunctionIndexSpace&amp; functionIndexSpace)
</del><ins>+String validateFunction(const uint8_t* source, size_t length, const Signature* signature, const FunctionIndexSpace&amp; functionIndexSpace, const MemoryInformation&amp; memory)
</ins><span class="cx"> {
</span><del>-    Validate context(signature-&gt;returnType);
</del><ins>+    Validate context(signature-&gt;returnType, memory);
</ins><span class="cx">     FunctionParser&lt;Validate&gt; validator(context, source, length, signature, functionIndexSpace);
</span><span class="cx">     if (!validator.parse()) {
</span><span class="cx">         // FIXME: add better location information here. see: https://bugs.webkit.org/show_bug.cgi?id=164288
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWasmValidateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WasmValidate.h (209629 => 209630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WasmValidate.h        2016-12-09 22:12:08 UTC (rev 209629)
+++ trunk/Source/JavaScriptCore/wasm/WasmValidate.h        2016-12-09 22:38:39 UTC (rev 209630)
</span><span class="lines">@@ -31,7 +31,7 @@
</span><span class="cx"> 
</span><span class="cx"> namespace JSC { namespace Wasm {
</span><span class="cx"> 
</span><del>-String validateFunction(const uint8_t*, size_t, const Signature*, const FunctionIndexSpace&amp;);
</del><ins>+String validateFunction(const uint8_t*, size_t, const Signature*, const FunctionIndexSpace&amp;, const MemoryInformation&amp;);
</ins><span class="cx"> 
</span><span class="cx"> } } // namespace JSC::Wasm
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmgenerateWasmValidateInlinesHeaderpy"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/generateWasmValidateInlinesHeader.py (209629 => 209630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/generateWasmValidateInlinesHeader.py        2016-12-09 22:12:08 UTC (rev 209629)
+++ trunk/Source/JavaScriptCore/wasm/generateWasmValidateInlinesHeader.py        2016-12-09 22:38:39 UTC (rev 209630)
</span><span class="lines">@@ -143,6 +143,9 @@
</span><span class="cx"> 
</span><span class="cx"> bool Validate::load(LoadOpType op, ExpressionType pointer, ExpressionType&amp; result, uint32_t)
</span><span class="cx"> {
</span><ins>+    if (!hasMemory())
+        return false;
+
</ins><span class="cx">     switch (op) {
</span><span class="cx"> &quot;&quot;&quot; + loadCases + &quot;&quot;&quot;
</span><span class="cx">     }
</span><span class="lines">@@ -150,6 +153,9 @@
</span><span class="cx"> 
</span><span class="cx"> bool Validate::store(StoreOpType op, ExpressionType pointer, ExpressionType value, uint32_t)
</span><span class="cx"> {
</span><ins>+    if (!hasMemory())
+        return false;
+
</ins><span class="cx">     switch (op) {
</span><span class="cx"> &quot;&quot;&quot; + storeCases + &quot;&quot;&quot;
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsJSWebAssemblyInstancecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.cpp (209629 => 209630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.cpp        2016-12-09 22:12:08 UTC (rev 209629)
+++ trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.cpp        2016-12-09 22:38:39 UTC (rev 209630)
</span><span class="lines">@@ -32,6 +32,7 @@
</span><span class="cx"> #include &quot;JSCInlines.h&quot;
</span><span class="cx"> #include &quot;JSModuleEnvironment.h&quot;
</span><span class="cx"> #include &quot;JSModuleNamespaceObject.h&quot;
</span><ins>+#include &quot;JSWebAssemblyMemory.h&quot;
</ins><span class="cx"> #include &quot;JSWebAssemblyModule.h&quot;
</span><span class="cx"> #include &lt;wtf/StdLibExtras.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -78,6 +79,7 @@
</span><span class="cx">     Base::visitChildren(thisObject, visitor);
</span><span class="cx">     visitor.append(&amp;thisObject-&gt;m_module);
</span><span class="cx">     visitor.append(&amp;thisObject-&gt;m_moduleNamespaceObject);
</span><ins>+    visitor.append(&amp;thisObject-&gt;m_memory);
</ins><span class="cx">     for (unsigned i = 0; i &lt; thisObject-&gt;m_numImportFunctions; ++i)
</span><span class="cx">         visitor.append(thisObject-&gt;importFunction(i));
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsJSWebAssemblyInstanceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.h (209629 => 209630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.h        2016-12-09 22:12:08 UTC (rev 209629)
+++ trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.h        2016-12-09 22:38:39 UTC (rev 209630)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;JSDestructibleObject.h&quot;
</span><span class="cx"> #include &quot;JSObject.h&quot;
</span><ins>+#include &quot;JSWebAssemblyMemory.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace JSC {
</span><span class="cx"> 
</span><span class="lines">@@ -67,10 +68,8 @@
</span><span class="cx">         importFunction(idx)-&gt;set(vm, this, value);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    static size_t offsetOfImportFunctions()
-    {
-        return WTF::roundUpToMultipleOf&lt;sizeof(WriteBarrier&lt;JSCell&gt;)&gt;(sizeof(JSWebAssemblyInstance));
-    }
</del><ins>+    JSWebAssemblyMemory* memory() { return m_memory.get(); }
+    void setMemory(VM&amp; vm, JSWebAssemblyMemory* memory) { m_memory.set(vm, this, memory); }
</ins><span class="cx"> 
</span><span class="cx">     static size_t offsetOfImportFunction(unsigned idx)
</span><span class="cx">     {
</span><span class="lines">@@ -77,11 +76,6 @@
</span><span class="cx">         return offsetOfImportFunctions() + sizeof(WriteBarrier&lt;JSCell&gt;) * idx;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    static size_t allocationSize(unsigned numImportFunctions)
-    {
-        return offsetOfImportFunctions() + sizeof(WriteBarrier&lt;JSCell&gt;) * numImportFunctions;
-    }
-
</del><span class="cx"> protected:
</span><span class="cx">     JSWebAssemblyInstance(VM&amp;, Structure*, unsigned);
</span><span class="cx">     void finishCreation(VM&amp;, JSWebAssemblyModule*, JSModuleNamespaceObject*);
</span><span class="lines">@@ -88,9 +82,20 @@
</span><span class="cx">     static void destroy(JSCell*);
</span><span class="cx">     static void visitChildren(JSCell*, SlotVisitor&amp;);
</span><span class="cx"> 
</span><ins>+    static size_t offsetOfImportFunctions()
+    {
+        return WTF::roundUpToMultipleOf&lt;sizeof(WriteBarrier&lt;JSCell&gt;)&gt;(sizeof(JSWebAssemblyInstance));
+    }
+
+    static size_t allocationSize(unsigned numImportFunctions)
+    {
+        return offsetOfImportFunctions() + sizeof(WriteBarrier&lt;JSCell&gt;) * numImportFunctions;
+    }
+
</ins><span class="cx"> private:
</span><span class="cx">     WriteBarrier&lt;JSWebAssemblyModule&gt; m_module;
</span><span class="cx">     WriteBarrier&lt;JSModuleNamespaceObject&gt; m_moduleNamespaceObject;
</span><ins>+    WriteBarrier&lt;JSWebAssemblyMemory&gt; m_memory;
</ins><span class="cx">     unsigned m_numImportFunctions;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsJSWebAssemblyMemorycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyMemory.cpp (209629 => 209630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyMemory.cpp        2016-12-09 22:12:08 UTC (rev 209629)
+++ trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyMemory.cpp        2016-12-09 22:38:39 UTC (rev 209630)
</span><span class="lines">@@ -30,11 +30,16 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;JSCInlines.h&quot;
</span><span class="cx"> 
</span><ins>+#include &quot;JSArrayBuffer.h&quot;
+#include &quot;ArrayBuffer.h&quot;
+
</ins><span class="cx"> namespace JSC {
</span><span class="cx"> 
</span><del>-JSWebAssemblyMemory* JSWebAssemblyMemory::create(VM&amp; vm, Structure* structure)
</del><ins>+const ClassInfo JSWebAssemblyMemory::s_info = { &quot;WebAssembly.Memory&quot;, &amp;Base::s_info, 0, CREATE_METHOD_TABLE(JSWebAssemblyMemory) };
+
+JSWebAssemblyMemory* JSWebAssemblyMemory::create(VM&amp; vm, Structure* structure, std::unique_ptr&lt;Wasm::Memory&gt;&amp;&amp; memory)
</ins><span class="cx"> {
</span><del>-    auto* instance = new (NotNull, allocateCell&lt;JSWebAssemblyMemory&gt;(vm.heap)) JSWebAssemblyMemory(vm, structure);
</del><ins>+    auto* instance = new (NotNull, allocateCell&lt;JSWebAssemblyMemory&gt;(vm.heap)) JSWebAssemblyMemory(vm, structure, WTFMove(memory));
</ins><span class="cx">     instance-&gt;finishCreation(vm);
</span><span class="cx">     return instance;
</span><span class="cx"> }
</span><span class="lines">@@ -44,11 +49,28 @@
</span><span class="cx">     return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-JSWebAssemblyMemory::JSWebAssemblyMemory(VM&amp; vm, Structure* structure)
</del><ins>+JSWebAssemblyMemory::JSWebAssemblyMemory(VM&amp; vm, Structure* structure, std::unique_ptr&lt;Wasm::Memory&gt;&amp;&amp; memory)
</ins><span class="cx">     : Base(vm, structure)
</span><ins>+    , m_memory(WTFMove(memory))
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+JSArrayBuffer* JSWebAssemblyMemory::buffer(VM&amp; vm, JSGlobalObject* globalObject)
+{
+    if (m_bufferWrapper)
+        return m_bufferWrapper.get();
+
+    auto destructor = [] (void*) {
+        // We don't need to do anything here to destroy the memory.
+        // The ArrayBuffer backing the JSArrayBuffer is only owned by us,
+        // so we guarantee its lifecylce.
+    };
+    m_buffer = ArrayBuffer::createFromBytes(memory()-&gt;memory(), memory()-&gt;size(), WTFMove(destructor));
+    m_bufferWrapper.set(vm, this, JSArrayBuffer::create(vm, globalObject-&gt;m_arrayBufferStructure.get(), m_buffer.get()));
+    RELEASE_ASSERT(m_bufferWrapper);
+    return m_bufferWrapper.get();
+}
+
</ins><span class="cx"> void JSWebAssemblyMemory::finishCreation(VM&amp; vm)
</span><span class="cx"> {
</span><span class="cx">     Base::finishCreation(vm);
</span><span class="lines">@@ -66,10 +88,9 @@
</span><span class="cx">     ASSERT_GC_OBJECT_INHERITS(thisObject, info());
</span><span class="cx"> 
</span><span class="cx">     Base::visitChildren(thisObject, visitor);
</span><ins>+    visitor.append(&amp;thisObject-&gt;m_bufferWrapper);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-const ClassInfo JSWebAssemblyMemory::s_info = { &quot;WebAssembly.Memory&quot;, &amp;Base::s_info, 0, CREATE_METHOD_TABLE(JSWebAssemblyMemory) };
-
</del><span class="cx"> } // namespace JSC
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(WEBASSEMBLY)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsJSWebAssemblyMemoryh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyMemory.h (209629 => 209630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyMemory.h        2016-12-09 22:12:08 UTC (rev 209629)
+++ trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyMemory.h        2016-12-09 22:38:39 UTC (rev 209630)
</span><span class="lines">@@ -29,23 +29,35 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;JSDestructibleObject.h&quot;
</span><span class="cx"> #include &quot;JSObject.h&quot;
</span><ins>+#include &quot;WasmMemory.h&quot;
+#include &lt;wtf/RefPtr.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> namespace JSC {
</span><span class="cx"> 
</span><ins>+class ArrayBuffer;
+class JSArrayBuffer;
+
</ins><span class="cx"> class JSWebAssemblyMemory : public JSDestructibleObject {
</span><span class="cx"> public:
</span><span class="cx">     typedef JSDestructibleObject Base;
</span><span class="cx"> 
</span><del>-    static JSWebAssemblyMemory* create(VM&amp;, Structure*);
</del><ins>+    static JSWebAssemblyMemory* create(VM&amp;, Structure*, std::unique_ptr&lt;Wasm::Memory&gt;&amp;&amp;);
</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><ins>+    Wasm::Memory* memory() { return m_memory.get(); }
+    JSArrayBuffer* buffer(VM&amp; vm, JSGlobalObject*);
+
</ins><span class="cx"> protected:
</span><del>-    JSWebAssemblyMemory(VM&amp;, Structure*);
</del><ins>+    JSWebAssemblyMemory(VM&amp;, Structure*, std::unique_ptr&lt;Wasm::Memory&gt;&amp;&amp;);
</ins><span class="cx">     void finishCreation(VM&amp;);
</span><span class="cx">     static void destroy(JSCell*);
</span><span class="cx">     static void visitChildren(JSCell*, SlotVisitor&amp;);
</span><ins>+
+    std::unique_ptr&lt;Wasm::Memory&gt; m_memory;
+    WriteBarrier&lt;JSArrayBuffer&gt; m_bufferWrapper;
+    RefPtr&lt;ArrayBuffer&gt; m_buffer;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace JSC
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsWebAssemblyFunctioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/WebAssemblyFunction.cpp (209629 => 209630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/WebAssemblyFunction.cpp        2016-12-09 22:12:08 UTC (rev 209629)
+++ trunk/Source/JavaScriptCore/wasm/js/WebAssemblyFunction.cpp        2016-12-09 22:38:39 UTC (rev 209630)
</span><span class="lines">@@ -34,10 +34,12 @@
</span><span class="cx"> #include &quot;JSObject.h&quot;
</span><span class="cx"> #include &quot;JSWebAssemblyCallee.h&quot;
</span><span class="cx"> #include &quot;JSWebAssemblyInstance.h&quot;
</span><ins>+#include &quot;JSWebAssemblyMemory.h&quot;
</ins><span class="cx"> #include &quot;LLIntThunks.h&quot;
</span><span class="cx"> #include &quot;ProtoCallFrame.h&quot;
</span><span class="cx"> #include &quot;VM.h&quot;
</span><span class="cx"> #include &quot;WasmFormat.h&quot;
</span><ins>+#include &quot;WasmMemory.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace JSC {
</span><span class="cx"> 
</span><span class="lines">@@ -90,6 +92,16 @@
</span><span class="cx">         argCount = boxedArgs.size();
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    // Setup the memory that the entrance loads.
+    if (JSWebAssemblyMemory* memory = wasmFunction-&gt;instance()-&gt;memory()) {
+        Wasm::Memory* wasmMemory = memory-&gt;memory();
+        vm.topWasmMemoryPointer = wasmMemory-&gt;memory();
+        vm.topWasmMemorySize = wasmMemory-&gt;size();
+    } else {
+        vm.topWasmMemoryPointer = nullptr;
+        vm.topWasmMemorySize = 0;
+    }
+
</ins><span class="cx">     // Note: we specifically use the WebAsseblyFunction as the callee to begin with in the ProtoCallFrame.
</span><span class="cx">     // The reason for this is that calling into the llint may stack overflow, and the stack overflow
</span><span class="cx">     // handler might read the global object from the callee. The JSWebAssemblyCallee doesn't have a
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsWebAssemblyInstanceConstructorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/WebAssemblyInstanceConstructor.cpp (209629 => 209630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/WebAssemblyInstanceConstructor.cpp        2016-12-09 22:12:08 UTC (rev 209629)
+++ trunk/Source/JavaScriptCore/wasm/js/WebAssemblyInstanceConstructor.cpp        2016-12-09 22:38:39 UTC (rev 209630)
</span><span class="lines">@@ -33,6 +33,7 @@
</span><span class="cx"> #include &quot;JSModuleEnvironment.h&quot;
</span><span class="cx"> #include &quot;JSModuleNamespaceObject.h&quot;
</span><span class="cx"> #include &quot;JSWebAssemblyInstance.h&quot;
</span><ins>+#include &quot;JSWebAssemblyMemory.h&quot;
</ins><span class="cx"> #include &quot;JSWebAssemblyModule.h&quot;
</span><span class="cx"> #include &quot;WebAssemblyFunction.h&quot;
</span><span class="cx"> #include &quot;WebAssemblyInstancePrototype.h&quot;
</span><span class="lines">@@ -51,37 +52,37 @@
</span><span class="cx">  @end
</span><span class="cx">  */
</span><span class="cx"> 
</span><del>-static EncodedJSValue JSC_HOST_CALL constructJSWebAssemblyInstance(ExecState* state)
</del><ins>+static EncodedJSValue JSC_HOST_CALL constructJSWebAssemblyInstance(ExecState* exec)
</ins><span class="cx"> {
</span><del>-    auto&amp; vm = state-&gt;vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-    auto* globalObject = state-&gt;lexicalGlobalObject();
</del><ins>+    auto&amp; vm = exec-&gt;vm();
+    auto throwScope = DECLARE_THROW_SCOPE(vm);
+    auto* globalObject = exec-&gt;lexicalGlobalObject();
</ins><span class="cx"> 
</span><span class="cx">     // If moduleObject is not a WebAssembly.Module instance, a TypeError is thrown.
</span><del>-    JSWebAssemblyModule* jsModule = jsDynamicCast&lt;JSWebAssemblyModule*&gt;(state-&gt;argument(0));
</del><ins>+    JSWebAssemblyModule* jsModule = jsDynamicCast&lt;JSWebAssemblyModule*&gt;(exec-&gt;argument(0));
</ins><span class="cx">     if (!jsModule)
</span><del>-        return JSValue::encode(throwException(state, scope, createTypeError(state, ASCIILiteral(&quot;first argument to WebAssembly.Instance must be a WebAssembly.Module&quot;), defaultSourceAppender, runtimeTypeForValue(state-&gt;argument(0)))));
</del><ins>+        return JSValue::encode(throwException(exec, throwScope, createTypeError(exec, ASCIILiteral(&quot;first argument to WebAssembly.Instance must be a WebAssembly.Module&quot;), defaultSourceAppender, runtimeTypeForValue(exec-&gt;argument(0)))));
</ins><span class="cx">     const Wasm::ModuleInformation&amp; moduleInformation = jsModule-&gt;moduleInformation();
</span><span class="cx"> 
</span><span class="cx">     // If the importObject parameter is not undefined and Type(importObject) is not Object, a TypeError is thrown.
</span><del>-    JSValue importArgument = state-&gt;argument(1);
</del><ins>+    JSValue importArgument = exec-&gt;argument(1);
</ins><span class="cx">     JSObject* importObject = importArgument.getObject();
</span><span class="cx">     if (!importArgument.isUndefined() &amp;&amp; !importObject)
</span><del>-        return JSValue::encode(throwException(state, scope, createTypeError(state, ASCIILiteral(&quot;second argument to WebAssembly.Instance must be undefined or an Object&quot;), defaultSourceAppender, runtimeTypeForValue(importArgument))));
</del><ins>+        return JSValue::encode(throwException(exec, throwScope, createTypeError(exec, ASCIILiteral(&quot;second argument to WebAssembly.Instance must be undefined or an Object&quot;), defaultSourceAppender, runtimeTypeForValue(importArgument))));
</ins><span class="cx"> 
</span><span class="cx">     // If the list of module.imports is not empty and Type(importObject) is not Object, a TypeError is thrown.
</span><span class="cx">     if (moduleInformation.imports.size() &amp;&amp; !importObject)
</span><del>-        return JSValue::encode(throwException(state, scope, createTypeError(state, ASCIILiteral(&quot;second argument to WebAssembly.Instance must be Object because the WebAssembly.Module has imports&quot;), defaultSourceAppender, runtimeTypeForValue(importArgument))));
</del><ins>+        return JSValue::encode(throwException(exec, throwScope, createTypeError(exec, ASCIILiteral(&quot;second argument to WebAssembly.Instance must be Object because the WebAssembly.Module has imports&quot;), defaultSourceAppender, runtimeTypeForValue(importArgument))));
</ins><span class="cx"> 
</span><span class="cx">     Identifier moduleKey = Identifier::fromUid(PrivateName(PrivateName::Description, &quot;WebAssemblyInstance&quot;));
</span><del>-    WebAssemblyModuleRecord* moduleRecord = WebAssemblyModuleRecord::create(state, vm, globalObject-&gt;webAssemblyModuleRecordStructure(), moduleKey, moduleInformation);
-    RETURN_IF_EXCEPTION(scope, { });
</del><ins>+    WebAssemblyModuleRecord* moduleRecord = WebAssemblyModuleRecord::create(exec, vm, globalObject-&gt;webAssemblyModuleRecordStructure(), moduleKey, moduleInformation);
+    RETURN_IF_EXCEPTION(throwScope, { });
</ins><span class="cx"> 
</span><del>-    Structure* instanceStructure = InternalFunction::createSubclassStructure(state, state-&gt;newTarget(), globalObject-&gt;WebAssemblyInstanceStructure());
-    RETURN_IF_EXCEPTION(scope, { });
</del><ins>+    Structure* instanceStructure = InternalFunction::createSubclassStructure(exec, exec-&gt;newTarget(), globalObject-&gt;WebAssemblyInstanceStructure());
+    RETURN_IF_EXCEPTION(throwScope, { });
</ins><span class="cx"> 
</span><del>-    JSWebAssemblyInstance* instance = JSWebAssemblyInstance::create(vm, instanceStructure, jsModule, moduleRecord-&gt;getModuleNamespace(state), moduleInformation.imports.size());
-    RETURN_IF_EXCEPTION(scope, { });
</del><ins>+    JSWebAssemblyInstance* instance = JSWebAssemblyInstance::create(vm, instanceStructure, jsModule, moduleRecord-&gt;getModuleNamespace(exec), moduleInformation.imports.size());
+    RETURN_IF_EXCEPTION(throwScope, { });
</ins><span class="cx"> 
</span><span class="cx">     // Let funcs, memories and tables be initially-empty lists of callable JavaScript objects, WebAssembly.Memory objects and WebAssembly.Table objects, respectively.
</span><span class="cx">     // Let imports be an initially-empty list of external values.
</span><span class="lines">@@ -88,27 +89,29 @@
</span><span class="cx">     unsigned numImportFunctions = 0;
</span><span class="cx"> 
</span><span class="cx">     // FIXME implement Table https://bugs.webkit.org/show_bug.cgi?id=164135
</span><del>-    // FIXME implement Memory https://bugs.webkit.org/show_bug.cgi?id=164134
</del><span class="cx">     // FIXME implement Global https://bugs.webkit.org/show_bug.cgi?id=164133
</span><span class="cx"> 
</span><ins>+    bool hasMemoryImport = false;
</ins><span class="cx">     // For each import i in module.imports:
</span><span class="cx">     for (auto&amp; import : moduleInformation.imports) {
</span><span class="cx">         // 1. Let o be the resultant value of performing Get(importObject, i.module_name).
</span><del>-        JSValue importModuleValue = importObject-&gt;get(state, import.module);
-        RETURN_IF_EXCEPTION(scope, { });
</del><ins>+        JSValue importModuleValue = importObject-&gt;get(exec, import.module);
+        RETURN_IF_EXCEPTION(throwScope, { });
</ins><span class="cx">         // 2. If Type(o) is not Object, throw a TypeError.
</span><span class="cx">         if (!importModuleValue.isObject())
</span><del>-            return JSValue::encode(throwException(state, scope, createTypeError(state, ASCIILiteral(&quot;import must be an object&quot;), defaultSourceAppender, runtimeTypeForValue(importModuleValue))));
</del><ins>+            return JSValue::encode(throwException(exec, throwScope, createTypeError(exec, ASCIILiteral(&quot;import must be an object&quot;), defaultSourceAppender, runtimeTypeForValue(importModuleValue))));
+
</ins><span class="cx">         // 3. Let v be the value of performing Get(o, i.item_name)
</span><span class="cx">         JSObject* object = jsCast&lt;JSObject*&gt;(importModuleValue);
</span><del>-        JSValue value = object-&gt;get(state, import.field);
-        RETURN_IF_EXCEPTION(scope, { });
</del><ins>+        JSValue value = object-&gt;get(exec, import.field);
+        RETURN_IF_EXCEPTION(throwScope, { });
+
</ins><span class="cx">         switch (import.kind) {
</span><span class="cx">         case Wasm::External::Function: {
</span><span class="cx">             // 4. If i is a function import:
</span><span class="cx">             // i. If IsCallable(v) is false, throw a TypeError.
</span><span class="cx">             if (!value.isFunction())
</span><del>-                return JSValue::encode(throwException(state, scope, createTypeError(state, ASCIILiteral(&quot;import function must be callable&quot;), defaultSourceAppender, runtimeTypeForValue(value))));
</del><ins>+                return JSValue::encode(throwException(exec, throwScope, createTypeError(exec, ASCIILiteral(&quot;import function must be callable&quot;), defaultSourceAppender, runtimeTypeForValue(value))));
</ins><span class="cx">             JSCell* cell = value.asCell();
</span><span class="cx">             // ii. If v is an Exported Function Exotic Object:
</span><span class="cx">             if (WebAssemblyFunction* importedExports = jsDynamicCast&lt;WebAssemblyFunction*&gt;(object)) {
</span><span class="lines">@@ -138,11 +141,34 @@
</span><span class="cx">         }
</span><span class="cx">         case Wasm::External::Memory: {
</span><span class="cx">             // 6. If i is a memory import:
</span><del>-            // FIXME implement Memory https://bugs.webkit.org/show_bug.cgi?id=164134
</del><ins>+            RELEASE_ASSERT(!hasMemoryImport); // This should be guaranteed by a validation failure.
+            RELEASE_ASSERT(moduleInformation.memory);
+            hasMemoryImport = true;
+            JSWebAssemblyMemory* memory = jsDynamicCast&lt;JSWebAssemblyMemory*&gt;(value);
</ins><span class="cx">             // i. If v is not a WebAssembly.Memory object, throw a TypeError.
</span><ins>+            if (!memory)
+                return JSValue::encode(throwException(exec, throwScope, createTypeError(exec, ASCIILiteral(&quot;Memory import is not an instance of WebAssembly.Memory&quot;))));
+
+            Wasm::PageCount expectedInitial = moduleInformation.memory.initial();
+            Wasm::PageCount actualInitial = memory-&gt;memory()-&gt;initial();
+            if (actualInitial &lt; expectedInitial)
+                return JSValue::encode(throwException(exec, throwScope, createTypeError(exec, ASCIILiteral(&quot;Memory import provided an 'initial' that is too small&quot;))));
+
+            if (Wasm::PageCount expectedMaximum = moduleInformation.memory.maximum()) {
+                Wasm::PageCount actualMaximum = memory-&gt;memory()-&gt;maximum();
+                if (!actualMaximum) {
+                    return JSValue::encode(
+                        throwException(exec, throwScope, createTypeError(exec, ASCIILiteral(&quot;Memory import did not have a 'maximum' but the module requires that it does&quot;))));
+                }
+
+                if (actualMaximum &gt; expectedMaximum) {
+                    return JSValue::encode(
+                        throwException(exec, throwScope, createTypeError(exec, ASCIILiteral(&quot;Memory imports 'maximum' is larger than the module's expected 'maximum&quot;))));
+                }
+            }
</ins><span class="cx">             // ii. Append v to memories.
</span><span class="cx">             // iii. Append v.[[Memory]] to imports.
</span><del>-            RELEASE_ASSERT_NOT_REACHED();
</del><ins>+            instance-&gt;setMemory(vm, memory);
</ins><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         case Wasm::External::Global: {
</span><span class="lines">@@ -157,13 +183,28 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    moduleRecord-&gt;link(state, instance);
-    RETURN_IF_EXCEPTION(scope, { });
</del><ins>+    {
+        if (!!moduleInformation.memory &amp;&amp; moduleInformation.memory.isImport()) {
+            // We should either have an import or we should have thrown an exception.
+            RELEASE_ASSERT(hasMemoryImport);
+        }
+
+        if (moduleInformation.memory &amp;&amp; !hasMemoryImport) {
+            RELEASE_ASSERT(!moduleInformation.memory.isImport());
+            // We create a memory when it's a memory definition.
+            std::unique_ptr&lt;Wasm::Memory&gt; memory = std::make_unique&lt;Wasm::Memory&gt;(moduleInformation.memory.initial(), moduleInformation.memory.maximum());
+            instance-&gt;setMemory(vm,
+               JSWebAssemblyMemory::create(vm, exec-&gt;lexicalGlobalObject()-&gt;WebAssemblyMemoryStructure(), WTFMove(memory)));
+        }
+    }
+
+    moduleRecord-&gt;link(exec, instance);
+    RETURN_IF_EXCEPTION(throwScope, { });
</ins><span class="cx">     if (verbose)
</span><span class="cx">         moduleRecord-&gt;dump();
</span><del>-    JSValue startResult = moduleRecord-&gt;evaluate(state);
</del><ins>+    JSValue startResult = moduleRecord-&gt;evaluate(exec);
</ins><span class="cx">     UNUSED_PARAM(startResult);
</span><del>-    RETURN_IF_EXCEPTION(scope, { });
</del><ins>+    RETURN_IF_EXCEPTION(throwScope, { });
</ins><span class="cx"> 
</span><span class="cx">     return JSValue::encode(instance);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsWebAssemblyMemoryConstructorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/WebAssemblyMemoryConstructor.cpp (209629 => 209630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/WebAssemblyMemoryConstructor.cpp        2016-12-09 22:12:08 UTC (rev 209629)
+++ trunk/Source/JavaScriptCore/wasm/js/WebAssemblyMemoryConstructor.cpp        2016-12-09 22:38:39 UTC (rev 209630)
</span><span class="lines">@@ -30,7 +30,11 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;FunctionPrototype.h&quot;
</span><span class="cx"> #include &quot;JSCInlines.h&quot;
</span><ins>+#include &quot;JSWebAssemblyMemory.h&quot;
+#include &quot;WasmMemory.h&quot;
+#include &quot;WasmPageCount.h&quot;
</ins><span class="cx"> #include &quot;WebAssemblyMemoryPrototype.h&quot;
</span><ins>+#include &lt;wtf/Optional.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> #include &quot;WebAssemblyMemoryConstructor.lut.h&quot;
</span><span class="cx"> 
</span><span class="lines">@@ -43,19 +47,75 @@
</span><span class="cx">  @end
</span><span class="cx">  */
</span><span class="cx"> 
</span><del>-static EncodedJSValue JSC_HOST_CALL constructJSWebAssemblyMemory(ExecState* state)
</del><ins>+static EncodedJSValue JSC_HOST_CALL constructJSWebAssemblyMemory(ExecState* exec)
</ins><span class="cx"> {
</span><del>-    VM&amp; vm = state-&gt;vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-    // FIXME https://bugs.webkit.org/show_bug.cgi?id=164134
-    return JSValue::encode(throwException(state, scope, createError(state, ASCIILiteral(&quot;WebAssembly doesn't yet implement the Memory constructor property&quot;))));
</del><ins>+    VM&amp; vm = exec-&gt;vm();
+    auto throwScope = DECLARE_THROW_SCOPE(vm);
+    if (exec-&gt;argumentCount() != 1)
+        return JSValue::encode(throwException(exec, throwScope, createTypeError(exec, ASCIILiteral(&quot;WebAssembly.Memory expects exactly one argument&quot;))));
+
+    auto getUint32 = [&amp;] (JSValue value) -&gt; uint32_t {
+        double doubleValue = value.toInteger(exec);
+        RETURN_IF_EXCEPTION(throwScope, { });
+        if (doubleValue &lt; 0 || doubleValue &gt; UINT_MAX) {
+            throwException(exec, throwScope,
+                createRangeError(exec, ASCIILiteral(&quot;WebAssembly.Memory expects the 'initial' and 'maximum' properties to be integers in the range: [0, 2^32 - 1]&quot;)));
+            return 0;
+        }
+        return static_cast&lt;uint32_t&gt;(doubleValue);
+    };
+
+    JSObject* memoryDescriptor;
+    {
+        JSValue argument = exec-&gt;argument(0);
+        if (!argument.isObject())
+            return JSValue::encode(throwException(exec, throwScope, createTypeError(exec, ASCIILiteral(&quot;WebAssembly.Memory expects its first argument to be an object&quot;))));
+        memoryDescriptor = jsCast&lt;JSObject*&gt;(argument);
+    }
+
+    Wasm::PageCount initialPageCount;
+    {
+        Identifier initial = Identifier::fromString(&amp;vm, &quot;initial&quot;);
+        JSValue minSizeValue = memoryDescriptor-&gt;get(exec, initial);
+        RETURN_IF_EXCEPTION(throwScope, { });
+        uint32_t size = getUint32(minSizeValue);
+        RETURN_IF_EXCEPTION(throwScope, { });
+        if (!Wasm::PageCount::isValid(size))
+            return JSValue::encode(throwException(exec, throwScope, createRangeError(exec, ASCIILiteral(&quot;WebAssembly.Memory 'initial' page count is too large&quot;))));
+        initialPageCount = Wasm::PageCount(size);
+    }
+
+    Wasm::PageCount maximumPageCount;
+    {
+        Identifier maximum = Identifier::fromString(&amp;vm, &quot;maximum&quot;);
+        bool hasProperty = memoryDescriptor-&gt;hasProperty(exec, maximum);
+        RETURN_IF_EXCEPTION(throwScope, { });
+        if (hasProperty) {
+            JSValue maxSizeValue = memoryDescriptor-&gt;get(exec, maximum);
+            RETURN_IF_EXCEPTION(throwScope, { });
+            uint32_t size = getUint32(maxSizeValue);
+            if (!Wasm::PageCount::isValid(size))
+                return JSValue::encode(throwException(exec, throwScope, createRangeError(exec, ASCIILiteral(&quot;WebAssembly.Memory 'maximum' page count is too large&quot;))));
+            RETURN_IF_EXCEPTION(throwScope, { });
+            maximumPageCount = Wasm::PageCount(size);
+
+            if (initialPageCount &gt; maximumPageCount) {
+                return JSValue::encode(throwException(exec, throwScope,
+                    createRangeError(exec, ASCIILiteral(&quot;'maximum' page count must be than greater than or equal to the 'initial' page count&quot;))));
+            }
+        }
+    }
+
+    std::unique_ptr&lt;Wasm::Memory&gt; memory = std::make_unique&lt;Wasm::Memory&gt;(initialPageCount, maximumPageCount);
+
+    return JSValue::encode(JSWebAssemblyMemory::create(vm, exec-&gt;lexicalGlobalObject()-&gt;WebAssemblyMemoryStructure(), WTFMove(memory)));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static EncodedJSValue JSC_HOST_CALL callJSWebAssemblyMemory(ExecState* state)
</span><span class="cx"> {
</span><span class="cx">     VM&amp; vm = state-&gt;vm();
</span><del>-    auto scope = DECLARE_THROW_SCOPE(vm);
-    return JSValue::encode(throwConstructorCannotBeCalledAsFunctionTypeError(state, scope, &quot;WebAssembly.Memory&quot;));
</del><ins>+    auto throwScope = DECLARE_THROW_SCOPE(vm);
+    return JSValue::encode(throwConstructorCannotBeCalledAsFunctionTypeError(state, throwScope, &quot;WebAssembly.Memory&quot;));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> WebAssemblyMemoryConstructor* WebAssemblyMemoryConstructor::create(VM&amp; vm, Structure* structure, WebAssemblyMemoryPrototype* thisPrototype)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsWebAssemblyMemoryPrototypecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/WebAssemblyMemoryPrototype.cpp (209629 => 209630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/WebAssemblyMemoryPrototype.cpp        2016-12-09 22:12:08 UTC (rev 209629)
+++ trunk/Source/JavaScriptCore/wasm/js/WebAssemblyMemoryPrototype.cpp        2016-12-09 22:38:39 UTC (rev 209630)
</span><span class="lines">@@ -29,7 +29,9 @@
</span><span class="cx"> #if ENABLE(WEBASSEMBLY)
</span><span class="cx"> 
</span><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;JSWebAssemblyMemory.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> #include &quot;WebAssemblyMemoryPrototype.lut.h&quot;
</span><span class="cx"> 
</span><span class="lines">@@ -42,10 +44,25 @@
</span><span class="cx">  @end
</span><span class="cx">  */
</span><span class="cx"> 
</span><del>-WebAssemblyMemoryPrototype* WebAssemblyMemoryPrototype::create(VM&amp; vm, JSGlobalObject*, Structure* structure)
</del><ins>+static EncodedJSValue JSC_HOST_CALL webAssemblyMemoryProtoFuncBuffer(ExecState*);
+
+EncodedJSValue JSC_HOST_CALL webAssemblyMemoryProtoFuncBuffer(ExecState* exec)
</ins><span class="cx"> {
</span><ins>+    VM&amp; vm = exec-&gt;vm();
+    auto throwScope = DECLARE_THROW_SCOPE(vm);
+
+    JSWebAssemblyMemory* memory = jsDynamicCast&lt;JSWebAssemblyMemory*&gt;(exec-&gt;thisValue()); 
+    if (!memory) {
+        return JSValue::encode(throwException(exec, throwScope, 
+                    createTypeError(exec, ASCIILiteral(&quot;WebAssembly.Memory.prototype.buffer getter called with non WebAssembly.Memory |this| value&quot;))));
+    }
+    return JSValue::encode(memory-&gt;buffer(exec-&gt;vm(), exec-&gt;lexicalGlobalObject()));
+}
+
+WebAssemblyMemoryPrototype* WebAssemblyMemoryPrototype::create(VM&amp; vm, JSGlobalObject* globalObject, Structure* structure)
+{
</ins><span class="cx">     auto* object = new (NotNull, allocateCell&lt;WebAssemblyMemoryPrototype&gt;(vm.heap)) WebAssemblyMemoryPrototype(vm, structure);
</span><del>-    object-&gt;finishCreation(vm);
</del><ins>+    object-&gt;finishCreation(vm, globalObject);
</ins><span class="cx">     return object;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -54,9 +71,10 @@
</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 WebAssemblyMemoryPrototype::finishCreation(VM&amp; vm)
</del><ins>+void WebAssemblyMemoryPrototype::finishCreation(VM&amp; vm, JSGlobalObject* globalObject)
</ins><span class="cx"> {
</span><span class="cx">     Base::finishCreation(vm);
</span><ins>+    JSC_NATIVE_GETTER(&quot;buffer&quot;, webAssemblyMemoryProtoFuncBuffer, DontEnum | Accessor);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> WebAssemblyMemoryPrototype::WebAssemblyMemoryPrototype(VM&amp; vm, Structure* structure)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsWebAssemblyMemoryPrototypeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/WebAssemblyMemoryPrototype.h (209629 => 209630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/WebAssemblyMemoryPrototype.h        2016-12-09 22:12:08 UTC (rev 209629)
+++ trunk/Source/JavaScriptCore/wasm/js/WebAssemblyMemoryPrototype.h        2016-12-09 22:38:39 UTC (rev 209630)
</span><span class="lines">@@ -43,7 +43,7 @@
</span><span class="cx">     DECLARE_INFO;
</span><span class="cx"> 
</span><span class="cx"> protected:
</span><del>-    void finishCreation(VM&amp;);
</del><ins>+    void finishCreation(VM&amp;, JSGlobalObject*);
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     WebAssemblyMemoryPrototype(VM&amp;, Structure*);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsWebAssemblyModuleRecordcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.cpp (209629 => 209630)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.cpp        2016-12-09 22:12:08 UTC (rev 209629)
+++ trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.cpp        2016-12-09 22:38:39 UTC (rev 209630)
</span><span class="lines">@@ -79,7 +79,7 @@
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         case Wasm::External::Memory: {
</span><del>-            // FIXME https://bugs.webkit.org/show_bug.cgi?id=164134
</del><ins>+            // FIXME: https://bugs.webkit.org/show_bug.cgi?id=165671
</ins><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         case Wasm::External::Global: {
</span><span class="lines">@@ -140,7 +140,7 @@
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         case Wasm::External::Memory: {
</span><del>-            // FIXME https://bugs.webkit.org/show_bug.cgi?id=164134
</del><ins>+            // FIXME: https://bugs.webkit.org/show_bug.cgi?id=165671
</ins><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         case Wasm::External::Global: {
</span></span></pre>
</div>
</div>

</body>
</html>