<!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>[162089] branches/jsCStack/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/162089">162089</a></dd>
<dt>Author</dt> <dd>fpizlo@apple.com</dd>
<dt>Date</dt> <dd>2014-01-15 14:16:41 -0800 (Wed, 15 Jan 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>reentrant-caching sometimes fails with LLInt disabled
https://bugs.webkit.org/show_bug.cgi?id=126781

Reviewed by Michael Saboff.
        
The lookupExceptionHandler-&gt;genericUnwind-&gt;handleUncaughtException paths need to
be resilient against the frame from which we claim to be throwing the exception
being the sentinel frame.

Also attempted to add a test that pinpoints the problem, but it didn't cause a
crash either before or after my change. That's fine, I figured it would be good to
have more coverage for madness like this.

* dfg/DFGJITCompiler.cpp:
(JSC::DFG::JITCompiler::compileExceptionHandlers):
* ftl/FTLCompile.cpp:
(JSC::FTL::fixFunctionBasedOnStackMaps):
* interpreter/Interpreter.cpp:
(JSC::Interpreter::unwind):
* interpreter/Interpreter.h:
(JSC::NativeCallFrameTracer::NativeCallFrameTracer):
* jit/CCallHelpers.h:
(JSC::CCallHelpers::setupArguments):
* jit/JIT.cpp:
(JSC::JIT::privateCompileExceptionHandlers):
* jit/JITOperations.cpp:
* jit/JITOperations.h:
* jit/Repatch.cpp:
(JSC::tryBuildGetByIDList):
* jit/ThunkGenerators.cpp:
(JSC::throwExceptionFromCallSlowPathGenerator):
* llint/LowLevelInterpreter64.asm:
* tests/stress/recurse-infinitely-on-getter.js: Added.
(.var):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchesjsCStackSourceJavaScriptCoreChangeLog">branches/jsCStack/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoredfgDFGJITCompilercpp">branches/jsCStack/Source/JavaScriptCore/dfg/DFGJITCompiler.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreftlFTLCompilecpp">branches/jsCStack/Source/JavaScriptCore/ftl/FTLCompile.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreinterpreterInterpretercpp">branches/jsCStack/Source/JavaScriptCore/interpreter/Interpreter.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreinterpreterInterpreterh">branches/jsCStack/Source/JavaScriptCore/interpreter/Interpreter.h</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCorejitCCallHelpersh">branches/jsCStack/Source/JavaScriptCore/jit/CCallHelpers.h</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCorejitJITcpp">branches/jsCStack/Source/JavaScriptCore/jit/JIT.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCorejitJITOperationscpp">branches/jsCStack/Source/JavaScriptCore/jit/JITOperations.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCorejitJITOperationsh">branches/jsCStack/Source/JavaScriptCore/jit/JITOperations.h</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCorejitRepatchcpp">branches/jsCStack/Source/JavaScriptCore/jit/Repatch.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCorejitThunkGeneratorscpp">branches/jsCStack/Source/JavaScriptCore/jit/ThunkGenerators.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCorellintLowLevelInterpreter64asm">branches/jsCStack/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#branchesjsCStackSourceJavaScriptCoretestsstressrecurseinfinitelyongetterjs">branches/jsCStack/Source/JavaScriptCore/tests/stress/recurse-infinitely-on-getter.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchesjsCStackSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/ChangeLog (162088 => 162089)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/ChangeLog        2014-01-15 21:39:14 UTC (rev 162088)
+++ branches/jsCStack/Source/JavaScriptCore/ChangeLog        2014-01-15 22:16:41 UTC (rev 162089)
</span><span class="lines">@@ -1,3 +1,40 @@
</span><ins>+2014-01-15  Filip Pizlo  &lt;fpizlo@apple.com&gt;
+
+        reentrant-caching sometimes fails with LLInt disabled
+        https://bugs.webkit.org/show_bug.cgi?id=126781
+
+        Reviewed by Michael Saboff.
+        
+        The lookupExceptionHandler-&gt;genericUnwind-&gt;handleUncaughtException paths need to
+        be resilient against the frame from which we claim to be throwing the exception
+        being the sentinel frame.
+
+        Also attempted to add a test that pinpoints the problem, but it didn't cause a
+        crash either before or after my change. That's fine, I figured it would be good to
+        have more coverage for madness like this.
+
+        * dfg/DFGJITCompiler.cpp:
+        (JSC::DFG::JITCompiler::compileExceptionHandlers):
+        * ftl/FTLCompile.cpp:
+        (JSC::FTL::fixFunctionBasedOnStackMaps):
+        * interpreter/Interpreter.cpp:
+        (JSC::Interpreter::unwind):
+        * interpreter/Interpreter.h:
+        (JSC::NativeCallFrameTracer::NativeCallFrameTracer):
+        * jit/CCallHelpers.h:
+        (JSC::CCallHelpers::setupArguments):
+        * jit/JIT.cpp:
+        (JSC::JIT::privateCompileExceptionHandlers):
+        * jit/JITOperations.cpp:
+        * jit/JITOperations.h:
+        * jit/Repatch.cpp:
+        (JSC::tryBuildGetByIDList):
+        * jit/ThunkGenerators.cpp:
+        (JSC::throwExceptionFromCallSlowPathGenerator):
+        * llint/LowLevelInterpreter64.asm:
+        * tests/stress/recurse-infinitely-on-getter.js: Added.
+        (.var):
+
</ins><span class="cx"> 2014-01-14  Filip Pizlo  &lt;fpizlo@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         FTL slow path calls in inline caches should be down with exceptions
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoredfgDFGJITCompilercpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/dfg/DFGJITCompiler.cpp (162088 => 162089)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/dfg/DFGJITCompiler.cpp        2014-01-15 21:39:14 UTC (rev 162088)
+++ branches/jsCStack/Source/JavaScriptCore/dfg/DFGJITCompiler.cpp        2014-01-15 22:16:41 UTC (rev 162089)
</span><span class="lines">@@ -121,22 +121,25 @@
</span><span class="cx"> 
</span><span class="cx">     if (!m_exceptionChecksWithCallFrameRollback.empty()) {
</span><span class="cx">         m_exceptionChecksWithCallFrameRollback.link(this);
</span><del>-        emitGetCallerFrameFromCallFrameHeaderPtr(GPRInfo::argumentGPR0);
</del><ins>+        emitGetCallerFrameFromCallFrameHeaderPtr(GPRInfo::argumentGPR1);
</ins><span class="cx">         doLookup = jump();
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (!m_exceptionChecks.empty())
</span><span class="cx">         m_exceptionChecks.link(this);
</span><span class="cx"> 
</span><del>-    // lookupExceptionHandler is passed one argument, the exec (the CallFrame*).
-    move(GPRInfo::callFrameRegister, GPRInfo::argumentGPR0);
</del><ins>+    // lookupExceptionHandler is passed two arguments, the VM and the exec (the CallFrame*).
+    move(GPRInfo::callFrameRegister, GPRInfo::argumentGPR1);
</ins><span class="cx"> 
</span><span class="cx">     if (doLookup.isSet())
</span><span class="cx">         doLookup.link(this);
</span><span class="cx"> 
</span><ins>+    move(TrustedImmPtr(vm()), GPRInfo::argumentGPR0);
+
</ins><span class="cx"> #if CPU(X86)
</span><span class="cx">     // FIXME: should use the call abstraction, but this is currently in the SpeculativeJIT layer!
</span><span class="cx">     poke(GPRInfo::argumentGPR0);
</span><ins>+    poke(GPRInfo::argumentGPR1, 1);
</ins><span class="cx"> #endif
</span><span class="cx">     m_calls.append(CallLinkRecord(call(), lookupExceptionHandler));
</span><span class="cx">     jumpToExceptionHandler();
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreftlFTLCompilecpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/ftl/FTLCompile.cpp (162088 => 162089)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/ftl/FTLCompile.cpp        2014-01-15 21:39:14 UTC (rev 162088)
+++ branches/jsCStack/Source/JavaScriptCore/ftl/FTLCompile.cpp        2014-01-15 22:16:41 UTC (rev 162089)
</span><span class="lines">@@ -179,7 +179,8 @@
</span><span class="cx">         checkJIT.move(MacroAssembler::TrustedImm64(TagTypeNumber), GPRInfo::tagTypeNumberRegister);
</span><span class="cx">         checkJIT.move(MacroAssembler::TrustedImm64(TagMask), GPRInfo::tagMaskRegister);
</span><span class="cx">         
</span><del>-        checkJIT.move(GPRInfo::callFrameRegister, GPRInfo::argumentGPR0);
</del><ins>+        checkJIT.move(MacroAssembler::TrustedImmPtr(&amp;vm), GPRInfo::argumentGPR0);
+        checkJIT.move(GPRInfo::callFrameRegister, GPRInfo::argumentGPR1);
</ins><span class="cx">         MacroAssembler::Call call = checkJIT.call();
</span><span class="cx">         checkJIT.jumpToExceptionHandler();
</span><span class="cx">         
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreinterpreterInterpretercpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/interpreter/Interpreter.cpp (162088 => 162089)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/interpreter/Interpreter.cpp        2014-01-15 21:39:14 UTC (rev 162088)
+++ branches/jsCStack/Source/JavaScriptCore/interpreter/Interpreter.cpp        2014-01-15 22:16:41 UTC (rev 162089)
</span><span class="lines">@@ -649,6 +649,15 @@
</span><span class="cx"> 
</span><span class="cx"> NEVER_INLINE HandlerInfo* Interpreter::unwind(CallFrame*&amp; callFrame, JSValue&amp; exceptionValue)
</span><span class="cx"> {
</span><ins>+    if (callFrame-&gt;isVMEntrySentinel()) {
+        // This happens when we throw stack overflow in a function that is called
+        // directly from callToJavaScript.  Stack overflow throws the exception in the
+        // context of the caller.  In that case the caller is the sentinel frame.  The
+        // right thing to do is to pretend that the exception is uncaught so that we
+        // go to the uncaught exception handler, which returns through callToJavaScript.
+        return 0;
+    }
+    
</ins><span class="cx">     CodeBlock* codeBlock = callFrame-&gt;codeBlock();
</span><span class="cx">     bool isTermination = false;
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreinterpreterInterpreterh"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/interpreter/Interpreter.h (162088 => 162089)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/interpreter/Interpreter.h        2014-01-15 21:39:14 UTC (rev 162088)
+++ branches/jsCStack/Source/JavaScriptCore/interpreter/Interpreter.h        2014-01-15 22:16:41 UTC (rev 162089)
</span><span class="lines">@@ -180,6 +180,15 @@
</span><span class="cx">             ASSERT(!callFrame-&gt;isVMEntrySentinel());
</span><span class="cx">             vm-&gt;topCallFrame = callFrame;
</span><span class="cx">         }
</span><ins>+        
+        enum VMEntrySentinelOKTag { VMEntrySentinelOK };
+        ALWAYS_INLINE NativeCallFrameTracer(VM* vm, CallFrame* callFrame, VMEntrySentinelOKTag)
+        {
+            ASSERT(vm);
+            ASSERT(callFrame);
+            if (!callFrame-&gt;isVMEntrySentinel())
+                vm-&gt;topCallFrame = callFrame;
+        }
</ins><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx">     class Interpreter {
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCorejitCCallHelpersh"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/jit/CCallHelpers.h (162088 => 162089)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/jit/CCallHelpers.h        2014-01-15 21:39:14 UTC (rev 162088)
+++ branches/jsCStack/Source/JavaScriptCore/jit/CCallHelpers.h        2014-01-15 22:16:41 UTC (rev 162089)
</span><span class="lines">@@ -95,6 +95,13 @@
</span><span class="cx">         addCallArgument(arg2);
</span><span class="cx">     }
</span><span class="cx">     
</span><ins>+    ALWAYS_INLINE void setupArguments(TrustedImmPtr arg1, GPRReg arg2)
+    {
+        resetCallArguments();
+        addCallArgument(arg1);
+        addCallArgument(arg2);
+    }
+    
</ins><span class="cx">     ALWAYS_INLINE void setupArguments(GPRReg arg1, GPRReg arg2, GPRReg arg3)
</span><span class="cx">     {
</span><span class="cx">         resetCallArguments();
</span><span class="lines">@@ -939,6 +946,12 @@
</span><span class="cx">         move(arg1, GPRInfo::argumentGPR0);
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    ALWAYS_INLINE void setupArguments(TrustedImmPtr arg1, GPRReg arg2)
+    {
+        move(arg2, GPRInfo::argumentGPR1);
+        move(arg1, GPRInfo::argumentGPR0);
+    }
+    
</ins><span class="cx">     ALWAYS_INLINE void setupArguments(GPRReg arg1, GPRReg arg2)
</span><span class="cx">     {
</span><span class="cx">         setupTwoStubArgsGPR&lt;GPRInfo::argumentGPR0, GPRInfo::argumentGPR1&gt;(arg1, arg2);
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCorejitJITcpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/jit/JIT.cpp (162088 => 162089)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/jit/JIT.cpp        2014-01-15 21:39:14 UTC (rev 162088)
+++ branches/jsCStack/Source/JavaScriptCore/jit/JIT.cpp        2014-01-15 22:16:41 UTC (rev 162089)
</span><span class="lines">@@ -702,7 +702,7 @@
</span><span class="cx"> 
</span><span class="cx">     if (!m_exceptionChecksWithCallFrameRollback.empty()) {
</span><span class="cx">         m_exceptionChecksWithCallFrameRollback.link(this);
</span><del>-        emitGetCallerFrameFromCallFrameHeaderPtr(GPRInfo::argumentGPR0);
</del><ins>+        emitGetCallerFrameFromCallFrameHeaderPtr(GPRInfo::argumentGPR1);
</ins><span class="cx">         doLookup = jump();
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -710,14 +710,17 @@
</span><span class="cx">         m_exceptionChecks.link(this);
</span><span class="cx">     
</span><span class="cx">     // lookupExceptionHandler is passed one argument, the exec (the CallFrame*).
</span><del>-    move(GPRInfo::callFrameRegister, GPRInfo::argumentGPR0);
</del><ins>+    move(GPRInfo::callFrameRegister, GPRInfo::argumentGPR1);
</ins><span class="cx"> 
</span><span class="cx">     if (doLookup.isSet())
</span><span class="cx">         doLookup.link(this);
</span><span class="cx"> 
</span><ins>+    move(TrustedImmPtr(vm()), GPRInfo::argumentGPR0);
+
</ins><span class="cx"> #if CPU(X86)
</span><span class="cx">     // FIXME: should use the call abstraction, but this is currently in the SpeculativeJIT layer!
</span><span class="cx">     poke(GPRInfo::argumentGPR0);
</span><ins>+    poke(GPRInfo::argumentGPR1, 1);
</ins><span class="cx"> #endif
</span><span class="cx">     m_calls.append(CallRecord(call(), (unsigned)-1, FunctionPtr(lookupExceptionHandler).value()));
</span><span class="cx">     jumpToExceptionHandler();
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCorejitJITOperationscpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/jit/JITOperations.cpp (162088 => 162089)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/jit/JITOperations.cpp        2014-01-15 21:39:14 UTC (rev 162088)
+++ branches/jsCStack/Source/JavaScriptCore/jit/JITOperations.cpp        2014-01-15 22:16:41 UTC (rev 162089)
</span><span class="lines">@@ -1731,12 +1731,11 @@
</span><span class="cx">     genericUnwind(vm, exec, exceptionValue);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void JIT_OPERATION lookupExceptionHandler(ExecState* exec)
</del><ins>+void JIT_OPERATION lookupExceptionHandler(VM* vm, ExecState* exec)
</ins><span class="cx"> {
</span><del>-    VM* vm = &amp;exec-&gt;vm();
-    NativeCallFrameTracer tracer(vm, exec);
</del><ins>+    NativeCallFrameTracer tracer(vm, exec, NativeCallFrameTracer::VMEntrySentinelOK);
</ins><span class="cx"> 
</span><del>-    JSValue exceptionValue = exec-&gt;exception();
</del><ins>+    JSValue exceptionValue = vm-&gt;exception();
</ins><span class="cx">     ASSERT(exceptionValue);
</span><span class="cx">     
</span><span class="cx">     genericUnwind(vm, exec, exceptionValue);
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCorejitJITOperationsh"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/jit/JITOperations.h (162088 => 162089)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/jit/JITOperations.h        2014-01-15 21:39:14 UTC (rev 162088)
+++ branches/jsCStack/Source/JavaScriptCore/jit/JITOperations.h        2014-01-15 22:16:41 UTC (rev 162089)
</span><span class="lines">@@ -183,8 +183,8 @@
</span><span class="cx"> 
</span><span class="cx"> // This method is used to lookup an exception hander, keyed by faultLocation, which is
</span><span class="cx"> // the return location from one of the calls out to one of the helper operations above.
</span><del>-    
-void JIT_OPERATION lookupExceptionHandler(ExecState*) WTF_INTERNAL;
</del><ins>+
+void JIT_OPERATION lookupExceptionHandler(VM*, ExecState*) WTF_INTERNAL;
</ins><span class="cx"> void JIT_OPERATION operationVMHandleException(ExecState*) WTF_INTERNAL;
</span><span class="cx"> 
</span><span class="cx"> void JIT_OPERATION operationThrowStackOverflowError(ExecState*, CodeBlock*) WTF_INTERNAL;
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCorejitRepatchcpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/jit/Repatch.cpp (162088 => 162089)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/jit/Repatch.cpp        2014-01-15 21:39:14 UTC (rev 162088)
+++ branches/jsCStack/Source/JavaScriptCore/jit/Repatch.cpp        2014-01-15 22:16:41 UTC (rev 162089)
</span><span class="lines">@@ -559,7 +559,7 @@
</span><span class="cx"> #endif
</span><span class="cx">             success = stubJit.emitExceptionCheck(CCallHelpers::InvertedExceptionCheck);
</span><span class="cx">             
</span><del>-            stubJit.setupArgumentsExecState();
</del><ins>+            stubJit.setupArguments(CCallHelpers::TrustedImmPtr(vm), GPRInfo::callFrameRegister);
</ins><span class="cx">             handlerCall = stubJit.call();
</span><span class="cx">             stubJit.jumpToExceptionHandler();
</span><span class="cx">         } else {
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCorejitThunkGeneratorscpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/jit/ThunkGenerators.cpp (162088 => 162089)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/jit/ThunkGenerators.cpp        2014-01-15 21:39:14 UTC (rev 162088)
+++ branches/jsCStack/Source/JavaScriptCore/jit/ThunkGenerators.cpp        2014-01-15 22:16:41 UTC (rev 162089)
</span><span class="lines">@@ -66,7 +66,7 @@
</span><span class="cx">     // even though we won't use it.
</span><span class="cx">     jit.preserveReturnAddressAfterCall(GPRInfo::nonPreservedNonReturnGPR);
</span><span class="cx"> 
</span><del>-    jit.setupArgumentsExecState();
</del><ins>+    jit.setupArguments(CCallHelpers::TrustedImmPtr(vm), GPRInfo::callFrameRegister);
</ins><span class="cx">     jit.move(CCallHelpers::TrustedImmPtr(bitwise_cast&lt;void*&gt;(lookupExceptionHandler)), GPRInfo::nonArgGPR0);
</span><span class="cx">     emitPointerValidation(jit, GPRInfo::nonArgGPR0);
</span><span class="cx">     jit.call(GPRInfo::nonArgGPR0);
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCorellintLowLevelInterpreter64asm"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm (162088 => 162089)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm        2014-01-15 21:39:14 UTC (rev 162088)
+++ branches/jsCStack/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm        2014-01-15 22:16:41 UTC (rev 162089)
</span><span class="lines">@@ -267,10 +267,13 @@
</span><span class="cx">     loadp MarkedBlock::m_weakSet + WeakSet::m_vm[t3], t3
</span><span class="cx">     loadp VM::callFrameForThrow[t3], cfr
</span><span class="cx"> 
</span><del>-    # So far, we've unwound the stack to the frame just below the sentinel frame.
-    # We need to pop to the sentinel frame and do the necessary clean up for
</del><ins>+    # So far, we've unwound the stack to the frame just below the sentinel frame, except
+    # in the case of stack overflow in the first function called from callToJavaScript.
+    # Check if we need to pop to the sentinel frame and do the necessary clean up for
</ins><span class="cx">     # returning to the caller C frame.
</span><ins>+    bpeq CodeBlock[cfr], 1, .handleUncaughtExceptionAlreadyIsSentinel
</ins><span class="cx">     loadp CallerFrame[cfr], cfr
</span><ins>+.handleUncaughtExceptionAlreadyIsSentinel:
</ins><span class="cx"> 
</span><span class="cx">     loadp Callee[cfr], t3 # VM
</span><span class="cx">     loadp ScopeChain[cfr], t5 # previous topCallFrame
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoretestsstressrecurseinfinitelyongetterjs"></a>
<div class="addfile"><h4>Added: branches/jsCStack/Source/JavaScriptCore/tests/stress/recurse-infinitely-on-getter.js (0 => 162089)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/tests/stress/recurse-infinitely-on-getter.js                                (rev 0)
+++ branches/jsCStack/Source/JavaScriptCore/tests/stress/recurse-infinitely-on-getter.js        2014-01-15 22:16:41 UTC (rev 162089)
</span><span class="lines">@@ -0,0 +1,19 @@
</span><ins>+for (var i = 0; i &lt; 100; ++i) {
+    var o = {};
+    o.__defineGetter__(&quot;f&quot;, function() {
+        return o.f;
+    });
+    var didThrow;
+    var result;
+    result = &quot;not set&quot;;
+    try {
+        result = o.f;
+    } catch (e) {
+        didThrow = e;
+    }
+    if (result != &quot;not set&quot;)
+        throw &quot;Did set result: &quot; + result;
+    if (!didThrow || didThrow.toString().indexOf(&quot;RangeError&quot;) != 0)
+        throw &quot;Bad exception: &quot; + didThrow;
+}
+
</ins></span></pre>
</div>
</div>

</body>
</html>