<!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>[210073] 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/210073">210073</a></dd>
<dt>Author</dt> <dd>jfbastien@apple.com</dd>
<dt>Date</dt> <dd>2016-12-21 12:34:04 -0800 (Wed, 21 Dec 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>WebAssembly JS API: cleanup &amp; pass VM around to {Compile/Runtime}Error
https://bugs.webkit.org/show_bug.cgi?id=166295
&lt;rdar://problem/29762017&gt;

Reviewed by Mark Lam.

JSTests:

Update tests to generate new error messages. Adapt some to use the
assert.js module.

* wasm/assert.js: allow filtering out sometimes-useless source
location information. Return the exception so that further
processing can occur on it as desired.
* wasm/function-tests/exceptions.js:
* wasm/function-tests/trap-load-2.js:
(assert): Deleted.
(i.catch): Deleted.
* wasm/function-tests/trap-load.js:
(assert): Deleted.
(i.catch): Deleted.
* wasm/function-tests/trap-store-2.js:
(import.Builder.from.string_appeared_here.assert): Deleted.
(i.catch): Deleted.
* wasm/function-tests/trap-store.js:
(import.Builder.from.string_appeared_here.assert): Deleted.
(i.catch): Deleted.

Source/JavaScriptCore:

Rename the create* functions, and pass VM around, as suggested for
LinkError in #165805.

At the same time, use the default source appender when
constructing these error types, which gives a nice map back to the
original source as part of the error message. This is clearer when
using the current frame, so add that as well.

* jit/ThunkGenerators.cpp:
(JSC::throwExceptionFromWasmThunkGenerator):
* wasm/js/JSWebAssemblyCompileError.cpp:
(JSC::JSWebAssemblyCompileError::create):
(JSC::createJSWebAssemblyCompileError):
(JSC::createWebAssemblyCompileError): Deleted.
* wasm/js/JSWebAssemblyCompileError.h:
(JSC::JSWebAssemblyCompileError::create):
* wasm/js/JSWebAssemblyRuntimeError.cpp:
(JSC::JSWebAssemblyRuntimeError::create):
* wasm/js/JSWebAssemblyRuntimeError.h:
(JSC::JSWebAssemblyRuntimeError::create):
* wasm/js/WebAssemblyCompileErrorConstructor.cpp:
(JSC::constructJSWebAssemblyCompileError):
* wasm/js/WebAssemblyModuleConstructor.cpp:
(JSC::WebAssemblyModuleConstructor::createModule):
* wasm/js/WebAssemblyRuntimeErrorConstructor.cpp:
(JSC::constructJSWebAssemblyRuntimeError):</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="#trunkJSTestswasmfunctiontestsexceptionsjs">trunk/JSTests/wasm/function-tests/exceptions.js</a></li>
<li><a href="#trunkJSTestswasmfunctionteststrapload2js">trunk/JSTests/wasm/function-tests/trap-load-2.js</a></li>
<li><a href="#trunkJSTestswasmfunctionteststraploadjs">trunk/JSTests/wasm/function-tests/trap-load.js</a></li>
<li><a href="#trunkJSTestswasmfunctionteststrapstore2js">trunk/JSTests/wasm/function-tests/trap-store-2.js</a></li>
<li><a href="#trunkJSTestswasmfunctionteststrapstorejs">trunk/JSTests/wasm/function-tests/trap-store.js</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCorejitThunkGeneratorscpp">trunk/Source/JavaScriptCore/jit/ThunkGenerators.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsJSWebAssemblyCompileErrorcpp">trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyCompileError.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsJSWebAssemblyCompileErrorh">trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyCompileError.h</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsJSWebAssemblyLinkErrorcpp">trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyLinkError.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsJSWebAssemblyLinkErrorh">trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyLinkError.h</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsJSWebAssemblyRuntimeErrorcpp">trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyRuntimeError.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsJSWebAssemblyRuntimeErrorh">trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyRuntimeError.h</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsWebAssemblyCompileErrorConstructorcpp">trunk/Source/JavaScriptCore/wasm/js/WebAssemblyCompileErrorConstructor.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsWebAssemblyInstanceConstructorcpp">trunk/Source/JavaScriptCore/wasm/js/WebAssemblyInstanceConstructor.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsWebAssemblyLinkErrorConstructorcpp">trunk/Source/JavaScriptCore/wasm/js/WebAssemblyLinkErrorConstructor.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsWebAssemblyModuleConstructorcpp">trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleConstructor.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsWebAssemblyModuleRecordcpp">trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsWebAssemblyRuntimeErrorConstructorcpp">trunk/Source/JavaScriptCore/wasm/js/WebAssemblyRuntimeErrorConstructor.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkJSTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/ChangeLog (210072 => 210073)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/ChangeLog        2016-12-21 20:27:46 UTC (rev 210072)
+++ trunk/JSTests/ChangeLog        2016-12-21 20:34:04 UTC (rev 210073)
</span><span class="lines">@@ -1,3 +1,31 @@
</span><ins>+2016-12-21  JF Bastien  &lt;jfbastien@apple.com&gt;
+
+        WebAssembly JS API: cleanup &amp; pass VM around to {Compile/Runtime}Error
+        https://bugs.webkit.org/show_bug.cgi?id=166295
+        &lt;rdar://problem/29762017&gt;
+
+        Reviewed by Mark Lam.
+
+        Update tests to generate new error messages. Adapt some to use the
+        assert.js module.
+
+        * wasm/assert.js: allow filtering out sometimes-useless source
+        location information. Return the exception so that further
+        processing can occur on it as desired.
+        * wasm/function-tests/exceptions.js:
+        * wasm/function-tests/trap-load-2.js:
+        (assert): Deleted.
+        (i.catch): Deleted.
+        * wasm/function-tests/trap-load.js:
+        (assert): Deleted.
+        (i.catch): Deleted.
+        * wasm/function-tests/trap-store-2.js:
+        (import.Builder.from.string_appeared_here.assert): Deleted.
+        (i.catch): Deleted.
+        * wasm/function-tests/trap-store.js:
+        (import.Builder.from.string_appeared_here.assert): Deleted.
+        (i.catch): Deleted.
+
</ins><span class="cx"> 2016-12-20  Keith Miller  &lt;keith_miller@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Add support for global
</span></span></pre></div>
<a id="trunkJSTestswasmassertjs"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/wasm/assert.js (210072 => 210073)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/wasm/assert.js        2016-12-21 20:27:46 UTC (rev 210072)
+++ trunk/JSTests/wasm/assert.js        2016-12-21 20:34:04 UTC (rev 210073)
</span><span class="lines">@@ -103,12 +103,20 @@
</span><span class="cx">         _fail(`Expected: &quot;${lhs}&quot; &gt; &quot;${rhs}&quot;`, msg);
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+// Ignore source information at the end of the error message if the expected message didn't specify that information. Sometimes it changes, or it's tricky to get just right.
+const _sourceRe = new RegExp(/ \(evaluating '.*'\)/);
+
</ins><span class="cx"> const _throws = (func, type, message, ...args) =&gt; {
</span><span class="cx">     try {
</span><span class="cx">         func(...args);
</span><span class="cx">     } catch (e) {
</span><del>-        if (e instanceof type &amp;&amp; e.message === message)
-            return;
</del><ins>+        if (e instanceof type) {
+            if (e.message === message)
+                return e;
+            const cleanMessage = e.message.replace(_sourceRe, '');
+            if (cleanMessage === message)
+                return e;
+        }
</ins><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 class="cx">     _fail(`Expected to throw a ${type.name} with message &quot;${message}&quot;`);
</span></span></pre></div>
<a id="trunkJSTestswasmfunctiontestsexceptionsjs"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/wasm/function-tests/exceptions.js (210072 => 210073)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/wasm/function-tests/exceptions.js        2016-12-21 20:27:46 UTC (rev 210072)
+++ trunk/JSTests/wasm/function-tests/exceptions.js        2016-12-21 20:34:04 UTC (rev 210073)
</span><span class="lines">@@ -45,7 +45,7 @@
</span><span class="cx">     assert.eq(table.get(0), null);
</span><span class="cx"> 
</span><span class="cx">     for (let i = 0; i &lt; 1000; i++) {
</span><del>-        assert.throws(() =&gt; foo(0, i), WebAssembly.RuntimeError, &quot;call_indirect to a null table entry&quot;);
</del><ins>+        assert.throws(() =&gt; foo(0, i), WebAssembly.RuntimeError, &quot;call_indirect to a null table entry (evaluating 'func(...args)')&quot;);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     table.set(0, foo);
</span><span class="lines">@@ -52,11 +52,11 @@
</span><span class="cx">     assert.eq(table.get(0), foo);
</span><span class="cx"> 
</span><span class="cx">     for (let i = 0; i &lt; 1000; i++) {
</span><del>-        assert.throws(() =&gt; foo(1 + i, i), WebAssembly.RuntimeError, &quot;Out of bounds call_indirect&quot;);
</del><ins>+        assert.throws(() =&gt; foo(1 + i, i), WebAssembly.RuntimeError, &quot;Out of bounds call_indirect (evaluating 'func(...args)')&quot;);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     for (let i = 0; i &lt; 1000; i++) {
</span><del>-        assert.throws(() =&gt; foo(0, i), WebAssembly.RuntimeError, &quot;call_indirect to a signature that does not match&quot;);
</del><ins>+        assert.throws(() =&gt; foo(0, i), WebAssembly.RuntimeError, &quot;call_indirect to a signature that does not match (evaluating 'func(...args)')&quot;);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     table.set(0, bar);
</span></span></pre></div>
<a id="trunkJSTestswasmfunctionteststrapload2js"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/wasm/function-tests/trap-load-2.js (210072 => 210073)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/wasm/function-tests/trap-load-2.js        2016-12-21 20:27:46 UTC (rev 210072)
+++ trunk/JSTests/wasm/function-tests/trap-load-2.js        2016-12-21 20:34:04 UTC (rev 210073)
</span><span class="lines">@@ -1,4 +1,5 @@
</span><span class="cx"> import Builder from '../Builder.js'
</span><ins>+import * as assert from '../assert.js'
</ins><span class="cx"> 
</span><span class="cx"> const pageSize = 64 * 1024;
</span><span class="cx"> const numPages = 10;
</span><span class="lines">@@ -18,11 +19,6 @@
</span><span class="cx">         .End()
</span><span class="cx">     .End();
</span><span class="cx"> 
</span><del>-function assert(b) {
-    if (!b)
-        throw new Error(&quot;Bad&quot;)
-}
-
</del><span class="cx"> function wasmFrameCountFromError(e) {
</span><span class="cx">     let stackFrames = e.stack.split(&quot;\n&quot;).filter((s) =&gt; s.indexOf(&quot;&lt;wasm&gt;@[wasm code]&quot;) !== -1);
</span><span class="cx">     return stackFrames.length;
</span><span class="lines">@@ -70,18 +66,10 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     for (let i = 0; i &lt; 5000; i++) {
</span><del>-        let threw = false;
-        try {
-            foo(5, address);
-        } catch(e) {
-            assert(e instanceof WebAssembly.RuntimeError);
-            assert(e.message === &quot;Out of bounds memory access&quot;);
-            // There are 5 total calls, and each call does:
-            // JS entry, wasm entry, js call stub.
-            // The last call that traps just has JS entry and wasm entry.
-            assert(wasmFrameCountFromError(e) === 5 * 3 + 2);
-            threw = true;
-        }
-        assert(threw);
</del><ins>+        const e = assert.throws(() =&gt; foo(5, address), WebAssembly.RuntimeError, &quot;Out of bounds memory access (evaluating 'foo(x - 1, address)')&quot;);
+        // There are 5 total calls, and each call does:
+        // JS entry, wasm entry, js call stub.
+        // The last call that traps just has JS entry and wasm entry.
+        assert.eq(wasmFrameCountFromError(e), 5 * 3 + 2);
</ins><span class="cx">     }
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkJSTestswasmfunctionteststraploadjs"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/wasm/function-tests/trap-load.js (210072 => 210073)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/wasm/function-tests/trap-load.js        2016-12-21 20:27:46 UTC (rev 210072)
+++ trunk/JSTests/wasm/function-tests/trap-load.js        2016-12-21 20:34:04 UTC (rev 210073)
</span><span class="lines">@@ -1,4 +1,5 @@
</span><span class="cx"> import Builder from '../Builder.js'
</span><ins>+import * as assert from '../assert.js'
</ins><span class="cx"> 
</span><span class="cx"> const pageSize = 64 * 1024;
</span><span class="cx"> const numPages = 10;
</span><span class="lines">@@ -22,11 +23,6 @@
</span><span class="cx"> const module = new WebAssembly.Module(bin);
</span><span class="cx"> const foo = new WebAssembly.Instance(module, {a: {b: new WebAssembly.Memory({initial: numPages})}}).exports.foo;
</span><span class="cx"> 
</span><del>-function assert(b) {
-    if (!b)
-        throw new Error(&quot;Bad&quot;)
-}
-
</del><span class="cx"> function wasmFrameCountFromError(e) {
</span><span class="cx">     let stackFrames = e.stack.split(&quot;\n&quot;).filter((s) =&gt; s.indexOf(&quot;&lt;wasm&gt;@[wasm code]&quot;) !== -1);
</span><span class="cx">     return stackFrames.length;
</span><span class="lines">@@ -33,14 +29,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> for (let i = 0; i &lt; 1000; i++) {
</span><del>-    let threw = false;
-    try {
-        foo(numPages * pageSize + 1);
-    } catch(e) {
-        assert(e instanceof WebAssembly.RuntimeError);
-        assert(e.message === &quot;Out of bounds memory access&quot;);
-        threw = true;
-        assert(wasmFrameCountFromError(e) === 2);
-    }
-    assert(threw);
</del><ins>+    const e = assert.throws(() =&gt; foo(numPages * pageSize + 1), WebAssembly.RuntimeError, &quot;Out of bounds memory access (evaluating 'func(...args)')&quot;);
+    assert.eq(wasmFrameCountFromError(e), 2);
</ins><span class="cx"> }
</span></span></pre></div>
<a id="trunkJSTestswasmfunctionteststrapstore2js"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/wasm/function-tests/trap-store-2.js (210072 => 210073)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/wasm/function-tests/trap-store-2.js        2016-12-21 20:27:46 UTC (rev 210072)
+++ trunk/JSTests/wasm/function-tests/trap-store-2.js        2016-12-21 20:34:04 UTC (rev 210073)
</span><span class="lines">@@ -1,10 +1,6 @@
</span><span class="cx"> import Builder from '../Builder.js'
</span><ins>+import * as assert from '../assert.js'
</ins><span class="cx"> 
</span><del>-function assert(b) {
-    if (!b)
-        throw new Error(&quot;Bad&quot;)
-}
-
</del><span class="cx"> const pageSize = 64 * 1024;
</span><span class="cx"> const numPages = 10;
</span><span class="cx"> 
</span><span class="lines">@@ -49,15 +45,6 @@
</span><span class="cx">         foo(x - 1, address);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    for (let i = 0; i &lt; 5000; i++) {
-        let threw = false;
-        try {
-            foo(6, address);
-        } catch(e) {
-            assert(e instanceof WebAssembly.RuntimeError);
-            assert(e.message === &quot;Out of bounds memory access&quot;);
-            threw = true;
-        }
-        assert(threw);
-    }
</del><ins>+    for (let i = 0; i &lt; 5000; i++)
+        assert.throws(() =&gt; foo(6, address), WebAssembly.RuntimeError, &quot;Out of bounds memory access&quot;);
</ins><span class="cx"> }
</span></span></pre></div>
<a id="trunkJSTestswasmfunctionteststrapstorejs"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/wasm/function-tests/trap-store.js (210072 => 210073)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/wasm/function-tests/trap-store.js        2016-12-21 20:27:46 UTC (rev 210072)
+++ trunk/JSTests/wasm/function-tests/trap-store.js        2016-12-21 20:34:04 UTC (rev 210073)
</span><span class="lines">@@ -1,10 +1,6 @@
</span><span class="cx"> import Builder from '../Builder.js'
</span><ins>+import * as assert from '../assert.js'
</ins><span class="cx"> 
</span><del>-function assert(b) {
-    if (!b)
-        throw new Error(&quot;Bad&quot;)
-}
-
</del><span class="cx"> const pageSize = 64 * 1024;
</span><span class="cx"> const numPages = 10;
</span><span class="cx"> 
</span><span class="lines">@@ -28,15 +24,6 @@
</span><span class="cx">     const module = new WebAssembly.Module(bin);
</span><span class="cx">     const foo = new WebAssembly.Instance(module, {a: {b: new WebAssembly.Memory({initial: numPages})}}).exports.foo;
</span><span class="cx"> 
</span><del>-    for (let i = 0; i &lt; 10000; i++) {
-        let threw = false;
-        try {
-            foo(i, numPages * pageSize + 1);
-        } catch(e) {
-            assert(e instanceof WebAssembly.RuntimeError);
-            assert(e.message === &quot;Out of bounds memory access&quot;);
-            threw = true;
-        }
-        assert(threw);
-    }
</del><ins>+    for (let i = 0; i &lt; 10000; i++)
+        assert.throws(() =&gt; foo(i, numPages * pageSize + 1), WebAssembly.RuntimeError, &quot;Out of bounds memory access (evaluating 'func(...args)')&quot;);
</ins><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (210072 => 210073)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-12-21 20:27:46 UTC (rev 210072)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-12-21 20:34:04 UTC (rev 210073)
</span><span class="lines">@@ -1,3 +1,38 @@
</span><ins>+2016-12-21  JF Bastien  &lt;jfbastien@apple.com&gt;
+
+        WebAssembly JS API: cleanup &amp; pass VM around to {Compile/Runtime}Error
+        https://bugs.webkit.org/show_bug.cgi?id=166295
+        &lt;rdar://problem/29762017&gt;
+
+        Reviewed by Mark Lam.
+
+        Rename the create* functions, and pass VM around, as suggested for
+        LinkError in #165805.
+
+        At the same time, use the default source appender when
+        constructing these error types, which gives a nice map back to the
+        original source as part of the error message. This is clearer when
+        using the current frame, so add that as well.
+
+        * jit/ThunkGenerators.cpp:
+        (JSC::throwExceptionFromWasmThunkGenerator):
+        * wasm/js/JSWebAssemblyCompileError.cpp:
+        (JSC::JSWebAssemblyCompileError::create):
+        (JSC::createJSWebAssemblyCompileError):
+        (JSC::createWebAssemblyCompileError): Deleted.
+        * wasm/js/JSWebAssemblyCompileError.h:
+        (JSC::JSWebAssemblyCompileError::create):
+        * wasm/js/JSWebAssemblyRuntimeError.cpp:
+        (JSC::JSWebAssemblyRuntimeError::create):
+        * wasm/js/JSWebAssemblyRuntimeError.h:
+        (JSC::JSWebAssemblyRuntimeError::create):
+        * wasm/js/WebAssemblyCompileErrorConstructor.cpp:
+        (JSC::constructJSWebAssemblyCompileError):
+        * wasm/js/WebAssemblyModuleConstructor.cpp:
+        (JSC::WebAssemblyModuleConstructor::createModule):
+        * wasm/js/WebAssemblyRuntimeErrorConstructor.cpp:
+        (JSC::constructJSWebAssemblyRuntimeError):
+
</ins><span class="cx"> 2016-12-21  Yusuke Suzuki  &lt;utatane.tea@gmail.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [ES6] Fix modules document in features.json
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitThunkGeneratorscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/ThunkGenerators.cpp (210072 => 210073)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/ThunkGenerators.cpp        2016-12-21 20:27:46 UTC (rev 210072)
+++ trunk/Source/JavaScriptCore/jit/ThunkGenerators.cpp        2016-12-21 20:34:04 UTC (rev 210073)
</span><span class="lines">@@ -1155,8 +1155,7 @@
</span><span class="cx">             auto throwScope = DECLARE_THROW_SCOPE(*vm);
</span><span class="cx">             JSGlobalObject* globalObject = vm-&gt;topJSWebAssemblyInstance-&gt;globalObject();
</span><span class="cx"> 
</span><del>-            JSWebAssemblyRuntimeError* error = JSWebAssemblyRuntimeError::create(
-                exec, globalObject-&gt;WebAssemblyRuntimeErrorStructure(), Wasm::errorMessageForExceptionType(type));
</del><ins>+            JSWebAssemblyRuntimeError* error = JSWebAssemblyRuntimeError::create(exec, *vm, globalObject-&gt;WebAssemblyRuntimeErrorStructure(), Wasm::errorMessageForExceptionType(type));
</ins><span class="cx">             throwException(exec, throwScope, error);
</span><span class="cx">         }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsJSWebAssemblyCompileErrorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyCompileError.cpp (210072 => 210073)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyCompileError.cpp        2016-12-21 20:27:46 UTC (rev 210072)
+++ trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyCompileError.cpp        2016-12-21 20:34:04 UTC (rev 210073)
</span><span class="lines">@@ -32,10 +32,11 @@
</span><span class="cx"> 
</span><span class="cx"> namespace JSC {
</span><span class="cx"> 
</span><del>-JSWebAssemblyCompileError* JSWebAssemblyCompileError::create(ExecState* state, Structure* structure, const String&amp; message, bool useCurrentFrame)
</del><ins>+JSWebAssemblyCompileError* JSWebAssemblyCompileError::create(ExecState* state, VM&amp; vm, Structure* structure, const String&amp; message)
</ins><span class="cx"> {
</span><del>-    auto&amp; vm = state-&gt;vm();
</del><span class="cx">     auto* instance = new (NotNull, allocateCell&lt;JSWebAssemblyCompileError&gt;(vm.heap)) JSWebAssemblyCompileError(vm, structure);
</span><ins>+    instance-&gt;m_sourceAppender = defaultSourceAppender;
+    bool useCurrentFrame = true;
</ins><span class="cx">     instance-&gt;finishCreation(state, vm, message, useCurrentFrame);
</span><span class="cx">     return instance;
</span><span class="cx"> }
</span><span class="lines">@@ -48,11 +49,11 @@
</span><span class="cx"> const ClassInfo JSWebAssemblyCompileError::s_info = { &quot;WebAssembly.CompileError&quot;, &amp;Base::s_info, 0, CREATE_METHOD_TABLE(JSWebAssemblyCompileError) };
</span><span class="cx"> 
</span><span class="cx">     
</span><del>-JSObject* createWebAssemblyCompileError(ExecState* exec, const String&amp; message)
</del><ins>+JSObject* createJSWebAssemblyCompileError(ExecState* state, VM&amp; vm, const String&amp; message)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(!message.isEmpty());
</span><del>-    JSGlobalObject* globalObject = exec-&gt;lexicalGlobalObject();
-    return ErrorInstance::create(exec, globalObject-&gt;vm(), globalObject-&gt;WebAssemblyCompileErrorStructure(), message, defaultSourceAppender, TypeNothing, true);
</del><ins>+    JSGlobalObject* globalObject = state-&gt;lexicalGlobalObject();
+    return JSWebAssemblyCompileError::create(state, vm, globalObject-&gt;WebAssemblyCompileErrorStructure(), message);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace JSC
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsJSWebAssemblyCompileErrorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyCompileError.h (210072 => 210073)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyCompileError.h        2016-12-21 20:27:46 UTC (rev 210072)
+++ trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyCompileError.h        2016-12-21 20:34:04 UTC (rev 210073)
</span><span class="lines">@@ -35,10 +35,10 @@
</span><span class="cx"> public:
</span><span class="cx">     typedef ErrorInstance Base;
</span><span class="cx"> 
</span><del>-    static JSWebAssemblyCompileError* create(ExecState*, Structure*, const String&amp;, bool);
-    static JSWebAssemblyCompileError* create(ExecState* exec, Structure* structure, JSValue message, bool useCurrentFrame)
</del><ins>+    static JSWebAssemblyCompileError* create(ExecState*, VM&amp;, Structure*, const String&amp;);
+    static JSWebAssemblyCompileError* create(ExecState* state, VM&amp; vm, Structure* structure, JSValue message)
</ins><span class="cx">     {
</span><del>-        return create(exec, structure, message.isUndefined() ? String() : message.toWTFString(exec), useCurrentFrame);
</del><ins>+        return create(state, vm, structure, message.isUndefined() ? String() : message.toWTFString(state));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     DECLARE_INFO;
</span><span class="lines">@@ -47,7 +47,7 @@
</span><span class="cx">     JSWebAssemblyCompileError(VM&amp;, Structure*);
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-JSObject* createWebAssemblyCompileError(ExecState*, const String&amp;);
</del><ins>+JSObject* createJSWebAssemblyCompileError(ExecState*, VM&amp;, const String&amp;);
</ins><span class="cx"> 
</span><span class="cx"> } // namespace JSC
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsJSWebAssemblyLinkErrorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyLinkError.cpp (210072 => 210073)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyLinkError.cpp        2016-12-21 20:27:46 UTC (rev 210072)
+++ trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyLinkError.cpp        2016-12-21 20:34:04 UTC (rev 210073)
</span><span class="lines">@@ -32,11 +32,12 @@
</span><span class="cx"> 
</span><span class="cx"> namespace JSC {
</span><span class="cx"> 
</span><del>-JSWebAssemblyLinkError* JSWebAssemblyLinkError::create(ExecState* state, VM* vm, Structure* structure, const String&amp; message)
</del><ins>+JSWebAssemblyLinkError* JSWebAssemblyLinkError::create(ExecState* state, VM&amp; vm, Structure* structure, const String&amp; message)
</ins><span class="cx"> {
</span><del>-    auto* instance = new (NotNull, allocateCell&lt;JSWebAssemblyLinkError&gt;(vm-&gt;heap)) JSWebAssemblyLinkError(*vm, structure);
</del><ins>+    auto* instance = new (NotNull, allocateCell&lt;JSWebAssemblyLinkError&gt;(vm.heap)) JSWebAssemblyLinkError(vm, structure);
</ins><span class="cx">     instance-&gt;m_sourceAppender = defaultSourceAppender;
</span><del>-    instance-&gt;finishCreation(state, *vm, message, true);
</del><ins>+    bool useCurrentFrame = true;
+    instance-&gt;finishCreation(state, vm, message, useCurrentFrame);
</ins><span class="cx">     return instance;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -48,7 +49,7 @@
</span><span class="cx"> const ClassInfo JSWebAssemblyLinkError::s_info = { &quot;WebAssembly.LinkError&quot;, &amp;Base::s_info, 0, CREATE_METHOD_TABLE(JSWebAssemblyLinkError) };
</span><span class="cx"> 
</span><span class="cx">     
</span><del>-JSObject* createJSWebAssemblyLinkError(ExecState* state, VM* vm, const String&amp; message)
</del><ins>+JSObject* createJSWebAssemblyLinkError(ExecState* state, VM&amp; vm, const String&amp; message)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(!message.isEmpty());
</span><span class="cx">     JSGlobalObject* globalObject = state-&gt;lexicalGlobalObject();
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsJSWebAssemblyLinkErrorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyLinkError.h (210072 => 210073)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyLinkError.h        2016-12-21 20:27:46 UTC (rev 210072)
+++ trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyLinkError.h        2016-12-21 20:34:04 UTC (rev 210073)
</span><span class="lines">@@ -35,8 +35,8 @@
</span><span class="cx"> public:
</span><span class="cx">     typedef ErrorInstance Base;
</span><span class="cx"> 
</span><del>-    static JSWebAssemblyLinkError* create(ExecState*, VM*, Structure*, const String&amp;);
-    static JSWebAssemblyLinkError* create(ExecState* state, VM* vm, Structure* structure, JSValue message)
</del><ins>+    static JSWebAssemblyLinkError* create(ExecState*, VM&amp;, Structure*, const String&amp;);
+    static JSWebAssemblyLinkError* create(ExecState* state, VM&amp; vm, Structure* structure, JSValue message)
</ins><span class="cx">     {
</span><span class="cx">         return create(state, vm, structure, message.isUndefined() ? String() : message.toWTFString(state));
</span><span class="cx">     }
</span><span class="lines">@@ -47,7 +47,7 @@
</span><span class="cx">     JSWebAssemblyLinkError(VM&amp;, Structure*);
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-JSObject* createJSWebAssemblyLinkError(ExecState*, VM*, const String&amp;);
</del><ins>+JSObject* createJSWebAssemblyLinkError(ExecState*, VM&amp;, const String&amp;);
</ins><span class="cx"> 
</span><span class="cx"> } // namespace JSC
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsJSWebAssemblyRuntimeErrorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyRuntimeError.cpp (210072 => 210073)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyRuntimeError.cpp        2016-12-21 20:27:46 UTC (rev 210072)
+++ trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyRuntimeError.cpp        2016-12-21 20:34:04 UTC (rev 210073)
</span><span class="lines">@@ -32,10 +32,11 @@
</span><span class="cx"> 
</span><span class="cx"> namespace JSC {
</span><span class="cx"> 
</span><del>-JSWebAssemblyRuntimeError* JSWebAssemblyRuntimeError::create(ExecState* state, Structure* structure, const String&amp; message, bool useCurrentFrame)
</del><ins>+JSWebAssemblyRuntimeError* JSWebAssemblyRuntimeError::create(ExecState* state, VM&amp; vm, Structure* structure, const String&amp; message)
</ins><span class="cx"> {
</span><del>-    auto&amp; vm = state-&gt;vm();
</del><span class="cx">     auto* instance = new (NotNull, allocateCell&lt;JSWebAssemblyRuntimeError&gt;(vm.heap)) JSWebAssemblyRuntimeError(vm, structure);
</span><ins>+    instance-&gt;m_sourceAppender = defaultSourceAppender;
+    bool useCurrentFrame = true;
</ins><span class="cx">     instance-&gt;finishCreation(state, vm, message, useCurrentFrame);
</span><span class="cx">     return instance;
</span><span class="cx"> }
</span><span class="lines">@@ -47,6 +48,7 @@
</span><span class="cx"> 
</span><span class="cx"> const ClassInfo JSWebAssemblyRuntimeError::s_info = { &quot;WebAssembly.RuntimeError&quot;, &amp;Base::s_info, 0, CREATE_METHOD_TABLE(JSWebAssemblyRuntimeError) };
</span><span class="cx"> 
</span><ins>+    
</ins><span class="cx"> } // namespace JSC
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(WEBASSEMBLY)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsJSWebAssemblyRuntimeErrorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyRuntimeError.h (210072 => 210073)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyRuntimeError.h        2016-12-21 20:27:46 UTC (rev 210072)
+++ trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyRuntimeError.h        2016-12-21 20:34:04 UTC (rev 210073)
</span><span class="lines">@@ -35,10 +35,10 @@
</span><span class="cx"> public:
</span><span class="cx">     typedef ErrorInstance Base;
</span><span class="cx"> 
</span><del>-    static JSWebAssemblyRuntimeError* create(ExecState*, Structure*, const String&amp;, bool useCurrentFrame = true);
-    static JSWebAssemblyRuntimeError* create(ExecState* exec, Structure* structure, JSValue message, bool useCurrentFrame)
</del><ins>+    static JSWebAssemblyRuntimeError* create(ExecState*, VM&amp;, Structure*, const String&amp;);
+    static JSWebAssemblyRuntimeError* create(ExecState* state, VM&amp; vm, Structure* structure, JSValue message)
</ins><span class="cx">     {
</span><del>-        return create(exec, structure, message.isUndefined() ? String() : message.toWTFString(exec), useCurrentFrame);
</del><ins>+        return create(state, vm, structure, message.isUndefined() ? String() : message.toWTFString(state));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     DECLARE_INFO;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsWebAssemblyCompileErrorConstructorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/WebAssemblyCompileErrorConstructor.cpp (210072 => 210073)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/WebAssemblyCompileErrorConstructor.cpp        2016-12-21 20:27:46 UTC (rev 210072)
+++ trunk/Source/JavaScriptCore/wasm/js/WebAssemblyCompileErrorConstructor.cpp        2016-12-21 20:34:04 UTC (rev 210073)
</span><span class="lines">@@ -51,7 +51,7 @@
</span><span class="cx">     JSValue message = state-&gt;argument(0);
</span><span class="cx">     auto* structure = InternalFunction::createSubclassStructure(state, state-&gt;newTarget(), asInternalFunction(state-&gt;jsCallee())-&gt;globalObject()-&gt;WebAssemblyCompileErrorStructure());
</span><span class="cx">     RETURN_IF_EXCEPTION(scope, encodedJSValue());
</span><del>-    return JSValue::encode(JSWebAssemblyCompileError::create(state, structure, message, false));
</del><ins>+    return JSValue::encode(JSWebAssemblyCompileError::create(state, vm, structure, message));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static EncodedJSValue JSC_HOST_CALL callJSWebAssemblyCompileError(ExecState* state)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsWebAssemblyInstanceConstructorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/WebAssemblyInstanceConstructor.cpp (210072 => 210073)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/WebAssemblyInstanceConstructor.cpp        2016-12-21 20:27:46 UTC (rev 210072)
+++ trunk/Source/JavaScriptCore/wasm/js/WebAssemblyInstanceConstructor.cpp        2016-12-21 20:34:04 UTC (rev 210073)
</span><span class="lines">@@ -111,7 +111,7 @@
</span><span class="cx">             // 4. If i is a function import:
</span><span class="cx">             // i. If IsCallable(v) is false, throw a WebAssembly.LinkError.
</span><span class="cx">             if (!value.isFunction())
</span><del>-                return JSValue::encode(throwException(exec, throwScope, createJSWebAssemblyLinkError(exec, &amp;vm, ASCIILiteral(&quot;import function must be callable&quot;))));
</del><ins>+                return JSValue::encode(throwException(exec, throwScope, createJSWebAssemblyLinkError(exec, vm, ASCIILiteral(&quot;import function must be callable&quot;))));
</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">@@ -137,22 +137,22 @@
</span><span class="cx">             JSWebAssemblyTable* table = jsDynamicCast&lt;JSWebAssemblyTable*&gt;(value);
</span><span class="cx">             // i. If v is not a WebAssembly.Table object, throw a WebAssembly.LinkError.
</span><span class="cx">             if (!table)
</span><del>-                return JSValue::encode(throwException(exec, throwScope, createJSWebAssemblyLinkError(exec, &amp;vm, ASCIILiteral(&quot;Table import is not an instance of WebAssembly.Table&quot;))));
</del><ins>+                return JSValue::encode(throwException(exec, throwScope, createJSWebAssemblyLinkError(exec, vm, ASCIILiteral(&quot;Table import is not an instance of WebAssembly.Table&quot;))));
</ins><span class="cx"> 
</span><span class="cx">             uint32_t expectedInitial = moduleInformation.tableInformation.initial();
</span><span class="cx">             uint32_t actualInitial = table-&gt;size();
</span><span class="cx">             if (actualInitial &lt; expectedInitial)
</span><del>-                return JSValue::encode(throwException(exec, throwScope, createJSWebAssemblyLinkError(exec, &amp;vm, ASCIILiteral(&quot;Table import provided an 'initial' that is too small&quot;))));
</del><ins>+                return JSValue::encode(throwException(exec, throwScope, createJSWebAssemblyLinkError(exec, vm, ASCIILiteral(&quot;Table import provided an 'initial' that is too small&quot;))));
</ins><span class="cx"> 
</span><span class="cx">             if (std::optional&lt;uint32_t&gt; expectedMaximum = moduleInformation.tableInformation.maximum()) {
</span><span class="cx">                 std::optional&lt;uint32_t&gt; actualMaximum = table-&gt;maximum();
</span><span class="cx">                 if (!actualMaximum) {
</span><span class="cx">                     return JSValue::encode(
</span><del>-                        throwException(exec, throwScope, createJSWebAssemblyLinkError(exec, &amp;vm, ASCIILiteral(&quot;Table import does not have a 'maximum' but the module requires that it does&quot;))));
</del><ins>+                        throwException(exec, throwScope, createJSWebAssemblyLinkError(exec, vm, ASCIILiteral(&quot;Table import does not have a 'maximum' but the module requires that it does&quot;))));
</ins><span class="cx">                 }
</span><span class="cx">                 if (*actualMaximum &gt; *expectedMaximum) {
</span><span class="cx">                     return JSValue::encode(
</span><del>-                        throwException(exec, throwScope, createJSWebAssemblyLinkError(exec, &amp;vm, ASCIILiteral(&quot;Imported Table's 'maximum' is larger than the module's expected 'maximum'&quot;))));
</del><ins>+                        throwException(exec, throwScope, createJSWebAssemblyLinkError(exec, vm, ASCIILiteral(&quot;Imported Table's 'maximum' is larger than the module's expected 'maximum'&quot;))));
</ins><span class="cx">                 }
</span><span class="cx">             }
</span><span class="cx"> 
</span><span class="lines">@@ -169,23 +169,23 @@
</span><span class="cx">             JSWebAssemblyMemory* memory = jsDynamicCast&lt;JSWebAssemblyMemory*&gt;(value);
</span><span class="cx">             // i. If v is not a WebAssembly.Memory object, throw a WebAssembly.LinkError.
</span><span class="cx">             if (!memory)
</span><del>-                return JSValue::encode(throwException(exec, throwScope, createJSWebAssemblyLinkError(exec, &amp;vm, ASCIILiteral(&quot;Memory import is not an instance of WebAssembly.Memory&quot;))));
</del><ins>+                return JSValue::encode(throwException(exec, throwScope, createJSWebAssemblyLinkError(exec, vm, ASCIILiteral(&quot;Memory import is not an instance of WebAssembly.Memory&quot;))));
</ins><span class="cx"> 
</span><span class="cx">             Wasm::PageCount expectedInitial = moduleInformation.memory.initial();
</span><span class="cx">             Wasm::PageCount actualInitial = memory-&gt;memory()-&gt;initial();
</span><span class="cx">             if (actualInitial &lt; expectedInitial)
</span><del>-                return JSValue::encode(throwException(exec, throwScope, createJSWebAssemblyLinkError(exec, &amp;vm, ASCIILiteral(&quot;Memory import provided an 'initial' that is too small&quot;))));
</del><ins>+                return JSValue::encode(throwException(exec, throwScope, createJSWebAssemblyLinkError(exec, vm, ASCIILiteral(&quot;Memory import provided an 'initial' that is too small&quot;))));
</ins><span class="cx"> 
</span><span class="cx">             if (Wasm::PageCount expectedMaximum = moduleInformation.memory.maximum()) {
</span><span class="cx">                 Wasm::PageCount actualMaximum = memory-&gt;memory()-&gt;maximum();
</span><span class="cx">                 if (!actualMaximum) {
</span><span class="cx">                     return JSValue::encode(
</span><del>-                        throwException(exec, throwScope, createJSWebAssemblyLinkError(exec, &amp;vm, ASCIILiteral(&quot;Memory import did not have a 'maximum' but the module requires that it does&quot;))));
</del><ins>+                        throwException(exec, throwScope, createJSWebAssemblyLinkError(exec, vm, ASCIILiteral(&quot;Memory import did not have a 'maximum' but the module requires that it does&quot;))));
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 if (actualMaximum &gt; expectedMaximum) {
</span><span class="cx">                     return JSValue::encode(
</span><del>-                        throwException(exec, throwScope, createJSWebAssemblyLinkError(exec, &amp;vm, ASCIILiteral(&quot;Memory imports 'maximum' is larger than the module's expected 'maximum'&quot;))));
</del><ins>+                        throwException(exec, throwScope, createJSWebAssemblyLinkError(exec, vm, ASCIILiteral(&quot;Memory imports 'maximum' is larger than the module's expected 'maximum'&quot;))));
</ins><span class="cx">                 }
</span><span class="cx">             }
</span><span class="cx">             // ii. Append v to memories.
</span><span class="lines">@@ -199,7 +199,7 @@
</span><span class="cx">             ASSERT(moduleInformation.globals[import.kindIndex].mutability == Wasm::Global::Immutable);
</span><span class="cx">             // ii. If Type(v) is not Number, throw a TypeError.
</span><span class="cx">             if (!value.isNumber())
</span><del>-                return JSValue::encode(throwException(exec, throwScope, createJSWebAssemblyLinkError(exec, &amp;vm, ASCIILiteral(&quot;imported global must be a number&quot;))));
</del><ins>+                return JSValue::encode(throwException(exec, throwScope, createJSWebAssemblyLinkError(exec, vm, ASCIILiteral(&quot;imported global must be a number&quot;))));
</ins><span class="cx">             // iii. Append ToWebAssemblyValue(v) to imports.
</span><span class="cx">             switch (moduleInformation.globals[import.kindIndex].type) {
</span><span class="cx">             case Wasm::I32:
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsWebAssemblyLinkErrorConstructorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/WebAssemblyLinkErrorConstructor.cpp (210072 => 210073)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/WebAssemblyLinkErrorConstructor.cpp        2016-12-21 20:27:46 UTC (rev 210072)
+++ trunk/Source/JavaScriptCore/wasm/js/WebAssemblyLinkErrorConstructor.cpp        2016-12-21 20:34:04 UTC (rev 210073)
</span><span class="lines">@@ -51,7 +51,7 @@
</span><span class="cx">     JSValue message = state-&gt;argument(0);
</span><span class="cx">     auto* structure = InternalFunction::createSubclassStructure(state, state-&gt;newTarget(), asInternalFunction(state-&gt;jsCallee())-&gt;globalObject()-&gt;WebAssemblyLinkErrorStructure());
</span><span class="cx">     RETURN_IF_EXCEPTION(scope, encodedJSValue());
</span><del>-    return JSValue::encode(JSWebAssemblyLinkError::create(state, &amp;vm, structure, message));
</del><ins>+    return JSValue::encode(JSWebAssemblyLinkError::create(state, vm, structure, message));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static EncodedJSValue JSC_HOST_CALL callJSWebAssemblyLinkError(ExecState* state)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsWebAssemblyModuleConstructorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleConstructor.cpp (210072 => 210073)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleConstructor.cpp        2016-12-21 20:27:46 UTC (rev 210072)
+++ trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleConstructor.cpp        2016-12-21 20:34:04 UTC (rev 210073)
</span><span class="lines">@@ -84,7 +84,7 @@
</span><span class="cx">     // On failure, a new WebAssembly.CompileError is thrown.
</span><span class="cx">     plan.run();
</span><span class="cx">     if (plan.failed())
</span><del>-        return throwException(state, scope, createWebAssemblyCompileError(state, plan.errorMessage()));
</del><ins>+        return throwException(state, scope, createJSWebAssemblyCompileError(state, vm, plan.errorMessage()));
</ins><span class="cx"> 
</span><span class="cx">     // On success, a new WebAssembly.Module object is returned with [[Module]] set to the validated Ast.module.
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsWebAssemblyModuleRecordcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.cpp (210072 => 210073)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.cpp        2016-12-21 20:27:46 UTC (rev 210072)
+++ trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.cpp        2016-12-21 20:34:04 UTC (rev 210073)
</span><span class="lines">@@ -199,7 +199,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template &lt;typename Scope, typename N, typename ...Args&gt;
</span><del>-NEVER_INLINE static JSValue dataSegmentFail(ExecState* state, VM* vm, Scope&amp; scope, N memorySize, N segmentSize, N offset, Args... args)
</del><ins>+NEVER_INLINE static JSValue dataSegmentFail(ExecState* state, VM&amp; vm, Scope&amp; scope, N memorySize, N segmentSize, N offset, Args... args)
</ins><span class="cx"> {
</span><span class="cx">     return throwException(state, scope, createJSWebAssemblyLinkError(state, vm, makeString(ASCIILiteral(&quot;Invalid data segment initialization: segment of &quot;), String::number(segmentSize), ASCIILiteral(&quot; bytes memory of &quot;), String::number(memorySize), ASCIILiteral(&quot; bytes, at offset &quot;), String::number(offset), args...)));
</span><span class="cx"> }
</span><span class="lines">@@ -225,7 +225,7 @@
</span><span class="cx">             uint32_t tableIndex = element.offset;
</span><span class="cx">             uint64_t lastWrittenIndex = static_cast&lt;uint64_t&gt;(tableIndex) + static_cast&lt;uint64_t&gt;(element.functionIndices.size()) - 1;
</span><span class="cx">             if (lastWrittenIndex &gt;= table-&gt;size())
</span><del>-                return throwException(state, scope, createJSWebAssemblyLinkError(state, &amp;vm, ASCIILiteral(&quot;Element is trying to set an out of bounds table index&quot;)));
</del><ins>+                return throwException(state, scope, createJSWebAssemblyLinkError(state, vm, ASCIILiteral(&quot;Element is trying to set an out of bounds table index&quot;)));
</ins><span class="cx"> 
</span><span class="cx">             for (uint32_t i = 0; i &lt; element.functionIndices.size(); ++i) {
</span><span class="cx">                 // FIXME: This essentially means we're exporting an import.
</span><span class="lines">@@ -266,9 +266,9 @@
</span><span class="cx">             for (auto&amp; segment : data) {
</span><span class="cx">                 if (segment-&gt;sizeInBytes) {
</span><span class="cx">                     if (UNLIKELY(sizeInBytes &lt; segment-&gt;sizeInBytes))
</span><del>-                        return dataSegmentFail(state, &amp;vm, scope, sizeInBytes, segment-&gt;sizeInBytes, segment-&gt;offset, ASCIILiteral(&quot;, segment is too big&quot;));
</del><ins>+                        return dataSegmentFail(state, vm, scope, sizeInBytes, segment-&gt;sizeInBytes, segment-&gt;offset, ASCIILiteral(&quot;, segment is too big&quot;));
</ins><span class="cx">                     if (UNLIKELY(segment-&gt;offset &gt; sizeInBytes - segment-&gt;sizeInBytes))
</span><del>-                        return dataSegmentFail(state, &amp;vm, scope, sizeInBytes, segment-&gt;sizeInBytes, segment-&gt;offset, ASCIILiteral(&quot;, segment writes outside of memory&quot;));
</del><ins>+                        return dataSegmentFail(state, vm, scope, sizeInBytes, segment-&gt;sizeInBytes, segment-&gt;offset, ASCIILiteral(&quot;, segment writes outside of memory&quot;));
</ins><span class="cx">                     memcpy(memory + segment-&gt;offset, &amp;segment-&gt;byte(0), segment-&gt;sizeInBytes);
</span><span class="cx">                 }
</span><span class="cx">             }
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsWebAssemblyRuntimeErrorConstructorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/WebAssemblyRuntimeErrorConstructor.cpp (210072 => 210073)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/WebAssemblyRuntimeErrorConstructor.cpp        2016-12-21 20:27:46 UTC (rev 210072)
+++ trunk/Source/JavaScriptCore/wasm/js/WebAssemblyRuntimeErrorConstructor.cpp        2016-12-21 20:34:04 UTC (rev 210073)
</span><span class="lines">@@ -51,7 +51,7 @@
</span><span class="cx">     JSValue message = state-&gt;argument(0);
</span><span class="cx">     auto* structure = InternalFunction::createSubclassStructure(state, state-&gt;newTarget(), asInternalFunction(state-&gt;jsCallee())-&gt;globalObject()-&gt;WebAssemblyRuntimeErrorStructure());
</span><span class="cx">     RETURN_IF_EXCEPTION(scope, encodedJSValue());
</span><del>-    return JSValue::encode(JSWebAssemblyRuntimeError::create(state, structure, message, false));
</del><ins>+    return JSValue::encode(JSWebAssemblyRuntimeError::create(state, vm, structure, message));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static EncodedJSValue JSC_HOST_CALL callJSWebAssemblyRuntimeError(ExecState* state)
</span></span></pre>
</div>
</div>

</body>
</html>