<!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>[194739] trunk/Source/JavaScriptCore</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/194739">194739</a></dd>
<dt>Author</dt> <dd>fpizlo@apple.com</dd>
<dt>Date</dt> <dd>2016-01-07 15:47:16 -0800 (Thu, 07 Jan 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>FTL B3 JS calls should do exceptions
https://bugs.webkit.org/show_bug.cgi?id=152851

Reviewed by Geoffrey Garen.

This reduces the number of JSC test failures with FTL B3 to 111.

* dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::emitCall):
* ftl/FTLLowerDFGToLLVM.cpp:
(JSC::FTL::DFG::LowerDFGToLLVM::compileCallOrConstruct):
(JSC::FTL::DFG::LowerDFGToLLVM::compileTailCall):
(JSC::FTL::DFG::LowerDFGToLLVM::compileCallOrConstructVarargs):
* tests/stress/ftl-call-bad-args-exception-interesting-live-state.js: Added.
* tests/stress/ftl-call-bad-callee-exception-interesting-live-state.js: Added.
* tests/stress/ftl-call-exception-interesting-live-state.js: Added.
* tests/stress/ftl-call-exception-no-catch.js: Added.
* tests/stress/ftl-call-exception.js: Added.
* tests/stress/ftl-call-varargs-bad-callee-exception-interesting-live-state.js: Added.
* tests/stress/ftl-call-varargs-exception-interesting-live-state.js: Added.
* tests/stress/ftl-call-varargs-exception-no-catch.js: Added.
* tests/stress/ftl-call-varargs-exception.js: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGSpeculativeJIT64cpp">trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreftlFTLLowerDFGToLLVMcpp">trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoretestsstressftlcallbadcalleeexceptioninterestinglivestatejs">trunk/Source/JavaScriptCore/tests/stress/ftl-call-bad-callee-exception-interesting-live-state.js</a></li>
<li><a href="#trunkSourceJavaScriptCoretestsstressftlcallexceptioninterestinglivestatejs">trunk/Source/JavaScriptCore/tests/stress/ftl-call-exception-interesting-live-state.js</a></li>
<li><a href="#trunkSourceJavaScriptCoretestsstressftlcallexceptionnocatchjs">trunk/Source/JavaScriptCore/tests/stress/ftl-call-exception-no-catch.js</a></li>
<li><a href="#trunkSourceJavaScriptCoretestsstressftlcallexceptionjs">trunk/Source/JavaScriptCore/tests/stress/ftl-call-exception.js</a></li>
<li><a href="#trunkSourceJavaScriptCoretestsstressftlcallvarargsbadargsexceptioninterestinglivestatejs">trunk/Source/JavaScriptCore/tests/stress/ftl-call-varargs-bad-args-exception-interesting-live-state.js</a></li>
<li><a href="#trunkSourceJavaScriptCoretestsstressftlcallvarargsbadcalleeexceptioninterestinglivestatejs">trunk/Source/JavaScriptCore/tests/stress/ftl-call-varargs-bad-callee-exception-interesting-live-state.js</a></li>
<li><a href="#trunkSourceJavaScriptCoretestsstressftlcallvarargsexceptioninterestinglivestatejs">trunk/Source/JavaScriptCore/tests/stress/ftl-call-varargs-exception-interesting-live-state.js</a></li>
<li><a href="#trunkSourceJavaScriptCoretestsstressftlcallvarargsexceptionnocatchjs">trunk/Source/JavaScriptCore/tests/stress/ftl-call-varargs-exception-no-catch.js</a></li>
<li><a href="#trunkSourceJavaScriptCoretestsstressftlcallvarargsexceptionjs">trunk/Source/JavaScriptCore/tests/stress/ftl-call-varargs-exception.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (194738 => 194739)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-01-07 23:47:14 UTC (rev 194738)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-01-07 23:47:16 UTC (rev 194739)
</span><span class="lines">@@ -1,5 +1,30 @@
</span><span class="cx"> 2016-01-07  Filip Pizlo  &lt;fpizlo@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        FTL B3 JS calls should do exceptions
+        https://bugs.webkit.org/show_bug.cgi?id=152851
+
+        Reviewed by Geoffrey Garen.
+
+        This reduces the number of JSC test failures with FTL B3 to 111.
+
+        * dfg/DFGSpeculativeJIT64.cpp:
+        (JSC::DFG::SpeculativeJIT::emitCall):
+        * ftl/FTLLowerDFGToLLVM.cpp:
+        (JSC::FTL::DFG::LowerDFGToLLVM::compileCallOrConstruct):
+        (JSC::FTL::DFG::LowerDFGToLLVM::compileTailCall):
+        (JSC::FTL::DFG::LowerDFGToLLVM::compileCallOrConstructVarargs):
+        * tests/stress/ftl-call-bad-args-exception-interesting-live-state.js: Added.
+        * tests/stress/ftl-call-bad-callee-exception-interesting-live-state.js: Added.
+        * tests/stress/ftl-call-exception-interesting-live-state.js: Added.
+        * tests/stress/ftl-call-exception-no-catch.js: Added.
+        * tests/stress/ftl-call-exception.js: Added.
+        * tests/stress/ftl-call-varargs-bad-callee-exception-interesting-live-state.js: Added.
+        * tests/stress/ftl-call-varargs-exception-interesting-live-state.js: Added.
+        * tests/stress/ftl-call-varargs-exception-no-catch.js: Added.
+        * tests/stress/ftl-call-varargs-exception.js: Added.
+
+2016-01-07  Filip Pizlo  &lt;fpizlo@apple.com&gt;
+
</ins><span class="cx">         FTL B3 PutById should do exceptions
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=152850
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGSpeculativeJIT64cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp (194738 => 194739)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp        2016-01-07 23:47:14 UTC (rev 194738)
+++ trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp        2016-01-07 23:47:16 UTC (rev 194739)
</span><span class="lines">@@ -821,7 +821,7 @@
</span><span class="cx">     ASSERT(!isTail || !staticOrigin.inlineCallFrame || !staticOrigin.inlineCallFrame-&gt;getCallerSkippingTailCalls());
</span><span class="cx">     ASSERT(!isEmulatedTail || (staticOrigin.inlineCallFrame &amp;&amp; staticOrigin.inlineCallFrame-&gt;getCallerSkippingTailCalls()));
</span><span class="cx">     CodeOrigin dynamicOrigin =
</span><del>-    isEmulatedTail ? *staticOrigin.inlineCallFrame-&gt;getCallerSkippingTailCalls() : staticOrigin;
</del><ins>+        isEmulatedTail ? *staticOrigin.inlineCallFrame-&gt;getCallerSkippingTailCalls() : staticOrigin;
</ins><span class="cx"> 
</span><span class="cx">     CallSiteIndex callSite = m_jit.recordCallSiteAndGenerateExceptionHandlingOSRExitIfNeeded(dynamicOrigin, m_stream-&gt;size());
</span><span class="cx">     m_jit.emitStoreCallSiteIndex(callSite);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreftlFTLLowerDFGToLLVMcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp (194738 => 194739)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp        2016-01-07 23:47:14 UTC (rev 194738)
+++ trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp        2016-01-07 23:47:16 UTC (rev 194739)
</span><span class="lines">@@ -5036,6 +5036,10 @@
</span><span class="cx"> 
</span><span class="cx">         PatchpointValue* patchpoint = m_out.patchpoint(Int64);
</span><span class="cx">         patchpoint-&gt;appendVector(arguments);
</span><ins>+
+        RefPtr&lt;PatchpointExceptionHandle&gt; exceptionHandle =
+            preparePatchpointForExceptions(patchpoint);
+        
</ins><span class="cx">         patchpoint-&gt;clobber(RegisterSet::macroScratchRegisters());
</span><span class="cx">         patchpoint-&gt;clobberLate(RegisterSet::volatileRegistersForJSCall());
</span><span class="cx">         patchpoint-&gt;resultConstraint = ValueRep::reg(GPRInfo::returnValueGPR);
</span><span class="lines">@@ -5047,10 +5051,7 @@
</span><span class="cx">                 AllowMacroScratchRegisterUsage allowScratch(jit);
</span><span class="cx">                 CallSiteIndex callSiteIndex = state-&gt;jitCode-&gt;common.addUniqueCallSiteIndex(codeOrigin);
</span><span class="cx"> 
</span><del>-                // FIXME: If we were handling exceptions, then at this point we would ask our descriptor
-                // to prepare and then we would modify the OSRExit data structure inside the
-                // OSRExitHandle to link it up to this call.
-                // https://bugs.webkit.org/show_bug.cgi?id=151686
</del><ins>+                exceptionHandle-&gt;scheduleExitCreationForUnwind(params, callSiteIndex);
</ins><span class="cx"> 
</span><span class="cx">                 jit.store32(
</span><span class="cx">                     CCallHelpers::TrustedImm32(callSiteIndex.bits()),
</span><span class="lines">@@ -5140,6 +5141,9 @@
</span><span class="cx">         // convenient. The generator then shuffles those arguments into our own call frame,
</span><span class="cx">         // destroying our frame in the process.
</span><span class="cx"> 
</span><ins>+        // Note that we don't have to do anything special for exceptions. A tail call is only a
+        // tail call if it is not inside a try block.
+
</ins><span class="cx">         Vector&lt;ConstrainedValue&gt; arguments;
</span><span class="cx"> 
</span><span class="cx">         arguments.append(ConstrainedValue(jsCallee, ValueRep::reg(GPRInfo::regT0)));
</span><span class="lines">@@ -5170,9 +5174,6 @@
</span><span class="cx">             [=] (CCallHelpers&amp; jit, const StackmapGenerationParams&amp; params) {
</span><span class="cx">                 AllowMacroScratchRegisterUsage allowScratch(jit);
</span><span class="cx"> 
</span><del>-                // FIXME: There may be some exception things that need to happen here.
-                // https://bugs.webkit.org/show_bug.cgi?id=151686
-
</del><span class="cx">                 CallFrameShuffleData shuffleData;
</span><span class="cx">                 shuffleData.numLocals = state-&gt;jitCode-&gt;common.frameRegisterCount;
</span><span class="cx">                 shuffleData.callee = ValueRecovery::inGPR(GPRInfo::regT0, DataFormatJS);
</span><span class="lines">@@ -5281,9 +5282,6 @@
</span><span class="cx">         }
</span><span class="cx">         
</span><span class="cx"> #if FTL_USES_B3
</span><del>-        // FIXME: Need a story for exceptions.
-        // https://bugs.webkit.org/show_bug.cgi?id=151686
-
</del><span class="cx">         PatchpointValue* patchpoint = m_out.patchpoint(Int64);
</span><span class="cx"> 
</span><span class="cx">         // Append the forms of the arguments that we will use before any clobbering happens.
</span><span class="lines">@@ -5301,6 +5299,9 @@
</span><span class="cx">             patchpoint-&gt;append(thisArg, ValueRep::LateColdAny);
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        RefPtr&lt;PatchpointExceptionHandle&gt; exceptionHandle =
+            preparePatchpointForExceptions(patchpoint);
+        
</ins><span class="cx">         patchpoint-&gt;clobber(RegisterSet::macroScratchRegisters());
</span><span class="cx">         patchpoint-&gt;clobberLate(RegisterSet::volatileRegistersForJSCall());
</span><span class="cx">         patchpoint-&gt;resultConstraint = ValueRep::reg(GPRInfo::returnValueGPR);
</span><span class="lines">@@ -5320,12 +5321,11 @@
</span><span class="cx">                 CallSiteIndex callSiteIndex =
</span><span class="cx">                     state-&gt;jitCode-&gt;common.addUniqueCallSiteIndex(codeOrigin);
</span><span class="cx"> 
</span><del>-                // FIXME: We would ask the OSR exit descriptor to prepare and then we would modify
-                // the OSRExit data structure inside the OSRExitHandle to link it up to this call.
-                // Also, the exception checks JumpList should be linked to somewhere.
-                // https://bugs.webkit.org/show_bug.cgi?id=151686
-                CCallHelpers::JumpList exceptions;
</del><ins>+                Box&lt;CCallHelpers::JumpList&gt; exceptions =
+                    exceptionHandle-&gt;scheduleExitCreation(params)-&gt;jumps(jit);
</ins><span class="cx"> 
</span><ins>+                exceptionHandle-&gt;scheduleExitCreationForUnwind(params, callSiteIndex);
+
</ins><span class="cx">                 jit.store32(
</span><span class="cx">                     CCallHelpers::TrustedImm32(callSiteIndex.bits()),
</span><span class="cx">                     CCallHelpers::tagFor(VirtualRegister(JSStack::ArgumentCount)));
</span><span class="lines">@@ -5406,7 +5406,7 @@
</span><span class="cx">                 auto callWithExceptionCheck = [&amp;] (void* callee) {
</span><span class="cx">                     jit.move(CCallHelpers::TrustedImmPtr(callee), GPRInfo::nonPreservedNonArgumentGPR);
</span><span class="cx">                     jit.call(GPRInfo::nonPreservedNonArgumentGPR);
</span><del>-                    exceptions.append(jit.emitExceptionCheck(AssemblyHelpers::NormalExceptionCheck, AssemblyHelpers::FarJumpWidth));
</del><ins>+                    exceptions-&gt;append(jit.emitExceptionCheck(AssemblyHelpers::NormalExceptionCheck, AssemblyHelpers::FarJumpWidth));
</ins><span class="cx">                 };
</span><span class="cx"> 
</span><span class="cx">                 auto adjustStack = [&amp;] (GPRReg amount) {
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstressftlcallbadcalleeexceptioninterestinglivestatejs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/stress/ftl-call-bad-callee-exception-interesting-live-state.js (0 => 194739)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/ftl-call-bad-callee-exception-interesting-live-state.js                                (rev 0)
+++ trunk/Source/JavaScriptCore/tests/stress/ftl-call-bad-callee-exception-interesting-live-state.js        2016-01-07 23:47:16 UTC (rev 194739)
</span><span class="lines">@@ -0,0 +1,57 @@
</span><ins>+function foo(f, p) {
+    var x = 100;
+    var result = 101;
+    var pf = p.g;
+    try {
+        x = 102;
+        pf++;
+        result = f();
+        f = 104;
+        pf++;
+        x = 106;
+    } catch (e) {
+        return {outcome: &quot;exception&quot;, values: [f, pf, x, result]};
+    }
+    return {outcome: &quot;return&quot;, values: [f, pf, x, result]};
+}
+
+noInline(foo);
+
+function bar() {
+    return 107;
+}
+
+noInline(bar);
+
+// Warm up foo().
+for (var i = 0; i &lt; 100000; ++i) {
+    var result = foo(bar, {g:200});
+    if (result.outcome !== &quot;return&quot;)
+        throw &quot;Error in loop: bad outcome: &quot; + result.outcome;
+    if (result.values.length !== 4)
+        throw &quot;Error in loop: bad number of values: &quot; + result.values.length;
+    if (result.values[0] !== 104)
+        throw &quot;Error in loop: bad values[0]: &quot; + result.values[0];
+    if (result.values[1] !== 202)
+        throw &quot;Error in loop: bad values[1]: &quot; + result.values[1];
+    if (result.values[2] !== 106)
+        throw &quot;Error in loop: bad values[2]: &quot; + result.values[2];
+    if (result.values[3] !== 107)
+        throw &quot;Error in loop: bad values[3]: &quot; + result.values[3];
+}
+
+// Now throw an exception.
+var result = foo(&quot;hello&quot;, {g:300});
+if (result.outcome !== &quot;exception&quot;)
+    throw &quot;Error at end: bad outcome: &quot; + result.outcome;
+if (result.values.length !== 4)
+    throw &quot;Error at end: bad number of values: &quot; + result.values.length;
+if (result.values[0] !== &quot;hello&quot;)
+    throw &quot;Error at end: bad values[0]: &quot; + result.values[0];
+if (result.values[1] !== 301)
+    throw &quot;Error at end: bad values[1]: &quot; + result.values[1];
+if (result.values[2] !== 102)
+    throw &quot;Error at end: bad values[2]: &quot; + result.values[2];
+if (result.values[3] !== 101)
+    throw &quot;Error at end: bad values[3]: &quot; + result.values[3];
+
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstressftlcallexceptioninterestinglivestatejs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/stress/ftl-call-exception-interesting-live-state.js (0 => 194739)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/ftl-call-exception-interesting-live-state.js                                (rev 0)
+++ trunk/Source/JavaScriptCore/tests/stress/ftl-call-exception-interesting-live-state.js        2016-01-07 23:47:16 UTC (rev 194739)
</span><span class="lines">@@ -0,0 +1,60 @@
</span><ins>+function foo(f, p) {
+    var x = 100;
+    var result = 101;
+    var pf = p.g;
+    try {
+        x = 102;
+        pf++;
+        result = f();
+        f = 104;
+        pf++;
+        x = 106;
+    } catch (e) {
+        return {outcome: &quot;exception&quot;, values: [f, pf, x, result]};
+    }
+    return {outcome: &quot;return&quot;, values: [f, pf, x, result]};
+}
+
+noInline(foo);
+
+function bar() {
+    return 107;
+}
+
+noInline(bar);
+
+// Warm up foo().
+for (var i = 0; i &lt; 100000; ++i) {
+    var result = foo(bar, {g:200});
+    if (result.outcome !== &quot;return&quot;)
+        throw &quot;Error in loop: bad outcome: &quot; + result.outcome;
+    if (result.values.length !== 4)
+        throw &quot;Error in loop: bad number of values: &quot; + result.values.length;
+    if (result.values[0] !== 104)
+        throw &quot;Error in loop: bad values[0]: &quot; + result.values[0];
+    if (result.values[1] !== 202)
+        throw &quot;Error in loop: bad values[1]: &quot; + result.values[1];
+    if (result.values[2] !== 106)
+        throw &quot;Error in loop: bad values[2]: &quot; + result.values[2];
+    if (result.values[3] !== 107)
+        throw &quot;Error in loop: bad values[3]: &quot; + result.values[3];
+}
+
+// Now throw an exception.
+bar = function() {
+    throw &quot;Error42&quot;;
+}
+var result = foo(bar, {g:300});
+if (result.outcome !== &quot;exception&quot;)
+    throw &quot;Error at end: bad outcome: &quot; + result.outcome;
+if (result.values.length !== 4)
+    throw &quot;Error at end: bad number of values: &quot; + result.values.length;
+if (result.values[0] !== bar)
+    throw &quot;Error at end: bad values[0]: &quot; + result.values[0];
+if (result.values[1] !== 301)
+    throw &quot;Error at end: bad values[1]: &quot; + result.values[1];
+if (result.values[2] !== 102)
+    throw &quot;Error at end: bad values[2]: &quot; + result.values[2];
+if (result.values[3] !== 101)
+    throw &quot;Error at end: bad values[3]: &quot; + result.values[3];
+
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstressftlcallexceptionnocatchjs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/stress/ftl-call-exception-no-catch.js (0 => 194739)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/ftl-call-exception-no-catch.js                                (rev 0)
+++ trunk/Source/JavaScriptCore/tests/stress/ftl-call-exception-no-catch.js        2016-01-07 23:47:16 UTC (rev 194739)
</span><span class="lines">@@ -0,0 +1,51 @@
</span><ins>+function foo(f, p) {
+    var x = 100;
+    var result = 101;
+    x = 102;
+    p = 103;
+    result = f();
+    f = 104;
+    p = 105;
+    x = 106;
+    return {outcome: &quot;return&quot;, values: [f, p, x, result]};
+}
+
+noInline(foo);
+
+function bar() {
+    return 107;
+}
+
+noInline(bar);
+
+// Warm up foo().
+for (var i = 0; i &lt; 100000; ++i) {
+    var result = foo(bar);
+    if (result.outcome !== &quot;return&quot;)
+        throw &quot;Error in loop: bad outcome: &quot; + result.outcome;
+    if (result.values.length !== 4)
+        throw &quot;Error in loop: bad number of values: &quot; + result.values.length;
+    if (result.values[0] !== 104)
+        throw &quot;Error in loop: bad values[0]: &quot; + result.values[0];
+    if (result.values[1] !== 105)
+        throw &quot;Error in loop: bad values[1]: &quot; + result.values[1];
+    if (result.values[2] !== 106)
+        throw &quot;Error in loop: bad values[2]: &quot; + result.values[2];
+    if (result.values[3] !== 107)
+        throw &quot;Error in loop: bad values[3]: &quot; + result.values[3];
+}
+
+// Now throw an exception.
+var result;
+try {
+    bar = function() {
+        throw &quot;Error42&quot;;
+    }
+    var result = foo(bar, 108);
+} catch (e) {
+    if (e != &quot;Error42&quot;)
+        throw &quot;Error at end: bad exception: &quot; + e;
+    result = {outcome: &quot;exception&quot;};
+}
+if (result.outcome !== &quot;exception&quot;)
+    throw &quot;Error at end: bad outcome: &quot; + result.outcome;
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstressftlcallexceptionjs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/stress/ftl-call-exception.js (0 => 194739)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/ftl-call-exception.js                                (rev 0)
+++ trunk/Source/JavaScriptCore/tests/stress/ftl-call-exception.js        2016-01-07 23:47:16 UTC (rev 194739)
</span><span class="lines">@@ -0,0 +1,59 @@
</span><ins>+function foo(f, p, args) {
+    var x = 100;
+    var result = 101;
+    try {
+        x = 102;
+        p = 103;
+        result = f.apply(this, args);
+        f = 104;
+        p = 105;
+        x = 106;
+    } catch (e) {
+        return {outcome: &quot;exception&quot;, values: [f, p, x, result]};
+    }
+    return {outcome: &quot;return&quot;, values: [f, p, x, result]};
+}
+
+noInline(foo);
+
+function bar(a, b, c) {
+    return a + b + c;
+}
+
+noInline(bar);
+
+// Warm up foo().
+for (var i = 0; i &lt; 100000; ++i) {
+    var result = foo(bar, null, [105, 1, 1]);
+    if (result.outcome !== &quot;return&quot;)
+        throw &quot;Error in loop: bad outcome: &quot; + result.outcome;
+    if (result.values.length !== 4)
+        throw &quot;Error in loop: bad number of values: &quot; + result.values.length;
+    if (result.values[0] !== 104)
+        throw &quot;Error in loop: bad values[0]: &quot; + result.values[0];
+    if (result.values[1] !== 105)
+        throw &quot;Error in loop: bad values[1]: &quot; + result.values[1];
+    if (result.values[2] !== 106)
+        throw &quot;Error in loop: bad values[2]: &quot; + result.values[2];
+    if (result.values[3] !== 107)
+        throw &quot;Error in loop: bad values[3]: &quot; + result.values[3];
+}
+
+// Now throw an exception.
+bar = function() {
+    throw &quot;Error42&quot;;
+}
+var result = foo(bar, 108, [105, 1, 1]);
+if (result.outcome !== &quot;exception&quot;)
+    throw &quot;Error at end: bad outcome: &quot; + result.outcome;
+if (result.values.length !== 4)
+    throw &quot;Error at end: bad number of values: &quot; + result.values.length;
+if (result.values[0] !== bar)
+    throw &quot;Error at end: bad values[0]: &quot; + result.values[0];
+if (result.values[1] !== 103)
+    throw &quot;Error at end: bad values[1]: &quot; + result.values[1];
+if (result.values[2] !== 102)
+    throw &quot;Error at end: bad values[2]: &quot; + result.values[2];
+if (result.values[3] !== 101)
+    throw &quot;Error at end: bad values[3]: &quot; + result.values[3];
+
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstressftlcallvarargsbadargsexceptioninterestinglivestatejs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/stress/ftl-call-varargs-bad-args-exception-interesting-live-state.js (0 => 194739)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/ftl-call-varargs-bad-args-exception-interesting-live-state.js                                (rev 0)
+++ trunk/Source/JavaScriptCore/tests/stress/ftl-call-varargs-bad-args-exception-interesting-live-state.js        2016-01-07 23:47:16 UTC (rev 194739)
</span><span class="lines">@@ -0,0 +1,57 @@
</span><ins>+function foo(f, p, args) {
+    var x = 100;
+    var result = 101;
+    var pf = p.g;
+    try {
+        x = 102;
+        pf++;
+        result = f.apply(this, args);
+        f = 104;
+        pf++;
+        x = 106;
+    } catch (e) {
+        return {outcome: &quot;exception&quot;, values: [f, pf, x, result]};
+    }
+    return {outcome: &quot;return&quot;, values: [f, pf, x, result]};
+}
+
+noInline(foo);
+
+function bar(a, b, c) {
+    return a + b + c;
+}
+
+noInline(bar);
+
+// Warm up foo().
+for (var i = 0; i &lt; 100000; ++i) {
+    var result = foo(bar, {g:200}, [105, 1, 1]);
+    if (result.outcome !== &quot;return&quot;)
+        throw &quot;Error in loop: bad outcome: &quot; + result.outcome;
+    if (result.values.length !== 4)
+        throw &quot;Error in loop: bad number of values: &quot; + result.values.length;
+    if (result.values[0] !== 104)
+        throw &quot;Error in loop: bad values[0]: &quot; + result.values[0];
+    if (result.values[1] !== 202)
+        throw &quot;Error in loop: bad values[1]: &quot; + result.values[1];
+    if (result.values[2] !== 106)
+        throw &quot;Error in loop: bad values[2]: &quot; + result.values[2];
+    if (result.values[3] !== 107)
+        throw &quot;Error in loop: bad values[3]: &quot; + result.values[3];
+}
+
+// Now throw an exception.
+var result = foo(bar, {g:300}, 42);
+if (result.outcome !== &quot;exception&quot;)
+    throw &quot;Error at end: bad outcome: &quot; + result.outcome;
+if (result.values.length !== 4)
+    throw &quot;Error at end: bad number of values: &quot; + result.values.length;
+if (result.values[0] !== bar)
+    throw &quot;Error at end: bad values[0]: &quot; + result.values[0];
+if (result.values[1] !== 301)
+    throw &quot;Error at end: bad values[1]: &quot; + result.values[1];
+if (result.values[2] !== 102)
+    throw &quot;Error at end: bad values[2]: &quot; + result.values[2];
+if (result.values[3] !== 101)
+    throw &quot;Error at end: bad values[3]: &quot; + result.values[3];
+
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstressftlcallvarargsbadcalleeexceptioninterestinglivestatejs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/stress/ftl-call-varargs-bad-callee-exception-interesting-live-state.js (0 => 194739)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/ftl-call-varargs-bad-callee-exception-interesting-live-state.js                                (rev 0)
+++ trunk/Source/JavaScriptCore/tests/stress/ftl-call-varargs-bad-callee-exception-interesting-live-state.js        2016-01-07 23:47:16 UTC (rev 194739)
</span><span class="lines">@@ -0,0 +1,57 @@
</span><ins>+function foo(f, p, args) {
+    var x = 100;
+    var result = 101;
+    var pf = p.g;
+    try {
+        x = 102;
+        pf++;
+        result = f.apply(this, args);
+        f = 104;
+        pf++;
+        x = 106;
+    } catch (e) {
+        return {outcome: &quot;exception&quot;, values: [f, pf, x, result]};
+    }
+    return {outcome: &quot;return&quot;, values: [f, pf, x, result]};
+}
+
+noInline(foo);
+
+function bar(a, b, c) {
+    return a + b + c;
+}
+
+noInline(bar);
+
+// Warm up foo().
+for (var i = 0; i &lt; 100000; ++i) {
+    var result = foo(bar, {g:200}, [105, 1, 1]);
+    if (result.outcome !== &quot;return&quot;)
+        throw &quot;Error in loop: bad outcome: &quot; + result.outcome;
+    if (result.values.length !== 4)
+        throw &quot;Error in loop: bad number of values: &quot; + result.values.length;
+    if (result.values[0] !== 104)
+        throw &quot;Error in loop: bad values[0]: &quot; + result.values[0];
+    if (result.values[1] !== 202)
+        throw &quot;Error in loop: bad values[1]: &quot; + result.values[1];
+    if (result.values[2] !== 106)
+        throw &quot;Error in loop: bad values[2]: &quot; + result.values[2];
+    if (result.values[3] !== 107)
+        throw &quot;Error in loop: bad values[3]: &quot; + result.values[3];
+}
+
+// Now throw an exception.
+var result = foo(&quot;hello&quot;, {g:300}, [105, 1, 1]);
+if (result.outcome !== &quot;exception&quot;)
+    throw &quot;Error at end: bad outcome: &quot; + result.outcome;
+if (result.values.length !== 4)
+    throw &quot;Error at end: bad number of values: &quot; + result.values.length;
+if (result.values[0] !== &quot;hello&quot;)
+    throw &quot;Error at end: bad values[0]: &quot; + result.values[0];
+if (result.values[1] !== 301)
+    throw &quot;Error at end: bad values[1]: &quot; + result.values[1];
+if (result.values[2] !== 102)
+    throw &quot;Error at end: bad values[2]: &quot; + result.values[2];
+if (result.values[3] !== 101)
+    throw &quot;Error at end: bad values[3]: &quot; + result.values[3];
+
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstressftlcallvarargsexceptioninterestinglivestatejs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/stress/ftl-call-varargs-exception-interesting-live-state.js (0 => 194739)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/ftl-call-varargs-exception-interesting-live-state.js                                (rev 0)
+++ trunk/Source/JavaScriptCore/tests/stress/ftl-call-varargs-exception-interesting-live-state.js        2016-01-07 23:47:16 UTC (rev 194739)
</span><span class="lines">@@ -0,0 +1,60 @@
</span><ins>+function foo(f, p, args) {
+    var x = 100;
+    var result = 101;
+    var pf = p.g;
+    try {
+        x = 102;
+        pf++;
+        result = f.apply(this, args);
+        f = 104;
+        pf++;
+        x = 106;
+    } catch (e) {
+        return {outcome: &quot;exception&quot;, values: [f, pf, x, result]};
+    }
+    return {outcome: &quot;return&quot;, values: [f, pf, x, result]};
+}
+
+noInline(foo);
+
+function bar(a, b, c) {
+    return a + b + c;
+}
+
+noInline(bar);
+
+// Warm up foo().
+for (var i = 0; i &lt; 100000; ++i) {
+    var result = foo(bar, {g:200}, [105, 1, 1]);
+    if (result.outcome !== &quot;return&quot;)
+        throw &quot;Error in loop: bad outcome: &quot; + result.outcome;
+    if (result.values.length !== 4)
+        throw &quot;Error in loop: bad number of values: &quot; + result.values.length;
+    if (result.values[0] !== 104)
+        throw &quot;Error in loop: bad values[0]: &quot; + result.values[0];
+    if (result.values[1] !== 202)
+        throw &quot;Error in loop: bad values[1]: &quot; + result.values[1];
+    if (result.values[2] !== 106)
+        throw &quot;Error in loop: bad values[2]: &quot; + result.values[2];
+    if (result.values[3] !== 107)
+        throw &quot;Error in loop: bad values[3]: &quot; + result.values[3];
+}
+
+// Now throw an exception.
+bar = function() {
+    throw &quot;Error42&quot;;
+}
+var result = foo(bar, {g:300}, [105, 1, 1]);
+if (result.outcome !== &quot;exception&quot;)
+    throw &quot;Error at end: bad outcome: &quot; + result.outcome;
+if (result.values.length !== 4)
+    throw &quot;Error at end: bad number of values: &quot; + result.values.length;
+if (result.values[0] !== bar)
+    throw &quot;Error at end: bad values[0]: &quot; + result.values[0];
+if (result.values[1] !== 301)
+    throw &quot;Error at end: bad values[1]: &quot; + result.values[1];
+if (result.values[2] !== 102)
+    throw &quot;Error at end: bad values[2]: &quot; + result.values[2];
+if (result.values[3] !== 101)
+    throw &quot;Error at end: bad values[3]: &quot; + result.values[3];
+
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstressftlcallvarargsexceptionnocatchjs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/stress/ftl-call-varargs-exception-no-catch.js (0 => 194739)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/ftl-call-varargs-exception-no-catch.js                                (rev 0)
+++ trunk/Source/JavaScriptCore/tests/stress/ftl-call-varargs-exception-no-catch.js        2016-01-07 23:47:16 UTC (rev 194739)
</span><span class="lines">@@ -0,0 +1,51 @@
</span><ins>+function foo(f, p, args) {
+    var x = 100;
+    var result = 101;
+    x = 102;
+    p = 103;
+    result = f.apply(this, args);
+    f = 104;
+    p = 105;
+    x = 106;
+    return {outcome: &quot;return&quot;, values: [f, p, x, result]};
+}
+
+noInline(foo);
+
+function bar(a, b, c) {
+    return a + b + c;
+}
+
+noInline(bar);
+
+// Warm up foo().
+for (var i = 0; i &lt; 100000; ++i) {
+    var result = foo(bar, null, [105, 1, 1]);
+    if (result.outcome !== &quot;return&quot;)
+        throw &quot;Error in loop: bad outcome: &quot; + result.outcome;
+    if (result.values.length !== 4)
+        throw &quot;Error in loop: bad number of values: &quot; + result.values.length;
+    if (result.values[0] !== 104)
+        throw &quot;Error in loop: bad values[0]: &quot; + result.values[0];
+    if (result.values[1] !== 105)
+        throw &quot;Error in loop: bad values[1]: &quot; + result.values[1];
+    if (result.values[2] !== 106)
+        throw &quot;Error in loop: bad values[2]: &quot; + result.values[2];
+    if (result.values[3] !== 107)
+        throw &quot;Error in loop: bad values[3]: &quot; + result.values[3];
+}
+
+// Now throw an exception.
+var result;
+try {
+    bar = function() {
+        throw &quot;Error42&quot;;
+    }
+    var result = foo(bar, 108, [105, 1, 1]);
+} catch (e) {
+    if (e != &quot;Error42&quot;)
+        throw &quot;Error at end: bad exception: &quot; + e;
+    result = {outcome: &quot;exception&quot;};
+}
+if (result.outcome !== &quot;exception&quot;)
+    throw &quot;Error at end: bad outcome: &quot; + result.outcome;
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstressftlcallvarargsexceptionjs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/stress/ftl-call-varargs-exception.js (0 => 194739)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/ftl-call-varargs-exception.js                                (rev 0)
+++ trunk/Source/JavaScriptCore/tests/stress/ftl-call-varargs-exception.js        2016-01-07 23:47:16 UTC (rev 194739)
</span><span class="lines">@@ -0,0 +1,59 @@
</span><ins>+function foo(f, p) {
+    var x = 100;
+    var result = 101;
+    try {
+        x = 102;
+        p = 103;
+        result = f();
+        f = 104;
+        p = 105;
+        x = 106;
+    } catch (e) {
+        return {outcome: &quot;exception&quot;, values: [f, p, x, result]};
+    }
+    return {outcome: &quot;return&quot;, values: [f, p, x, result]};
+}
+
+noInline(foo);
+
+function bar() {
+    return 107;
+}
+
+noInline(bar);
+
+// Warm up foo().
+for (var i = 0; i &lt; 100000; ++i) {
+    var result = foo(bar);
+    if (result.outcome !== &quot;return&quot;)
+        throw &quot;Error in loop: bad outcome: &quot; + result.outcome;
+    if (result.values.length !== 4)
+        throw &quot;Error in loop: bad number of values: &quot; + result.values.length;
+    if (result.values[0] !== 104)
+        throw &quot;Error in loop: bad values[0]: &quot; + result.values[0];
+    if (result.values[1] !== 105)
+        throw &quot;Error in loop: bad values[1]: &quot; + result.values[1];
+    if (result.values[2] !== 106)
+        throw &quot;Error in loop: bad values[2]: &quot; + result.values[2];
+    if (result.values[3] !== 107)
+        throw &quot;Error in loop: bad values[3]: &quot; + result.values[3];
+}
+
+// Now throw an exception.
+bar = function() {
+    throw &quot;Error42&quot;;
+}
+var result = foo(bar, 108);
+if (result.outcome !== &quot;exception&quot;)
+    throw &quot;Error at end: bad outcome: &quot; + result.outcome;
+if (result.values.length !== 4)
+    throw &quot;Error at end: bad number of values: &quot; + result.values.length;
+if (result.values[0] !== bar)
+    throw &quot;Error at end: bad values[0]: &quot; + result.values[0];
+if (result.values[1] !== 103)
+    throw &quot;Error at end: bad values[1]: &quot; + result.values[1];
+if (result.values[2] !== 102)
+    throw &quot;Error at end: bad values[2]: &quot; + result.values[2];
+if (result.values[3] !== 101)
+    throw &quot;Error at end: bad values[3]: &quot; + result.values[3];
+
</ins></span></pre>
</div>
</div>

</body>
</html>