<!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>[214547] 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/214547">214547</a></dd>
<dt>Author</dt> <dd>jfbastien@apple.com</dd>
<dt>Date</dt> <dd>2017-03-29 10:44:59 -0700 (Wed, 29 Mar 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>WebAssembly: add shell-only Memory mode helper
https://bugs.webkit.org/show_bug.cgi?id=170227

Reviewed by Mark Lam.

JSTests:

* wasm/assert.js: fix a prior debug thing I forgot to remove
* wasm/function-tests/memory-section-and-import.js: the assert
issue was hiding a failure in error message here
* wasm/js-api/element.js: the assert issue was hiding a failure in
error message here
(badInstantiation.test):
(badInstantiation):
* wasm/js-api/extension-MemoryMode.js: Added.
(const.validateMode.what.switch):
(testMemoryNoMax):
(testMemory):
(testInstanceNoMemory):
(testInstanceNoMax):
(testInstance):
* wasm/js-api/test_memory.js: the assert issue was hiding a
failure in error message here
(test):

Source/JavaScriptCore:

* jsc.cpp:
(GlobalObject::finishCreation):
(functionWebAssemblyMemoryMode):
* wasm/WasmMemory.h:
* wasm/js/JSWebAssemblyInstance.h:
* wasm/js/JSWebAssemblyMemory.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkJSTestsChangeLog">trunk/JSTests/ChangeLog</a></li>
<li><a href="#trunkJSTestswasmassertjs">trunk/JSTests/wasm/assert.js</a></li>
<li><a href="#trunkJSTestswasmfunctiontestsmemorysectionandimportjs">trunk/JSTests/wasm/function-tests/memory-section-and-import.js</a></li>
<li><a href="#trunkJSTestswasmjsapielementjs">trunk/JSTests/wasm/js-api/element.js</a></li>
<li><a href="#trunkJSTestswasmjsapitest_memoryjs">trunk/JSTests/wasm/js-api/test_memory.js</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCorejsccpp">trunk/Source/JavaScriptCore/jsc.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmWasmMemoryh">trunk/Source/JavaScriptCore/wasm/WasmMemory.h</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsJSWebAssemblyInstanceh">trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.h</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsJSWebAssemblyMemoryh">trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyMemory.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkJSTestswasmjsapiextensionMemoryModejs">trunk/JSTests/wasm/js-api/extension-MemoryMode.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkJSTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/ChangeLog (214546 => 214547)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/ChangeLog        2017-03-29 17:40:21 UTC (rev 214546)
+++ trunk/JSTests/ChangeLog        2017-03-29 17:44:59 UTC (rev 214547)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2017-03-29  JF Bastien  &lt;jfbastien@apple.com&gt;
+
+        WebAssembly: add shell-only Memory mode helper
+        https://bugs.webkit.org/show_bug.cgi?id=170227
+
+        Reviewed by Mark Lam.
+
+        * wasm/assert.js: fix a prior debug thing I forgot to remove
+        * wasm/function-tests/memory-section-and-import.js: the assert
+        issue was hiding a failure in error message here
+        * wasm/js-api/element.js: the assert issue was hiding a failure in
+        error message here
+        (badInstantiation.test):
+        (badInstantiation):
+        * wasm/js-api/extension-MemoryMode.js: Added.
+        (const.validateMode.what.switch):
+        (testMemoryNoMax):
+        (testMemory):
+        (testInstanceNoMemory):
+        (testInstanceNoMax):
+        (testInstance):
+        * wasm/js-api/test_memory.js: the assert issue was hiding a
+        failure in error message here
+        (test):
+
</ins><span class="cx"> 2017-03-28  Keith Miller  &lt;keith_miller@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         WebAssembly: Make WebAssembly.instantiate/compile truly asynchronous
</span></span></pre></div>
<a id="trunkJSTestswasmassertjs"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/wasm/assert.js (214546 => 214547)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/wasm/assert.js        2017-03-29 17:40:21 UTC (rev 214546)
+++ trunk/JSTests/wasm/assert.js        2017-03-29 17:44:59 UTC (rev 214547)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2016 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -45,6 +45,8 @@
</span><span class="cx"> export const isString = (v, msg) =&gt; isA(v, &quot;string&quot;, msg);
</span><span class="cx"> export const notNumber = (v, msg) =&gt; isNotA(v, &quot;number&quot;, msg);
</span><span class="cx"> export const isNumber = (v, msg) =&gt; isA(v, &quot;number&quot;, msg);
</span><ins>+export const notFunction = (v, msg) =&gt; isNotA(v, &quot;function&quot;, msg);
+export const isFunction = (v, msg) =&gt; isA(v, &quot;function&quot;, msg);
</ins><span class="cx"> 
</span><span class="cx"> export const hasObjectProperty = (o, p, msg) =&gt; {
</span><span class="cx">     isObject(o, msg);
</span><span class="lines">@@ -127,7 +129,6 @@
</span><span class="cx">                 if (cleanMessage === message)
</span><span class="cx">                     return e;
</span><span class="cx">             }
</span><del>-            return e;
</del><span class="cx">         }
</span><span class="cx">         _fail(`Expected to throw a ${type.name} with message &quot;${message}&quot;, got ${e.name} with message &quot;${e.message}&quot;`);
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkJSTestswasmfunctiontestsmemorysectionandimportjs"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/wasm/function-tests/memory-section-and-import.js (214546 => 214547)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/wasm/function-tests/memory-section-and-import.js        2017-03-29 17:40:21 UTC (rev 214546)
+++ trunk/JSTests/wasm/function-tests/memory-section-and-import.js        2017-03-29 17:44:59 UTC (rev 214547)
</span><span class="lines">@@ -28,4 +28,4 @@
</span><span class="cx">       .Code().End();
</span><span class="cx"> 
</span><span class="cx"> const i0 = instantiate(builder0);
</span><del>-assert.throws(() =&gt; instantiate(builder1, { imp: { memory: i0.exports.memory } }), WebAssembly.CompileError, `WebAssembly.Module doesn't parse at byte 34 / 40: Memory section cannot exist if an Import has a memory`);
</del><ins>+assert.throws(() =&gt; instantiate(builder1, { imp: { memory: i0.exports.memory } }), WebAssembly.CompileError, `WebAssembly.Module doesn't parse at byte 35 / 41: Memory section cannot exist if an Import has a memory`);
</ins></span></pre></div>
<a id="trunkJSTestswasmjsapielementjs"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/wasm/js-api/element.js (214546 => 214547)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/wasm/js-api/element.js        2017-03-29 17:40:21 UTC (rev 214546)
+++ trunk/JSTests/wasm/js-api/element.js        2017-03-29 17:44:59 UTC (rev 214547)
</span><span class="lines">@@ -181,7 +181,7 @@
</span><span class="cx">             if (j === i)
</span><span class="cx">                 assert.eq(table.get(j)(i*2), i*2 + 42);
</span><span class="cx">             else
</span><del>-                assert.throws(() =&gt; table.get(j)(i*2), TypeError, &quot;table.get(j) is not a function.&quot;);
</del><ins>+                assert.throws(() =&gt; table.get(j)(i*2), TypeError, &quot;table.get(j) is not a function. (In 'table.get(j)(i*2)', 'table.get(j)' is null)&quot;);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     for (let i = 0; i &lt; 19; i++)
</span></span></pre></div>
<a id="trunkJSTestswasmjsapiextensionMemoryModejs"></a>
<div class="addfile"><h4>Added: trunk/JSTests/wasm/js-api/extension-MemoryMode.js (0 => 214547)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/wasm/js-api/extension-MemoryMode.js                                (rev 0)
+++ trunk/JSTests/wasm/js-api/extension-MemoryMode.js        2017-03-29 17:44:59 UTC (rev 214547)
</span><span class="lines">@@ -0,0 +1,102 @@
</span><ins>+import Builder from '../Builder.js';
+import * as assert from '../assert.js';
+
+const iterations = 32;
+
+// This API isn't part of WebAssembly's official spec. It is use for testing within the shell.
+
+const version = 0x01;
+const emptyModuleArray = Uint8Array.of(0x0, 0x61, 0x73, 0x6d, version, 0x00, 0x00, 0x00);
+
+assert.isFunction(WebAssemblyMemoryMode);
+
+const message = `WebAssemblyMemoryMode expects either a WebAssembly.Memory or WebAssembly.Instance`;
+assert.throws(() =&gt; WebAssemblyMemoryMode(null), TypeError, message);
+assert.throws(() =&gt; WebAssemblyMemoryMode(undefined), TypeError, message);
+assert.throws(() =&gt; WebAssemblyMemoryMode(1), TypeError, message);
+assert.throws(() =&gt; WebAssemblyMemoryMode(&quot;&quot;), TypeError, message);
+assert.throws(() =&gt; WebAssemblyMemoryMode({}), TypeError, message);
+assert.throws(() =&gt; WebAssemblyMemoryMode(new WebAssembly.Module(emptyModuleArray)), TypeError, message);
+assert.throws(() =&gt; WebAssemblyMemoryMode(new WebAssembly.Table({initial: 1, element: &quot;anyfunc&quot;})), TypeError, message);
+
+const validateMode = what =&gt; {
+    const mode = WebAssemblyMemoryMode(what);
+    switch (mode) {
+    case &quot;Signaling&quot;:
+        break;
+    case &quot;BoundsChecking&quot;:
+        break;
+    default:
+        throw new Error(`Unexpected WebAssembly.Memory mode '${mode}'`);
+    }
+    return what;
+}
+
+const instantiate = builder =&gt; {
+    const bin = builder.WebAssembly();
+    const module = new WebAssembly.Module(bin.get());
+    return new WebAssembly.Instance(module);
+};
+
+(function testMemoryNoMax() {
+    let memories = [];
+    for (let i = 0; i != iterations; ++i)
+        memories.push(validateMode(new WebAssembly.Memory({ initial: i })));
+    return memories;
+})();
+
+fullGC();
+
+(function testMemory() {
+    let memories = [];
+    for (let i = 0; i != iterations; ++i)
+        memories.push(validateMode(new WebAssembly.Memory({ initial: i, maximum: i })));
+    return memories;
+})();
+
+fullGC();
+
+(function testInstanceNoMemory() {
+    let instances = [];
+    for (let i = 0; i != iterations; ++i) {
+        const builder = (new Builder())
+              .Type().End()
+              .Function().End()
+              .Code().End();
+        const instance = instantiate(builder);
+        // No-memory instances should never be Signaling: it would be wasteful.
+        assert.eq(WebAssemblyMemoryMode(instance), &quot;BoundsChecking&quot;);
+        instances.push(instance);
+    }
+    return instances;
+})();
+
+fullGC();
+
+(function testInstanceNoMax() {
+    let instances = [];
+    for (let i = 0; i != iterations; ++i) {
+        // Note: not exported! The internal API can still access.
+        const builder = (new Builder())
+              .Type().End()
+              .Function().End()
+              .Memory().InitialMaxPages(i).End()
+              .Code().End();
+        instances.push(validateMode(instantiate(builder)));
+    }
+})();
+
+fullGC();
+
+(function testInstance() {
+    let instances = [];
+    for (let i = 0; i != iterations; ++i) {
+        // Note: not exported! The internal API can still access.
+        const builder = (new Builder())
+              .Type().End()
+              .Function().End()
+              .Memory().InitialMaxPages(i, i).End()
+              .Code().End();
+        instances.push(validateMode(instantiate(builder)));
+    }
+})();
</ins></span></pre></div>
<a id="trunkJSTestswasmjsapitest_memoryjs"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/wasm/js-api/test_memory.js (214546 => 214547)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/wasm/js-api/test_memory.js        2017-03-29 17:40:21 UTC (rev 214546)
+++ trunk/JSTests/wasm/js-api/test_memory.js        2017-03-29 17:44:59 UTC (rev 214547)
</span><span class="lines">@@ -317,14 +317,14 @@
</span><span class="cx">     const bin = builder.WebAssembly().get();
</span><span class="cx">     const module = new WebAssembly.Module(bin);
</span><span class="cx"> 
</span><del>-    assert.throws(() =&gt; new WebAssembly.Instance(module, 20), TypeError, `second argument to WebAssembly.Instance must be undefined or an Object (evaluating 'new WebAssembly.Instance(module, 20)')`);
-    assert.throws(() =&gt; new WebAssembly.Instance(module, {}), TypeError, `import must be an object (evaluating 'new WebAssembly.Instance(module, {})')`);
-    assert.throws(() =&gt; new WebAssembly.Instance(module, {imp: { } }), WebAssembly.LinkError, `Memory import is not an instance of WebAssembly.Memory (evaluating 'new WebAssembly.Instance(module, {imp: { } })')`);
-    assert.throws(() =&gt; new WebAssembly.Instance(module, {imp: { memory: 20 } }), WebAssembly.LinkError, `Memory import is not an instance of WebAssembly.Memory (evaluating 'new WebAssembly.Instance(module, {imp: { memory: 20 } })')`);
-    assert.throws(() =&gt; new WebAssembly.Instance(module, {imp: { memory: [] } }), WebAssembly.LinkError, `Memory import is not an instance of WebAssembly.Memory (evaluating 'new WebAssembly.Instance(module, {imp: { memory: [] } })')`);
-    assert.throws(() =&gt; new WebAssembly.Instance(module, {imp: { memory: new WebAssembly.Memory({initial: 19, maximum: 25}) } }), WebAssembly.LinkError, `Memory import provided an 'initial' that is too small (evaluating 'new WebAssembly.Instance(module, {imp: { memory: new WebAssembly.Memory({initial: 19, maximum: 25}) } })')`);
-    assert.throws(() =&gt; new WebAssembly.Instance(module, {imp: { memory: new WebAssembly.Memory({initial: 20}) } }), WebAssembly.LinkError, `Memory import did not have a 'maximum' but the module requires that it does (evaluating 'new WebAssembly.Instance(module, {imp: { memory: new WebAssembly.Memory({initial: 20}) } })')`);
-    assert.throws(() =&gt; new WebAssembly.Instance(module, {imp: { memory: new WebAssembly.Memory({initial: 20, maximum: 26}) } }), WebAssembly.LinkError, `Memory imports 'maximum' is larger than the module's expected 'maximum' (evaluating 'new WebAssembly.Instance(module, {imp: { memory: new WebAssembly.Memory({initial: 20, maximum: 26}) } })')`);
</del><ins>+    assert.throws(() =&gt; new WebAssembly.Instance(module, 20), TypeError, `second argument to WebAssembly.Instance must be undefined or an Object`);
+    assert.throws(() =&gt; new WebAssembly.Instance(module, {}), TypeError, `import must be an object`);
+    assert.throws(() =&gt; new WebAssembly.Instance(module, {imp: { } }), WebAssembly.LinkError, `Memory import is not an instance of WebAssembly.Memory`);
+    assert.throws(() =&gt; new WebAssembly.Instance(module, {imp: { memory: 20 } }), WebAssembly.LinkError, `Memory import is not an instance of WebAssembly.Memory`);
+    assert.throws(() =&gt; new WebAssembly.Instance(module, {imp: { memory: [] } }), WebAssembly.LinkError, `Memory import is not an instance of WebAssembly.Memory`);
+    assert.throws(() =&gt; new WebAssembly.Instance(module, {imp: { memory: new WebAssembly.Memory({initial: 19, maximum: 25}) } }), WebAssembly.LinkError, `Memory import provided an 'initial' that is smaller than the module's declared 'initial' import memory size`);
+    assert.throws(() =&gt; new WebAssembly.Instance(module, {imp: { memory: new WebAssembly.Memory({initial: 20}) } }), WebAssembly.LinkError, `Memory import did not have a 'maximum' but the module requires that it does`);
+    assert.throws(() =&gt; new WebAssembly.Instance(module, {imp: { memory: new WebAssembly.Memory({initial: 20, maximum: 26}) } }), WebAssembly.LinkError, `Memory import provided a 'maximum' that is larger than the module's declared 'maximum' import memory size`);
</ins><span class="cx"> });
</span><span class="cx"> 
</span><span class="cx"> test(function() {
</span><span class="lines">@@ -354,8 +354,8 @@
</span><span class="cx">         assert.throws(() =&gt; new WebAssembly.Instance(module, instanceObj), WebAssembly.LinkError, expectedError);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    testMemImportError({imp: { memory: new WebAssembly.Memory({initial: 19, maximum: 25}) } }, &quot;Memory import provided an 'initial' that is too small (evaluating 'new WebAssembly.Instance(module, instanceObj)')&quot;);
-    testMemImportError({imp: { memory: new WebAssembly.Memory({initial: 19}) } }, &quot;Memory import provided an 'initial' that is too small (evaluating 'new WebAssembly.Instance(module, instanceObj)')&quot;);
</del><ins>+    testMemImportError({imp: { memory: new WebAssembly.Memory({initial: 19, maximum: 25}) } }, `Memory import provided an 'initial' that is smaller than the module's declared 'initial' import memory size`);
+    testMemImportError({imp: { memory: new WebAssembly.Memory({initial: 19}) } }, `Memory import provided an 'initial' that is smaller than the module's declared 'initial' import memory size`);
</ins><span class="cx"> 
</span><span class="cx">     // This should not throw.
</span><span class="cx">     new WebAssembly.Instance(module, {imp: {memory: new WebAssembly.Memory({initial:20})}});
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (214546 => 214547)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2017-03-29 17:40:21 UTC (rev 214546)
+++ trunk/Source/JavaScriptCore/ChangeLog        2017-03-29 17:44:59 UTC (rev 214547)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2017-03-29  JF Bastien  &lt;jfbastien@apple.com&gt;
+
+        WebAssembly: add shell-only Memory mode helper
+        https://bugs.webkit.org/show_bug.cgi?id=170227
+
+        Reviewed by Mark Lam.
+
+        * jsc.cpp:
+        (GlobalObject::finishCreation):
+        (functionWebAssemblyMemoryMode):
+        * wasm/WasmMemory.h:
+        * wasm/js/JSWebAssemblyInstance.h:
+        * wasm/js/JSWebAssemblyMemory.h:
+
</ins><span class="cx"> 2017-03-29  Keith Miller  &lt;keith_miller@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         WebAssembly: pack OpcodeOrigin to fit in a pointer
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejsccpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jsc.cpp (214546 => 214547)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jsc.cpp        2017-03-29 17:40:21 UTC (rev 214546)
+++ trunk/Source/JavaScriptCore/jsc.cpp        2017-03-29 17:44:59 UTC (rev 214547)
</span><span class="lines">@@ -57,6 +57,8 @@
</span><span class="cx"> #include &quot;JSString.h&quot;
</span><span class="cx"> #include &quot;JSTypedArrays.h&quot;
</span><span class="cx"> #include &quot;JSWebAssemblyCallee.h&quot;
</span><ins>+#include &quot;JSWebAssemblyInstance.h&quot;
+#include &quot;JSWebAssemblyMemory.h&quot;
</ins><span class="cx"> #include &quot;LLIntData.h&quot;
</span><span class="cx"> #include &quot;LLIntThunks.h&quot;
</span><span class="cx"> #include &quot;ObjectConstructor.h&quot;
</span><span class="lines">@@ -1084,6 +1086,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(WEBASSEMBLY)
</span><span class="cx"> static EncodedJSValue JSC_HOST_CALL functionTestWasmModuleFunctions(ExecState*);
</span><ins>+static EncodedJSValue JSC_HOST_CALL functionWebAssemblyMemoryMode(ExecState*);
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(SAMPLING_FLAGS)
</span><span class="lines">@@ -1358,6 +1361,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(WEBASSEMBLY)
</span><span class="cx">         addFunction(vm, &quot;testWasmModuleFunctions&quot;, functionTestWasmModuleFunctions, 0);
</span><ins>+        addFunction(vm, &quot;WebAssemblyMemoryMode&quot;, functionWebAssemblyMemoryMode, 1);
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">         if (!arguments.isEmpty()) {
</span><span class="lines">@@ -3246,6 +3250,24 @@
</span><span class="cx">     return encodedJSUndefined();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static EncodedJSValue JSC_HOST_CALL functionWebAssemblyMemoryMode(ExecState* exec)
+{
+    VM&amp; vm = exec-&gt;vm();
+    auto scope = DECLARE_THROW_SCOPE(vm);
+    
+    if (!Options::useWebAssembly())
+        return throwVMTypeError(exec, scope, ASCIILiteral(&quot;WebAssemblyMemoryMode should only be called if the useWebAssembly option is set&quot;));
+
+    if (JSObject* object = exec-&gt;argument(0).getObject()) {
+        if (auto* memory = jsDynamicCast&lt;JSWebAssemblyMemory*&gt;(vm, object))
+            return JSValue::encode(jsString(&amp;vm, makeString(memory-&gt;memory().mode())));
+        if (auto* instance = jsDynamicCast&lt;JSWebAssemblyInstance*&gt;(vm, object))
+            return JSValue::encode(jsString(&amp;vm, makeString(instance-&gt;memoryMode())));
+    }
+
+    return throwVMTypeError(exec, scope, ASCIILiteral(&quot;WebAssemblyMemoryMode expects either a WebAssembly.Memory or WebAssembly.Instance&quot;));
+}
+
</ins><span class="cx"> #endif // ENABLE(WEBASSEBLY)
</span><span class="cx"> 
</span><span class="cx"> // Use SEH for Release builds only to get rid of the crash report dialog
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWasmMemoryh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WasmMemory.h (214546 => 214547)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WasmMemory.h        2017-03-29 17:40:21 UTC (rev 214546)
+++ trunk/Source/JavaScriptCore/wasm/WasmMemory.h        2017-03-29 17:44:59 UTC (rev 214547)
</span><span class="lines">@@ -51,7 +51,7 @@
</span><span class="cx">     NumberOfMemoryModes
</span><span class="cx"> };
</span><span class="cx"> static constexpr size_t NumberOfMemoryModes = static_cast&lt;size_t&gt;(MemoryMode::NumberOfMemoryModes);
</span><del>-const char* makeString(MemoryMode);
</del><ins>+JS_EXPORT_PRIVATE const char* makeString(MemoryMode);
</ins><span class="cx"> 
</span><span class="cx"> class Memory : public RefCounted&lt;Memory&gt; {
</span><span class="cx">     WTF_MAKE_NONCOPYABLE(Memory);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsJSWebAssemblyInstanceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.h (214546 => 214547)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.h        2017-03-29 17:40:21 UTC (rev 214546)
+++ trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.h        2017-03-29 17:44:59 UTC (rev 214547)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2016 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -51,7 +51,7 @@
</span><span class="cx">     static JSWebAssemblyInstance* create(VM&amp;, ExecState*, JSWebAssemblyModule*, JSObject* importObject, Structure*);
</span><span class="cx">     static Structure* createStructure(VM&amp;, JSGlobalObject*, JSValue);
</span><span class="cx"> 
</span><del>-    DECLARE_INFO;
</del><ins>+    DECLARE_EXPORT_INFO;
</ins><span class="cx"> 
</span><span class="cx">     JSWebAssemblyCodeBlock* codeBlock() const { return m_codeBlock.get(); }
</span><span class="cx">     bool initialized() const { return codeBlock() &amp;&amp; codeBlock()-&gt;initialized(); }
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsJSWebAssemblyMemoryh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyMemory.h (214546 => 214547)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyMemory.h        2017-03-29 17:40:21 UTC (rev 214546)
+++ trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyMemory.h        2017-03-29 17:44:59 UTC (rev 214547)
</span><span class="lines">@@ -44,7 +44,7 @@
</span><span class="cx">     static JSWebAssemblyMemory* create(VM&amp;, Structure*, Ref&lt;Wasm::Memory&gt;&amp;&amp;);
</span><span class="cx">     static Structure* createStructure(VM&amp;, JSGlobalObject*, JSValue);
</span><span class="cx"> 
</span><del>-    DECLARE_INFO;
</del><ins>+    DECLARE_EXPORT_INFO;
</ins><span class="cx"> 
</span><span class="cx">     Wasm::Memory&amp; memory() { return m_memory.get(); }
</span><span class="cx">     JSArrayBuffer* buffer(VM&amp; vm, JSGlobalObject*);
</span></span></pre>
</div>
</div>

</body>
</html>