<!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>[209928] 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/209928">209928</a></dd>
<dt>Author</dt> <dd>sbarati@apple.com</dd>
<dt>Date</dt> <dd>2016-12-16 11:24:06 -0800 (Fri, 16 Dec 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>WebAssembly: WasmB3IRGenerator should throw exceptions instead of crash
https://bugs.webkit.org/show_bug.cgi?id=165834

Reviewed by Keith Miller.

JSTests:

* wasm/function-tests/exceptions.js: Added.
(import.Builder.from.string_appeared_here.import.as.assert.from.string_appeared_here.makeInstance):
* wasm/function-tests/table-basic.js:
(i.i.42.throw.new.Error):

Source/JavaScriptCore:

This patch generalizes how we throw exceptions in the Wasm::B3IRGenerator.
There are still places where we need to throw exceptions and we don't, but
this patch removes most of those places inside the IR generator. There are
still a few places we need to throw exceptions inside the IR generator, like
div/mod by 0. Those will be done in a separate patch. Also, there are
still some stubs we need to throw exceptions from; those will also be
done in a separate patch.

All exceptions thrown from Wasm share a common stub. The ABI for the stub
is to move the Wasm::ExceptionType into argGPR1 and jump to the stub.
The stub will then throw an exception with an error message tailored
to the particular Wasm::ExceptionType failure.

This patch also refactors B3::Compilation. Before, B3::Compilation(VM, Procedure)
constructor would compile a B3 function. This patch makes B3::Compilation a simple
tuple that keeps the necessary bits of B3 function alive in order to be runnable.
There is a new function that actually does the compilation for you. It is:
Compilation B3::compile(VM&amp;, Procedure&amp;)
The reason for this change is that I'm now using B3::Compilation(CodeRef, OpaqueByproducts)
constructor in Wasm code. It is weird to have a class both have a
constructor that instantiates the tuple, and another that performs the
compilation and then instantiates the tuple. It's more straight
forward if Compilation's job wasn't to actually do the compilation
but just to hold the necessary bits to keep a compiled B3 alive.

* CMakeLists.txt:
* JavaScriptCore.xcodeproj/project.pbxproj:
* b3/B3Compilation.cpp:
(JSC::B3::Compilation::Compilation):
* b3/B3Compilation.h:
* b3/B3Compile.cpp: Added.
(JSC::B3::compile):
* b3/B3Compile.h: Added.
* b3/testb3.cpp:
(JSC::B3::compile):
* jit/ThunkGenerators.cpp:
(JSC::throwExceptionFromWasmThunkGenerator):
* jit/ThunkGenerators.h:
* wasm/WasmB3IRGenerator.cpp:
(JSC::Wasm::B3IRGenerator::B3IRGenerator):
(JSC::Wasm::B3IRGenerator::emitExceptionCheck):
(JSC::Wasm::createJSToWasmWrapper):
(JSC::Wasm::parseAndCompile):
* wasm/WasmExceptionType.h: Added.
(JSC::Wasm::errorMessageForExceptionType):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkJSTestsChangeLog">trunk/JSTests/ChangeLog</a></li>
<li><a href="#trunkJSTestswasmfunctionteststablebasicjs">trunk/JSTests/wasm/function-tests/table-basic.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="#trunkSourceJavaScriptCoreb3B3Compilationcpp">trunk/Source/JavaScriptCore/b3/B3Compilation.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreb3B3Compilationh">trunk/Source/JavaScriptCore/b3/B3Compilation.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreb3testb3cpp">trunk/Source/JavaScriptCore/b3/testb3.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorejitThunkGeneratorscpp">trunk/Source/JavaScriptCore/jit/ThunkGenerators.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorejitThunkGeneratorsh">trunk/Source/JavaScriptCore/jit/ThunkGenerators.h</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmWasmB3IRGeneratorcpp">trunk/Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkJSTestswasmfunctiontestsexceptionsjs">trunk/JSTests/wasm/function-tests/exceptions.js</a></li>
<li><a href="#trunkSourceJavaScriptCoreb3B3Compilecpp">trunk/Source/JavaScriptCore/b3/B3Compile.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreb3B3Compileh">trunk/Source/JavaScriptCore/b3/B3Compile.h</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmWasmExceptionTypeh">trunk/Source/JavaScriptCore/wasm/WasmExceptionType.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkJSTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/ChangeLog (209927 => 209928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/ChangeLog        2016-12-16 18:56:24 UTC (rev 209927)
+++ trunk/JSTests/ChangeLog        2016-12-16 19:24:06 UTC (rev 209928)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2016-12-16  Saam Barati  &lt;sbarati@apple.com&gt;
+
+        WebAssembly: WasmB3IRGenerator should throw exceptions instead of crash
+        https://bugs.webkit.org/show_bug.cgi?id=165834
+
+        Reviewed by Keith Miller.
+
+        * wasm/function-tests/exceptions.js: Added.
+        (import.Builder.from.string_appeared_here.import.as.assert.from.string_appeared_here.makeInstance):
+        * wasm/function-tests/table-basic.js:
+        (i.i.42.throw.new.Error):
+
</ins><span class="cx"> 2016-12-16  Keith Miller  &lt;keith_miller@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         i64.eqz should use an Int64 zero
</span></span></pre></div>
<a id="trunkJSTestswasmfunctiontestsexceptionsjsfromrev209927trunkJSTestswasmfunctionteststablebasicjs"></a>
<div class="copfile"><h4>Copied: trunk/JSTests/wasm/function-tests/exceptions.js (from rev 209927, trunk/JSTests/wasm/function-tests/table-basic.js) (0 => 209928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/wasm/function-tests/exceptions.js                                (rev 0)
+++ trunk/JSTests/wasm/function-tests/exceptions.js        2016-12-16 19:24:06 UTC (rev 209928)
</span><span class="lines">@@ -0,0 +1,67 @@
</span><ins>+import Builder from '../Builder.js'
+import * as assert from '../assert.js'
+
+function makeInstance() {
+    const tableDescription = {initial: 1, element: &quot;anyfunc&quot;};
+    const builder = new Builder()
+        .Type()
+            .Func([&quot;i32&quot;, &quot;i32&quot;], &quot;i32&quot;)
+            .Func([&quot;i32&quot;], &quot;i32&quot;)
+        .End()
+        .Import()
+            .Table(&quot;imp&quot;, &quot;table&quot;, tableDescription)
+        .End()
+        .Function().End()
+        .Export()
+            .Function(&quot;foo&quot;)
+            .Function(&quot;bar&quot;)
+        .End()
+        .Code()
+            .Function(&quot;foo&quot;, 0 /*['i32', 'i32'] =&gt; 'i32'*/)
+                .GetLocal(1) // parameter to call
+                .GetLocal(0) // call index
+                .CallIndirect(1, 0) // calling function of type ['i32'] =&gt; 'i32'
+                .Return()
+            .End()
+            .Function(&quot;bar&quot;, 1 /*['i32'] =&gt; 'i32'*/)
+                .GetLocal(0)
+                .I32Const(42)
+                .I32Add()
+                .Return()
+            .End()
+        .End();
+
+
+    const bin = builder.WebAssembly().get();
+    const module = new WebAssembly.Module(bin);
+    const table = new WebAssembly.Table(tableDescription);
+    return {instance: new WebAssembly.Instance(module, {imp: {table}}), table};
+}
+
+{
+    const {instance, table} = makeInstance();
+    const foo = instance.exports.foo;
+    const bar = instance.exports.bar;
+    assert.eq(table.get(0), null);
+
+    for (let i = 0; i &lt; 1000; i++) {
+        assert.throws(() =&gt; foo(0, i), WebAssembly.RuntimeError, &quot;call_indirect to a null table entry&quot;);
+    }
+
+    table.set(0, foo);
+    assert.eq(table.get(0), foo);
+
+    for (let i = 0; i &lt; 1000; i++) {
+        assert.throws(() =&gt; foo(1 + i, i), WebAssembly.RuntimeError, &quot;Out of bounds call_indirect&quot;);
+    }
+
+    for (let i = 0; i &lt; 1000; i++) {
+        assert.throws(() =&gt; foo(0, i), WebAssembly.RuntimeError, &quot;call_indirect to a signature that does not match&quot;);
+    }
+
+    table.set(0, bar);
+    assert.eq(table.get(0), bar);
+    for (let i = 0; i &lt; 25; i++) {
+        assert.eq(foo(0, i), i + 42);
+    }
+}
</ins></span></pre></div>
<a id="trunkJSTestswasmfunctionteststablebasicjs"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/wasm/function-tests/table-basic.js (209927 => 209928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/wasm/function-tests/table-basic.js        2016-12-16 18:56:24 UTC (rev 209927)
+++ trunk/JSTests/wasm/function-tests/table-basic.js        2016-12-16 19:24:06 UTC (rev 209928)
</span><span class="lines">@@ -53,15 +53,12 @@
</span><span class="cx"> // FIXME: make this work cross module. The reason it doesn't
</span><span class="cx"> // now is that we don't unique Signature*.
</span><span class="cx"> // https://bugs.webkit.org/show_bug.cgi?id=165511
</span><del>-/*
</del><span class="cx"> {
</span><span class="cx">     const {instance, table} = makeInstance();
</span><span class="cx">     const foo = instance.exports.foo;
</span><del>-    //table.set(0, makeInstance().instance.exports.bar); // Cross instance function.
</del><ins>+    table.set(0, makeInstance().instance.exports.bar); // Cross instance function.
</ins><span class="cx"> 
</span><span class="cx">     for (let i = 0; i &lt; 1000; i++) {
</span><del>-        if (foo(0, i) !== i + 42)
-            throw new Error(&quot;Bad call indirect&quot;);
</del><ins>+        assert.throws(() =&gt; foo(0, i), WebAssembly.RuntimeError, &quot;call_indirect to a signature that does not match&quot;);
</ins><span class="cx">     }
</span><span class="cx"> }
</span><del>-*/
</del></span></pre></div>
<a id="trunkSourceJavaScriptCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/CMakeLists.txt (209927 => 209928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/CMakeLists.txt        2016-12-16 18:56:24 UTC (rev 209927)
+++ trunk/Source/JavaScriptCore/CMakeLists.txt        2016-12-16 19:24:06 UTC (rev 209928)
</span><span class="lines">@@ -116,6 +116,7 @@
</span><span class="cx">     b3/B3CheckValue.cpp
</span><span class="cx">     b3/B3Common.cpp
</span><span class="cx">     b3/B3Commutativity.cpp
</span><ins>+    b3/B3Compile.cpp
</ins><span class="cx">     b3/B3Compilation.cpp
</span><span class="cx">     b3/B3Const32Value.cpp
</span><span class="cx">     b3/B3Const64Value.cpp
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (209927 => 209928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-12-16 18:56:24 UTC (rev 209927)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-12-16 19:24:06 UTC (rev 209928)
</span><span class="lines">@@ -1,3 +1,56 @@
</span><ins>+2016-12-16  Saam Barati  &lt;sbarati@apple.com&gt;
+
+        WebAssembly: WasmB3IRGenerator should throw exceptions instead of crash
+        https://bugs.webkit.org/show_bug.cgi?id=165834
+
+        Reviewed by Keith Miller.
+
+        This patch generalizes how we throw exceptions in the Wasm::B3IRGenerator.
+        There are still places where we need to throw exceptions and we don't, but
+        this patch removes most of those places inside the IR generator. There are
+        still a few places we need to throw exceptions inside the IR generator, like
+        div/mod by 0. Those will be done in a separate patch. Also, there are
+        still some stubs we need to throw exceptions from; those will also be
+        done in a separate patch.
+
+        All exceptions thrown from Wasm share a common stub. The ABI for the stub
+        is to move the Wasm::ExceptionType into argGPR1 and jump to the stub.
+        The stub will then throw an exception with an error message tailored
+        to the particular Wasm::ExceptionType failure.
+
+        This patch also refactors B3::Compilation. Before, B3::Compilation(VM, Procedure)
+        constructor would compile a B3 function. This patch makes B3::Compilation a simple 
+        tuple that keeps the necessary bits of B3 function alive in order to be runnable.
+        There is a new function that actually does the compilation for you. It is:
+        Compilation B3::compile(VM&amp;, Procedure&amp;)
+        The reason for this change is that I'm now using B3::Compilation(CodeRef, OpaqueByproducts)
+        constructor in Wasm code. It is weird to have a class both have a
+        constructor that instantiates the tuple, and another that performs the
+        compilation and then instantiates the tuple. It's more straight
+        forward if Compilation's job wasn't to actually do the compilation
+        but just to hold the necessary bits to keep a compiled B3 alive.
+
+        * CMakeLists.txt:
+        * JavaScriptCore.xcodeproj/project.pbxproj:
+        * b3/B3Compilation.cpp:
+        (JSC::B3::Compilation::Compilation):
+        * b3/B3Compilation.h:
+        * b3/B3Compile.cpp: Added.
+        (JSC::B3::compile):
+        * b3/B3Compile.h: Added.
+        * b3/testb3.cpp:
+        (JSC::B3::compile):
+        * jit/ThunkGenerators.cpp:
+        (JSC::throwExceptionFromWasmThunkGenerator):
+        * jit/ThunkGenerators.h:
+        * wasm/WasmB3IRGenerator.cpp:
+        (JSC::Wasm::B3IRGenerator::B3IRGenerator):
+        (JSC::Wasm::B3IRGenerator::emitExceptionCheck):
+        (JSC::Wasm::createJSToWasmWrapper):
+        (JSC::Wasm::parseAndCompile):
+        * wasm/WasmExceptionType.h: Added.
+        (JSC::Wasm::errorMessageForExceptionType):
+
</ins><span class="cx"> 2016-12-16  Keith Miller  &lt;keith_miller@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         i64.eqz should use an Int64 zero
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj (209927 => 209928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2016-12-16 18:56:24 UTC (rev 209927)
+++ trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2016-12-16 19:24:06 UTC (rev 209928)
</span><span class="lines">@@ -1302,7 +1302,7 @@
</span><span class="cx">                 53FA2AE11CF37F3F0022711D /* LLIntPrototypeLoadAdaptiveStructureWatchpoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 53FA2AE01CF37F3F0022711D /* LLIntPrototypeLoadAdaptiveStructureWatchpoint.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 53FA2AE31CF380390022711D /* LLIntPrototypeLoadAdaptiveStructureWatchpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53FA2AE21CF380390022711D /* LLIntPrototypeLoadAdaptiveStructureWatchpoint.cpp */; };
</span><span class="cx">                 53FD04D31D7AB277003287D3 /* WasmCallingConvention.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53FD04D11D7AB187003287D3 /* WasmCallingConvention.cpp */; };
</span><del>-                53FD04D41D7AB291003287D3 /* WasmCallingConvention.h in Headers */ = {isa = PBXBuildFile; fileRef = 53FD04D21D7AB187003287D3 /* WasmCallingConvention.h */; };
</del><ins>+                53FD04D41D7AB291003287D3 /* WasmCallingConvention.h in Headers */ = {isa = PBXBuildFile; fileRef = 53FD04D21D7AB187003287D3 /* WasmCallingConvention.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 53FF7F991DBFCD9000A26CCC /* WasmValidate.h in Headers */ = {isa = PBXBuildFile; fileRef = 53FF7F981DBFCD9000A26CCC /* WasmValidate.h */; };
</span><span class="cx">                 53FF7F9B1DBFD2B900A26CCC /* WasmValidate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53FF7F9A1DBFD2B900A26CCC /* WasmValidate.cpp */; };
</span><span class="cx">                 5B70CFDE1DB69E6600EC23F9 /* JSAsyncFunction.h in Headers */ = {isa = PBXBuildFile; fileRef = 5B70CFD81DB69E5C00EC23F9 /* JSAsyncFunction.h */; };
</span><span class="lines">@@ -1406,11 +1406,13 @@
</span><span class="cx">                 7905BB691D12050E0019FE57 /* InlineAccess.h in Headers */ = {isa = PBXBuildFile; fileRef = 7905BB671D12050E0019FE57 /* InlineAccess.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 79160DBD1C8E3EC8008C085A /* ProxyRevoke.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 79160DBB1C8E3EC8008C085A /* ProxyRevoke.cpp */; };
</span><span class="cx">                 79160DBE1C8E3EC8008C085A /* ProxyRevoke.h in Headers */ = {isa = PBXBuildFile; fileRef = 79160DBC1C8E3EC8008C085A /* ProxyRevoke.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+                7919B7801E03559C005BEED8 /* B3Compile.h in Headers */ = {isa = PBXBuildFile; fileRef = 7919B77F1E03559C005BEED8 /* B3Compile.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 79233C2B1D34715700C5A834 /* JITMathIC.h in Headers */ = {isa = PBXBuildFile; fileRef = 79233C291D34715700C5A834 /* JITMathIC.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 792CB3491C4EED5C00D13AF3 /* PCToCodeOriginMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 792CB3471C4EED5C00D13AF3 /* PCToCodeOriginMap.cpp */; };
</span><span class="cx">                 792CB34A1C4EED5C00D13AF3 /* PCToCodeOriginMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 792CB3481C4EED5C00D13AF3 /* PCToCodeOriginMap.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 795B19971D78BE3500262FA0 /* MapBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 795B19951D78BE3500262FA0 /* MapBase.cpp */; };
</span><span class="cx">                 795B19981D78BE3500262FA0 /* MapBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 795B19961D78BE3500262FA0 /* MapBase.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+                795F099D1E03600500BBE37F /* B3Compile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 795F099C1E03600500BBE37F /* B3Compile.cpp */; };
</ins><span class="cx">                 7964656A1B952FF0003059EE /* GetPutInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 796465681B952FF0003059EE /* GetPutInfo.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 796FB43A1DFF8C3F0039C95D /* JSWebAssemblyHelpers.h in Headers */ = {isa = PBXBuildFile; fileRef = 796FB4391DFF8C3F0039C95D /* JSWebAssemblyHelpers.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 797E07A91B8FCFB9008400BA /* JSGlobalLexicalEnvironment.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 797E07A71B8FCFB9008400BA /* JSGlobalLexicalEnvironment.cpp */; };
</span><span class="lines">@@ -1437,6 +1439,7 @@
</span><span class="cx">                 79CFC6F01C33B10000C768EA /* LLIntPCRanges.h in Headers */ = {isa = PBXBuildFile; fileRef = 79CFC6EF1C33B10000C768EA /* LLIntPCRanges.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 79D5CD5A1C1106A900CECA07 /* SamplingProfiler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 79D5CD581C1106A900CECA07 /* SamplingProfiler.cpp */; };
</span><span class="cx">                 79D5CD5B1C1106A900CECA07 /* SamplingProfiler.h in Headers */ = {isa = PBXBuildFile; fileRef = 79D5CD591C1106A900CECA07 /* SamplingProfiler.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+                79DAE27A1E03C82200B526AA /* WasmExceptionType.h in Headers */ = {isa = PBXBuildFile; fileRef = 79DAE2791E03C82200B526AA /* WasmExceptionType.h */; };
</ins><span class="cx">                 79DFCBDB1D88C59600527D03 /* HasOwnPropertyCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 79DFCBDA1D88C59600527D03 /* HasOwnPropertyCache.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 79E423E21DEE65320078D355 /* JSWebAssemblyCallee.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 79E423E01DEE65320078D355 /* JSWebAssemblyCallee.cpp */; };
</span><span class="cx">                 79E423E31DEE65320078D355 /* JSWebAssemblyCallee.h in Headers */ = {isa = PBXBuildFile; fileRef = 79E423E11DEE65320078D355 /* JSWebAssemblyCallee.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -3835,11 +3838,13 @@
</span><span class="cx">                 7905BB671D12050E0019FE57 /* InlineAccess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InlineAccess.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 79160DBB1C8E3EC8008C085A /* ProxyRevoke.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ProxyRevoke.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 79160DBC1C8E3EC8008C085A /* ProxyRevoke.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProxyRevoke.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                7919B77F1E03559C005BEED8 /* B3Compile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = B3Compile.h; path = b3/B3Compile.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 79233C291D34715700C5A834 /* JITMathIC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JITMathIC.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 792CB3471C4EED5C00D13AF3 /* PCToCodeOriginMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PCToCodeOriginMap.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 792CB3481C4EED5C00D13AF3 /* PCToCodeOriginMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PCToCodeOriginMap.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 795B19951D78BE3500262FA0 /* MapBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MapBase.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 795B19961D78BE3500262FA0 /* MapBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MapBase.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                795F099C1E03600500BBE37F /* B3Compile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = B3Compile.cpp; path = b3/B3Compile.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 796465681B952FF0003059EE /* GetPutInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GetPutInfo.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 796FB4391DFF8C3F0039C95D /* JSWebAssemblyHelpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSWebAssemblyHelpers.h; path = js/JSWebAssemblyHelpers.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 797E07A71B8FCFB9008400BA /* JSGlobalLexicalEnvironment.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSGlobalLexicalEnvironment.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -3866,6 +3871,7 @@
</span><span class="cx">                 79CFC6EF1C33B10000C768EA /* LLIntPCRanges.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LLIntPCRanges.h; path = llint/LLIntPCRanges.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 79D5CD581C1106A900CECA07 /* SamplingProfiler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SamplingProfiler.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 79D5CD591C1106A900CECA07 /* SamplingProfiler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SamplingProfiler.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                79DAE2791E03C82200B526AA /* WasmExceptionType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmExceptionType.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 79DFCBDA1D88C59600527D03 /* HasOwnPropertyCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HasOwnPropertyCache.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 79E423E01DEE65320078D355 /* JSWebAssemblyCallee.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JSWebAssemblyCallee.cpp; path = js/JSWebAssemblyCallee.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 79E423E11DEE65320078D355 /* JSWebAssemblyCallee.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSWebAssemblyCallee.h; path = js/JSWebAssemblyCallee.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -5178,6 +5184,8 @@
</span><span class="cx">                                 0FEC84C01BDACDAC0080FF74 /* B3Common.h */,
</span><span class="cx">                                 0FEC84C11BDACDAC0080FF74 /* B3Commutativity.cpp */,
</span><span class="cx">                                 0FEC84C21BDACDAC0080FF74 /* B3Commutativity.h */,
</span><ins>+                                7919B77F1E03559C005BEED8 /* B3Compile.h */,
+                                795F099C1E03600500BBE37F /* B3Compile.cpp */,
</ins><span class="cx">                                 0F338DFF1BF0276C0013C88F /* B3Compilation.cpp */,
</span><span class="cx">                                 0F338E001BF0276C0013C88F /* B3Compilation.h */,
</span><span class="cx">                                 0F86AE1F1C5311C5006BE8EC /* B3ComputeDivisionMagic.h */,
</span><span class="lines">@@ -6011,6 +6019,7 @@
</span><span class="cx">                                 AD4B1DF81DF244D70071AE32 /* WasmBinding.h */,
</span><span class="cx">                                 53FD04D11D7AB187003287D3 /* WasmCallingConvention.cpp */,
</span><span class="cx">                                 53FD04D21D7AB187003287D3 /* WasmCallingConvention.h */,
</span><ins>+                                79DAE2791E03C82200B526AA /* WasmExceptionType.h */,
</ins><span class="cx">                                 AD2FCC321DC4045300B3E736 /* WasmFormat.cpp */,
</span><span class="cx">                                 7BC547D21B69599B00959B58 /* WasmFormat.h */,
</span><span class="cx">                                 53F40E8A1D5901BB0099A1B6 /* WasmFunctionParser.h */,
</span><span class="lines">@@ -8294,6 +8303,7 @@
</span><span class="cx">                                 52B310FB1974AE610080857C /* FunctionHasExecutedCache.h in Headers */,
</span><span class="cx">                                 FE4BFF2C1AD476E700088F87 /* FunctionOverrides.h in Headers */,
</span><span class="cx">                                 BC18C4050E16F5CD00B34460 /* FunctionPrototype.h in Headers */,
</span><ins>+                                7919B7801E03559C005BEED8 /* B3Compile.h in Headers */,
</ins><span class="cx">                                 62D2D3901ADF103F000206C1 /* FunctionRareData.h in Headers */,
</span><span class="cx">                                 FEA0C4031CDD7D1D00481991 /* FunctionWhitelist.h in Headers */,
</span><span class="cx">                                 2AACE63D18CA5A0300ED0191 /* GCActivityCallback.h in Headers */,
</span><span class="lines">@@ -8345,6 +8355,7 @@
</span><span class="cx">                                 0F0332C418B01763005F979A /* GetByIdVariant.h in Headers */,
</span><span class="cx">                                 7964656A1B952FF0003059EE /* GetPutInfo.h in Headers */,
</span><span class="cx">                                 14AD910E1DCA92940014F9FE /* GlobalCodeBlock.h in Headers */,
</span><ins>+                                79DAE27A1E03C82200B526AA /* WasmExceptionType.h in Headers */,
</ins><span class="cx">                                 0F24E54417EA9F5900ABB217 /* GPRInfo.h in Headers */,
</span><span class="cx">                                 142E3134134FF0A600AFADB5 /* Handle.h in Headers */,
</span><span class="cx">                                 C283190016FE4B7D00157BFD /* HandleBlock.h in Headers */,
</span><span class="lines">@@ -9838,6 +9849,7 @@
</span><span class="cx">                                 0FB17662196B8F9E0091052A /* DFGPureValue.cpp in Sources */,
</span><span class="cx">                                 0F3A1BF91A9ECB7D000DE01A /* DFGPutStackSinkingPhase.cpp in Sources */,
</span><span class="cx">                                 0F2FCCFB18A60070001A27F8 /* DFGSafepoint.cpp in Sources */,
</span><ins>+                                795F099D1E03600500BBE37F /* B3Compile.cpp in Sources */,
</ins><span class="cx">                                 86EC9DD21328DF82002B2AD7 /* DFGSpeculativeJIT.cpp in Sources */,
</span><span class="cx">                                 86880F1F14328BB900B08D42 /* DFGSpeculativeJIT32_64.cpp in Sources */,
</span><span class="cx">                                 86880F4D14353B2100B08D42 /* DFGSpeculativeJIT64.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreb3B3Compilationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/b3/B3Compilation.cpp (209927 => 209928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/b3/B3Compilation.cpp        2016-12-16 18:56:24 UTC (rev 209927)
+++ trunk/Source/JavaScriptCore/b3/B3Compilation.cpp        2016-12-16 19:24:06 UTC (rev 209928)
</span><span class="lines">@@ -28,30 +28,11 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(B3_JIT)
</span><span class="cx"> 
</span><del>-#include &quot;B3Generate.h&quot;
</del><span class="cx"> #include &quot;B3OpaqueByproducts.h&quot;
</span><del>-#include &quot;B3Procedure.h&quot;
-#include &quot;B3TimingScope.h&quot;
</del><span class="cx"> #include &quot;CCallHelpers.h&quot;
</span><del>-#include &quot;JSCInlines.h&quot;
-#include &quot;LinkBuffer.h&quot;
</del><span class="cx"> 
</span><span class="cx"> namespace JSC { namespace B3 {
</span><span class="cx"> 
</span><del>-Compilation::Compilation(VM&amp; vm, Procedure&amp; proc, unsigned optLevel)
-{
-    TimingScope timingScope(&quot;Compilation&quot;);
-    
-    prepareForGeneration(proc, optLevel);
-    
-    CCallHelpers jit(&amp;vm);
-    generate(proc, jit);
-    LinkBuffer linkBuffer(vm, jit, nullptr);
-
-    m_codeRef = FINALIZE_CODE(linkBuffer, (&quot;B3::Compilation&quot;));
-    m_byproducts = proc.releaseByproducts();
-}
-
</del><span class="cx"> Compilation::Compilation(MacroAssemblerCodeRef codeRef, std::unique_ptr&lt;OpaqueByproducts&gt; byproducts)
</span><span class="cx">     : m_codeRef(codeRef)
</span><span class="cx">     , m_byproducts(WTFMove(byproducts))
</span><span class="lines">@@ -58,6 +39,12 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+Compilation::Compilation(Compilation&amp;&amp; other)
+    : m_codeRef(WTFMove(other.m_codeRef))
+    , m_byproducts(WTFMove(other.m_byproducts))
+{
+}
+
</ins><span class="cx"> Compilation::~Compilation()
</span><span class="cx"> {
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreb3B3Compilationh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/b3/B3Compilation.h (209927 => 209928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/b3/B3Compilation.h        2016-12-16 18:56:24 UTC (rev 209927)
+++ trunk/Source/JavaScriptCore/b3/B3Compilation.h        2016-12-16 19:24:06 UTC (rev 209928)
</span><span class="lines">@@ -40,13 +40,8 @@
</span><span class="cx"> class OpaqueByproducts;
</span><span class="cx"> class Procedure;
</span><span class="cx"> 
</span><del>-// This is a fool-proof API for compiling a Procedure to code and then running that code. You compile
-// a Procedure using this API by doing:
-//
-// std::unique_ptr&lt;Compilation&gt; compilation = std::make_unique&lt;Compilation&gt;(vm, proc);
-//
-// Then you keep the Compilation object alive for as long as you want to be able to run the code. If
-// this API feels too high-level, you can use B3::generate() directly.
</del><ins>+// This class is a way to keep the result of a B3 compilation alive
+// and runnable.
</ins><span class="cx"> 
</span><span class="cx"> class Compilation {
</span><span class="cx">     WTF_MAKE_NONCOPYABLE(Compilation);
</span><span class="lines">@@ -53,12 +48,8 @@
</span><span class="cx">     WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> 
</span><span class="cx"> public:
</span><del>-    JS_EXPORT_PRIVATE Compilation(VM&amp;, Procedure&amp;, unsigned optLevel = 1);
-
-    // This constructor allows you to manually create a Compilation. It's currently only used by test
-    // code. Probably best to keep it that way.
</del><span class="cx">     JS_EXPORT_PRIVATE Compilation(MacroAssemblerCodeRef, std::unique_ptr&lt;OpaqueByproducts&gt;);
</span><del>-    
</del><ins>+    JS_EXPORT_PRIVATE Compilation(Compilation&amp;&amp;);
</ins><span class="cx">     JS_EXPORT_PRIVATE ~Compilation();
</span><span class="cx"> 
</span><span class="cx">     MacroAssemblerCodePtr code() const { return m_codeRef.code(); }
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreb3B3Compilecppfromrev209927trunkSourceJavaScriptCoreb3B3Compilationcpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/JavaScriptCore/b3/B3Compile.cpp (from rev 209927, trunk/Source/JavaScriptCore/b3/B3Compilation.cpp) (0 => 209928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/b3/B3Compile.cpp                                (rev 0)
+++ trunk/Source/JavaScriptCore/b3/B3Compile.cpp        2016-12-16 19:24:06 UTC (rev 209928)
</span><span class="lines">@@ -0,0 +1,57 @@
</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;B3Compile.h&quot;
+
+#if ENABLE(B3_JIT)
+
+#include &quot;B3Generate.h&quot;
+#include &quot;B3OpaqueByproducts.h&quot;
+#include &quot;B3Procedure.h&quot;
+#include &quot;B3TimingScope.h&quot;
+#include &quot;CCallHelpers.h&quot;
+#include &quot;JSCInlines.h&quot;
+#include &quot;LinkBuffer.h&quot;
+
+namespace JSC { namespace B3 {
+
+Compilation compile(VM&amp; vm, Procedure&amp; proc, unsigned optLevel)
+{
+    TimingScope timingScope(&quot;Compilation&quot;);
+    
+    prepareForGeneration(proc, optLevel);
+    
+    CCallHelpers jit(&amp;vm);
+    generate(proc, jit);
+    LinkBuffer linkBuffer(vm, jit, nullptr);
+
+    return Compilation(FINALIZE_CODE(linkBuffer, (&quot;B3::Compilation&quot;)), proc.releaseByproducts());
+}
+
+} } // namespace JSC::B3
+
+#endif // ENABLE(B3_JIT)
+
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreb3B3Compilehfromrev209927trunkSourceJavaScriptCoreb3B3Compilationcpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/JavaScriptCore/b3/B3Compile.h (from rev 209927, trunk/Source/JavaScriptCore/b3/B3Compilation.cpp) (0 => 209928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/b3/B3Compile.h                                (rev 0)
+++ trunk/Source/JavaScriptCore/b3/B3Compile.h        2016-12-16 19:24:06 UTC (rev 209928)
</span><span class="lines">@@ -0,0 +1,52 @@
</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(B3_JIT)
+
+#include &quot;B3Compilation.h&quot;
+
+namespace JSC {
+
+class VM;
+
+namespace B3 {
+
+class Procedure;
+
+// This is a fool-proof API for compiling a Procedure to code and then running that code. You compile
+// a Procedure using this API by doing:
+//
+// Compilation compilation = B3::compile(vm, proc);
+//
+// Then you keep the Compilation object alive for as long as you want to be able to run the code.
+// If this API feels too high-level, you can use B3::generate() directly.
+
+JS_EXPORT_PRIVATE Compilation compile(VM&amp;, Procedure&amp;, unsigned optLevel = 1);
+
+} } // namespace JSC::B3
+
+#endif // ENABLE(B3_JIT)
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreb3testb3cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/b3/testb3.cpp (209927 => 209928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/b3/testb3.cpp        2016-12-16 18:56:24 UTC (rev 209927)
+++ trunk/Source/JavaScriptCore/b3/testb3.cpp        2016-12-16 19:24:06 UTC (rev 209928)
</span><span class="lines">@@ -33,6 +33,7 @@
</span><span class="cx"> #include &quot;B3BasicBlockInlines.h&quot;
</span><span class="cx"> #include &quot;B3CCallValue.h&quot;
</span><span class="cx"> #include &quot;B3Compilation.h&quot;
</span><ins>+#include &quot;B3Compile.h&quot;
</ins><span class="cx"> #include &quot;B3ComputeDivisionMagic.h&quot;
</span><span class="cx"> #include &quot;B3Const32Value.h&quot;
</span><span class="cx"> #include &quot;B3ConstPtrValue.h&quot;
</span><span class="lines">@@ -118,7 +119,7 @@
</span><span class="cx"> 
</span><span class="cx"> std::unique_ptr&lt;Compilation&gt; compile(Procedure&amp; procedure, unsigned optLevel = 1)
</span><span class="cx"> {
</span><del>-    return std::make_unique&lt;Compilation&gt;(*vm, procedure, optLevel);
</del><ins>+    return std::make_unique&lt;Compilation&gt;(B3::compile(*vm, procedure, optLevel));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template&lt;typename T, typename... Arguments&gt;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitThunkGeneratorscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/ThunkGenerators.cpp (209927 => 209928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/ThunkGenerators.cpp        2016-12-16 18:56:24 UTC (rev 209927)
+++ trunk/Source/JavaScriptCore/jit/ThunkGenerators.cpp        2016-12-16 19:24:06 UTC (rev 209928)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;CodeBlock.h&quot;
</span><span class="cx"> #include &quot;DFGSpeculativeJIT.h&quot;
</span><ins>+#include &quot;JITExceptions.h&quot;
</ins><span class="cx"> #include &quot;JITOperations.h&quot;
</span><span class="cx"> #include &quot;JSArray.h&quot;
</span><span class="cx"> #include &quot;JSBoundFunction.h&quot;
</span><span class="lines">@@ -34,7 +35,10 @@
</span><span class="cx"> #include &quot;MathCommon.h&quot;
</span><span class="cx"> #include &quot;MaxFrameExtentForSlowPathCall.h&quot;
</span><span class="cx"> #include &quot;JSCInlines.h&quot;
</span><ins>+#include &quot;JSWebAssemblyInstance.h&quot;
+#include &quot;JSWebAssemblyRuntimeError.h&quot;
</ins><span class="cx"> #include &quot;SpecializedThunkJIT.h&quot;
</span><ins>+#include &quot;WasmExceptionType.h&quot;
</ins><span class="cx"> #include &lt;wtf/InlineASM.h&gt;
</span><span class="cx"> #include &lt;wtf/StringPrintStream.h&gt;
</span><span class="cx"> #include &lt;wtf/text/StringImpl.h&gt;
</span><span class="lines">@@ -1126,6 +1130,47 @@
</span><span class="cx">         linkBuffer, (&quot;Specialized thunk for bound function calls with no arguments&quot;));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if ENABLE(WEBASSEMBLY)
+MacroAssemblerCodeRef throwExceptionFromWasmThunkGenerator(VM* vm)
+{
+    CCallHelpers jit(vm);
+
+    // The thing that jumps here must move ExceptionType into the argumentGPR1 and jump here.
+    // We're allowed to use temp registers here, but not callee saves.
+    {
+        RegisterSet usedRegisters = RegisterSet::stubUnavailableRegisters();
+        usedRegisters.set(GPRInfo::argumentGPR1);
+        jit.copyCalleeSavesToVMEntryFrameCalleeSavesBuffer(usedRegisters);
+    }
+
+    jit.move(GPRInfo::callFrameRegister, GPRInfo::argumentGPR0);
+    CCallHelpers::Call call = jit.call();
+    jit.jumpToExceptionHandler();
+
+    void (*throwWasmException)(ExecState*, Wasm::ExceptionType) = [] (ExecState* exec, Wasm::ExceptionType type) {
+        VM* vm = &amp;exec-&gt;vm();
+        NativeCallFrameTracer tracer(vm, exec);
+
+        {
+            auto throwScope = DECLARE_THROW_SCOPE(*vm);
+            JSGlobalObject* globalObject = vm-&gt;topJSWebAssemblyInstance-&gt;globalObject();
+
+            JSWebAssemblyRuntimeError* error = JSWebAssemblyRuntimeError::create(
+                exec, globalObject-&gt;WebAssemblyRuntimeErrorStructure(), Wasm::errorMessageForExceptionType(type));
+            throwException(exec, throwScope, error);
+        }
+
+        genericUnwind(vm, exec);
+        ASSERT(!!vm-&gt;callFrameForCatch);
+    };
+
+    LinkBuffer linkBuffer(*vm, jit, GLOBAL_THUNK_ID);
+    linkBuffer.link(call, throwWasmException);
+    return FINALIZE_CODE(
+        linkBuffer, (&quot;Throw exception from Wasm&quot;));
+}
+#endif // ENABLE(WEBASSEMBLY)
+
</ins><span class="cx"> } // namespace JSC
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(JIT)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitThunkGeneratorsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/ThunkGenerators.h (209927 => 209928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/ThunkGenerators.h        2016-12-16 18:56:24 UTC (rev 209927)
+++ trunk/Source/JavaScriptCore/jit/ThunkGenerators.h        2016-12-16 19:24:06 UTC (rev 209928)
</span><span class="lines">@@ -63,7 +63,11 @@
</span><span class="cx"> MacroAssemblerCodeRef randomThunkGenerator(VM*);
</span><span class="cx"> MacroAssemblerCodeRef truncThunkGenerator(VM*);
</span><span class="cx"> 
</span><del>-MacroAssemblerCodeRef boundThisNoArgsFunctionCallGenerator(VM* vm);
</del><ins>+MacroAssemblerCodeRef boundThisNoArgsFunctionCallGenerator(VM*);
</ins><span class="cx"> 
</span><ins>+#if ENABLE(WEBASSEMBLY)
+MacroAssemblerCodeRef throwExceptionFromWasmThunkGenerator(VM*);
+#endif
+
</ins><span class="cx"> }
</span><span class="cx"> #endif // ENABLE(JIT)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWasmB3IRGeneratorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp (209927 => 209928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp        2016-12-16 18:56:24 UTC (rev 209927)
+++ trunk/Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp        2016-12-16 19:24:06 UTC (rev 209928)
</span><span class="lines">@@ -30,8 +30,10 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;B3BasicBlockInlines.h&quot;
</span><span class="cx"> #include &quot;B3CCallValue.h&quot;
</span><ins>+#include &quot;B3Compile.h&quot;
</ins><span class="cx"> #include &quot;B3ConstPtrValue.h&quot;
</span><span class="cx"> #include &quot;B3FixSSA.h&quot;
</span><ins>+#include &quot;B3Generate.h&quot;
</ins><span class="cx"> #include &quot;B3StackmapGenerationParams.h&quot;
</span><span class="cx"> #include &quot;B3SwitchValue.h&quot;
</span><span class="cx"> #include &quot;B3Validate.h&quot;
</span><span class="lines">@@ -40,9 +42,6 @@
</span><span class="cx"> #include &quot;B3VariableValue.h&quot;
</span><span class="cx"> #include &quot;B3WasmAddressValue.h&quot;
</span><span class="cx"> #include &quot;B3WasmBoundsCheckValue.h&quot;
</span><del>-#include &quot;ExceptionScope.h&quot;
-#include &quot;FrameTracers.h&quot;
-#include &quot;JITExceptions.h&quot;
</del><span class="cx"> #include &quot;JSCInlines.h&quot;
</span><span class="cx"> #include &quot;JSWebAssemblyInstance.h&quot;
</span><span class="cx"> #include &quot;JSWebAssemblyModule.h&quot;
</span><span class="lines">@@ -49,6 +48,7 @@
</span><span class="cx"> #include &quot;JSWebAssemblyRuntimeError.h&quot;
</span><span class="cx"> #include &quot;VirtualRegister.h&quot;
</span><span class="cx"> #include &quot;WasmCallingConvention.h&quot;
</span><ins>+#include &quot;WasmExceptionType.h&quot;
</ins><span class="cx"> #include &quot;WasmFunctionParser.h&quot;
</span><span class="cx"> #include &quot;WasmMemory.h&quot;
</span><span class="cx"> #include &lt;wtf/Optional.h&gt;
</span><span class="lines">@@ -197,6 +197,8 @@
</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>+    void emitExceptionCheck(CCallHelpers&amp;, ExceptionType);
+
</ins><span class="cx"> private:
</span><span class="cx">     ExpressionType emitCheckAndPreparePointer(ExpressionType pointer, uint32_t offset, uint32_t sizeOfOp);
</span><span class="cx">     ExpressionType emitLoadOp(LoadOpType, Origin, ExpressionType pointer, uint32_t offset);
</span><span class="lines">@@ -217,7 +219,6 @@
</span><span class="cx">     GPRReg m_memorySizeGPR;
</span><span class="cx">     Value* m_zeroValues[numTypes];
</span><span class="cx">     Value* m_instanceValue;
</span><del>-
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> B3IRGenerator::B3IRGenerator(VM&amp; vm, const ModuleInformation&amp; info, Procedure&amp; procedure, WasmInternalFunction* compilation, Vector&lt;UnlinkedWasmToWasmCall&gt;&amp; unlinkedWasmToWasmCalls, const ImmutableFunctionIndexSpace&amp; functionIndexSpace)
</span><span class="lines">@@ -254,33 +255,7 @@
</span><span class="cx">         m_proc.setWasmBoundsCheckGenerator([=] (CCallHelpers&amp; jit, GPRReg pinnedGPR, unsigned) {
</span><span class="cx">             AllowMacroScratchRegisterUsage allowScratch(jit);
</span><span class="cx">             ASSERT_UNUSED(pinnedGPR, m_memorySizeGPR == pinnedGPR);
</span><del>-            jit.copyCalleeSavesToVMEntryFrameCalleeSavesBuffer();
-
-            jit.move(GPRInfo::callFrameRegister, GPRInfo::argumentGPR0);
-
-            CCallHelpers::Call call = jit.call();
-            jit.jumpToExceptionHandler();
-
-            jit.addLinkTask([=] (LinkBuffer&amp; linkBuffer) {
-                void (*throwMemoryException)(ExecState*) = [] (ExecState* exec) {
-                    VM* vm = &amp;exec-&gt;vm();
-                    NativeCallFrameTracer tracer(vm, exec);
-
-                    {
-                        auto throwScope = DECLARE_THROW_SCOPE(*vm);
-                        JSGlobalObject* globalObject = vm-&gt;topJSWebAssemblyInstance-&gt;globalObject();
-
-                        JSWebAssemblyRuntimeError* error = JSWebAssemblyRuntimeError::create(
-                            exec, globalObject-&gt;WebAssemblyRuntimeErrorStructure(), &quot;Out of bounds memory access&quot;);
-                        throwException(exec, throwScope, error);
-                    }
-
-                    genericUnwind(vm, exec);
-                    ASSERT(!!vm-&gt;callFrameForCatch);
-                };
-
-                linkBuffer.link(call, throwMemoryException);
-            });
</del><ins>+            this-&gt;emitExceptionCheck(jit, ExceptionType::OutOfBoundsMemoryAccess);
</ins><span class="cx">         });
</span><span class="cx"> 
</span><span class="cx">         B3::PatchpointValue* foo = m_currentBlock-&gt;appendNew&lt;B3::PatchpointValue&gt;(m_proc, B3::Void, Origin());
</span><span class="lines">@@ -296,6 +271,17 @@
</span><span class="cx">         m_currentBlock-&gt;appendNew&lt;ConstPtrValue&gt;(m_proc, Origin(), &amp;m_vm.topJSWebAssemblyInstance));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void B3IRGenerator::emitExceptionCheck(CCallHelpers&amp; jit, ExceptionType type)
+{
+    jit.move(CCallHelpers::TrustedImm32(static_cast&lt;uint32_t&gt;(type)), GPRInfo::argumentGPR1);
+    auto jumpToExceptionStub = jit.jump();
+
+    VM* vm = &amp;m_vm;
+    jit.addLinkTask([=] (LinkBuffer&amp; linkBuffer) {
+        linkBuffer.link(jumpToExceptionStub, CodeLocationLabel(vm-&gt;getCTIStub(throwExceptionFromWasmThunkGenerator).code()));
+    });
+}
+
</ins><span class="cx"> Value* B3IRGenerator::zeroForType(Type type)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(type != Void);
</span><span class="lines">@@ -739,8 +725,8 @@
</span><span class="cx">         CheckValue* check = m_currentBlock-&gt;appendNew&lt;CheckValue&gt;(m_proc, Check, Origin(),
</span><span class="cx">             m_currentBlock-&gt;appendNew&lt;Value&gt;(m_proc, AboveEqual, Origin(), calleeIndex, callableFunctionBufferSize));
</span><span class="cx"> 
</span><del>-        check-&gt;setGenerator([] (CCallHelpers&amp; jit, const B3::StackmapGenerationParams&amp;) {
-            jit.breakpoint();
</del><ins>+        check-&gt;setGenerator([=] (CCallHelpers&amp; jit, const B3::StackmapGenerationParams&amp;) {
+            this-&gt;emitExceptionCheck(jit, ExceptionType::OutOfBoundsCallIndirect);
</ins><span class="cx">         });
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -758,8 +744,8 @@
</span><span class="cx">                 calleeSignature, 
</span><span class="cx">                 m_currentBlock-&gt;appendNew&lt;ConstPtrValue&gt;(m_proc, Origin(), 0)));
</span><span class="cx"> 
</span><del>-        check-&gt;setGenerator([] (CCallHelpers&amp; jit, const B3::StackmapGenerationParams&amp;) {
-            jit.breakpoint();
</del><ins>+        check-&gt;setGenerator([=] (CCallHelpers&amp; jit, const B3::StackmapGenerationParams&amp;) {
+            this-&gt;emitExceptionCheck(jit, ExceptionType::NullTableEntry);
</ins><span class="cx">         });
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -769,8 +755,8 @@
</span><span class="cx">         CheckValue* check = m_currentBlock-&gt;appendNew&lt;CheckValue&gt;(m_proc, Check, Origin(),
</span><span class="cx">             m_currentBlock-&gt;appendNew&lt;Value&gt;(m_proc, NotEqual, Origin(), calleeSignature, expectedSignature));
</span><span class="cx"> 
</span><del>-        check-&gt;setGenerator([] (CCallHelpers&amp; jit, const B3::StackmapGenerationParams&amp;) {
-            jit.breakpoint();
</del><ins>+        check-&gt;setGenerator([=] (CCallHelpers&amp; jit, const B3::StackmapGenerationParams&amp;) {
+            this-&gt;emitExceptionCheck(jit, ExceptionType::BadSignature);
</ins><span class="cx">         });
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -831,7 +817,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, WasmInternalFunction&amp; function, const Signature* signature, MacroAssemblerCodePtr mainFunction, const MemoryInformation&amp; memory)
</del><ins>+static std::unique_ptr&lt;B3::Compilation&gt; createJSToWasmWrapper(VM&amp; vm, WasmInternalFunction&amp; function, const Signature* signature, MacroAssemblerCodePtr mainFunction, const 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">@@ -840,19 +826,23 @@
</span><span class="cx"> 
</span><span class="cx">     jscCallingConvention().setupFrameInPrologue(&amp;function.jsToWasmCalleeMoveLocation, proc, origin, block);
</span><span class="cx"> 
</span><del>-    Value* framePointer = block-&gt;appendNew&lt;B3::Value&gt;(proc, B3::FramePointer, origin);
-    Value* offSetOfArgumentCount = block-&gt;appendNew&lt;Const64Value&gt;(proc, origin, CallFrameSlot::argumentCount * sizeof(Register));
-    Value* argumentCount = block-&gt;appendNew&lt;MemoryValue&gt;(proc, Load, Int32, origin,
-        block-&gt;appendNew&lt;Value&gt;(proc, Add, origin, framePointer, offSetOfArgumentCount));
</del><ins>+    if (!ASSERT_DISABLED) {
+        // This should be guaranteed by our JS wrapper that handles calls to us.
+        // Just prevent against crazy when ASSERT is enabled.
+        Value* framePointer = block-&gt;appendNew&lt;B3::Value&gt;(proc, B3::FramePointer, origin);
+        Value* offSetOfArgumentCount = block-&gt;appendNew&lt;Const64Value&gt;(proc, origin, CallFrameSlot::argumentCount * sizeof(Register));
+        Value* argumentCount = block-&gt;appendNew&lt;MemoryValue&gt;(proc, Load, Int32, origin,
+            block-&gt;appendNew&lt;Value&gt;(proc, Add, origin, framePointer, offSetOfArgumentCount));
</ins><span class="cx"> 
</span><del>-    Value* expectedArgumentCount = block-&gt;appendNew&lt;Const32Value&gt;(proc, origin, signature-&gt;arguments.size());
</del><ins>+        Value* expectedArgumentCount = block-&gt;appendNew&lt;Const32Value&gt;(proc, origin, signature-&gt;arguments.size());
</ins><span class="cx"> 
</span><del>-    CheckValue* argumentCountCheck = block-&gt;appendNew&lt;CheckValue&gt;(proc, Check, origin,
-        block-&gt;appendNew&lt;Value&gt;(proc, Above, origin, expectedArgumentCount, argumentCount));
</del><ins>+        CheckValue* argumentCountCheck = block-&gt;appendNew&lt;CheckValue&gt;(proc, Check, origin,
+            block-&gt;appendNew&lt;Value&gt;(proc, Above, origin, expectedArgumentCount, argumentCount));
</ins><span class="cx"> 
</span><del>-    argumentCountCheck-&gt;setGenerator([] (CCallHelpers&amp; jit, const StackmapGenerationParams&amp;) {
-        jit.breakpoint();
-    });
</del><ins>+        argumentCountCheck-&gt;setGenerator([] (CCallHelpers&amp; jit, const StackmapGenerationParams&amp;) {
+            jit.breakpoint();
+        });
+    }
</ins><span class="cx"> 
</span><span class="cx">     // Move memory values to the approriate places, if needed.
</span><span class="cx">     Value* baseMemory = nullptr;
</span><span class="lines">@@ -912,7 +902,7 @@
</span><span class="cx">         RELEASE_ASSERT_NOT_REACHED();
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    auto jsEntrypoint = std::make_unique&lt;Compilation&gt;(vm, proc);
</del><ins>+    auto jsEntrypoint = std::make_unique&lt;Compilation&gt;(B3::compile(vm, proc));
</ins><span class="cx">     function.jsToWasmEntrypoint.calleeSaveRegisters = proc.calleeSaveRegisters();
</span><span class="cx">     return jsEntrypoint;
</span><span class="cx"> }
</span><span class="lines">@@ -935,8 +925,9 @@
</span><span class="cx">     if (verbose)
</span><span class="cx">         dataLog(&quot;Post SSA: &quot;, procedure);
</span><span class="cx"> 
</span><del>-    result-&gt;wasmEntrypoint.compilation = std::make_unique&lt;Compilation&gt;(vm, procedure, optLevel);
</del><ins>+    result-&gt;wasmEntrypoint.compilation = std::make_unique&lt;B3::Compilation&gt;(B3::compile(vm, procedure, optLevel));
</ins><span class="cx">     result-&gt;wasmEntrypoint.calleeSaveRegisters = procedure.calleeSaveRegisters();
</span><ins>+
</ins><span class="cx">     result-&gt;jsToWasmEntrypoint.compilation = createJSToWasmWrapper(vm, *result, signature, result-&gt;wasmEntrypoint.compilation-&gt;code(), info.memory);
</span><span class="cx">     return WTFMove(result);
</span><span class="cx"> }
</span><span class="lines">@@ -1093,8 +1084,8 @@
</span><span class="cx">         m_currentBlock-&gt;appendNew&lt;Value&gt;(m_proc, GreaterEqual, Origin(), arg, min));
</span><span class="cx">     outOfBounds = m_currentBlock-&gt;appendNew&lt;Value&gt;(m_proc, Equal, Origin(), outOfBounds, zeroForType(I32));
</span><span class="cx">     CheckValue* trap = m_currentBlock-&gt;appendNew&lt;CheckValue&gt;(m_proc, Check, Origin(), outOfBounds);
</span><del>-    trap-&gt;setGenerator([] (CCallHelpers&amp; jit, const StackmapGenerationParams&amp;) {
-        jit.breakpoint();
</del><ins>+    trap-&gt;setGenerator([=] (CCallHelpers&amp; jit, const StackmapGenerationParams&amp;) {
+        this-&gt;emitExceptionCheck(jit, ExceptionType::OutOfBoundsTrunc);
</ins><span class="cx">     });
</span><span class="cx">     PatchpointValue* patchpoint = m_currentBlock-&gt;appendNew&lt;PatchpointValue&gt;(m_proc, Int32, Origin());
</span><span class="cx">     patchpoint-&gt;append(arg, ValueRep::SomeRegister);
</span><span class="lines">@@ -1116,8 +1107,8 @@
</span><span class="cx">         m_currentBlock-&gt;appendNew&lt;Value&gt;(m_proc, GreaterEqual, Origin(), arg, min));
</span><span class="cx">     outOfBounds = m_currentBlock-&gt;appendNew&lt;Value&gt;(m_proc, Equal, Origin(), outOfBounds, zeroForType(I32));
</span><span class="cx">     CheckValue* trap = m_currentBlock-&gt;appendNew&lt;CheckValue&gt;(m_proc, Check, Origin(), outOfBounds);
</span><del>-    trap-&gt;setGenerator([] (CCallHelpers&amp; jit, const StackmapGenerationParams&amp;) {
-        jit.breakpoint();
</del><ins>+    trap-&gt;setGenerator([=] (CCallHelpers&amp; jit, const StackmapGenerationParams&amp;) {
+        this-&gt;emitExceptionCheck(jit, ExceptionType::OutOfBoundsTrunc);
</ins><span class="cx">     });
</span><span class="cx">     PatchpointValue* patchpoint = m_currentBlock-&gt;appendNew&lt;PatchpointValue&gt;(m_proc, Int32, Origin());
</span><span class="cx">     patchpoint-&gt;append(arg, ValueRep::SomeRegister);
</span><span class="lines">@@ -1140,8 +1131,8 @@
</span><span class="cx">         m_currentBlock-&gt;appendNew&lt;Value&gt;(m_proc, GreaterThan, Origin(), arg, min));
</span><span class="cx">     outOfBounds = m_currentBlock-&gt;appendNew&lt;Value&gt;(m_proc, Equal, Origin(), outOfBounds, zeroForType(I32));
</span><span class="cx">     CheckValue* trap = m_currentBlock-&gt;appendNew&lt;CheckValue&gt;(m_proc, Check, Origin(), outOfBounds);
</span><del>-    trap-&gt;setGenerator([] (CCallHelpers&amp; jit, const StackmapGenerationParams&amp;) {
-        jit.breakpoint();
</del><ins>+    trap-&gt;setGenerator([=] (CCallHelpers&amp; jit, const StackmapGenerationParams&amp;) {
+        this-&gt;emitExceptionCheck(jit, ExceptionType::OutOfBoundsTrunc);
</ins><span class="cx">     });
</span><span class="cx">     PatchpointValue* patchpoint = m_currentBlock-&gt;appendNew&lt;PatchpointValue&gt;(m_proc, Int32, Origin());
</span><span class="cx">     patchpoint-&gt;append(arg, ValueRep::SomeRegister);
</span><span class="lines">@@ -1163,8 +1154,8 @@
</span><span class="cx">         m_currentBlock-&gt;appendNew&lt;Value&gt;(m_proc, GreaterThan, Origin(), arg, min));
</span><span class="cx">     outOfBounds = m_currentBlock-&gt;appendNew&lt;Value&gt;(m_proc, Equal, Origin(), outOfBounds, zeroForType(I32));
</span><span class="cx">     CheckValue* trap = m_currentBlock-&gt;appendNew&lt;CheckValue&gt;(m_proc, Check, Origin(), outOfBounds);
</span><del>-    trap-&gt;setGenerator([] (CCallHelpers&amp; jit, const StackmapGenerationParams&amp;) {
-        jit.breakpoint();
</del><ins>+    trap-&gt;setGenerator([=] (CCallHelpers&amp; jit, const StackmapGenerationParams&amp;) {
+        this-&gt;emitExceptionCheck(jit, ExceptionType::OutOfBoundsTrunc);
</ins><span class="cx">     });
</span><span class="cx">     PatchpointValue* patchpoint = m_currentBlock-&gt;appendNew&lt;PatchpointValue&gt;(m_proc, Int32, Origin());
</span><span class="cx">     patchpoint-&gt;append(arg, ValueRep::SomeRegister);
</span><span class="lines">@@ -1186,8 +1177,8 @@
</span><span class="cx">         m_currentBlock-&gt;appendNew&lt;Value&gt;(m_proc, GreaterEqual, Origin(), arg, min));
</span><span class="cx">     outOfBounds = m_currentBlock-&gt;appendNew&lt;Value&gt;(m_proc, Equal, Origin(), outOfBounds, zeroForType(I32));
</span><span class="cx">     CheckValue* trap = m_currentBlock-&gt;appendNew&lt;CheckValue&gt;(m_proc, Check, Origin(), outOfBounds);
</span><del>-    trap-&gt;setGenerator([] (CCallHelpers&amp; jit, const StackmapGenerationParams&amp;) {
-        jit.breakpoint();
</del><ins>+    trap-&gt;setGenerator([=] (CCallHelpers&amp; jit, const StackmapGenerationParams&amp;) {
+        this-&gt;emitExceptionCheck(jit, ExceptionType::OutOfBoundsTrunc);
</ins><span class="cx">     });
</span><span class="cx">     PatchpointValue* patchpoint = m_currentBlock-&gt;appendNew&lt;PatchpointValue&gt;(m_proc, Int64, Origin());
</span><span class="cx">     patchpoint-&gt;append(arg, ValueRep::SomeRegister);
</span><span class="lines">@@ -1209,8 +1200,8 @@
</span><span class="cx">         m_currentBlock-&gt;appendNew&lt;Value&gt;(m_proc, GreaterThan, Origin(), arg, min));
</span><span class="cx">     outOfBounds = m_currentBlock-&gt;appendNew&lt;Value&gt;(m_proc, Equal, Origin(), outOfBounds, zeroForType(I32));
</span><span class="cx">     CheckValue* trap = m_currentBlock-&gt;appendNew&lt;CheckValue&gt;(m_proc, Check, Origin(), outOfBounds);
</span><del>-    trap-&gt;setGenerator([] (CCallHelpers&amp; jit, const StackmapGenerationParams&amp;) {
-        jit.breakpoint();
</del><ins>+    trap-&gt;setGenerator([=] (CCallHelpers&amp; jit, const StackmapGenerationParams&amp;) {
+        this-&gt;emitExceptionCheck(jit, ExceptionType::OutOfBoundsTrunc);
</ins><span class="cx">     });
</span><span class="cx"> 
</span><span class="cx">     Value* constant;
</span><span class="lines">@@ -1251,8 +1242,8 @@
</span><span class="cx">         m_currentBlock-&gt;appendNew&lt;Value&gt;(m_proc, GreaterEqual, Origin(), arg, min));
</span><span class="cx">     outOfBounds = m_currentBlock-&gt;appendNew&lt;Value&gt;(m_proc, Equal, Origin(), outOfBounds, zeroForType(I32));
</span><span class="cx">     CheckValue* trap = m_currentBlock-&gt;appendNew&lt;CheckValue&gt;(m_proc, Check, Origin(), outOfBounds);
</span><del>-    trap-&gt;setGenerator([] (CCallHelpers&amp; jit, const StackmapGenerationParams&amp;) {
-        jit.breakpoint();
</del><ins>+    trap-&gt;setGenerator([=] (CCallHelpers&amp; jit, const StackmapGenerationParams&amp;) {
+        this-&gt;emitExceptionCheck(jit, ExceptionType::OutOfBoundsTrunc);
</ins><span class="cx">     });
</span><span class="cx">     PatchpointValue* patchpoint = m_currentBlock-&gt;appendNew&lt;PatchpointValue&gt;(m_proc, Int64, Origin());
</span><span class="cx">     patchpoint-&gt;append(arg, ValueRep::SomeRegister);
</span><span class="lines">@@ -1274,8 +1265,8 @@
</span><span class="cx">         m_currentBlock-&gt;appendNew&lt;Value&gt;(m_proc, GreaterThan, Origin(), arg, min));
</span><span class="cx">     outOfBounds = m_currentBlock-&gt;appendNew&lt;Value&gt;(m_proc, Equal, Origin(), outOfBounds, zeroForType(I32));
</span><span class="cx">     CheckValue* trap = m_currentBlock-&gt;appendNew&lt;CheckValue&gt;(m_proc, Check, Origin(), outOfBounds);
</span><del>-    trap-&gt;setGenerator([] (CCallHelpers&amp; jit, const StackmapGenerationParams&amp;) {
-        jit.breakpoint();
</del><ins>+    trap-&gt;setGenerator([=] (CCallHelpers&amp; jit, const StackmapGenerationParams&amp;) {
+        this-&gt;emitExceptionCheck(jit, ExceptionType::OutOfBoundsTrunc);
</ins><span class="cx">     });
</span><span class="cx"> 
</span><span class="cx">     Value* constant;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWasmExceptionTypehfromrev209927trunkSourceJavaScriptCoreb3B3Compilationcpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/JavaScriptCore/wasm/WasmExceptionType.h (from rev 209927, trunk/Source/JavaScriptCore/b3/B3Compilation.cpp) (0 => 209928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WasmExceptionType.h                                (rev 0)
+++ trunk/Source/JavaScriptCore/wasm/WasmExceptionType.h        2016-12-16 19:24:06 UTC (rev 209928)
</span><span class="lines">@@ -0,0 +1,62 @@
</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 {
+
+#define FOR_EACH_EXCEPTION(macro) \
+    macro(OutOfBoundsMemoryAccess,  &quot;Out of bounds memory access&quot;) \
+    macro(OutOfBoundsCallIndirect, &quot;Out of bounds call_indirect&quot;) \
+    macro(NullTableEntry,  &quot;call_indirect to a null table entry&quot;) \
+    macro(BadSignature, &quot;call_indirect to a signature that does not match&quot;) \
+    macro(OutOfBoundsTrunc, &quot;Out of bounds Trunc operation&quot;) \
+
+enum class ExceptionType : uint32_t {
+#define MAKE_ENUM(enumName, error) enumName,
+    FOR_EACH_EXCEPTION(MAKE_ENUM)
+#undef MAKE_ENUM
+};
+
+ALWAYS_INLINE const char* errorMessageForExceptionType(ExceptionType type)
+{
+    switch (type) {
+#define SWITCH_CASE(enumName, error) \
+    case ExceptionType::enumName: return error;
+
+    FOR_EACH_EXCEPTION(SWITCH_CASE)
+#undef SWITCH_CASE
+    }
+    ASSERT_NOT_REACHED();
+    return &quot;&quot;;
+}
+
+} } // namespace JSC::Wasm
+
+#endif // ENABLE(WEBASSEMBLY)
</ins></span></pre>
</div>
</div>

</body>
</html>