<!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>[161575] branches/jsCStack</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/161575">161575</a></dd>
<dt>Author</dt> <dd>mark.lam@apple.com</dd>
<dt>Date</dt> <dd>2014-01-09 13:10:46 -0800 (Thu, 09 Jan 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>CStack: Need a separate stack limit for the JS stack and the C stack.
https://bugs.webkit.org/show_bug.cgi?id=126320.

Reviewed by Geoffrey Garen.

Source/JavaScriptCore: 

The purpose of this patch is mainly to change the way we compute the stack
limit for JS stack checks. Previously, we tally up the stack usage per
session of VM re-entry as tracked by the VMEntryScope, and we ensure that
the total usage does not exceed Options::maxStackSize(), and of course, is
also capped by the amount of native C stack available. The usage tracking
here does not count host / native function stack usage against the max
stack usage.

The new way is to compute a limit as an offset from the VMEntryScope of
the first entry into the VM. Options::maxPerThreadStackUsage()
will provide that offset. Any host / native function stack usage after
we've entered the VM will be counted against the max stack usage.

This patch supplants parts or all of the following previously committed
patches:

    <a href="http://trac.webkit.org/projects/webkit/changeset/161104">r161104</a>: https://bugs.webkit.org/show_bug.cgi?id=126266
             Rename VM::entryScope to firstEntryScope.
    <a href="http://trac.webkit.org/projects/webkit/changeset/161232">r161232</a>: https://bugs.webkit.org/show_bug.cgi?id=126321
             Introducing Options::maxStackSize().
    <a href="http://trac.webkit.org/projects/webkit/changeset/161172">r161172</a>: https://bugs.webkit.org/show_bug.cgi?id=126331
             Refactor to split the tracking of the jsStackLimit from the
             native stackLimit.
    <a href="http://trac.webkit.org/projects/webkit/changeset/161174">r161174</a>: https://bugs.webkit.org/show_bug.cgi?id=126334
             Introduce tracking of the top VMEntryScope.
    <a href="http://trac.webkit.org/projects/webkit/changeset/161361">r161361</a>: https://bugs.webkit.org/show_bug.cgi?id=126487
             The fixed up jsStackLimit in doCallToJavaScript should not
             exceed the native stack limit.
    <a href="http://trac.webkit.org/projects/webkit/changeset/161180">r161180</a>: https://bugs.webkit.org/show_bug.cgi?id=126320
             Need a separate stack limit for the JS stack and the C stack.
             This was for the old way of tracking chunks of stack usage
             per VMEntryScope.

Details of this patch:

1. Renamed VM::firstEntryScope back to VM::entryScope.
   Removed the tracking of topEntryScope and related code.

2. Renamed Options::maxStackSize() to maxPerThreadStackUsage().
   Added Options::hostZoneSize() and Options::errorModeHostZoneSize().

3. The VM now tracks its current hostZoneSize and stack limits.
   VM::m_stackLimit is computed when the hostZoneSize is set via
   VM::updateStackLimitWithHostZoneSize().

   In the C Loop LLINT case, the VM also provides a setJSStackLimit()
   since VM::m_stackLimit and VM::m_jsStackLimit are 2 different values
   in that case.

4. Replaced Interpreter::ErrorHandlingMode with ErrorHandlingScope.
   The ErrorHandlingScope constructor will set the VM host zone size to
   Options::errorModeHostZoneSize(), and restore the previous host zone
   size.

   The destructor for ErrorHandlingScope will restore the previous stack
   limit. We can enter multiple ErrorHandlingScopes. Only the destruction
   of the very first one will restore the stack limit with the non-error
   mode host zone.

5. LLINT C loop JSStack changes:
   5.1 Replaced calls to roundUpToAllocationSize() with WTF::roundUpToMultipleOf().
       roundUpToAllocationSize() is redundant and is now removed.

   5.2 Removed enable/disableErrorStackReserve() and updateStackLimit().
       Their function is now handled by JSStack::setHostZoneSize().

   5.3 Added accounting for a host zone in the LLINT C loop JSStack.
       This includes growing the JS stack to allow space for the host zone
       whenever the host zone size is adjusted via JSStack::setHostZoneSize().

       Note: though setHostZoneSize() is based on disableErrorStackReserve(),
       we don't retain the logic to shrink the stack there. That logic was
       always dead code: we only call shrink() if m_end + 1 &lt; m_useableTop,
       but shrink() will only shrink the stack if m_end is pointing to the
       base of the stack i.e. the 2 conditions are mutually exclusive, and
       no work to shrink the stack will ever be done here.

       m_useableTop is no longer needed and is now removed.

   5.4 Change all non C loop code to reference VM::stackLimit() instead of
       VM::jsStackLimit(). Though the 2 are the same for non C loop builds,
       this makes it more straightforward. We now only reference the
       jsStackLimit in 2 cases:

       a. LLINT and JIT code performing stack checks where they expect the
          jsStackLimit to be a pseudonym for the stackLimit in non C loop
          builds.

       b. In the C loop build, the JSStack itself sets VM::m_jsStackLimit()
          when it adjusts its host zone size.

       In all other cases, we work directly with VM::stackLimit().

6. Simplify the tracking of VM::stackPointerAtVMEntry. We now set
   VM::stackPointerAtVMEntry when we install a VMEntryScope if and only if
   it isn't already set.

   When we drop the API locks, we'll save the current stackPointerAtVMEntry
   and stack limit value, and clear stackPointerAtVMEntry to allow a new
   thread acquiring the API locks to re-set it when it installs a VMEntryScope.
   When we re-acquire the API locks again, we'll restore the previously saved
   stackPointerAtVMEntry and stack limit.

   With this change, we also no longer need the stackPointerAtVMEntry fix up
   code in doCallToJavaScript(). That code is now removed.

* CMakeLists.txt:
* GNUmakefile.list.am:
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters:
* JavaScriptCore.xcodeproj/project.pbxproj:
* debugger/Debugger.cpp:
(JSC::Debugger::recompileAllJSFunctions):
* debugger/DebuggerCallFrame.cpp:
* heap/Heap.cpp:
(JSC::Heap::lastChanceToFinalize):
(JSC::Heap::deleteAllCompiledCode):
* interpreter/CallFrame.cpp:
(JSC::CallFrame::vmEntryGlobalObject):
* interpreter/Interpreter.cpp:
* interpreter/Interpreter.h:
* interpreter/JSStack.cpp:
(JSC::JSStack::JSStack):
(JSC::JSStack::~JSStack):
(JSC::JSStack::growSlowCase):
(JSC::JSStack::releaseExcessCapacity):
(JSC::JSStack::setHostZoneSize):
(JSC::JSStack::lowAddress):
* interpreter/JSStack.h:
* interpreter/JSStackInlines.h:
(JSC::JSStack::ensureCapacityFor):
(JSC::JSStack::shrink):
* jit/ExecutableAllocator.h:
* jit/JITOperations.cpp:
* llint/LLIntSlowPaths.cpp:
(JSC::LLInt::LLINT_SLOW_PATH_DECL):
* llint/LowLevelInterpreter64.asm:
* parser/ParserError.h:
(JSC::ParserError::toErrorObject):
* runtime/CommonSlowPaths.cpp:
(JSC::SLOW_PATH_DECL):
* runtime/ErrorHandlingScope.cpp: Added.
(JSC::ErrorHandlingScope::ErrorHandlingScope):
(JSC::ErrorHandlingScope::~ErrorHandlingScope):
* runtime/ErrorHandlingScope.h: Added.
* runtime/ExceptionHelpers.cpp:
(JSC::throwStackOverflowError):
(JSC::throwTerminatedExecutionException):
* runtime/JSLock.cpp:
(JSC::JSLock::DropAllLocks::DropAllLocks):
(JSC::JSLock::DropAllLocks::~DropAllLocks):
* runtime/JSLock.h:
* runtime/Options.h:
* runtime/VM.cpp:
(JSC::VM::VM):
(JSC::VM::releaseExecutableMemory):
(JSC::VM::updateStackLimitWithHostZoneSize):
* runtime/VM.h:
* runtime/VMEntryScope.cpp:
(JSC::VMEntryScope::VMEntryScope):
(JSC::VMEntryScope::~VMEntryScope):
* runtime/VMEntryScope.h:

Source/WebCore: 

No new tests.

* ForwardingHeaders/runtime/ErrorHandlingScope.h: Added.
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* bindings/js/JSDOMBinding.cpp:
(WebCore::reportException):
- Updated to use ErrorHandlingScope instead of Interpreter::ErrorHandlingMode.

Source/WTF: 

* wtf/StackBounds.h:
(WTF::StackBounds::recursionLimit):
- Previously, StackBounds::recursionLimit() only takes a host zone size
  which it uses to compute the client's desired stack limit. Now, there's
  an alternate version that also allows the client to explicitly specify
  its desired stack limit in addition to its hostZoneSize requirement.
  In both cases, StackBounds::recursionLimit() will cap the limit (with
  allowance for the hostZoneSize) to be within its bounds, and return the
  capped limit.

LayoutTests: 

* js/large-expressions-expected.txt:
* js/script-tests/large-expressions.js:
- Changed expected result to reflect the much more constrained stack size
  now that the JS stack limit also limits stack usage by host / native
  functions.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchesjsCStackLayoutTestsChangeLog">branches/jsCStack/LayoutTests/ChangeLog</a></li>
<li><a href="#branchesjsCStackLayoutTestsjslargeexpressionsexpectedtxt">branches/jsCStack/LayoutTests/js/large-expressions-expected.txt</a></li>
<li><a href="#branchesjsCStackLayoutTestsjsscripttestslargeexpressionsjs">branches/jsCStack/LayoutTests/js/script-tests/large-expressions.js</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreCMakeListstxt">branches/jsCStack/Source/JavaScriptCore/CMakeLists.txt</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreChangeLog">branches/jsCStack/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreGNUmakefilelistam">branches/jsCStack/Source/JavaScriptCore/GNUmakefile.list.am</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreJavaScriptCorevcxprojJavaScriptCorevcxproj">branches/jsCStack/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreJavaScriptCorevcxprojJavaScriptCorevcxprojfilters">branches/jsCStack/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj">branches/jsCStack/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoredebuggerDebuggercpp">branches/jsCStack/Source/JavaScriptCore/debugger/Debugger.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoredebuggerDebuggerCallFramecpp">branches/jsCStack/Source/JavaScriptCore/debugger/DebuggerCallFrame.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreheapHeapcpp">branches/jsCStack/Source/JavaScriptCore/heap/Heap.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreinterpreterCallFramecpp">branches/jsCStack/Source/JavaScriptCore/interpreter/CallFrame.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="#branchesjsCStackSourceJavaScriptCoreinterpreterJSStackcpp">branches/jsCStack/Source/JavaScriptCore/interpreter/JSStack.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreinterpreterJSStackh">branches/jsCStack/Source/JavaScriptCore/interpreter/JSStack.h</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreinterpreterJSStackInlinesh">branches/jsCStack/Source/JavaScriptCore/interpreter/JSStackInlines.h</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCorejitExecutableAllocatorh">branches/jsCStack/Source/JavaScriptCore/jit/ExecutableAllocator.h</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCorejitJITOperationscpp">branches/jsCStack/Source/JavaScriptCore/jit/JITOperations.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCorellintLLIntSlowPathscpp">branches/jsCStack/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCorellintLowLevelInterpreter64asm">branches/jsCStack/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreparserParserErrorh">branches/jsCStack/Source/JavaScriptCore/parser/ParserError.h</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreruntimeCommonSlowPathscpp">branches/jsCStack/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreruntimeExceptionHelperscpp">branches/jsCStack/Source/JavaScriptCore/runtime/ExceptionHelpers.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreruntimeJSLockcpp">branches/jsCStack/Source/JavaScriptCore/runtime/JSLock.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreruntimeJSLockh">branches/jsCStack/Source/JavaScriptCore/runtime/JSLock.h</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreruntimeOptionsh">branches/jsCStack/Source/JavaScriptCore/runtime/Options.h</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreruntimeVMcpp">branches/jsCStack/Source/JavaScriptCore/runtime/VM.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreruntimeVMh">branches/jsCStack/Source/JavaScriptCore/runtime/VM.h</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreruntimeVMEntryScopecpp">branches/jsCStack/Source/JavaScriptCore/runtime/VMEntryScope.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreruntimeVMEntryScopeh">branches/jsCStack/Source/JavaScriptCore/runtime/VMEntryScope.h</a></li>
<li><a href="#branchesjsCStackSourceWTFChangeLog">branches/jsCStack/Source/WTF/ChangeLog</a></li>
<li><a href="#branchesjsCStackSourceWTFwtfStackBoundsh">branches/jsCStack/Source/WTF/wtf/StackBounds.h</a></li>
<li><a href="#branchesjsCStackSourceWebCoreChangeLog">branches/jsCStack/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchesjsCStackSourceWebCoreWebCorevcxprojWebCorevcxproj">branches/jsCStack/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj</a></li>
<li><a href="#branchesjsCStackSourceWebCoreWebCorevcxprojWebCorevcxprojfilters">branches/jsCStack/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters</a></li>
<li><a href="#branchesjsCStackSourceWebCorebindingsjsJSDOMBindingcpp">branches/jsCStack/Source/WebCore/bindings/js/JSDOMBinding.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#branchesjsCStackSourceJavaScriptCoreruntimeErrorHandlingScopecpp">branches/jsCStack/Source/JavaScriptCore/runtime/ErrorHandlingScope.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreruntimeErrorHandlingScopeh">branches/jsCStack/Source/JavaScriptCore/runtime/ErrorHandlingScope.h</a></li>
<li><a href="#branchesjsCStackSourceWebCoreForwardingHeadersruntimeErrorHandlingScopeh">branches/jsCStack/Source/WebCore/ForwardingHeaders/runtime/ErrorHandlingScope.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchesjsCStackLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/LayoutTests/ChangeLog (161574 => 161575)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/LayoutTests/ChangeLog        2014-01-09 20:41:06 UTC (rev 161574)
+++ branches/jsCStack/LayoutTests/ChangeLog        2014-01-09 21:10:46 UTC (rev 161575)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2014-01-08  Mark Lam  &lt;mark.lam@apple.com&gt;
+
+        CStack: Need a separate stack limit for the JS stack and the C stack.
+        https://bugs.webkit.org/show_bug.cgi?id=126320.
+
+        Reviewed by Geoffrey Garen.
+
+        * js/large-expressions-expected.txt:
+        * js/script-tests/large-expressions.js:
+        - Changed expected result to reflect the much more constrained stack size
+          now that the JS stack limit also limits stack usage by host / native
+          functions.
+
</ins><span class="cx"> 2014-01-06  Filip Pizlo  &lt;fpizlo@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Merge trunk r161072.
</span></span></pre></div>
<a id="branchesjsCStackLayoutTestsjslargeexpressionsexpectedtxt"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/LayoutTests/js/large-expressions-expected.txt (161574 => 161575)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/LayoutTests/js/large-expressions-expected.txt        2014-01-09 20:41:06 UTC (rev 161574)
+++ branches/jsCStack/LayoutTests/js/large-expressions-expected.txt        2014-01-09 21:10:46 UTC (rev 161575)
</span><span class="lines">@@ -5,7 +5,7 @@
</span><span class="cx"> 
</span><span class="cx"> PASS eval(repeatedExpression(&quot;letterA&quot;, &quot;+&quot;, 100)) is repeatedString(&quot;a&quot;, 100)
</span><span class="cx"> PASS eval(repeatedExpression(&quot;letterA&quot;, &quot;+&quot;, 1000)) is repeatedString(&quot;a&quot;, 1000)
</span><del>-PASS eval(repeatedExpression(&quot;letterA&quot;, &quot;+&quot;, 10000)) is repeatedString(&quot;a&quot;, 10000)
</del><ins>+PASS eval(repeatedExpression(&quot;letterA&quot;, &quot;+&quot;, 10000)) threw exception Error: Out of memory.
</ins><span class="cx"> PASS eval(repeatedExpression(&quot;letterA&quot;, &quot;+&quot;, 100000)) threw exception Error: Out of memory.
</span><span class="cx"> PASS successfullyParsed is true
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchesjsCStackLayoutTestsjsscripttestslargeexpressionsjs"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/LayoutTests/js/script-tests/large-expressions.js (161574 => 161575)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/LayoutTests/js/script-tests/large-expressions.js        2014-01-09 20:41:06 UTC (rev 161574)
+++ branches/jsCStack/LayoutTests/js/script-tests/large-expressions.js        2014-01-09 21:10:46 UTC (rev 161575)
</span><span class="lines">@@ -30,5 +30,5 @@
</span><span class="cx"> 
</span><span class="cx"> shouldBe('eval(repeatedExpression(&quot;letterA&quot;, &quot;+&quot;, 100))', 'repeatedString(&quot;a&quot;, 100)');
</span><span class="cx"> shouldBe('eval(repeatedExpression(&quot;letterA&quot;, &quot;+&quot;, 1000))', 'repeatedString(&quot;a&quot;, 1000)');
</span><del>-shouldBe('eval(repeatedExpression(&quot;letterA&quot;, &quot;+&quot;, 10000))', 'repeatedString(&quot;a&quot;, 10000)');
</del><ins>+shouldThrow('eval(repeatedExpression(&quot;letterA&quot;, &quot;+&quot;, 10000))');
</ins><span class="cx"> shouldThrow('eval(repeatedExpression(&quot;letterA&quot;, &quot;+&quot;, 100000))');
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/CMakeLists.txt (161574 => 161575)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/CMakeLists.txt        2014-01-09 20:41:06 UTC (rev 161574)
+++ branches/jsCStack/Source/JavaScriptCore/CMakeLists.txt        2014-01-09 21:10:46 UTC (rev 161575)
</span><span class="lines">@@ -311,6 +311,7 @@
</span><span class="cx">     runtime/DumpContext.cpp
</span><span class="cx">     runtime/Error.cpp
</span><span class="cx">     runtime/ErrorConstructor.cpp
</span><ins>+    runtime/ErrorHandlingScope.cpp
</ins><span class="cx">     runtime/ErrorInstance.cpp
</span><span class="cx">     runtime/ErrorPrototype.cpp
</span><span class="cx">     runtime/ExceptionHelpers.cpp
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/ChangeLog (161574 => 161575)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/ChangeLog        2014-01-09 20:41:06 UTC (rev 161574)
+++ branches/jsCStack/Source/JavaScriptCore/ChangeLog        2014-01-09 21:10:46 UTC (rev 161575)
</span><span class="lines">@@ -1,3 +1,173 @@
</span><ins>+2014-01-09  Mark Lam  &lt;mark.lam@apple.com&gt;
+
+        CStack: Need a separate stack limit for the JS stack and the C stack.
+        https://bugs.webkit.org/show_bug.cgi?id=126320.
+
+        Reviewed by Geoffrey Garen.
+
+        The purpose of this patch is mainly to change the way we compute the stack
+        limit for JS stack checks. Previously, we tally up the stack usage per
+        session of VM re-entry as tracked by the VMEntryScope, and we ensure that
+        the total usage does not exceed Options::maxStackSize(), and of course, is
+        also capped by the amount of native C stack available. The usage tracking
+        here does not count host / native function stack usage against the max
+        stack usage.
+
+        The new way is to compute a limit as an offset from the VMEntryScope of
+        the first entry into the VM. Options::maxPerThreadStackUsage()
+        will provide that offset. Any host / native function stack usage after
+        we've entered the VM will be counted against the max stack usage.
+
+        This patch supplants parts or all of the following previously committed
+        patches:
+
+            r161104: https://bugs.webkit.org/show_bug.cgi?id=126266
+                     Rename VM::entryScope to firstEntryScope.
+            r161232: https://bugs.webkit.org/show_bug.cgi?id=126321
+                     Introducing Options::maxStackSize().
+            r161172: https://bugs.webkit.org/show_bug.cgi?id=126331
+                     Refactor to split the tracking of the jsStackLimit from the
+                     native stackLimit.
+            r161174: https://bugs.webkit.org/show_bug.cgi?id=126334
+                     Introduce tracking of the top VMEntryScope.
+            r161361: https://bugs.webkit.org/show_bug.cgi?id=126487
+                     The fixed up jsStackLimit in doCallToJavaScript should not
+                     exceed the native stack limit.
+            r161180: https://bugs.webkit.org/show_bug.cgi?id=126320
+                     Need a separate stack limit for the JS stack and the C stack.
+                     This was for the old way of tracking chunks of stack usage
+                     per VMEntryScope.
+
+        Details of this patch:
+
+        1. Renamed VM::firstEntryScope back to VM::entryScope.
+           Removed the tracking of topEntryScope and related code.
+
+        2. Renamed Options::maxStackSize() to maxPerThreadStackUsage().
+           Added Options::hostZoneSize() and Options::errorModeHostZoneSize().
+
+        3. The VM now tracks its current hostZoneSize and stack limits.
+           VM::m_stackLimit is computed when the hostZoneSize is set via
+           VM::updateStackLimitWithHostZoneSize().
+
+           In the C Loop LLINT case, the VM also provides a setJSStackLimit()
+           since VM::m_stackLimit and VM::m_jsStackLimit are 2 different values
+           in that case.
+
+        4. Replaced Interpreter::ErrorHandlingMode with ErrorHandlingScope.
+           The ErrorHandlingScope constructor will set the VM host zone size to
+           Options::errorModeHostZoneSize(), and restore the previous host zone
+           size.
+
+           The destructor for ErrorHandlingScope will restore the previous stack
+           limit. We can enter multiple ErrorHandlingScopes. Only the destruction
+           of the very first one will restore the stack limit with the non-error
+           mode host zone.
+
+        5. LLINT C loop JSStack changes:
+           5.1 Replaced calls to roundUpToAllocationSize() with WTF::roundUpToMultipleOf().
+               roundUpToAllocationSize() is redundant and is now removed.
+
+           5.2 Removed enable/disableErrorStackReserve() and updateStackLimit().
+               Their function is now handled by JSStack::setHostZoneSize().
+
+           5.3 Added accounting for a host zone in the LLINT C loop JSStack.
+               This includes growing the JS stack to allow space for the host zone
+               whenever the host zone size is adjusted via JSStack::setHostZoneSize().
+
+               Note: though setHostZoneSize() is based on disableErrorStackReserve(),
+               we don't retain the logic to shrink the stack there. That logic was
+               always dead code: we only call shrink() if m_end + 1 &lt; m_useableTop,
+               but shrink() will only shrink the stack if m_end is pointing to the
+               base of the stack i.e. the 2 conditions are mutually exclusive, and
+               no work to shrink the stack will ever be done here.
+
+               m_useableTop is no longer needed and is now removed.
+
+           5.4 Change all non C loop code to reference VM::stackLimit() instead of
+               VM::jsStackLimit(). Though the 2 are the same for non C loop builds,
+               this makes it more straightforward. We now only reference the
+               jsStackLimit in 2 cases:
+
+               a. LLINT and JIT code performing stack checks where they expect the
+                  jsStackLimit to be a pseudonym for the stackLimit in non C loop
+                  builds.
+
+               b. In the C loop build, the JSStack itself sets VM::m_jsStackLimit()
+                  when it adjusts its host zone size.
+
+               In all other cases, we work directly with VM::stackLimit().
+
+        6. Simplify the tracking of VM::stackPointerAtVMEntry. We now set
+           VM::stackPointerAtVMEntry when we install a VMEntryScope if and only if
+           it isn't already set.
+
+           When we drop the API locks, we'll save the current stackPointerAtVMEntry
+           and stack limit value, and clear stackPointerAtVMEntry to allow a new
+           thread acquiring the API locks to re-set it when it installs a VMEntryScope.
+           When we re-acquire the API locks again, we'll restore the previously saved
+           stackPointerAtVMEntry and stack limit.
+
+           With this change, we also no longer need the stackPointerAtVMEntry fix up
+           code in doCallToJavaScript(). That code is now removed.
+
+        * CMakeLists.txt:
+        * GNUmakefile.list.am:
+        * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
+        * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters:
+        * JavaScriptCore.xcodeproj/project.pbxproj:
+        * debugger/Debugger.cpp:
+        (JSC::Debugger::recompileAllJSFunctions):
+        * debugger/DebuggerCallFrame.cpp:
+        * heap/Heap.cpp:
+        (JSC::Heap::lastChanceToFinalize):
+        (JSC::Heap::deleteAllCompiledCode):
+        * interpreter/CallFrame.cpp:
+        (JSC::CallFrame::vmEntryGlobalObject):
+        * interpreter/Interpreter.cpp:
+        * interpreter/Interpreter.h:
+        * interpreter/JSStack.cpp:
+        (JSC::JSStack::JSStack):
+        (JSC::JSStack::~JSStack):
+        (JSC::JSStack::growSlowCase):
+        (JSC::JSStack::releaseExcessCapacity):
+        (JSC::JSStack::setHostZoneSize):
+        (JSC::JSStack::lowAddress):
+        * interpreter/JSStack.h:
+        * interpreter/JSStackInlines.h:
+        (JSC::JSStack::ensureCapacityFor):
+        (JSC::JSStack::shrink):
+        * jit/ExecutableAllocator.h:
+        * jit/JITOperations.cpp:
+        * llint/LLIntSlowPaths.cpp:
+        (JSC::LLInt::LLINT_SLOW_PATH_DECL):
+        * llint/LowLevelInterpreter64.asm:
+        * parser/ParserError.h:
+        (JSC::ParserError::toErrorObject):
+        * runtime/CommonSlowPaths.cpp:
+        (JSC::SLOW_PATH_DECL):
+        * runtime/ErrorHandlingScope.cpp: Added.
+        (JSC::ErrorHandlingScope::ErrorHandlingScope):
+        (JSC::ErrorHandlingScope::~ErrorHandlingScope):
+        * runtime/ErrorHandlingScope.h: Added.
+        * runtime/ExceptionHelpers.cpp:
+        (JSC::throwStackOverflowError):
+        (JSC::throwTerminatedExecutionException):
+        * runtime/JSLock.cpp:
+        (JSC::JSLock::DropAllLocks::DropAllLocks):
+        (JSC::JSLock::DropAllLocks::~DropAllLocks):
+        * runtime/JSLock.h:
+        * runtime/Options.h:
+        * runtime/VM.cpp:
+        (JSC::VM::VM):
+        (JSC::VM::releaseExecutableMemory):
+        (JSC::VM::updateStackLimitWithHostZoneSize):
+        * runtime/VM.h:
+        * runtime/VMEntryScope.cpp:
+        (JSC::VMEntryScope::VMEntryScope):
+        (JSC::VMEntryScope::~VMEntryScope):
+        * runtime/VMEntryScope.h:
+
</ins><span class="cx"> 2014-01-08  Filip Pizlo  &lt;fpizlo@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         FTL should be able to be parallel
</span><span class="lines">@@ -398,6 +568,7 @@
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=126487.
</span><span class="cx"> 
</span><span class="cx">         Reviewed by Michael Saboff.
</span><ins>+        Update: this is supplanted by the 2014-01-08 patch for https://bugs.webkit.org/show_bug.cgi?id=126320.
</ins><span class="cx"> 
</span><span class="cx">         In doCallToJavaScript, we fixup VM::m_jsStackLimit once we know what the
</span><span class="cx">         stackPointerAtVMEntry is. However, we also need to ensure that the fixed
</span><span class="lines">@@ -715,7 +886,8 @@
</span><span class="cx">         CStack: Need a separate stack limit for the JS stack and the C stack.
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=126320.
</span><span class="cx"> 
</span><del>-        Not yet reviewed.
</del><ins>+        Rejected by Geoffrey Garen.
+        Update: this is supplanted by the 2014-01-08 patch for https://bugs.webkit.org/show_bug.cgi?id=126320.
</ins><span class="cx"> 
</span><span class="cx">         With this patch, we now accurately track how much JS stack space the
</span><span class="cx">         VM has used, and cap that at the value specified by Options::maxStackSize().
</span><span class="lines">@@ -802,6 +974,10 @@
</span><span class="cx"> 
</span><span class="cx">         Not yet reviewed.
</span><span class="cx"> 
</span><ins>+        We cannot do a meaningful assertion here on the size of the stack span
+        because we don't know the stack bounds that the span came from. Hence,
+        the assertion is now removed.
+
</ins><span class="cx">         * heap/ConservativeRoots.cpp:
</span><span class="cx">         (JSC::ConservativeRoots::genericAddSpan):
</span><span class="cx"> 
</span><span class="lines">@@ -811,6 +987,7 @@
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=126334.
</span><span class="cx"> 
</span><span class="cx">         Reviewed by Geoffrey Garen.
</span><ins>+        Update: this is supplanted by the 2014-01-08 patch for https://bugs.webkit.org/show_bug.cgi?id=126320.
</ins><span class="cx"> 
</span><span class="cx">         When we start measuring the stack usage of each VMEntryScope, we'll need
</span><span class="cx">         to know which VMEntryScope is the top (most recent) one, not just the
</span><span class="lines">@@ -840,7 +1017,8 @@
</span><span class="cx">         CStack: Refactor to split the tracking of the jsStackLimit from the native stackLimit.
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=126331.
</span><span class="cx"> 
</span><del>-        Not yet reviewed.
</del><ins>+        Rejected by Geoffrey Garen.
+        Update: this is supplanted by the 2014-01-08 patch for https://bugs.webkit.org/show_bug.cgi?id=126320.
</ins><span class="cx"> 
</span><span class="cx">         Previously, when using the C stack for the JS stack, VM::m_jsStackLimit is a union
</span><span class="cx">         with VM::m_stackLimit. We now separate them into 2 distinct fields but haven't yet
</span><span class="lines">@@ -875,6 +1053,7 @@
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=126321.
</span><span class="cx"> 
</span><span class="cx">         Reviewed by Geoffrey Garen.
</span><ins>+        Update: this is supplanted by the 2014-01-08 patch for https://bugs.webkit.org/show_bug.cgi?id=126320.
</ins><span class="cx"> 
</span><span class="cx">         We need an option to limit the JS stack size. Currently, we just change
</span><span class="cx">         the JSStack class to use this limit.
</span><span class="lines">@@ -905,7 +1084,8 @@
</span><span class="cx">         CStack: Cosmetic: rename VM::entryScope to firstEntryScope.
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=126266.
</span><span class="cx"> 
</span><del>-        Not yet reviewed.
</del><ins>+        Rejected by Geoffrey Garen.
+        Update: this is supplanted by the 2014-01-08 patch for https://bugs.webkit.org/show_bug.cgi?id=126320.
</ins><span class="cx"> 
</span><span class="cx">         This patch is so that we can distinguish firstEntryScope from topEntryScope
</span><span class="cx">         which will be introduced later in https://bugs.webkit.org/show_bug.cgi?id=126334.
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreGNUmakefilelistam"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/GNUmakefile.list.am (161574 => 161575)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/GNUmakefile.list.am        2014-01-09 20:41:06 UTC (rev 161574)
+++ branches/jsCStack/Source/JavaScriptCore/GNUmakefile.list.am        2014-01-09 21:10:46 UTC (rev 161575)
</span><span class="lines">@@ -851,6 +851,8 @@
</span><span class="cx">         Source/JavaScriptCore/runtime/ErrorConstructor.h \
</span><span class="cx">         Source/JavaScriptCore/runtime/Error.cpp \
</span><span class="cx">         Source/JavaScriptCore/runtime/Error.h \
</span><ins>+        Source/JavaScriptCore/runtime/ErrorHandlingScope.cpp \
+        Source/JavaScriptCore/runtime/ErrorHandlingScope.h \
</ins><span class="cx">         Source/JavaScriptCore/runtime/ErrorInstance.cpp \
</span><span class="cx">         Source/JavaScriptCore/runtime/ErrorInstance.h \
</span><span class="cx">         Source/JavaScriptCore/runtime/ErrorPrototype.cpp \
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreJavaScriptCorevcxprojJavaScriptCorevcxproj"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj (161574 => 161575)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj        2014-01-09 20:41:06 UTC (rev 161574)
+++ branches/jsCStack/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj        2014-01-09 21:10:46 UTC (rev 161575)
</span><span class="lines">@@ -553,6 +553,7 @@
</span><span class="cx">     &lt;ClCompile Include=&quot;..\runtime\DumpContext.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\runtime\Error.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\runtime\ErrorConstructor.cpp&quot; /&gt;
</span><ins>+    &lt;ClCompile Include=&quot;..\runtime\ErrorHandlingScope.cpp&quot; /&gt;
</ins><span class="cx">     &lt;ClCompile Include=&quot;..\runtime\ErrorInstance.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\runtime\ErrorPrototype.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\runtime\ExceptionHelpers.cpp&quot; /&gt;
</span><span class="lines">@@ -1133,6 +1134,7 @@
</span><span class="cx">     &lt;ClInclude Include=&quot;..\runtime\DumpContext.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\runtime\Error.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\runtime\ErrorConstructor.h&quot; /&gt;
</span><ins>+    &lt;ClInclude Include=&quot;..\runtime\ErrorHandlingScope.h&quot; /&gt;
</ins><span class="cx">     &lt;ClInclude Include=&quot;..\runtime\ErrorInstance.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\runtime\ErrorPrototype.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\runtime\ExceptionHelpers.h&quot; /&gt;
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreJavaScriptCorevcxprojJavaScriptCorevcxprojfilters"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters (161574 => 161575)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters        2014-01-09 20:41:06 UTC (rev 161574)
+++ branches/jsCStack/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters        2014-01-09 21:10:46 UTC (rev 161575)
</span><span class="lines">@@ -507,6 +507,9 @@
</span><span class="cx">     &lt;ClCompile Include=&quot;..\runtime\ErrorConstructor.cpp&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;runtime&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClCompile&gt;
</span><ins>+    &lt;ClCompile Include=&quot;..\runtime\ErrorHandlingScope.cpp&quot;&gt;
+      &lt;Filter&gt;runtime&lt;/Filter&gt;
+    &lt;/ClCompile&gt;
</ins><span class="cx">     &lt;ClCompile Include=&quot;..\runtime\ErrorInstance.cpp&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;runtime&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClCompile&gt;
</span><span class="lines">@@ -2036,6 +2039,9 @@
</span><span class="cx">     &lt;ClInclude Include=&quot;..\runtime\ErrorConstructor.h&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;runtime&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClInclude&gt;
</span><ins>+    &lt;ClInclude Include=&quot;..\runtime\ErrorHandlingScope.h&quot;&gt;
+      &lt;Filter&gt;runtime&lt;/Filter&gt;
+    &lt;/ClInclude&gt;
</ins><span class="cx">     &lt;ClInclude Include=&quot;..\runtime\ErrorInstance.h&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;runtime&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClInclude&gt;
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj (161574 => 161575)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2014-01-09 20:41:06 UTC (rev 161574)
+++ branches/jsCStack/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2014-01-09 21:10:46 UTC (rev 161575)
</span><span class="lines">@@ -1283,6 +1283,8 @@
</span><span class="cx">                 FE5932A8183C5A2600A1ECCC /* VMEntryScope.h in Headers */ = {isa = PBXBuildFile; fileRef = FE5932A6183C5A2600A1ECCC /* VMEntryScope.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 FEA08620182B7A0400F6D851 /* Breakpoint.h in Headers */ = {isa = PBXBuildFile; fileRef = FEA0861E182B7A0400F6D851 /* Breakpoint.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 FEA08621182B7A0400F6D851 /* DebuggerPrimitives.h in Headers */ = {isa = PBXBuildFile; fileRef = FEA0861F182B7A0400F6D851 /* DebuggerPrimitives.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+                FEB58C14187B8B160098EF0B /* ErrorHandlingScope.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEB58C12187B8B160098EF0B /* ErrorHandlingScope.cpp */; };
+                FEB58C15187B8B160098EF0B /* ErrorHandlingScope.h in Headers */ = {isa = PBXBuildFile; fileRef = FEB58C13187B8B160098EF0B /* ErrorHandlingScope.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 FED287B215EC9A5700DA8161 /* LLIntOpcode.h in Headers */ = {isa = PBXBuildFile; fileRef = FED287B115EC9A5700DA8161 /* LLIntOpcode.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 FED94F2E171E3E2300BE77A4 /* Watchdog.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FED94F2B171E3E2300BE77A4 /* Watchdog.cpp */; };
</span><span class="cx">                 FED94F2F171E3E2300BE77A4 /* Watchdog.h in Headers */ = {isa = PBXBuildFile; fileRef = FED94F2C171E3E2300BE77A4 /* Watchdog.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -2655,6 +2657,8 @@
</span><span class="cx">                 FE5932A6183C5A2600A1ECCC /* VMEntryScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VMEntryScope.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 FEA0861E182B7A0400F6D851 /* Breakpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Breakpoint.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 FEA0861F182B7A0400F6D851 /* DebuggerPrimitives.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DebuggerPrimitives.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                FEB58C12187B8B160098EF0B /* ErrorHandlingScope.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ErrorHandlingScope.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                FEB58C13187B8B160098EF0B /* ErrorHandlingScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ErrorHandlingScope.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 FED287B115EC9A5700DA8161 /* LLIntOpcode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LLIntOpcode.h; path = llint/LLIntOpcode.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 FED94F2B171E3E2300BE77A4 /* Watchdog.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Watchdog.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 FED94F2C171E3E2300BE77A4 /* Watchdog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Watchdog.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -3492,6 +3496,8 @@
</span><span class="cx">                                 BC3046060E1F497F003232CF /* Error.h */,
</span><span class="cx">                                 BC02E9040E1839DB000F9297 /* ErrorConstructor.cpp */,
</span><span class="cx">                                 BC02E9050E1839DB000F9297 /* ErrorConstructor.h */,
</span><ins>+                                FEB58C12187B8B160098EF0B /* ErrorHandlingScope.cpp */,
+                                FEB58C13187B8B160098EF0B /* ErrorHandlingScope.h */,
</ins><span class="cx">                                 BC02E98A0E183E38000F9297 /* ErrorInstance.cpp */,
</span><span class="cx">                                 BC02E98B0E183E38000F9297 /* ErrorInstance.h */,
</span><span class="cx">                                 BC02E9060E1839DB000F9297 /* ErrorPrototype.cpp */,
</span><span class="lines">@@ -4325,6 +4331,7 @@
</span><span class="cx">                                 65C0285D1717966800351E35 /* ARMv7DOpcode.h in Headers */,
</span><span class="cx">                                 FE5932A8183C5A2600A1ECCC /* VMEntryScope.h in Headers */,
</span><span class="cx">                                 0F24E54F17EE274900ABB217 /* TempRegisterSet.h in Headers */,
</span><ins>+                                FEB58C15187B8B160098EF0B /* ErrorHandlingScope.h in Headers */,
</ins><span class="cx">                                 A7BFF3C0179868940002F462 /* DFGFiltrationResult.h in Headers */,
</span><span class="cx">                                 C2FCAE1117A9C24E0034C735 /* BytecodeBasicBlock.h in Headers */,
</span><span class="cx">                                 C2FCAE1317A9C24E0034C735 /* BytecodeLivenessAnalysis.h in Headers */,
</span><span class="lines">@@ -5501,6 +5508,7 @@
</span><span class="cx">                                 0F63948415E48118006A597C /* DFGArrayMode.cpp in Sources */,
</span><span class="cx">                                 A7D9A29417A0BC7400EE2618 /* DFGAtTailAbstractState.cpp in Sources */,
</span><span class="cx">                                 0F714CA416EA92F000F3EBEB /* DFGBackwardsPropagationPhase.cpp in Sources */,
</span><ins>+                                FEB58C14187B8B160098EF0B /* ErrorHandlingScope.cpp in Sources */,
</ins><span class="cx">                                 A7D89CF217A0B8CC00773AD8 /* DFGBasicBlock.cpp in Sources */,
</span><span class="cx">                                 A70B083217A0B79B00DAF14B /* DFGBinarySwitch.cpp in Sources */,
</span><span class="cx">                                 A7D89CF317A0B8CC00773AD8 /* DFGBlockInsertionSet.cpp in Sources */,
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoredebuggerDebuggercpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/debugger/Debugger.cpp (161574 => 161575)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/debugger/Debugger.cpp        2014-01-09 20:41:06 UTC (rev 161574)
+++ branches/jsCStack/Source/JavaScriptCore/debugger/Debugger.cpp        2014-01-09 21:10:46 UTC (rev 161575)
</span><span class="lines">@@ -34,7 +34,6 @@
</span><span class="cx"> #include &quot;Operations.h&quot;
</span><span class="cx"> #include &quot;Parser.h&quot;
</span><span class="cx"> #include &quot;Protect.h&quot;
</span><del>-#include &quot;VMEntryScope.h&quot;
</del><span class="cx"> 
</span><span class="cx"> namespace {
</span><span class="cx"> 
</span><span class="lines">@@ -196,8 +195,8 @@
</span><span class="cx"> {
</span><span class="cx">     // If JavaScript is running, it's not safe to recompile, since we'll end
</span><span class="cx">     // up throwing away code that is live on the stack.
</span><del>-    ASSERT(!vm-&gt;firstEntryScope);
-    if (vm-&gt;firstEntryScope)
</del><ins>+    ASSERT(!vm-&gt;entryScope);
+    if (vm-&gt;entryScope)
</ins><span class="cx">         return;
</span><span class="cx">     
</span><span class="cx">     vm-&gt;prepareToDiscardCode();
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoredebuggerDebuggerCallFramecpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/debugger/DebuggerCallFrame.cpp (161574 => 161575)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/debugger/DebuggerCallFrame.cpp        2014-01-09 20:41:06 UTC (rev 161574)
+++ branches/jsCStack/Source/JavaScriptCore/debugger/DebuggerCallFrame.cpp        2014-01-09 21:10:46 UTC (rev 161575)
</span><span class="lines">@@ -35,7 +35,6 @@
</span><span class="cx"> #include &quot;Operations.h&quot;
</span><span class="cx"> #include &quot;Parser.h&quot;
</span><span class="cx"> #include &quot;StackVisitor.h&quot;
</span><del>-#include &quot;VMEntryScope.h&quot;
</del><span class="cx"> 
</span><span class="cx"> namespace JSC {
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreheapHeapcpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/heap/Heap.cpp (161574 => 161575)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/heap/Heap.cpp        2014-01-09 20:41:06 UTC (rev 161574)
+++ branches/jsCStack/Source/JavaScriptCore/heap/Heap.cpp        2014-01-09 21:10:46 UTC (rev 161575)
</span><span class="lines">@@ -291,7 +291,7 @@
</span><span class="cx"> // Run all pending finalizers now because we won't get another chance.
</span><span class="cx"> void Heap::lastChanceToFinalize()
</span><span class="cx"> {
</span><del>-    RELEASE_ASSERT(!m_vm-&gt;firstEntryScope);
</del><ins>+    RELEASE_ASSERT(!m_vm-&gt;entryScope);
</ins><span class="cx">     RELEASE_ASSERT(m_operationInProgress == NoOperation);
</span><span class="cx"> 
</span><span class="cx">     m_objectSpace.lastChanceToFinalize();
</span><span class="lines">@@ -695,7 +695,7 @@
</span><span class="cx"> {
</span><span class="cx">     // If JavaScript is running, it's not safe to delete code, since we'll end
</span><span class="cx">     // up deleting code that is live on the stack.
</span><del>-    if (m_vm-&gt;firstEntryScope)
</del><ins>+    if (m_vm-&gt;entryScope)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     for (ExecutableBase* current = m_compiledCode.head(); current; current = current-&gt;next()) {
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreinterpreterCallFramecpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/interpreter/CallFrame.cpp (161574 => 161575)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/interpreter/CallFrame.cpp        2014-01-09 20:41:06 UTC (rev 161574)
+++ branches/jsCStack/Source/JavaScriptCore/interpreter/CallFrame.cpp        2014-01-09 21:10:46 UTC (rev 161575)
</span><span class="lines">@@ -130,8 +130,8 @@
</span><span class="cx"> 
</span><span class="cx">     // For any ExecState that's not a globalExec, the 
</span><span class="cx">     // dynamic global object must be set since code is running
</span><del>-    ASSERT(vm().firstEntryScope);
-    return vm().firstEntryScope-&gt;globalObject();
</del><ins>+    ASSERT(vm().entryScope);
+    return vm().entryScope-&gt;globalObject();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace JSC
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreinterpreterInterpretercpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/interpreter/Interpreter.cpp (161574 => 161575)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/interpreter/Interpreter.cpp        2014-01-09 20:41:06 UTC (rev 161574)
+++ branches/jsCStack/Source/JavaScriptCore/interpreter/Interpreter.cpp        2014-01-09 21:10:46 UTC (rev 161575)
</span><span class="lines">@@ -91,21 +91,6 @@
</span><span class="cx"> 
</span><span class="cx"> namespace JSC {
</span><span class="cx"> 
</span><del>-Interpreter::ErrorHandlingMode::ErrorHandlingMode(ExecState *exec)
-    : m_interpreter(*exec-&gt;interpreter())
-{
-    m_interpreter.m_errorHandlingModeReentry++;
-    m_interpreter.stack().updateStackLimit();
-}
-
-Interpreter::ErrorHandlingMode::~ErrorHandlingMode()
-{
-    m_interpreter.m_errorHandlingModeReentry--;
-    ASSERT(m_interpreter.m_errorHandlingModeReentry &gt;= 0);
-    if (!m_interpreter.m_errorHandlingModeReentry)
-        m_interpreter.stack().updateStackLimit();
-}
-
</del><span class="cx"> JSValue eval(CallFrame* callFrame)
</span><span class="cx"> {
</span><span class="cx">     if (!callFrame-&gt;argumentCount())
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreinterpreterInterpreterh"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/interpreter/Interpreter.h (161574 => 161575)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/interpreter/Interpreter.h        2014-01-09 20:41:06 UTC (rev 161574)
+++ branches/jsCStack/Source/JavaScriptCore/interpreter/Interpreter.h        2014-01-09 21:10:46 UTC (rev 161575)
</span><span class="lines">@@ -190,14 +190,6 @@
</span><span class="cx">         friend class VM;
</span><span class="cx"> 
</span><span class="cx">     public:
</span><del>-        class ErrorHandlingMode {
-        public:
-            JS_EXPORT_PRIVATE ErrorHandlingMode(ExecState*);
-            JS_EXPORT_PRIVATE ~ErrorHandlingMode();
-        private:
-            Interpreter&amp; m_interpreter;
-        };
-
</del><span class="cx">         Interpreter(VM &amp;);
</span><span class="cx">         ~Interpreter();
</span><span class="cx">         
</span><span class="lines">@@ -237,8 +229,6 @@
</span><span class="cx">         
</span><span class="cx">         SamplingTool* sampler() { return m_sampler.get(); }
</span><span class="cx"> 
</span><del>-        bool isInErrorHandlingMode() { return m_errorHandlingModeReentry; }
-
</del><span class="cx">         NEVER_INLINE HandlerInfo* unwind(CallFrame*&amp;, JSValue&amp;);
</span><span class="cx">         NEVER_INLINE void debug(CallFrame*, DebugHookID);
</span><span class="cx">         JSString* stackTraceAsString(ExecState*, Vector&lt;StackFrame&gt;);
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreinterpreterJSStackcpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/interpreter/JSStack.cpp (161574 => 161575)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/interpreter/JSStack.cpp        2014-01-09 20:41:06 UTC (rev 161574)
+++ branches/jsCStack/Source/JavaScriptCore/interpreter/JSStack.cpp        2014-01-09 21:10:46 UTC (rev 161575)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2008, 2013 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2008, 2013, 2014 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -31,7 +31,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;ConservativeRoots.h&quot;
</span><span class="cx"> #include &quot;Interpreter.h&quot;
</span><del>-#include &quot;VMEntryScope.h&quot;
</del><ins>+#include &quot;Options.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace JSC {
</span><span class="cx"> 
</span><span class="lines">@@ -50,19 +50,18 @@
</span><span class="cx">     , m_topCallFrame(vm.topCallFrame)
</span><span class="cx"> #if ENABLE(LLINT_C_LOOP)
</span><span class="cx">     , m_end(0)
</span><ins>+    , m_hostZoneSizeInRegisters(0)
</ins><span class="cx"> #endif
</span><span class="cx"> {
</span><span class="cx"> #if ENABLE(LLINT_C_LOOP)
</span><del>-    size_t capacity = Options::maxStackSize();
</del><ins>+    size_t capacity = Options::maxPerThreadStackUsage();
</ins><span class="cx">     ASSERT(capacity &amp;&amp; isPageAligned(capacity));
</span><span class="cx"> 
</span><del>-    m_reservation = PageReservation::reserve(roundUpAllocationSize(capacity, commitSize), OSAllocator::JSVMStackPages);
</del><ins>+    m_reservation = PageReservation::reserve(WTF::roundUpToMultipleOf(commitSize, capacity), OSAllocator::JSVMStackPages);
</ins><span class="cx">     setStackLimit(highAddress());
</span><span class="cx">     m_commitTop = highAddress();
</span><span class="cx">     
</span><span class="cx">     m_lastStackTop = baseOfStack();
</span><del>-
-    disableErrorStackReserve();
</del><span class="cx"> #endif // ENABLE(LLINT_C_LOOP)
</span><span class="cx"> 
</span><span class="cx">     m_topCallFrame = 0;
</span><span class="lines">@@ -71,17 +70,19 @@
</span><span class="cx"> #if ENABLE(LLINT_C_LOOP)
</span><span class="cx"> JSStack::~JSStack()
</span><span class="cx"> {
</span><del>-    void* highAddress = reinterpret_cast&lt;void*&gt;(static_cast&lt;char*&gt;(m_reservation.base()) + m_reservation.size());
-    m_reservation.decommit(reinterpret_cast&lt;void*&gt;(m_commitTop), reinterpret_cast&lt;intptr_t&gt;(highAddress) - reinterpret_cast&lt;intptr_t&gt;(m_commitTop));
-    addToCommittedByteCount(-(reinterpret_cast&lt;intptr_t&gt;(highAddress) - reinterpret_cast&lt;intptr_t&gt;(m_commitTop)));
</del><ins>+    ptrdiff_t sizeToDecommit = reinterpret_cast&lt;char*&gt;(highAddress()) - reinterpret_cast&lt;char*&gt;(m_commitTop);
+    m_reservation.decommit(reinterpret_cast&lt;void*&gt;(m_commitTop), sizeToDecommit);
+    addToCommittedByteCount(-sizeToDecommit);
</ins><span class="cx">     m_reservation.deallocate();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool JSStack::growSlowCase(Register* newTopOfStack)
</span><span class="cx"> {
</span><ins>+    Register* newTopOfStackWithHostZone = newTopOfStack - m_hostZoneSizeInRegisters;
+
</ins><span class="cx">     // If we have already committed enough memory to satisfy this request,
</span><span class="cx">     // just update the end pointer and return.
</span><del>-    if (newTopOfStack &gt;= m_commitTop) {
</del><ins>+    if (newTopOfStackWithHostZone &gt;= m_commitTop) {
</ins><span class="cx">         setStackLimit(newTopOfStack);
</span><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="lines">@@ -89,15 +90,17 @@
</span><span class="cx">     // Compute the chunk size of additional memory to commit, and see if we
</span><span class="cx">     // have it is still within our budget. If not, we'll fail to grow and
</span><span class="cx">     // return false.
</span><del>-    long delta = roundUpAllocationSize(reinterpret_cast&lt;char*&gt;(m_commitTop) - reinterpret_cast&lt;char*&gt;(newTopOfStack), commitSize);
-    if (reinterpret_cast&lt;char*&gt;(m_commitTop) - delta &lt;= reinterpret_cast&lt;char*&gt;(m_useableTop))
</del><ins>+    ptrdiff_t delta = reinterpret_cast&lt;char*&gt;(m_commitTop) - reinterpret_cast&lt;char*&gt;(newTopOfStackWithHostZone);
+    delta = WTF::roundUpToMultipleOf(commitSize, delta);
+    Register* newCommitTop = m_commitTop - (delta / sizeof(Register));
+    if (newCommitTop &lt; reservationTop())
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     // Otherwise, the growth is still within our budget. Go ahead and commit
</span><span class="cx">     // it and return true.
</span><del>-    m_reservation.commit(reinterpret_cast&lt;char*&gt;(m_commitTop) - delta, delta);
</del><ins>+    m_reservation.commit(newCommitTop, delta);
</ins><span class="cx">     addToCommittedByteCount(delta);
</span><del>-    m_commitTop = reinterpret_cast_ptr&lt;Register*&gt;(reinterpret_cast&lt;char*&gt;(m_commitTop) - delta);
</del><ins>+    m_commitTop = newCommitTop;
</ins><span class="cx">     setStackLimit(newTopOfStack);
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="lines">@@ -127,10 +130,11 @@
</span><span class="cx"> 
</span><span class="cx"> void JSStack::releaseExcessCapacity()
</span><span class="cx"> {
</span><del>-    ptrdiff_t delta = reinterpret_cast&lt;uintptr_t&gt;(highAddress()) - reinterpret_cast&lt;uintptr_t&gt;(m_commitTop);
</del><ins>+    Register* highAddressWithHostZone = highAddress() - m_hostZoneSizeInRegisters;
+    ptrdiff_t delta = reinterpret_cast&lt;char*&gt;(highAddressWithHostZone) - reinterpret_cast&lt;char*&gt;(m_commitTop);
</ins><span class="cx">     m_reservation.decommit(m_commitTop, delta);
</span><span class="cx">     addToCommittedByteCount(-delta);
</span><del>-    m_commitTop = highAddress();
</del><ins>+    m_commitTop = highAddressWithHostZone;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void JSStack::initializeThreading()
</span><span class="lines">@@ -145,33 +149,19 @@
</span><span class="cx">     committedBytesCount += byteCount;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void JSStack::enableErrorStackReserve()
</del><ins>+void JSStack::setHostZoneSize(size_t hostZoneSize)
</ins><span class="cx"> {
</span><del>-    m_useableTop = reservationTop();
</del><ins>+    m_hostZoneSizeInRegisters = hostZoneSize / sizeof(Register);
+    if (m_commitTop &gt;= (m_end + 1) - m_hostZoneSizeInRegisters)
+        growSlowCase(m_end + 1);
</ins><span class="cx"> }
</span><del>-
-void JSStack::disableErrorStackReserve()
-{
-    char* useableTop = reinterpret_cast&lt;char*&gt;(reservationTop()) + commitSize;
-    m_useableTop = reinterpret_cast_ptr&lt;Register*&gt;(useableTop);
-
-    // By the time we get here, we are guaranteed to be destructing the last
-    // Interpreter::ErrorHandlingMode that enabled this reserve in the first
-    // place. That means the stack space beyond m_useableTop before we
-    // enabled the reserve was not previously in use. Hence, it is safe to
-    // shrink back to that m_useableTop.
-    if (m_end + 1 &lt; m_useableTop) {
-        ASSERT(m_topCallFrame-&gt;topOfFrame() &gt; m_useableTop);
-        shrink(m_useableTop);
-    }
-}
</del><span class="cx"> #endif // ENABLE(LLINT_C_LOOP)
</span><span class="cx"> 
</span><span class="cx"> #if !ENABLE(LLINT_C_LOOP)
</span><span class="cx"> Register* JSStack::lowAddress() const
</span><span class="cx"> {
</span><span class="cx">     ASSERT(wtfThreadData().stack().isGrowingDownward());
</span><del>-    return reinterpret_cast&lt;Register*&gt;(m_vm.jsStackLimit());
</del><ins>+    return reinterpret_cast&lt;Register*&gt;(m_vm.stackLimit());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Register* JSStack::highAddress() const
</span><span class="lines">@@ -196,16 +186,4 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void JSStack::updateStackLimit()
-{
-#if ENABLE(LLINT_C_LOOP)
-    if (m_vm.interpreter-&gt;isInErrorHandlingMode())
-        enableErrorStackReserve();
-    else
-        disableErrorStackReserve();
-#endif
-    if (m_vm.topEntryScope)
-        m_vm.topEntryScope-&gt;updateStackLimits();
-}
-
</del><span class="cx"> } // namespace JSC
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreinterpreterJSStackh"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/interpreter/JSStack.h (161574 => 161575)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/interpreter/JSStack.h        2014-01-09 20:41:06 UTC (rev 161574)
+++ branches/jsCStack/Source/JavaScriptCore/interpreter/JSStack.h        2014-01-09 21:10:46 UTC (rev 161575)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2008, 2009, 2013 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2008, 2009, 2013, 2014 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -83,8 +83,6 @@
</span><span class="cx">         
</span><span class="cx">         bool ensureCapacityFor(Register* newTopOfStack);
</span><span class="cx"> 
</span><del>-        void updateStackLimit();
-
</del><span class="cx">         bool containsAddress(Register* address) { return (lowAddress() &lt;= address &amp;&amp; address &lt; highAddress()); }
</span><span class="cx">         static size_t committedByteCount();
</span><span class="cx"> 
</span><span class="lines">@@ -109,6 +107,8 @@
</span><span class="cx"> 
</span><span class="cx">         static void initializeThreading();
</span><span class="cx"> 
</span><ins>+        void setHostZoneSize(size_t);
+
</ins><span class="cx">         CallFrame* pushFrame(class CodeBlock*, JSScope*, int argsCount, JSObject* callee);
</span><span class="cx"> 
</span><span class="cx">         void popFrame(CallFrame*);
</span><span class="lines">@@ -167,17 +167,14 @@
</span><span class="cx">         void setStackLimit(Register* newTopOfStack);
</span><span class="cx"> #endif // ENABLE(LLINT_C_LOOP)
</span><span class="cx"> 
</span><del>-        void enableErrorStackReserve();
-        void disableErrorStackReserve();
-
</del><span class="cx">         VM&amp; m_vm;
</span><span class="cx">         CallFrame*&amp; m_topCallFrame;
</span><span class="cx"> #if ENABLE(LLINT_C_LOOP)
</span><span class="cx">         Register* m_end;
</span><span class="cx">         Register* m_commitTop;
</span><del>-        Register* m_useableTop;
</del><span class="cx">         PageReservation m_reservation;
</span><span class="cx">         Register* m_lastStackTop;
</span><ins>+        ptrdiff_t m_hostZoneSizeInRegisters;
</ins><span class="cx"> #endif // ENABLE(LLINT_C_LOOP)
</span><span class="cx"> 
</span><span class="cx">         friend class LLIntOffsetsExtractor;
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreinterpreterJSStackInlinesh"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/interpreter/JSStackInlines.h (161574 => 161575)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/interpreter/JSStackInlines.h        2014-01-09 20:41:06 UTC (rev 161574)
+++ branches/jsCStack/Source/JavaScriptCore/interpreter/JSStackInlines.h        2014-01-09 21:10:46 UTC (rev 161575)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2012, 2013, 2014 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -39,7 +39,7 @@
</span><span class="cx">     return grow(newTopOfStack);
</span><span class="cx"> #else
</span><span class="cx">     ASSERT(wtfThreadData().stack().isGrowingDownward());
</span><del>-    return newTopOfStack &gt;= m_vm.jsStackLimit();
</del><ins>+    return newTopOfStack &gt;= m_vm.stackLimit();
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -157,7 +157,12 @@
</span><span class="cx">     if (newEnd &gt;= m_end)
</span><span class="cx">         return;
</span><span class="cx">     setStackLimit(newTopOfStack);
</span><del>-    if (m_end == baseOfStack() &amp;&amp; (highAddress() - m_commitTop) &gt;= maxExcessCapacity)
</del><ins>+    // Note: Clang complains of an unresolved linkage to maxExcessCapacity if
+    // invoke std::max() with it as an argument. To work around this, we first
+    // assign the constant to a local variable, and use the local instead.
+    ptrdiff_t maxExcessCapacity = JSStack::maxExcessCapacity;
+    ptrdiff_t maxExcessInRegisters = std::max(maxExcessCapacity, m_hostZoneSizeInRegisters);
+    if (m_end == baseOfStack() &amp;&amp; (highAddress() - m_commitTop) &gt;= maxExcessInRegisters)
</ins><span class="cx">         releaseExcessCapacity();
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCorejitExecutableAllocatorh"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/jit/ExecutableAllocator.h (161574 => 161575)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/jit/ExecutableAllocator.h        2014-01-09 20:41:06 UTC (rev 161574)
+++ branches/jsCStack/Source/JavaScriptCore/jit/ExecutableAllocator.h        2014-01-09 21:10:46 UTC (rev 161575)
</span><span class="lines">@@ -78,21 +78,6 @@
</span><span class="cx"> 
</span><span class="cx"> static const unsigned jitAllocationGranule = 32;
</span><span class="cx"> 
</span><del>-inline size_t roundUpAllocationSize(size_t request, size_t granularity)
-{
-    RELEASE_ASSERT((std::numeric_limits&lt;size_t&gt;::max() - granularity) &gt; request);
-    
-    // Round up to next page boundary
-    size_t size = request + (granularity - 1);
-    size = size &amp; ~(granularity - 1);
-    ASSERT(size &gt;= request);
-    return size;
-}
-
-}
-
-namespace JSC {
-
</del><span class="cx"> typedef WTF::MetaAllocatorHandle ExecutableMemoryHandle;
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(ASSEMBLER)
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCorejitJITOperationscpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/jit/JITOperations.cpp (161574 => 161575)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/jit/JITOperations.cpp        2014-01-09 20:41:06 UTC (rev 161574)
+++ branches/jsCStack/Source/JavaScriptCore/jit/JITOperations.cpp        2014-01-09 21:10:46 UTC (rev 161575)
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> #include &quot;DFGOSREntry.h&quot;
</span><span class="cx"> #include &quot;DFGWorklist.h&quot;
</span><span class="cx"> #include &quot;Error.h&quot;
</span><ins>+#include &quot;ErrorHandlingScope.h&quot;
</ins><span class="cx"> #include &quot;GetterSetter.h&quot;
</span><span class="cx"> #include &quot;HostCallReturnValue.h&quot;
</span><span class="cx"> #include &quot;JIT.h&quot;
</span><span class="lines">@@ -79,7 +80,7 @@
</span><span class="cx">         callerFrame = exec;
</span><span class="cx"> 
</span><span class="cx">     NativeCallFrameTracer tracer(vm, callerFrame);
</span><del>-    Interpreter::ErrorHandlingMode mode(callerFrame);
</del><ins>+    ErrorHandlingScope errorScope(*vm);
</ins><span class="cx">     vm-&gt;throwException(callerFrame, createStackOverflowError(callerFrame));
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCorellintLLIntSlowPathscpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp (161574 => 161575)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp        2014-01-09 20:41:06 UTC (rev 161574)
+++ branches/jsCStack/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp        2014-01-09 21:10:46 UTC (rev 161575)
</span><span class="lines">@@ -33,6 +33,7 @@
</span><span class="cx"> #include &quot;CallFrame.h&quot;
</span><span class="cx"> #include &quot;CommonSlowPaths.h&quot;
</span><span class="cx"> #include &quot;CommonSlowPathsExceptions.h&quot;
</span><ins>+#include &quot;ErrorHandlingScope.h&quot;
</ins><span class="cx"> #include &quot;GetterSetter.h&quot;
</span><span class="cx"> #include &quot;HostCallReturnValue.h&quot;
</span><span class="cx"> #include &quot;Interpreter.h&quot;
</span><span class="lines">@@ -474,7 +475,7 @@
</span><span class="cx"> 
</span><span class="cx">     exec = exec-&gt;callerFrame();
</span><span class="cx">     vm.topCallFrame = exec;
</span><del>-    Interpreter::ErrorHandlingMode mode(exec);
</del><ins>+    ErrorHandlingScope errorScope(vm);
</ins><span class="cx">     CommonSlowPaths::interpreterThrowInCaller(exec, createStackOverflowError(exec));
</span><span class="cx">     pc = returnToThrowForThrownException(exec);
</span><span class="cx">     LLINT_RETURN_TWO(pc, exec);
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCorellintLowLevelInterpreter64asm"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm (161574 => 161575)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm        2014-01-09 20:41:06 UTC (rev 161574)
+++ branches/jsCStack/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm        2014-01-09 21:10:46 UTC (rev 161575)
</span><span class="lines">@@ -121,23 +121,6 @@
</span><span class="cx"> 
</span><span class="cx">     checkStackPointerAlignment(temp2, 0xbad0dc01)
</span><span class="cx"> 
</span><del>-    # The jsStackLimit was previously computed in VMEntryScope using an
-    # estimated stackPointerAtVMEntry value. Adjust the jsStackLimit by
-    # the delta between the actual stackPointerAtVMEntry and the estimate
-    # that we used previously.
-    move sp, temp2
-    subp VM::stackPointerAtVMEntry[vm], temp2, temp2
-    subp VM::m_jsStackLimit[vm], temp2, temp2
-if C_LOOP
-else
-    bpaeq temp2, VM::m_stackLimit[vm], .noNeedToCapJSStackToNativeStackLimit
-    loadp VM::m_stackLimit[vm], temp2
-.noNeedToCapJSStackToNativeStackLimit:
-end
-    storep temp2, VM::m_jsStackLimit[vm]
-    move sp, temp2
-    storep temp2, VM::stackPointerAtVMEntry[vm]
-
</del><span class="cx">     # The stack host zone ensures that we have adequate space for the
</span><span class="cx">     # VMEntrySentinelFrame. Proceed with allocating and initializing the
</span><span class="cx">     # sentinel frame.
</span><span class="lines">@@ -169,7 +152,6 @@
</span><span class="cx">     # up throwing a StackOverflowError.
</span><span class="cx">     end
</span><span class="cx"> 
</span><del>-    storep 0, VM::stackPointerAtVMEntry[vm]
</del><span class="cx">     cCall2(_llint_throw_stack_overflow_error, vm, protoCallFrame)
</span><span class="cx">     callToJavaScriptEpilogue()
</span><span class="cx">     ret
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreparserParserErrorh"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/parser/ParserError.h (161574 => 161575)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/parser/ParserError.h        2014-01-09 20:41:06 UTC (rev 161574)
+++ branches/jsCStack/Source/JavaScriptCore/parser/ParserError.h        2014-01-09 21:10:46 UTC (rev 161575)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx"> #define ParserError_h
</span><span class="cx"> 
</span><span class="cx"> #include &quot;Error.h&quot;
</span><ins>+#include &quot;ErrorHandlingScope.h&quot;
</ins><span class="cx"> #include &quot;ExceptionHelpers.h&quot;
</span><span class="cx"> #include &quot;ParserTokens.h&quot;
</span><span class="cx"> #include &lt;wtf/text/WTFString.h&gt;
</span><span class="lines">@@ -95,7 +96,7 @@
</span><span class="cx">         case EvalError:
</span><span class="cx">             return createSyntaxError(globalObject, m_message);
</span><span class="cx">         case StackOverflow: {
</span><del>-            Interpreter::ErrorHandlingMode mode(globalObject-&gt;globalExec());
</del><ins>+            ErrorHandlingScope errorScope(globalObject-&gt;vm());
</ins><span class="cx">             return createStackOverflowError(globalObject);
</span><span class="cx">         }
</span><span class="cx">         case OutOfMemory:
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreruntimeCommonSlowPathscpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp (161574 => 161575)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp        2014-01-09 20:41:06 UTC (rev 161574)
+++ branches/jsCStack/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp        2014-01-09 21:10:46 UTC (rev 161575)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx"> #include &quot;CallFrame.h&quot;
</span><span class="cx"> #include &quot;CodeProfiling.h&quot;
</span><span class="cx"> #include &quot;CommonSlowPathsExceptions.h&quot;
</span><ins>+#include &quot;ErrorHandlingScope.h&quot;
</ins><span class="cx"> #include &quot;GetterSetter.h&quot;
</span><span class="cx"> #include &quot;HostCallReturnValue.h&quot;
</span><span class="cx"> #include &quot;Interpreter.h&quot;
</span><span class="lines">@@ -185,7 +186,7 @@
</span><span class="cx">     int slotsToAdd = CommonSlowPaths::arityCheckFor(exec, &amp;vm.interpreter-&gt;stack(), CodeForCall);
</span><span class="cx">     if (slotsToAdd &lt; 0) {
</span><span class="cx">         exec = exec-&gt;callerFrame();
</span><del>-        Interpreter::ErrorHandlingMode mode(exec);
</del><ins>+        ErrorHandlingScope errorScope(exec-&gt;vm());
</ins><span class="cx">         CommonSlowPaths::interpreterThrowInCaller(exec, createStackOverflowError(exec));
</span><span class="cx">         RETURN_TWO(bitwise_cast&lt;void*&gt;(static_cast&lt;uintptr_t&gt;(1)), exec);
</span><span class="cx">     }
</span><span class="lines">@@ -198,7 +199,7 @@
</span><span class="cx">     int slotsToAdd = CommonSlowPaths::arityCheckFor(exec, &amp;vm.interpreter-&gt;stack(), CodeForConstruct);
</span><span class="cx">     if (slotsToAdd &lt; 0) {
</span><span class="cx">         exec = exec-&gt;callerFrame();
</span><del>-        Interpreter::ErrorHandlingMode mode(exec);
</del><ins>+        ErrorHandlingScope errorScope(exec-&gt;vm());
</ins><span class="cx">         CommonSlowPaths::interpreterThrowInCaller(exec, createStackOverflowError(exec));
</span><span class="cx">         RETURN_TWO(bitwise_cast&lt;void*&gt;(static_cast&lt;uintptr_t&gt;(1)), exec);
</span><span class="cx">     }
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreruntimeErrorHandlingScopecpp"></a>
<div class="addfile"><h4>Added: branches/jsCStack/Source/JavaScriptCore/runtime/ErrorHandlingScope.cpp (0 => 161575)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/runtime/ErrorHandlingScope.cpp                                (rev 0)
+++ branches/jsCStack/Source/JavaScriptCore/runtime/ErrorHandlingScope.cpp        2014-01-09 21:10:46 UTC (rev 161575)
</span><span class="lines">@@ -0,0 +1,57 @@
</span><ins>+/*
+ * Copyright (C) 2014 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;ErrorHandlingScope.h&quot;
+
+#include &quot;Interpreter.h&quot;
+#include &quot;Options.h&quot;
+#include &quot;VM.h&quot;
+
+namespace JSC {
+
+ErrorHandlingScope::ErrorHandlingScope(VM&amp; vm)
+    : m_vm(vm)
+{
+    if (!m_vm.stackPointerAtVMEntry)
+        m_vm.stackPointerAtVMEntry = this;
+    size_t newHostZoneSize = Options::errorModeHostZoneSize();
+    m_savedHostZoneSize = m_vm.updateStackLimitWithHostZoneSize(newHostZoneSize);
+#if ENABLE(LLINT_C_LOOP)
+    m_vm.interpreter-&gt;stack().setHostZoneSize(newHostZoneSize);
+#endif
+}
+
+ErrorHandlingScope::~ErrorHandlingScope()
+{
+    if (m_vm.stackPointerAtVMEntry == this)
+        m_vm.stackPointerAtVMEntry = nullptr;
+    m_vm.updateStackLimitWithHostZoneSize(m_savedHostZoneSize);
+#if ENABLE(LLINT_C_LOOP)
+    m_vm.interpreter-&gt;stack().setHostZoneSize(m_savedHostZoneSize);
+#endif
+}
+
+} // namespace JSC
</ins></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreruntimeErrorHandlingScopeh"></a>
<div class="addfile"><h4>Added: branches/jsCStack/Source/JavaScriptCore/runtime/ErrorHandlingScope.h (0 => 161575)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/runtime/ErrorHandlingScope.h                                (rev 0)
+++ branches/jsCStack/Source/JavaScriptCore/runtime/ErrorHandlingScope.h        2014-01-09 21:10:46 UTC (rev 161575)
</span><span class="lines">@@ -0,0 +1,45 @@
</span><ins>+/*
+ * Copyright (C) 2014 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. 
+ */
+
+#ifndef ErrorHandlingScope_h
+#define ErrorHandlingScope_h
+
+namespace JSC {
+
+class VM;
+
+class ErrorHandlingScope {
+public:
+    JS_EXPORT_PRIVATE ErrorHandlingScope(VM&amp;);
+    JS_EXPORT_PRIVATE ~ErrorHandlingScope();
+private:
+    VM&amp; m_vm;
+    size_t m_savedHostZoneSize;
+};
+
+} // namespace JSC
+
+#endif // ErrorHandlingScope_h
+
</ins></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreruntimeExceptionHelperscpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/runtime/ExceptionHelpers.cpp (161574 => 161575)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/runtime/ExceptionHelpers.cpp        2014-01-09 20:41:06 UTC (rev 161574)
+++ branches/jsCStack/Source/JavaScriptCore/runtime/ExceptionHelpers.cpp        2014-01-09 21:10:46 UTC (rev 161575)
</span><span class="lines">@@ -31,6 +31,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;CodeBlock.h&quot;
</span><span class="cx"> #include &quot;CallFrame.h&quot;
</span><ins>+#include &quot;ErrorHandlingScope.h&quot;
</ins><span class="cx"> #include &quot;ErrorInstance.h&quot;
</span><span class="cx"> #include &quot;JSGlobalObjectFunctions.h&quot;
</span><span class="cx"> #include &quot;JSObject.h&quot;
</span><span class="lines">@@ -160,14 +161,16 @@
</span><span class="cx"> 
</span><span class="cx"> JSObject* throwStackOverflowError(ExecState* exec)
</span><span class="cx"> {
</span><del>-    Interpreter::ErrorHandlingMode mode(exec);
-    return exec-&gt;vm().throwException(exec, createStackOverflowError(exec));
</del><ins>+    VM&amp; vm = exec-&gt;vm();
+    ErrorHandlingScope errorScope(vm);
+    return vm.throwException(exec, createStackOverflowError(exec));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> JSObject* throwTerminatedExecutionException(ExecState* exec)
</span><span class="cx"> {
</span><del>-    Interpreter::ErrorHandlingMode mode(exec);
-    return exec-&gt;vm().throwException(exec, createTerminatedExecutionException(&amp;exec-&gt;vm()));
</del><ins>+    VM&amp; vm = exec-&gt;vm();
+    ErrorHandlingScope errorScope(vm);
+    return vm.throwException(exec, createTerminatedExecutionException(&amp;vm));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace JSC
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreruntimeJSLockcpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/runtime/JSLock.cpp (161574 => 161575)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/runtime/JSLock.cpp        2014-01-09 20:41:06 UTC (rev 161574)
+++ branches/jsCStack/Source/JavaScriptCore/runtime/JSLock.cpp        2014-01-09 21:10:46 UTC (rev 161575)
</span><span class="lines">@@ -290,6 +290,10 @@
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     SpinLockHolder holder(&amp;spinLock);
</span><span class="cx"> #endif
</span><ins>+    m_savedHostZoneSize = m_vm-&gt;hostZoneSize();
+    m_savedStackPointerAtVMEntry = m_vm-&gt;stackPointerAtVMEntry;
+    m_vm-&gt;stackPointerAtVMEntry = nullptr;
+
</ins><span class="cx">     if (alwaysDropLocks)
</span><span class="cx">         m_lockCount = m_vm-&gt;apiLock().dropAllLocksUnconditionally(spinLock);
</span><span class="cx">     else
</span><span class="lines">@@ -306,6 +310,10 @@
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     SpinLockHolder holder(&amp;spinLock);
</span><span class="cx"> #endif
</span><ins>+    m_savedHostZoneSize = m_vm-&gt;hostZoneSize();
+    m_savedStackPointerAtVMEntry = m_vm-&gt;stackPointerAtVMEntry;
+    m_vm-&gt;stackPointerAtVMEntry = nullptr;
+
</ins><span class="cx">     if (alwaysDropLocks)
</span><span class="cx">         m_lockCount = m_vm-&gt;apiLock().dropAllLocksUnconditionally(spinLock);
</span><span class="cx">     else
</span><span class="lines">@@ -321,6 +329,9 @@
</span><span class="cx">     SpinLockHolder holder(&amp;spinLock);
</span><span class="cx"> #endif
</span><span class="cx">     m_vm-&gt;apiLock().grabAllLocks(m_lockCount, spinLock);
</span><ins>+
+    m_vm-&gt;stackPointerAtVMEntry = m_savedStackPointerAtVMEntry;
+    m_vm-&gt;updateStackLimitWithHostZoneSize(m_savedHostZoneSize);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace JSC
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreruntimeJSLockh"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/runtime/JSLock.h (161574 => 161575)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/runtime/JSLock.h        2014-01-09 20:41:06 UTC (rev 161574)
+++ branches/jsCStack/Source/JavaScriptCore/runtime/JSLock.h        2014-01-09 21:10:46 UTC (rev 161575)
</span><span class="lines">@@ -110,6 +110,8 @@
</span><span class="cx">         private:
</span><span class="cx">             intptr_t m_lockCount;
</span><span class="cx">             RefPtr&lt;VM&gt; m_vm;
</span><ins>+            size_t m_savedHostZoneSize;
+            void* m_savedStackPointerAtVMEntry;
</ins><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">     private:
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreruntimeOptionsh"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/runtime/Options.h (161574 => 161575)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/runtime/Options.h        2014-01-09 20:41:06 UTC (rev 161574)
+++ branches/jsCStack/Source/JavaScriptCore/runtime/Options.h        2014-01-09 21:10:46 UTC (rev 161575)
</span><span class="lines">@@ -95,7 +95,9 @@
</span><span class="cx">     v(bool, useDFGJIT, true) \
</span><span class="cx">     v(bool, useRegExpJIT, true) \
</span><span class="cx">     \
</span><del>-    v(unsigned, maxStackSize, 4 * MB) \
</del><ins>+    v(unsigned, maxPerThreadStackUsage, 4 * MB) \
+    v(unsigned, hostZoneSize, 128 * KB) \
+    v(unsigned, errorModeHostZoneSize, 64 * KB) \
</ins><span class="cx">     \
</span><span class="cx">     v(bool, crashIfCantAllocateJITMemory, false) \
</span><span class="cx">     \
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreruntimeVMcpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/runtime/VM.cpp (161574 => 161575)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/runtime/VM.cpp        2014-01-09 20:41:06 UTC (rev 161574)
+++ branches/jsCStack/Source/JavaScriptCore/runtime/VM.cpp        2014-01-09 21:10:46 UTC (rev 161575)
</span><span class="lines">@@ -200,8 +200,7 @@
</span><span class="cx">     , jsArrayClassInfo(JSArray::info())
</span><span class="cx">     , jsFinalObjectClassInfo(JSFinalObject::info())
</span><span class="cx">     , sizeOfLastScratchBuffer(0)
</span><del>-    , firstEntryScope(0)
-    , topEntryScope(0)
</del><ins>+    , entryScope(0)
</ins><span class="cx">     , m_enabledProfiler(0)
</span><span class="cx">     , m_regExpCache(new RegExpCache(this))
</span><span class="cx"> #if ENABLE(REGEXP_TRACING)
</span><span class="lines">@@ -230,7 +229,10 @@
</span><span class="cx"> {
</span><span class="cx">     interpreter = new Interpreter(*this);
</span><span class="cx">     StackBounds stack = wtfThreadData().stack();
</span><del>-    setStackLimit(stack.recursionLimit());
</del><ins>+    updateStackLimitWithHostZoneSize(Options::hostZoneSize());
+#if ENABLE(LLINT_C_LOOP)
+    interpreter-&gt;stack().setHostZoneSize(Options::hostZoneSize());
+#endif
</ins><span class="cx">     setLastStackTop(stack.origin());
</span><span class="cx"> 
</span><span class="cx">     // Need to be careful to keep everything consistent here
</span><span class="lines">@@ -553,7 +555,7 @@
</span><span class="cx"> {
</span><span class="cx">     prepareToDiscardCode();
</span><span class="cx">     
</span><del>-    if (firstEntryScope) {
</del><ins>+    if (entryScope) {
</ins><span class="cx">         StackPreservingRecompiler recompiler;
</span><span class="cx">         HeapIterationScope iterationScope(heap);
</span><span class="cx">         HashSet&lt;JSCell*&gt; roots;
</span><span class="lines">@@ -713,6 +715,24 @@
</span><span class="cx">     m_exceptionStack = RefCountedArray&lt;StackFrame&gt;();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+size_t VM::updateStackLimitWithHostZoneSize(size_t hostZoneSize)
+{
+    size_t oldHostZoneSize = m_hostZoneSize;
+    m_hostZoneSize = hostZoneSize;
+
+    void* stackLimit;
+    if (stackPointerAtVMEntry) {
+        ASSERT(wtfThreadData().stack().isGrowingDownward());
+        char* startOfStack = reinterpret_cast&lt;char*&gt;(stackPointerAtVMEntry);
+        char* desiredStackLimit = startOfStack - Options::maxPerThreadStackUsage() + hostZoneSize;
+        stackLimit = wtfThreadData().stack().recursionLimit(hostZoneSize, desiredStackLimit);
+    } else
+        stackLimit = wtfThreadData().stack().recursionLimit(hostZoneSize);
+
+    setStackLimit(stackLimit);
+    return oldHostZoneSize;
+}
+
</ins><span class="cx"> void releaseExecutableMemory(VM&amp; vm)
</span><span class="cx"> {
</span><span class="cx">     vm.releaseExecutableMemory();
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreruntimeVMh"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/runtime/VM.h (161574 => 161575)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/runtime/VM.h        2014-01-09 20:41:06 UTC (rev 161574)
+++ branches/jsCStack/Source/JavaScriptCore/runtime/VM.h        2014-01-09 21:10:46 UTC (rev 161575)
</span><span class="lines">@@ -375,12 +375,16 @@
</span><span class="cx">         JS_EXPORT_PRIVATE JSValue throwException(ExecState*, JSValue);
</span><span class="cx">         JS_EXPORT_PRIVATE JSObject* throwException(ExecState*, JSObject*);
</span><span class="cx">         
</span><ins>+        size_t hostZoneSize() const { return m_hostZoneSize; }
+        size_t updateStackLimitWithHostZoneSize(size_t hostZoneSize);
+
</ins><span class="cx">         void** addressOfJSStackLimit() { return &amp;m_jsStackLimit; }
</span><ins>+#if ENABLE(LLINT_C_LOOP)
</ins><span class="cx">         void* jsStackLimit() { return m_jsStackLimit; }
</span><span class="cx">         void setJSStackLimit(void* limit) { m_jsStackLimit = limit; }
</span><ins>+#endif
+        void* stackLimit() { return m_stackLimit; }
</ins><span class="cx"> 
</span><del>-        void* stackLimit() { return m_stackLimit; }
-        void setStackLimit(void* limit) { m_stackLimit = limit; }
</del><span class="cx">         bool isSafeToRecurse(size_t neededStackInBytes = 0) const
</span><span class="cx">         {
</span><span class="cx">             ASSERT(wtfThreadData().stack().isGrowingDownward());
</span><span class="lines">@@ -427,8 +431,7 @@
</span><span class="cx"> 
</span><span class="cx">         void gatherConservativeRoots(ConservativeRoots&amp;);
</span><span class="cx"> 
</span><del>-        VMEntryScope* firstEntryScope;
-        VMEntryScope* topEntryScope;
</del><ins>+        VMEntryScope* entryScope;
</ins><span class="cx"> 
</span><span class="cx">         HashSet&lt;JSObject*&gt; stringRecursionCheckVisitedObjects;
</span><span class="cx"> 
</span><span class="lines">@@ -495,6 +498,9 @@
</span><span class="cx">         VM(VMType, HeapType);
</span><span class="cx">         static VM*&amp; sharedInstanceInternal();
</span><span class="cx">         void createNativeThunk();
</span><ins>+
+        void setStackLimit(void* limit) { m_stackLimit = limit; }
+
</ins><span class="cx"> #if ENABLE(ASSEMBLER)
</span><span class="cx">         bool m_canUseAssembler;
</span><span class="cx"> #endif
</span><span class="lines">@@ -507,8 +513,18 @@
</span><span class="cx"> #if ENABLE(GC_VALIDATION)
</span><span class="cx">         const ClassInfo* m_initializingObjectClass;
</span><span class="cx"> #endif
</span><del>-        void* m_stackLimit;
-        void* m_jsStackLimit;
</del><ins>+        size_t m_hostZoneSize;
+#if ENABLE(LLINT_C_LOOP)
+        struct {
+            void* m_stackLimit;
+            void* m_jsStackLimit;
+        };
+#else
+        union {
+            void* m_stackLimit;
+            void* m_jsStackLimit;
+        };
+#endif
</ins><span class="cx">         void* m_lastStackTop;
</span><span class="cx">         JSValue m_exception;
</span><span class="cx">         bool m_inDefineOwnProperty;
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreruntimeVMEntryScopecpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/runtime/VMEntryScope.cpp (161574 => 161575)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/runtime/VMEntryScope.cpp        2014-01-09 20:41:06 UTC (rev 161574)
+++ branches/jsCStack/Source/JavaScriptCore/runtime/VMEntryScope.cpp        2014-01-09 21:10:46 UTC (rev 161575)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2013 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2013, 2014 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -34,163 +34,38 @@
</span><span class="cx"> 
</span><span class="cx"> VMEntryScope::VMEntryScope(VM&amp; vm, JSGlobalObject* globalObject)
</span><span class="cx">     : m_vm(vm)
</span><del>-    , m_stack(wtfThreadData().stack())
</del><span class="cx">     , m_globalObject(globalObject)
</span><del>-    , m_prevStackUsage(0)
-    , m_prevTopEntryScope(vm.topEntryScope)
-    , m_prevStackLimit(vm.stackLimit())
-#if !ENABLE(LLINT_C_LOOP)
-    , m_prevJSStackLimit(vm.jsStackLimit())
-#endif
-    , m_prevLastStackTop(vm.lastStackTop())
-    , m_prevStackPointerAtVMEntry(vm.stackPointerAtVMEntry)
-    , m_prevTopCallFrame(vm.topCallFrame)
</del><span class="cx"> {
</span><span class="cx">     ASSERT(wtfThreadData().stack().isGrowingDownward());
</span><del>-    ASSERT(!vm.topCallFrame || currentStackPointer() &lt;= reinterpret_cast&lt;char*&gt;(vm.topCallFrame-&gt;topOfFrame()));
-
-    // Step 1: Compute the stack usage of the last VM entry before we install
-    // the current entry scope below.
-    if (vm.topEntryScope) {
-        char* topOfStack = reinterpret_cast&lt;char*&gt;(vm.topCallFrame-&gt;topOfFrame());
-        m_prevStackUsage = vm.topEntryScope-&gt;stackUsageFor(topOfStack);
-    }
-
-    // Step 2: Install the current entry scope.
-    if (!vm.firstEntryScope) {
</del><ins>+    if (!vm.entryScope) {
</ins><span class="cx"> #if ENABLE(ASSEMBLER)
</span><span class="cx">         if (ExecutableAllocator::underMemoryPressure())
</span><span class="cx">             vm.heap.deleteAllCompiledCode();
</span><span class="cx"> #endif
</span><del>-        vm.firstEntryScope = this;
</del><ins>+        vm.entryScope = this;
</ins><span class="cx"> 
</span><span class="cx">         // Reset the date cache between JS invocations to force the VM to
</span><span class="cx">         // observe time xone changes.
</span><span class="cx">         vm.resetDateCache();
</span><span class="cx">     }
</span><del>-    vm.stackPointerAtVMEntry = 0;
-    vm.topEntryScope = this;
</del><span class="cx"> 
</span><ins>+    if (!vm.stackPointerAtVMEntry) {
+        vm.stackPointerAtVMEntry = this;
+        m_savedHostZoneSize = vm.updateStackLimitWithHostZoneSize(Options::hostZoneSize());
+    }
+
</ins><span class="cx">     // Clear the captured exception stack between entries
</span><span class="cx">     vm.clearExceptionStack();
</span><del>-
-    vm.setLastStackTop(m_stack.origin());
-
-    // Step 3: Compute the stack limit using the installed entry scope.
-    updateStackLimits();
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> VMEntryScope::~VMEntryScope()
</span><span class="cx"> {
</span><del>-    if (m_vm.firstEntryScope == this)
-        m_vm.firstEntryScope = nullptr;
-    m_vm.topEntryScope = m_prevTopEntryScope;
-    m_vm.setStackLimit(m_prevStackLimit);
-#if !ENABLE(LLINT_C_LOOP)
-    m_vm.setJSStackLimit(m_prevJSStackLimit);
-#endif
-    m_vm.setLastStackTop(m_prevLastStackTop);
-    m_vm.stackPointerAtVMEntry = m_prevStackPointerAtVMEntry;
-    m_vm.topCallFrame = m_prevTopCallFrame;
-}
-
-size_t VMEntryScope::stackUsageFor(char* topOfStack) const
-{
-    size_t currentStackUsage = 0;
-    ASSERT(m_vm.stackPointerAtVMEntry);
-    char* startOfStack = reinterpret_cast&lt;char*&gt;(m_vm.stackPointerAtVMEntry);
-    ASSERT(topOfStack &lt;= startOfStack);
-    currentStackUsage = startOfStack - topOfStack;
-
-    ASSERT(Options::maxStackSize() &gt;= m_prevStackUsage + currentStackUsage);
-    return m_prevStackUsage + currentStackUsage;
-}
-
-void VMEntryScope::updateStackLimits()
-{
-    ASSERT(wtfThreadData().stack().isGrowingDownward());
-    char* topOfStack = currentStackPointer();
-
-#if !ENABLE(LLINT_C_LOOP)
-    char* topOfJSStack = m_vm.topCallFrame ? reinterpret_cast&lt;char*&gt;(m_vm.topCallFrame-&gt;topOfFrame()) : topOfStack;
-
-    // If we have not re-entered the VM yet via callToJavaScript / callToNativeFunction,
-    // then stackPointerAtVMEntry will not have been set up yet. Instead, we'll
-    // compute the stack limit relative to the current topOfJSStack (as an estimate
-    // of stackPointerAtVMEntry). When we enter callToJavaScript later, we'll adjust
-    // the stack limit with the delta between the actual stackPointerAtVMEntry and
-    // the estimate value that we use here.
-    if (!m_vm.stackPointerAtVMEntry)
-        m_vm.stackPointerAtVMEntry = topOfJSStack;
-
-    void* jsStackLimit = m_stack.recursionLimit(requiredCapacity(topOfJSStack, JSStackCapacity));
-#ifndef NDEBUG
-    char* startOfStack = reinterpret_cast&lt;char*&gt;(m_vm.stackPointerAtVMEntry);
-    char* stackLimit = reinterpret_cast&lt;char*&gt;(jsStackLimit);
-    ASSERT(m_prevStackUsage + (startOfStack - stackLimit) &lt;= Options::maxStackSize());
-#endif
-    m_vm.setJSStackLimit(jsStackLimit);
-
-    // Some sanity checks for our pointers into the stack:
-    ASSERT(m_vm.interpreter-&gt;stack().containsAddress(reinterpret_cast&lt;Register*&gt;(m_vm.stackPointerAtVMEntry)));
-    ASSERT(m_vm.interpreter-&gt;stack().containsAddress(reinterpret_cast&lt;Register*&gt;(topOfJSStack)));
-    ASSERT(currentStackPointer() &lt;= topOfJSStack);
-    ASSERT(topOfJSStack &lt;= m_vm.stackPointerAtVMEntry);
-#endif // !ENABLE(LLINT_C_LOOP)
-
-    void* nativeStackLimit = m_stack.recursionLimit(requiredCapacity(topOfStack, NativeStackCapacity));
-    m_vm.setStackLimit(nativeStackLimit);
-}
-
-char* VMEntryScope::currentStackPointer() const
-{
-    char* p;
-#if ENABLE(LLINT_C_LOOP)
-    p = reinterpret_cast&lt;char*&gt;(m_vm.topCallFrame-&gt;topOfFrame());
-#else
-    p = reinterpret_cast&lt;char*&gt;(&amp;p);
-#endif
-    return p;
-}
-
-size_t VMEntryScope::requiredCapacity(char* topOfStack, CapacityType type) const
-{
-    ASSERT(m_stack.isGrowingDownward());
-
-    size_t excessCStackSize = 0;
-#if !ENABLE(LLINT_C_LOOP)
-    if (type == JSStackCapacity) {
-        ASSERT(Options::maxStackSize() &gt;= stackUsageFor(topOfStack));
-        size_t availableJSStack = Options::maxStackSize() - stackUsageFor(topOfStack);
-
-        char* bottomOfStack = reinterpret_cast&lt;char*&gt;(m_stack.origin());
-        size_t availableCStack = m_stack.size() - (bottomOfStack - topOfStack);
-        if (availableCStack &gt; availableJSStack)
-            excessCStackSize = availableCStack - availableJSStack;
</del><ins>+    if (m_vm.entryScope == this)
+        m_vm.entryScope = nullptr;
+    if (m_vm.stackPointerAtVMEntry == this) {
+        m_vm.stackPointerAtVMEntry = nullptr;
+        m_vm.updateStackLimitWithHostZoneSize(m_savedHostZoneSize);
</ins><span class="cx">     }
</span><del>-#else
-    UNUSED_PARAM(topOfStack);
-    UNUSED_PARAM(type);
-    ASSERT(type == NativeStackCapacity);
-#endif
-
-    // We require a smaller stack budget for the error stack. This is to allow
-    // some minimal JS execution to proceed and do the work of throwing a stack
-    // overflow error if needed. In contrast, arbitrary JS code will require the
-    // more generous stack budget in order to proceed.
-    //
-    // These sizes were derived from the stack usage of a number of sites when
-    // layout occurs when we've already consumed most of the C stack.
-    const size_t requiredStack = 128 * KB;
-    const size_t errorModeRequiredStack = 64 * KB;
-
-    Interpreter* interpreter = m_vm.interpreter;
-    size_t requiredCapacity = interpreter-&gt;isInErrorHandlingMode() ? errorModeRequiredStack : requiredStack;
-    requiredCapacity += excessCStackSize;
-
-    RELEASE_ASSERT(m_stack.size() &gt;= requiredCapacity);
-    return requiredCapacity; 
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace JSC
</span><del>-
</del></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreruntimeVMEntryScopeh"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/runtime/VMEntryScope.h (161574 => 161575)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/runtime/VMEntryScope.h        2014-01-09 20:41:06 UTC (rev 161574)
+++ branches/jsCStack/Source/JavaScriptCore/runtime/VMEntryScope.h        2014-01-09 21:10:46 UTC (rev 161575)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2013 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2013, 2014 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -40,33 +40,13 @@
</span><span class="cx">     JS_EXPORT_PRIVATE VMEntryScope(VM&amp;, JSGlobalObject*);
</span><span class="cx">     JS_EXPORT_PRIVATE ~VMEntryScope();
</span><span class="cx"> 
</span><del>-    void updateStackLimits();
</del><span class="cx">     JSGlobalObject* globalObject() const { return m_globalObject; }
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    enum CapacityType {
-        JSStackCapacity,
-        NativeStackCapacity,
-    };
-    size_t requiredCapacity(char* topOfStack, CapacityType) const;
-    char* currentStackPointer() const;
-    size_t stackUsageFor(char* topOfStack) const;
-
</del><span class="cx">     VM&amp; m_vm;
</span><span class="cx">     StackStats::CheckPoint m_stackCheckPoint;
</span><del>-    StackBounds m_stack;
</del><span class="cx">     JSGlobalObject* m_globalObject;
</span><del>-    size_t m_prevStackUsage;
-
-    // The following pointers may point to a different thread's stack.
-    VMEntryScope* m_prevTopEntryScope;
-    void* m_prevStackLimit;
-#if !ENABLE(LLINT_C_LOOP)
-    void* m_prevJSStackLimit;
-#endif
-    void* m_prevLastStackTop;
-    void* m_prevStackPointerAtVMEntry;
-    ExecState* m_prevTopCallFrame;
</del><ins>+    size_t m_savedHostZoneSize;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace JSC
</span></span></pre></div>
<a id="branchesjsCStackSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/WTF/ChangeLog (161574 => 161575)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/WTF/ChangeLog        2014-01-09 20:41:06 UTC (rev 161574)
+++ branches/jsCStack/Source/WTF/ChangeLog        2014-01-09 21:10:46 UTC (rev 161575)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2014-01-09  Mark Lam  &lt;mark.lam@apple.com&gt;
+
+        CStack: Need a separate stack limit for the JS stack and the C stack.
+        https://bugs.webkit.org/show_bug.cgi?id=126320.
+
+        Reviewed by Geoffrey Garen.
+
+        * wtf/StackBounds.h:
+        (WTF::StackBounds::recursionLimit):
+        - Previously, StackBounds::recursionLimit() only takes a host zone size
+          which it uses to compute the client's desired stack limit. Now, there's
+          an alternate version that also allows the client to explicitly specify
+          its desired stack limit in addition to its hostZoneSize requirement.
+          In both cases, StackBounds::recursionLimit() will cap the limit (with
+          allowance for the hostZoneSize) to be within its bounds, and return the
+          capped limit.
+
</ins><span class="cx"> 2014-01-06  Filip Pizlo  &lt;fpizlo@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Merge trunk r161364.
</span></span></pre></div>
<a id="branchesjsCStackSourceWTFwtfStackBoundsh"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/WTF/wtf/StackBounds.h (161574 => 161575)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/WTF/wtf/StackBounds.h        2014-01-09 20:41:06 UTC (rev 161574)
+++ branches/jsCStack/Source/WTF/wtf/StackBounds.h        2014-01-09 21:10:46 UTC (rev 161575)
</span><span class="lines">@@ -27,6 +27,8 @@
</span><span class="cx"> #ifndef StackBounds_h
</span><span class="cx"> #define StackBounds_h
</span><span class="cx"> 
</span><ins>+#include &lt;algorithm&gt;
+
</ins><span class="cx"> namespace WTF {
</span><span class="cx"> 
</span><span class="cx"> class StackBounds {
</span><span class="lines">@@ -67,6 +69,17 @@
</span><span class="cx">         return static_cast&lt;char*&gt;(m_bound) - minAvailableDelta;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    void* recursionLimit(size_t hostZoneSize, void* desiredLimit) const
+    {
+        checkConsistency();
+        if (isGrowingDownward()) {
+            char* endOfStackWithHostZone = reinterpret_cast&lt;char*&gt;(m_bound) + hostZoneSize;
+            return std::max(desiredLimit, reinterpret_cast&lt;void*&gt;(endOfStackWithHostZone));
+        }
+        char* endOfStackWithHostZone = reinterpret_cast&lt;char*&gt;(m_bound) - hostZoneSize;
+        return std::min(desiredLimit, reinterpret_cast&lt;void*&gt;(endOfStackWithHostZone));
+    }
+
</ins><span class="cx">     bool isGrowingDownward() const
</span><span class="cx">     {
</span><span class="cx">         ASSERT(m_origin &amp;&amp; m_bound);
</span></span></pre></div>
<a id="branchesjsCStackSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/WebCore/ChangeLog (161574 => 161575)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/WebCore/ChangeLog        2014-01-09 20:41:06 UTC (rev 161574)
+++ branches/jsCStack/Source/WebCore/ChangeLog        2014-01-09 21:10:46 UTC (rev 161575)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2014-01-09  Mark Lam  &lt;mark.lam@apple.com&gt;
+
+        CStack: Need a separate stack limit for the JS stack and the C stack.
+        https://bugs.webkit.org/show_bug.cgi?id=126320.
+
+        Reviewed by Geoffrey Garen.
+
+        No new tests.
+
+        * ForwardingHeaders/runtime/ErrorHandlingScope.h: Added.
+        * WebCore.vcxproj/WebCore.vcxproj:
+        * WebCore.vcxproj/WebCore.vcxproj.filters:
+        * bindings/js/JSDOMBinding.cpp:
+        (WebCore::reportException):
+        - Updated to use ErrorHandlingScope instead of Interpreter::ErrorHandlingMode.
+
</ins><span class="cx"> 2013-12-06  Laszlo Vidacs  &lt;lac@inf.u-szeged.hu&gt;
</span><span class="cx"> 
</span><span class="cx">         Define SHA1 hash size in SHA1.h and use it at various places.
</span></span></pre></div>
<a id="branchesjsCStackSourceWebCoreForwardingHeadersruntimeErrorHandlingScopeh"></a>
<div class="addfile"><h4>Added: branches/jsCStack/Source/WebCore/ForwardingHeaders/runtime/ErrorHandlingScope.h (0 => 161575)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/WebCore/ForwardingHeaders/runtime/ErrorHandlingScope.h                                (rev 0)
+++ branches/jsCStack/Source/WebCore/ForwardingHeaders/runtime/ErrorHandlingScope.h        2014-01-09 21:10:46 UTC (rev 161575)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+#ifndef WebCore_FWD_ErrorHandlingScope_h
+#define WebCore_FWD_ErrorHandlingScope_h
+#include &lt;JavaScriptCore/ErrorHandlingScope.h&gt;
+#endif
</ins></span></pre></div>
<a id="branchesjsCStackSourceWebCoreWebCorevcxprojWebCorevcxproj"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj (161574 => 161575)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2014-01-09 20:41:06 UTC (rev 161574)
+++ branches/jsCStack/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2014-01-09 21:10:46 UTC (rev 161575)
</span><span class="lines">@@ -18591,6 +18591,7 @@
</span><span class="cx">     &lt;ClInclude Include=&quot;..\ForwardingHeaders\runtime\ConstructData.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\ForwardingHeaders\runtime\DateInstance.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\ForwardingHeaders\runtime\Error.h&quot; /&gt;
</span><ins>+    &lt;ClInclude Include=&quot;..\ForwardingHeaders\runtime\ErrorHandlingScope.h&quot; /&gt;
</ins><span class="cx">     &lt;ClInclude Include=&quot;..\ForwardingHeaders\runtime\ErrorPrototype.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\ForwardingHeaders\runtime\ExceptionHelpers.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\ForwardingHeaders\runtime\Executable.h&quot; /&gt;
</span></span></pre></div>
<a id="branchesjsCStackSourceWebCoreWebCorevcxprojWebCorevcxprojfilters"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters (161574 => 161575)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters        2014-01-09 20:41:06 UTC (rev 161574)
+++ branches/jsCStack/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters        2014-01-09 21:10:46 UTC (rev 161575)
</span><span class="lines">@@ -12634,6 +12634,9 @@
</span><span class="cx">     &lt;ClInclude Include=&quot;..\ForwardingHeaders\runtime\Error.h&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;ForwardingHeaders\runtime&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClInclude&gt;
</span><ins>+    &lt;ClInclude Include=&quot;..\ForwardingHeaders\runtime\ErrorHandlingScope.h&quot;&gt;
+      &lt;Filter&gt;ForwardingHeaders\runtime&lt;/Filter&gt;
+    &lt;/ClInclude&gt;
</ins><span class="cx">     &lt;ClInclude Include=&quot;..\ForwardingHeaders\runtime\ErrorPrototype.h&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;ForwardingHeaders\runtime&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClInclude&gt;
</span></span></pre></div>
<a id="branchesjsCStackSourceWebCorebindingsjsJSDOMBindingcpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/WebCore/bindings/js/JSDOMBinding.cpp (161574 => 161575)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/WebCore/bindings/js/JSDOMBinding.cpp        2014-01-09 20:41:06 UTC (rev 161574)
+++ branches/jsCStack/Source/WebCore/bindings/js/JSDOMBinding.cpp        2014-01-09 21:10:46 UTC (rev 161575)
</span><span class="lines">@@ -39,6 +39,7 @@
</span><span class="cx"> #include &lt;interpreter/Interpreter.h&gt;
</span><span class="cx"> #include &lt;runtime/DateInstance.h&gt;
</span><span class="cx"> #include &lt;runtime/Error.h&gt;
</span><ins>+#include &lt;runtime/ErrorHandlingScope.h&gt;
</ins><span class="cx"> #include &lt;runtime/ExceptionHelpers.h&gt;
</span><span class="cx"> #include &lt;runtime/JSFunction.h&gt;
</span><span class="cx"> #include &lt;wtf/MathExtras.h&gt;
</span><span class="lines">@@ -149,7 +150,7 @@
</span><span class="cx">     if (isTerminatedExecutionException(exception))
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    Interpreter::ErrorHandlingMode mode(exec);
</del><ins>+    ErrorHandlingScope errorScope(exec-&gt;vm());
</ins><span class="cx"> 
</span><span class="cx">     RefPtr&lt;ScriptCallStack&gt; callStack(createScriptCallStackFromException(exec, exception, ScriptCallStack::maxCallStackSizeToCapture));
</span><span class="cx">     exec-&gt;clearException();
</span></span></pre>
</div>
</div>

</body>
</html>