<!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>[206212] trunk/Source/JavaScriptCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/206212">206212</a></dd>
<dt>Author</dt> <dd>msaboff@apple.com</dd>
<dt>Date</dt> <dd>2016-09-21 09:26:13 -0700 (Wed, 21 Sep 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>FTL needs to reserve callee stack space in bytes
https://bugs.webkit.org/show_bug.cgi?id=162324

Reviewed by Geoffrey Garen.

Changed two instances where we call B3::Procedure::requestCallArgAreaSize() with the
number of JSValue sized objects of stack space instead of bytes.  The correct units
to use is bytes.

Renamed both the Air and B3 related callArgAreaSize() to callArgAreaSizeInBytes().

No new tests as this doesn't surface as an issue when arguments are passed on the stack.

* b3/B3Procedure.cpp:
(JSC::B3::Procedure::callArgAreaSizeInBytes):
(JSC::B3::Procedure::requestCallArgAreaSizeInBytes):
(JSC::B3::Procedure::callArgAreaSize): Deleted.
(JSC::B3::Procedure::requestCallArgAreaSize): Deleted.
* b3/B3Procedure.h:
* b3/air/AirAllocateStack.cpp:
(JSC::B3::Air::allocateStack):
* b3/air/AirCCallingConvention.cpp:
(JSC::B3::Air::computeCCallingConvention):
* b3/air/AirCode.h:
(JSC::B3::Air::Code::callArgAreaSizeInBytes):
(JSC::B3::Air::Code::requestCallArgAreaSizeInBytes):
(JSC::B3::Air::Code::callArgAreaSize): Deleted.
(JSC::B3::Air::Code::requestCallArgAreaSize): Deleted.
* ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::compileCallOrConstruct):
(JSC::FTL::DFG::LowerDFGToB3::compileCallOrConstructVarargs):
(JSC::FTL::DFG::LowerDFGToB3::compileCallEval):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreb3B3Procedurecpp">trunk/Source/JavaScriptCore/b3/B3Procedure.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreb3B3Procedureh">trunk/Source/JavaScriptCore/b3/B3Procedure.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreb3airAirAllocateStackcpp">trunk/Source/JavaScriptCore/b3/air/AirAllocateStack.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreb3airAirCCallingConventioncpp">trunk/Source/JavaScriptCore/b3/air/AirCCallingConvention.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreb3airAirCodeh">trunk/Source/JavaScriptCore/b3/air/AirCode.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreftlFTLLowerDFGToB3cpp">trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (206211 => 206212)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-09-21 16:25:14 UTC (rev 206211)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-09-21 16:26:13 UTC (rev 206212)
</span><span class="lines">@@ -1,3 +1,38 @@
</span><ins>+2016-09-21  Michael Saboff  &lt;msaboff@apple.com&gt;
+
+        FTL needs to reserve callee stack space in bytes
+        https://bugs.webkit.org/show_bug.cgi?id=162324
+
+        Reviewed by Geoffrey Garen.
+
+        Changed two instances where we call B3::Procedure::requestCallArgAreaSize() with the
+        number of JSValue sized objects of stack space instead of bytes.  The correct units
+        to use is bytes.
+
+        Renamed both the Air and B3 related callArgAreaSize() to callArgAreaSizeInBytes().
+
+        No new tests as this doesn't surface as an issue when arguments are passed on the stack.
+
+        * b3/B3Procedure.cpp:
+        (JSC::B3::Procedure::callArgAreaSizeInBytes):
+        (JSC::B3::Procedure::requestCallArgAreaSizeInBytes):
+        (JSC::B3::Procedure::callArgAreaSize): Deleted.
+        (JSC::B3::Procedure::requestCallArgAreaSize): Deleted.
+        * b3/B3Procedure.h:
+        * b3/air/AirAllocateStack.cpp:
+        (JSC::B3::Air::allocateStack):
+        * b3/air/AirCCallingConvention.cpp:
+        (JSC::B3::Air::computeCCallingConvention):
+        * b3/air/AirCode.h:
+        (JSC::B3::Air::Code::callArgAreaSizeInBytes):
+        (JSC::B3::Air::Code::requestCallArgAreaSizeInBytes):
+        (JSC::B3::Air::Code::callArgAreaSize): Deleted.
+        (JSC::B3::Air::Code::requestCallArgAreaSize): Deleted.
+        * ftl/FTLLowerDFGToB3.cpp:
+        (JSC::FTL::DFG::LowerDFGToB3::compileCallOrConstruct):
+        (JSC::FTL::DFG::LowerDFGToB3::compileCallOrConstructVarargs):
+        (JSC::FTL::DFG::LowerDFGToB3::compileCallEval):
+
</ins><span class="cx"> 2016-09-21  Csaba Osztrogonác  &lt;ossy@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         [ARM] Unreviewed buildfix after r206136.
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreb3B3Procedurecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/b3/B3Procedure.cpp (206211 => 206212)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/b3/B3Procedure.cpp        2016-09-21 16:25:14 UTC (rev 206211)
+++ trunk/Source/JavaScriptCore/b3/B3Procedure.cpp        2016-09-21 16:26:13 UTC (rev 206212)
</span><span class="lines">@@ -295,14 +295,14 @@
</span><span class="cx">     return result;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-unsigned Procedure::callArgAreaSize() const
</del><ins>+unsigned Procedure::callArgAreaSizeInBytes() const
</ins><span class="cx"> {
</span><del>-    return code().callArgAreaSize();
</del><ins>+    return code().callArgAreaSizeInBytes();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Procedure::requestCallArgAreaSize(unsigned size)
</del><ins>+void Procedure::requestCallArgAreaSizeInBytes(unsigned size)
</ins><span class="cx"> {
</span><del>-    code().requestCallArgAreaSize(size);
</del><ins>+    code().requestCallArgAreaSizeInBytes(size);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> unsigned Procedure::frameSize() const
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreb3B3Procedureh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/b3/B3Procedure.h (206211 => 206212)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/b3/B3Procedure.h        2016-09-21 16:25:14 UTC (rev 206211)
+++ trunk/Source/JavaScriptCore/b3/B3Procedure.h        2016-09-21 16:26:13 UTC (rev 206212)
</span><span class="lines">@@ -210,8 +210,8 @@
</span><span class="cx">     const Air::Code&amp; code() const { return *m_code; }
</span><span class="cx">     Air::Code&amp; code() { return *m_code; }
</span><span class="cx"> 
</span><del>-    unsigned callArgAreaSize() const;
-    void requestCallArgAreaSize(unsigned size);
</del><ins>+    unsigned callArgAreaSizeInBytes() const;
+    void requestCallArgAreaSizeInBytes(unsigned size);
</ins><span class="cx"> 
</span><span class="cx">     JS_EXPORT_PRIVATE unsigned frameSize() const;
</span><span class="cx">     const RegisterAtOffsetList&amp; calleeSaveRegisters() const;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreb3airAirAllocateStackcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/b3/air/AirAllocateStack.cpp (206211 => 206212)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/b3/air/AirAllocateStack.cpp        2016-09-21 16:25:14 UTC (rev 206211)
+++ trunk/Source/JavaScriptCore/b3/air/AirAllocateStack.cpp        2016-09-21 16:26:13 UTC (rev 206212)
</span><span class="lines">@@ -240,13 +240,13 @@
</span><span class="cx">                     // such an awesome assumption.
</span><span class="cx">                     // FIXME: https://bugs.webkit.org/show_bug.cgi?id=150454
</span><span class="cx">                     ASSERT(arg.offset() &gt;= 0);
</span><del>-                    code.requestCallArgAreaSize(arg.offset() + 8);
</del><ins>+                    code.requestCallArgAreaSizeInBytes(arg.offset() + 8);
</ins><span class="cx">                 }
</span><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    code.setFrameSize(frameSizeForStackSlots + code.callArgAreaSize());
</del><ins>+    code.setFrameSize(frameSizeForStackSlots + code.callArgAreaSizeInBytes());
</ins><span class="cx"> 
</span><span class="cx">     // Finally, transform the code to use Addr's instead of StackSlot's. This is a lossless
</span><span class="cx">     // transformation since we can search the StackSlots array to figure out which StackSlot any
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreb3airAirCCallingConventioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/b3/air/AirCCallingConvention.cpp (206211 => 206212)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/b3/air/AirCCallingConvention.cpp        2016-09-21 16:25:14 UTC (rev 206211)
+++ trunk/Source/JavaScriptCore/b3/air/AirCCallingConvention.cpp        2016-09-21 16:26:13 UTC (rev 206212)
</span><span class="lines">@@ -85,7 +85,7 @@
</span><span class="cx">         result.append(
</span><span class="cx">             marshallCCallArgument(gpArgumentCount, fpArgumentCount, stackOffset, value-&gt;child(i)));
</span><span class="cx">     }
</span><del>-    code.requestCallArgAreaSize(WTF::roundUpToMultipleOf(stackAlignmentBytes(), stackOffset));
</del><ins>+    code.requestCallArgAreaSizeInBytes(WTF::roundUpToMultipleOf(stackAlignmentBytes(), stackOffset));
</ins><span class="cx">     return result;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreb3airAirCodeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/b3/air/AirCode.h (206211 => 206212)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/b3/air/AirCode.h        2016-09-21 16:25:14 UTC (rev 206211)
+++ trunk/Source/JavaScriptCore/b3/air/AirCode.h        2016-09-21 16:26:13 UTC (rev 206212)
</span><span class="lines">@@ -101,10 +101,10 @@
</span><span class="cx">         ASSERT_NOT_REACHED();
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    unsigned callArgAreaSize() const { return m_callArgAreaSize; }
</del><ins>+    unsigned callArgAreaSizeInBytes() const { return m_callArgAreaSize; }
</ins><span class="cx"> 
</span><span class="cx">     // You can call this before code generation to force a minimum call arg area size.
</span><del>-    void requestCallArgAreaSize(unsigned size)
</del><ins>+    void requestCallArgAreaSizeInBytes(unsigned size)
</ins><span class="cx">     {
</span><span class="cx">         m_callArgAreaSize = std::max(
</span><span class="cx">             m_callArgAreaSize,
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreftlFTLLowerDFGToB3cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp (206211 => 206212)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp        2016-09-21 16:25:14 UTC (rev 206211)
+++ trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp        2016-09-21 16:26:13 UTC (rev 206212)
</span><span class="lines">@@ -5293,8 +5293,8 @@
</span><span class="cx"> 
</span><span class="cx">         LValue jsCallee = lowJSValue(m_graph.varArgChild(node, 0));
</span><span class="cx"> 
</span><del>-        unsigned frameSize = CallFrame::headerSizeInRegisters + numArgs;
-        unsigned alignedFrameSize = WTF::roundUpToMultipleOf(stackAlignmentRegisters(), frameSize);
</del><ins>+        unsigned frameSize = (CallFrame::headerSizeInRegisters + numArgs) * sizeof(EncodedJSValue);
+        unsigned alignedFrameSize = WTF::roundUpToMultipleOf(stackAlignmentBytes(), frameSize);
</ins><span class="cx"> 
</span><span class="cx">         // JS-&gt;JS calling convention requires that the caller allows this much space on top of stack to
</span><span class="cx">         // get trashed by the callee, even if not all of that space is used to pass arguments. We tell
</span><span class="lines">@@ -5304,7 +5304,7 @@
</span><span class="cx">         // - The trashed stack guarantee is logically separate from the act of passing arguments, so we
</span><span class="cx">         //   shouldn't rely on Air to infer the trashed stack property based on the arguments it ends
</span><span class="cx">         //   up seeing.
</span><del>-        m_proc.requestCallArgAreaSize(alignedFrameSize);
</del><ins>+        m_proc.requestCallArgAreaSizeInBytes(alignedFrameSize);
</ins><span class="cx"> 
</span><span class="cx">         // Collect the arguments, since this can generate code and we want to generate it before we emit
</span><span class="cx">         // the call.
</span><span class="lines">@@ -5554,7 +5554,7 @@
</span><span class="cx">             sizeof(CallerFrameAndPC) +
</span><span class="cx">             WTF::roundUpToMultipleOf(stackAlignmentBytes(), 5 * sizeof(EncodedJSValue));
</span><span class="cx"> 
</span><del>-        m_proc.requestCallArgAreaSize(minimumJSCallAreaSize);
</del><ins>+        m_proc.requestCallArgAreaSizeInBytes(minimumJSCallAreaSize);
</ins><span class="cx">         
</span><span class="cx">         CodeOrigin codeOrigin = codeOriginDescriptionOfCallSite();
</span><span class="cx">         State* state = &amp;m_ftlState;
</span><span class="lines">@@ -5780,10 +5780,10 @@
</span><span class="cx">         
</span><span class="cx">         LValue jsCallee = lowJSValue(m_graph.varArgChild(node, 0));
</span><span class="cx">         
</span><del>-        unsigned frameSize = CallFrame::headerSizeInRegisters + numArgs;
-        unsigned alignedFrameSize = WTF::roundUpToMultipleOf(stackAlignmentRegisters(), frameSize);
</del><ins>+        unsigned frameSize = (CallFrame::headerSizeInRegisters + numArgs) * sizeof(EncodedJSValue);
+        unsigned alignedFrameSize = WTF::roundUpToMultipleOf(stackAlignmentBytes(), frameSize);
</ins><span class="cx">         
</span><del>-        m_proc.requestCallArgAreaSize(alignedFrameSize);
</del><ins>+        m_proc.requestCallArgAreaSizeInBytes(alignedFrameSize);
</ins><span class="cx">         
</span><span class="cx">         Vector&lt;ConstrainedValue&gt; arguments;
</span><span class="cx">         arguments.append(ConstrainedValue(jsCallee, ValueRep::reg(GPRInfo::regT0)));
</span></span></pre>
</div>
</div>

</body>
</html>