<!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>[160267] branches/jsCStack/Source/JavaScriptCore</title>
</head>
<body>

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

<h3>Log Message</h3>
<pre>CStack Branch: Enable basic JavaScript functionality in LLInt
https://bugs.webkit.org/show_bug.cgi?id=125378

Reviewed by Filip Pizlo.

This provides basic LLInt only functionality for X86_64.  It runs simple scripts.
There are several places where the code is tagged with &quot;&amp;&amp;&amp;&amp; FIXME: ...&quot; comments
as placeholders where more work needs to be done.

Added X86 compliant prologue / epilogues at the head and tail of functions.
Changed LLInt calls to leave the caller framePointer in callFrame register and
pass the callee framePointer (-16) in SP so that the callee receiving prologue
will make store the ReturnPC and CallerFrame at the right location in the call
frame header. Created a stack pointer sanity check macro (checkStackPointerAlignment)
in the LLInt that will cause a breakpoint on failure.

* dfg/DFGJITCompiler.cpp:
(JSC::DFG::JITCompiler::compileEntry):
* dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::compile):
* ftl/FTLLink.cpp:
(JSC::FTL::compileEntry):
(JSC::FTL::link):
* ftl/FTLThunks.cpp:
(JSC::FTL::osrExitGenerationThunkGenerator):
(JSC::FTL::slowPathCallThunkGenerator):
* interpreter/Interpreter.cpp:
(JSC::unwindCallFrame):
* interpreter/ProtoCallFrame.cpp:
(JSC::ProtoCallFrame::init):
* jit/AssemblyHelpers.h:
(JSC::AssemblyHelpers::emitFunctionPrologue):
(JSC::AssemblyHelpers::emitFunctionEpilogue):
* jit/JIT.cpp:
(JSC::JIT::privateCompile):
* jit/JITCall.cpp:
(JSC::JIT::privateCompileClosureCall):
* jit/JITOpcodes.cpp:
(JSC::JIT::emit_op_end):
(JSC::JIT::emit_op_ret):
(JSC::JIT::emit_op_ret_object_or_this):
* jit/Repatch.cpp:
(JSC::linkClosureCall):
* jit/ThunkGenerators.cpp:
(JSC::slowPathFor):
(JSC::nativeForGenerator):
* llint/LowLevelInterpreter.asm:
* llint/LowLevelInterpreter64.asm:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchesjsCStackSourceJavaScriptCoreChangeLog">branches/jsCStack/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoredfgDFGJITCompilercpp">branches/jsCStack/Source/JavaScriptCore/dfg/DFGJITCompiler.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoredfgDFGSpeculativeJIT64cpp">branches/jsCStack/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreftlFTLLinkcpp">branches/jsCStack/Source/JavaScriptCore/ftl/FTLLink.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreftlFTLThunkscpp">branches/jsCStack/Source/JavaScriptCore/ftl/FTLThunks.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreinterpreterInterpretercpp">branches/jsCStack/Source/JavaScriptCore/interpreter/Interpreter.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreinterpreterProtoCallFramecpp">branches/jsCStack/Source/JavaScriptCore/interpreter/ProtoCallFrame.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCorejitAssemblyHelpersh">branches/jsCStack/Source/JavaScriptCore/jit/AssemblyHelpers.h</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCorejitJITcpp">branches/jsCStack/Source/JavaScriptCore/jit/JIT.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCorejitJITCallcpp">branches/jsCStack/Source/JavaScriptCore/jit/JITCall.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCorejitJITOpcodescpp">branches/jsCStack/Source/JavaScriptCore/jit/JITOpcodes.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCorejitRepatchcpp">branches/jsCStack/Source/JavaScriptCore/jit/Repatch.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCorejitThunkGeneratorscpp">branches/jsCStack/Source/JavaScriptCore/jit/ThunkGenerators.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCorellintLowLevelInterpreterasm">branches/jsCStack/Source/JavaScriptCore/llint/LowLevelInterpreter.asm</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCorellintLowLevelInterpreter64asm">branches/jsCStack/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchesjsCStackSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/ChangeLog (160266 => 160267)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/ChangeLog        2013-12-07 02:55:23 UTC (rev 160266)
+++ branches/jsCStack/Source/JavaScriptCore/ChangeLog        2013-12-07 05:46:22 UTC (rev 160267)
</span><span class="lines">@@ -1,5 +1,56 @@
</span><span class="cx"> 2013-12-06  Michael Saboff  &lt;msaboff@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        CStack Branch: Enable basic JavaScript functionality in LLInt
+        https://bugs.webkit.org/show_bug.cgi?id=125378
+
+        Reviewed by Filip Pizlo.
+
+        This provides basic LLInt only functionality for X86_64.  It runs simple scripts.
+        There are several places where the code is tagged with &quot;&amp;&amp;&amp;&amp; FIXME: ...&quot; comments
+        as placeholders where more work needs to be done.
+
+        Added X86 compliant prologue / epilogues at the head and tail of functions.
+        Changed LLInt calls to leave the caller framePointer in callFrame register and
+        pass the callee framePointer (-16) in SP so that the callee receiving prologue
+        will make store the ReturnPC and CallerFrame at the right location in the call
+        frame header. Created a stack pointer sanity check macro (checkStackPointerAlignment)
+        in the LLInt that will cause a breakpoint on failure.
+
+        * dfg/DFGJITCompiler.cpp:
+        (JSC::DFG::JITCompiler::compileEntry):
+        * dfg/DFGSpeculativeJIT64.cpp:
+        (JSC::DFG::SpeculativeJIT::compile):
+        * ftl/FTLLink.cpp:
+        (JSC::FTL::compileEntry):
+        (JSC::FTL::link):
+        * ftl/FTLThunks.cpp:
+        (JSC::FTL::osrExitGenerationThunkGenerator):
+        (JSC::FTL::slowPathCallThunkGenerator):
+        * interpreter/Interpreter.cpp:
+        (JSC::unwindCallFrame):
+        * interpreter/ProtoCallFrame.cpp:
+        (JSC::ProtoCallFrame::init):
+        * jit/AssemblyHelpers.h:
+        (JSC::AssemblyHelpers::emitFunctionPrologue):
+        (JSC::AssemblyHelpers::emitFunctionEpilogue):
+        * jit/JIT.cpp:
+        (JSC::JIT::privateCompile):
+        * jit/JITCall.cpp:
+        (JSC::JIT::privateCompileClosureCall):
+        * jit/JITOpcodes.cpp:
+        (JSC::JIT::emit_op_end):
+        (JSC::JIT::emit_op_ret):
+        (JSC::JIT::emit_op_ret_object_or_this):
+        * jit/Repatch.cpp:
+        (JSC::linkClosureCall):
+        * jit/ThunkGenerators.cpp:
+        (JSC::slowPathFor):
+        (JSC::nativeForGenerator):
+        * llint/LowLevelInterpreter.asm:
+        * llint/LowLevelInterpreter64.asm:
+
+2013-12-06  Michael Saboff  &lt;msaboff@apple.com&gt;
+
</ins><span class="cx">     Merged from trunk r160244: &lt;http://trac.webkit.org/changeset/160244&gt;
</span><span class="cx"> 
</span><span class="cx">         Split sizing of VarArgs frames from loading arguments for the frame
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoredfgDFGJITCompilercpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/dfg/DFGJITCompiler.cpp (160266 => 160267)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/dfg/DFGJITCompiler.cpp        2013-12-07 02:55:23 UTC (rev 160266)
+++ branches/jsCStack/Source/JavaScriptCore/dfg/DFGJITCompiler.cpp        2013-12-07 05:46:22 UTC (rev 160267)
</span><span class="lines">@@ -98,8 +98,7 @@
</span><span class="cx">     // We'll need to convert the remaining cti_ style calls (specifically the stack
</span><span class="cx">     // check) which will be dependent on stack layout. (We'd need to account for this in
</span><span class="cx">     // both normal return code and when jumping to an exception handler).
</span><del>-    preserveReturnAddressAfterCall(GPRInfo::regT2);
-    emitPutReturnPCToCallFrameHeader(GPRInfo::regT2);
</del><ins>+    emitFunctionPrologue();
</ins><span class="cx">     emitPutImmediateToCallFrameHeader(m_codeBlock, JSStack::CodeBlock);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoredfgDFGSpeculativeJIT64cpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp (160266 => 160267)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp        2013-12-07 02:55:23 UTC (rev 160266)
+++ branches/jsCStack/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp        2013-12-07 05:46:22 UTC (rev 160267)
</span><span class="lines">@@ -3423,12 +3423,7 @@
</span><span class="cx">         JSValueOperand op1(this, node-&gt;child1());
</span><span class="cx">         m_jit.move(op1.gpr(), GPRInfo::returnValueGPR);
</span><span class="cx"> 
</span><del>-        // Grab the return address.
-        m_jit.emitGetReturnPCFromCallFrameHeaderPtr(GPRInfo::regT1);
-        // Restore our caller's &quot;r&quot;.
-        m_jit.emitGetCallerFrameFromCallFrameHeaderPtr(GPRInfo::callFrameRegister);
-        // Return.
-        m_jit.restoreReturnAddressBeforeReturn(GPRInfo::regT1);
</del><ins>+        m_jit.emitFunctionEpilogue();
</ins><span class="cx">         m_jit.ret();
</span><span class="cx">         
</span><span class="cx">         noResult(node);
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreftlFTLLinkcpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/ftl/FTLLink.cpp (160266 => 160267)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/ftl/FTLLink.cpp        2013-12-07 02:55:23 UTC (rev 160266)
+++ branches/jsCStack/Source/JavaScriptCore/ftl/FTLLink.cpp        2013-12-07 05:46:22 UTC (rev 160267)
</span><span class="lines">@@ -45,8 +45,7 @@
</span><span class="cx"> 
</span><span class="cx"> static void compileEntry(CCallHelpers&amp; jit)
</span><span class="cx"> {
</span><del>-    jit.preserveReturnAddressAfterCall(GPRInfo::regT2);
-    jit.emitPutReturnPCToCallFrameHeader(GPRInfo::regT2);
</del><ins>+    jit.emitFunctionPrologue();
</ins><span class="cx">     jit.emitPutImmediateToCallFrameHeader(jit.codeBlock(), JSStack::CodeBlock);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -96,9 +95,7 @@
</span><span class="cx">             CCallHelpers::TrustedImmPtr(reinterpret_cast&lt;void*&gt;(state.generatedFunction)),
</span><span class="cx">             GPRInfo::nonArgGPR0);
</span><span class="cx">         jit.call(GPRInfo::nonArgGPR0);
</span><del>-        jit.emitGetReturnPCFromCallFrameHeaderPtr(GPRInfo::regT1);
-        jit.emitGetCallerFrameFromCallFrameHeaderPtr(GPRInfo::callFrameRegister);
-        jit.restoreReturnAddressBeforeReturn(GPRInfo::regT1);
</del><ins>+        jit.emitFunctionEpilogue();
</ins><span class="cx">         jit.ret();
</span><span class="cx">         
</span><span class="cx">         stackCheck.link(&amp;jit);
</span><span class="lines">@@ -165,9 +162,7 @@
</span><span class="cx">             CCallHelpers::TrustedImmPtr(reinterpret_cast&lt;void*&gt;(state.generatedFunction)),
</span><span class="cx">             GPRInfo::nonArgGPR0);
</span><span class="cx">         jit.call(GPRInfo::nonArgGPR0);
</span><del>-        jit.emitGetReturnPCFromCallFrameHeaderPtr(GPRInfo::regT1);
-        jit.emitGetCallerFrameFromCallFrameHeaderPtr(GPRInfo::callFrameRegister);
-        jit.restoreReturnAddressBeforeReturn(GPRInfo::regT1);
</del><ins>+        jit.emitFunctionEpilogue();
</ins><span class="cx">         jit.ret();
</span><span class="cx">         
</span><span class="cx">         linkBuffer = adoptPtr(new LinkBuffer(
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreftlFTLThunkscpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/ftl/FTLThunks.cpp (160266 => 160267)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/ftl/FTLThunks.cpp        2013-12-07 02:55:23 UTC (rev 160266)
+++ branches/jsCStack/Source/JavaScriptCore/ftl/FTLThunks.cpp        2013-12-07 05:46:22 UTC (rev 160267)
</span><span class="lines">@@ -74,6 +74,7 @@
</span><span class="cx">     // Prepare for tail call.
</span><span class="cx">     jit.pop(GPRInfo::regT1);
</span><span class="cx">     jit.pop(GPRInfo::regT1);
</span><ins>+    // &amp;&amp;&amp;&amp;&amp; FIXME: Need to address the right way to adjust CFR and SP
</ins><span class="cx">     jit.pop(MacroAssembler::framePointerRegister);
</span><span class="cx">     
</span><span class="cx">     // At this point we're sitting on the return address - so if we did a jump right now, the
</span><span class="lines">@@ -81,7 +82,8 @@
</span><span class="cx">     // restore all registers.
</span><span class="cx">     
</span><span class="cx">     jit.restoreReturnAddressBeforeReturn(GPRInfo::regT0);
</span><del>-    
</del><ins>+    // &amp;&amp;&amp;&amp; Through here
+
</ins><span class="cx">     restoreAllRegisters(jit, buffer);
</span><span class="cx"> 
</span><span class="cx">     jit.ret();
</span><span class="lines">@@ -119,11 +121,13 @@
</span><span class="cx">         currentOffset += sizeof(double);
</span><span class="cx">     }
</span><span class="cx">     
</span><ins>+    // &amp;&amp;&amp;&amp; FIXME: Need to do soemething like jit.emitFunctionPrologue();
</ins><span class="cx">     jit.preserveReturnAddressAfterCall(GPRInfo::nonArgGPR0);
</span><span class="cx">     jit.storePtr(GPRInfo::nonArgGPR0, AssemblyHelpers::Address(MacroAssembler::stackPointerRegister, key.offset()));
</span><span class="cx">     
</span><span class="cx">     JITCompiler::Call call = jit.call();
</span><del>-    
</del><ins>+
+    // &amp;&amp;&amp;&amp; FIXME: Need to do something like jit.emitFunctionEpilogue();
</ins><span class="cx">     jit.loadPtr(AssemblyHelpers::Address(MacroAssembler::stackPointerRegister, key.offset()), GPRInfo::nonPreservedNonReturnGPR);
</span><span class="cx">     jit.restoreReturnAddressBeforeReturn(GPRInfo::nonPreservedNonReturnGPR);
</span><span class="cx">     
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreinterpreterInterpretercpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/interpreter/Interpreter.cpp (160266 => 160267)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/interpreter/Interpreter.cpp        2013-12-07 02:55:23 UTC (rev 160266)
+++ branches/jsCStack/Source/JavaScriptCore/interpreter/Interpreter.cpp        2013-12-07 05:46:22 UTC (rev 160267)
</span><span class="lines">@@ -456,7 +456,10 @@
</span><span class="cx"> 
</span><span class="cx">     CallFrame* callerFrame = callFrame-&gt;callerFrame();
</span><span class="cx">     if (callerFrame-&gt;isVMEntrySentinel()) {
</span><del>-        callFrame-&gt;vm().topCallFrame = callerFrame-&gt;vmEntrySentinelCallerFrame();
</del><ins>+        if (callerFrame-&gt;vmEntrySentinelCallerFrame())
+            callFrame-&gt;vm().topCallFrame = callerFrame-&gt;vmEntrySentinelCallerFrame();
+        else
+            callFrame-&gt;vm().topCallFrame = callFrame; // _returnFromJavaScript will pop the frame off.
</ins><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx">     return true;
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreinterpreterProtoCallFramecpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/interpreter/ProtoCallFrame.cpp (160266 => 160267)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/interpreter/ProtoCallFrame.cpp        2013-12-07 02:55:23 UTC (rev 160266)
+++ branches/jsCStack/Source/JavaScriptCore/interpreter/ProtoCallFrame.cpp        2013-12-07 05:46:22 UTC (rev 160267)
</span><span class="lines">@@ -43,6 +43,10 @@
</span><span class="cx">         if (paddedArgsCount &lt; numParameters)
</span><span class="cx">             paddedArgsCount = numParameters;
</span><span class="cx">     }
</span><ins>+    // &amp;&amp;&amp;&amp; FIXME: Align the combination of sentinel frame + callee frame
+    // Maybe this should be in callToJavaScript.
+    if (!(paddedArgsCount &amp; 1))
+        paddedArgsCount++;
</ins><span class="cx">     this-&gt;setPaddedArgsCount(paddedArgsCount);
</span><span class="cx">     this-&gt;clearCurrentVPC();
</span><span class="cx">     this-&gt;setThisValue(thisValue);
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCorejitAssemblyHelpersh"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/jit/AssemblyHelpers.h (160266 => 160267)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/jit/AssemblyHelpers.h        2013-12-07 02:55:23 UTC (rev 160266)
+++ branches/jsCStack/Source/JavaScriptCore/jit/AssemblyHelpers.h        2013-12-07 05:46:22 UTC (rev 160267)
</span><span class="lines">@@ -60,6 +60,19 @@
</span><span class="cx">     AssemblerType_T&amp; assembler() { return m_assembler; }
</span><span class="cx">     
</span><span class="cx"> #if CPU(X86_64) || CPU(X86)
</span><ins>+    void emitFunctionPrologue()
+    {
+        push(framePointerRegister);
+        move(stackPointerRegister, framePointerRegister);
+    }
+
+    void emitFunctionEpilogue()
+    {
+        // FIXME: The stack pointer need to be calculated from the framePointer
+        move(framePointerRegister, stackPointerRegister);
+        pop(framePointerRegister);
+    }
+    
</ins><span class="cx">     void preserveReturnAddressAfterCall(GPRReg reg)
</span><span class="cx">     {
</span><span class="cx">         pop(reg);
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCorejitJITcpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/jit/JIT.cpp (160266 => 160267)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/jit/JIT.cpp        2013-12-07 02:55:23 UTC (rev 160266)
+++ branches/jsCStack/Source/JavaScriptCore/jit/JIT.cpp        2013-12-07 05:46:22 UTC (rev 160267)
</span><span class="lines">@@ -506,8 +506,7 @@
</span><span class="cx">     if (m_randomGenerator.getUint32() &amp; 1)
</span><span class="cx">         nop();
</span><span class="cx"> 
</span><del>-    preserveReturnAddressAfterCall(regT2);
-    emitPutReturnPCToCallFrameHeader(regT2);
</del><ins>+    emitFunctionPrologue();
</ins><span class="cx">     emitPutImmediateToCallFrameHeader(m_codeBlock, JSStack::CodeBlock);
</span><span class="cx"> 
</span><span class="cx">     Label beginLabel(this);
</span><span class="lines">@@ -564,8 +563,7 @@
</span><span class="cx"> 
</span><span class="cx">         arityCheck = label();
</span><span class="cx">         store8(TrustedImm32(0), &amp;m_codeBlock-&gt;m_shouldAlwaysBeInlined);
</span><del>-        preserveReturnAddressAfterCall(regT2);
-        emitPutReturnPCToCallFrameHeader(regT2);
</del><ins>+        emitFunctionPrologue();
</ins><span class="cx">         emitPutImmediateToCallFrameHeader(m_codeBlock, JSStack::CodeBlock);
</span><span class="cx"> 
</span><span class="cx">         load32(payloadFor(JSStack::ArgumentCount), regT1);
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCorejitJITCallcpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/jit/JITCall.cpp (160266 => 160267)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/jit/JITCall.cpp        2013-12-07 02:55:23 UTC (rev 160266)
+++ branches/jsCStack/Source/JavaScriptCore/jit/JITCall.cpp        2013-12-07 05:46:22 UTC (rev 160267)
</span><span class="lines">@@ -226,7 +226,7 @@
</span><span class="cx"> void JIT::privateCompileClosureCall(CallLinkInfo* callLinkInfo, CodeBlock* calleeCodeBlock, Structure* expectedStructure, ExecutableBase* expectedExecutable, MacroAssemblerCodePtr codePtr)
</span><span class="cx"> {
</span><span class="cx">     JumpList slowCases;
</span><del>-    
</del><ins>+
</ins><span class="cx">     slowCases.append(branchTestPtr(NonZero, regT0, tagMaskRegister));
</span><span class="cx">     slowCases.append(branchPtr(NotEqual, Address(regT0, JSCell::structureOffset()), TrustedImmPtr(expectedStructure)));
</span><span class="cx">     slowCases.append(branchPtr(NotEqual, Address(regT0, JSFunction::offsetOfExecutable()), TrustedImmPtr(expectedExecutable)));
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCorejitJITOpcodescpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/jit/JITOpcodes.cpp (160266 => 160267)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/jit/JITOpcodes.cpp        2013-12-07 02:55:23 UTC (rev 160266)
+++ branches/jsCStack/Source/JavaScriptCore/jit/JITOpcodes.cpp        2013-12-07 05:46:22 UTC (rev 160267)
</span><span class="lines">@@ -73,7 +73,7 @@
</span><span class="cx"> {
</span><span class="cx">     RELEASE_ASSERT(returnValueGPR != callFrameRegister);
</span><span class="cx">     emitGetVirtualRegister(currentInstruction[1].u.operand, returnValueGPR);
</span><del>-    restoreReturnAddressBeforeReturn(Address(callFrameRegister, CallFrame::returnPCOffset()));
</del><ins>+    emitFunctionEpilogue();
</ins><span class="cx">     ret();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -262,14 +262,7 @@
</span><span class="cx">     // Return the result in %eax.
</span><span class="cx">     emitGetVirtualRegister(currentInstruction[1].u.operand, returnValueGPR);
</span><span class="cx"> 
</span><del>-    // Grab the return address.
-    emitGetReturnPCFromCallFrameHeaderPtr(regT1);
-
-    // Restore our caller's &quot;r&quot;.
-    emitGetCallerFrameFromCallFrameHeaderPtr(callFrameRegister);
-
-    // Return.
-    restoreReturnAddressBeforeReturn(regT1);
</del><ins>+    emitFunctionEpilogue();
</ins><span class="cx">     ret();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -288,11 +281,8 @@
</span><span class="cx">     // Grab the return address.
</span><span class="cx">     emitGetReturnPCFromCallFrameHeaderPtr(regT1);
</span><span class="cx"> 
</span><del>-    // Restore our caller's &quot;r&quot;.
-    emitGetCallerFrameFromCallFrameHeaderPtr(callFrameRegister);
-
</del><span class="cx">     // Return.
</span><del>-    restoreReturnAddressBeforeReturn(regT1);
</del><ins>+    emitFunctionEpilogue();
</ins><span class="cx">     ret();
</span><span class="cx"> 
</span><span class="cx">     // Return 'this' in %eax.
</span><span class="lines">@@ -300,14 +290,8 @@
</span><span class="cx">     notObject.link(this);
</span><span class="cx">     emitGetVirtualRegister(currentInstruction[2].u.operand, returnValueGPR);
</span><span class="cx"> 
</span><del>-    // Grab the return address.
-    emitGetReturnPCFromCallFrameHeaderPtr(regT1);
-
-    // Restore our caller's &quot;r&quot;.
-    emitGetCallerFrameFromCallFrameHeaderPtr(callFrameRegister);
-
</del><span class="cx">     // Return.
</span><del>-    restoreReturnAddressBeforeReturn(regT1);
</del><ins>+    emitFunctionEpilogue();
</ins><span class="cx">     ret();
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCorejitRepatchcpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/jit/Repatch.cpp (160266 => 160267)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/jit/Repatch.cpp        2013-12-07 02:55:23 UTC (rev 160266)
+++ branches/jsCStack/Source/JavaScriptCore/jit/Repatch.cpp        2013-12-07 05:46:22 UTC (rev 160267)
</span><span class="lines">@@ -1384,6 +1384,9 @@
</span><span class="cx">     stubJit.move(CCallHelpers::TrustedImm32(JSValue::CellTag), GPRInfo::regT1);
</span><span class="cx"> #endif
</span><span class="cx">     stubJit.move(CCallHelpers::TrustedImmPtr(callLinkInfo.callReturnLocation.executableAddress()), GPRInfo::nonArgGPR2);
</span><ins>+    
+    // &amp;&amp;&amp;&amp; FIXME: Think the following instruction should be a poke
+    stubJit.breakpoint();
</ins><span class="cx">     stubJit.restoreReturnAddressBeforeReturn(GPRInfo::nonArgGPR2);
</span><span class="cx">     AssemblyHelpers::Jump slow = stubJit.jump();
</span><span class="cx">     
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCorejitThunkGeneratorscpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/jit/ThunkGenerators.cpp (160266 => 160267)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/jit/ThunkGenerators.cpp        2013-12-07 02:55:23 UTC (rev 160266)
+++ branches/jsCStack/Source/JavaScriptCore/jit/ThunkGenerators.cpp        2013-12-07 05:46:22 UTC (rev 160267)
</span><span class="lines">@@ -82,9 +82,9 @@
</span><span class="cx"> static void slowPathFor(
</span><span class="cx">     CCallHelpers&amp; jit, VM* vm, P_JITOperation_E slowPathFunction)
</span><span class="cx"> {
</span><del>-    jit.preserveReturnAddressAfterCall(GPRInfo::nonArgGPR2);
-    emitPointerValidation(jit, GPRInfo::nonArgGPR2);
-    jit.emitPutReturnPCToCallFrameHeader(GPRInfo::nonArgGPR2);
</del><ins>+    // &amp;&amp;&amp;&amp;  FIXME: Need to cleanup frame below like emitFunctionEpilogue()
+    jit.breakpoint();
+    jit.emitFunctionPrologue();
</ins><span class="cx">     jit.storePtr(GPRInfo::callFrameRegister, &amp;vm-&gt;topCallFrame);
</span><span class="cx">     jit.setupArgumentsExecState();
</span><span class="cx">     jit.move(CCallHelpers::TrustedImmPtr(bitwise_cast&lt;void*&gt;(slowPathFunction)), GPRInfo::nonArgGPR0);
</span><span class="lines">@@ -250,7 +250,8 @@
</span><span class="cx">     int executableOffsetToFunction = NativeExecutable::offsetOfNativeFunctionFor(kind);
</span><span class="cx">     
</span><span class="cx">     JSInterfaceJIT jit(vm);
</span><del>-    
</del><ins>+
+    jit.emitFunctionPrologue();
</ins><span class="cx">     jit.emitPutImmediateToCallFrameHeader(0, JSStack::CodeBlock);
</span><span class="cx">     jit.storePtr(JSInterfaceJIT::callFrameRegister, &amp;vm-&gt;topCallFrame);
</span><span class="cx"> 
</span><span class="lines">@@ -261,9 +262,6 @@
</span><span class="cx">     jit.emitGetFromCallFrameHeaderPtr(JSStack::ScopeChain, JSInterfaceJIT::regT1, JSInterfaceJIT::regT0);
</span><span class="cx">     jit.emitPutCellToCallFrameHeader(JSInterfaceJIT::regT1, JSStack::ScopeChain);
</span><span class="cx"> 
</span><del>-    jit.peek(JSInterfaceJIT::regT1);
-    jit.emitPutReturnPCToCallFrameHeader(JSInterfaceJIT::regT1);
-
</del><span class="cx">     // Calling convention:      f(ecx, edx, ...);
</span><span class="cx">     // Host function signature: f(ExecState*);
</span><span class="cx">     jit.move(JSInterfaceJIT::callFrameRegister, X86Registers::ecx);
</span><span class="lines">@@ -390,6 +388,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     // Return.
</span><ins>+    jit.emitFunctionEpilogue();
</ins><span class="cx">     jit.ret();
</span><span class="cx"> 
</span><span class="cx">     // Handle an exception
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCorellintLowLevelInterpreterasm"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/llint/LowLevelInterpreter.asm (160266 => 160267)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/llint/LowLevelInterpreter.asm        2013-12-07 02:55:23 UTC (rev 160266)
+++ branches/jsCStack/Source/JavaScriptCore/llint/LowLevelInterpreter.asm        2013-12-07 05:46:22 UTC (rev 160267)
</span><span class="lines">@@ -206,6 +206,29 @@
</span><span class="cx">     end
</span><span class="cx"> end
</span><span class="cx"> 
</span><ins>+macro preserveCallerPCAndCFR()
+    if C_LOOP or ARM or ARMv7 or ARMv7_TRADITIONAL or ARM64 or MIPS or SH4
+        # In C_LOOP case, we're only preserving the bytecode vPC.
+        # FIXME: Need to fix for other ports
+        # move lr, destinationRegister
+    elsif X86 or X86_64
+        push cfr
+        move sp, cfr
+    else
+        error
+    end
+end
+
+macro restoreCallerPCAndCFR()
+    if C_LOOP or ARM or ARMv7 or ARMv7_TRADITIONAL or ARM64 or MIPS or SH4
+        # In C_LOOP case, we're only preserving the bytecode vPC.
+        # FIXME: Need to fix for other ports
+        # move lr, destinationRegister
+    elsif X86 or X86_64
+        move cfr, sp
+        pop cfr
+    end
+end
</ins><span class="cx"> macro preserveReturnAddressAfterCall(destinationRegister)
</span><span class="cx">     if C_LOOP or ARM or ARMv7 or ARMv7_TRADITIONAL or ARM64 or MIPS or SH4
</span><span class="cx">         # In C_LOOP case, we're only preserving the bytecode vPC.
</span><span class="lines">@@ -234,11 +257,13 @@
</span><span class="cx">     end
</span><span class="cx"> end
</span><span class="cx"> 
</span><del>-macro callTargetFunction(callLinkInfo)
</del><ins>+macro callTargetFunction(callLinkInfo, calleeFramePtr)
</ins><span class="cx">     if C_LOOP
</span><span class="cx">         cloopCallJSFunction LLIntCallLinkInfo::machineCodeTarget[callLinkInfo]
</span><span class="cx">     else
</span><ins>+        prepareStackPointerForJSCall(calleeFramePtr)
</ins><span class="cx">         call LLIntCallLinkInfo::machineCodeTarget[callLinkInfo]
</span><ins>+        restoreStackPointerAfterJSCall()
</ins><span class="cx">         dispatchAfterCall()
</span><span class="cx">     end
</span><span class="cx"> end
</span><span class="lines">@@ -250,7 +275,9 @@
</span><span class="cx">             if C_LOOP
</span><span class="cx">                 cloopCallJSFunction callee
</span><span class="cx">             else
</span><ins>+                prepareStackPointerForJSCall(t1) # The slow patch leaves the calle ExecState* in t1
</ins><span class="cx">                 call callee
</span><ins>+                restoreStackPointerAfterJSCall()
</ins><span class="cx">                 dispatchAfterCall()
</span><span class="cx">             end
</span><span class="cx">         end)
</span><span class="lines">@@ -313,10 +340,9 @@
</span><span class="cx"> # Do the bare minimum required to execute code. Sets up the PC, leave the CodeBlock*
</span><span class="cx"> # in t1. May also trigger prologue entry OSR.
</span><span class="cx"> macro prologue(codeBlockGetter, codeBlockSetter, osrSlowPath, traceSlowPath)
</span><del>-    preserveReturnAddressAfterCall(t2)
-    
</del><span class="cx">     # Set up the call frame and check if we should OSR.
</span><del>-    storep t2, ReturnPC[cfr]
</del><ins>+    preserveCallerPCAndCFR()
+
</ins><span class="cx">     if EXECUTION_TRACING
</span><span class="cx">         callSlowPath(traceSlowPath)
</span><span class="cx">     end
</span><span class="lines">@@ -326,8 +352,10 @@
</span><span class="cx">         cCall2(osrSlowPath, cfr, PC)
</span><span class="cx">         move t1, cfr
</span><span class="cx">         btpz t0, .recover
</span><del>-        loadp ReturnPC[cfr], t2
-        restoreReturnAddressBeforeReturn(t2)
</del><ins>+        # &amp;&amp;&amp;&amp; FIXME: Not sure this is right
+        break
+        # loadp ReturnPC[cfr], t2
+        # restoreReturnAddressBeforeReturn(t2)
</ins><span class="cx">         jmp t0
</span><span class="cx">     .recover:
</span><span class="cx">         codeBlockGetter(t1)
</span><span class="lines">@@ -335,6 +363,10 @@
</span><span class="cx">     end
</span><span class="cx">     codeBlockSetter(t1)
</span><span class="cx">     
</span><ins>+    loadi CodeBlock::m_numCalleeRegisters[t1], t2
+    lshiftp 3, t2
+    subp t2, sp
+
</ins><span class="cx">     # Set up the PC.
</span><span class="cx">     if JSVALUE64
</span><span class="cx">         loadp CodeBlock::m_instructions[t1], PB
</span><span class="lines">@@ -415,9 +447,7 @@
</span><span class="cx"> end
</span><span class="cx"> 
</span><span class="cx"> macro doReturn()
</span><del>-    loadp ReturnPC[cfr], t2
-    loadp CallerFrame[cfr], cfr
-    restoreReturnAddressBeforeReturn(t2)
</del><ins>+    restoreCallerPCAndCFR()
</ins><span class="cx">     ret
</span><span class="cx"> end
</span><span class="cx"> 
</span><span class="lines">@@ -429,10 +459,10 @@
</span><span class="cx"> # Note, if these stubs or one of their related macros are changed, make the
</span><span class="cx"> # equivalent changes in jit/JITStubsX86.h and/or jit/JITStubsMSVC64.asm
</span><span class="cx"> _callToJavaScript:
</span><del>-    doCallToJavaScript(makeJavaScriptCall, doReturnFromJavaScript)
</del><ins>+    doCallToJavaScript(makeJavaScriptCall)
</ins><span class="cx"> 
</span><span class="cx"> _callToNativeFunction:
</span><del>-    doCallToJavaScript(makeHostFunctionCall, doReturnFromHostFunction)
</del><ins>+    doCallToJavaScript(makeHostFunctionCall)
</ins><span class="cx"> end
</span><span class="cx"> 
</span><span class="cx"> # Indicate the beginning of LLInt.
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCorellintLowLevelInterpreter64asm"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm (160266 => 160267)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm        2013-12-07 02:55:23 UTC (rev 160266)
+++ branches/jsCStack/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm        2013-12-07 05:46:22 UTC (rev 160267)
</span><span class="lines">@@ -52,6 +52,7 @@
</span><span class="cx"> end
</span><span class="cx"> 
</span><span class="cx"> macro cCall2(function, arg1, arg2)
</span><ins>+    checkStackPointerAlignment(t5, 0xbad0c002)
</ins><span class="cx">     if X86_64
</span><span class="cx">         move arg1, t5
</span><span class="cx">         move arg2, t4
</span><span class="lines">@@ -69,6 +70,7 @@
</span><span class="cx"> 
</span><span class="cx"> # This barely works. arg3 and arg4 should probably be immediates.
</span><span class="cx"> macro cCall4(function, arg1, arg2, arg3, arg4)
</span><ins>+    checkStackPointerAlignment(t5, 0xbad0c004)
</ins><span class="cx">     if X86_64
</span><span class="cx">         move arg1, t5
</span><span class="cx">         move arg2, t4
</span><span class="lines">@@ -88,6 +90,15 @@
</span><span class="cx">     end
</span><span class="cx"> end
</span><span class="cx"> 
</span><ins>+macro checkStackPointerAlignment(tempReg, location)
+    andp sp, 0xf, tempReg
+    btpz tempReg, .stackPointerOkay
+    move location, tempReg
+    break
+.stackPointerOkay:
+end
+
+
</ins><span class="cx"> macro functionPrologue(extraStackSpace)
</span><span class="cx">     if X86_64
</span><span class="cx">         push cfr
</span><span class="lines">@@ -95,32 +106,71 @@
</span><span class="cx">     elsif ARM64
</span><span class="cx">         pushLRAndFP
</span><span class="cx">     end
</span><ins>+    subp extraStackSpace, sp
+end
+
+macro functionEpilogue(extraStackSpace)
+    addp extraStackSpace, sp
+    if X86_64
+        pop cfr
+    elsif ARM64
+        popLRAndFP
+    end
+end
+
+macro callToJavaScriptPrologue(extraStackSpace)
+    if X86_64
+#        push cfr
+#        move sp, cfr
+    elsif ARM64
+        pushLRAndFP
+    end
</ins><span class="cx">     pushCalleeSaves
</span><span class="cx">     if X86_64
</span><span class="cx">         subp extraStackSpace, sp
</span><span class="cx">     end
</span><span class="cx"> end
</span><span class="cx"> 
</span><del>-macro functionEpilogue(extraStackSpace)
</del><ins>+macro callToJavaScriptEpilogue(extraStackSpace)
+    addp (CallFrameHeaderSlots-1)*8, cfr, sp
+    loadp CallerFrame[cfr], cfr
+
</ins><span class="cx">     if X86_64
</span><span class="cx">         addp extraStackSpace, sp
</span><span class="cx">     end
</span><span class="cx">     popCalleeSaves
</span><span class="cx">     if X86_64
</span><del>-        pop cfr
</del><ins>+#        pop cfr
</ins><span class="cx">     elsif ARM64
</span><span class="cx">         popLRAndFP
</span><span class="cx">     end
</span><span class="cx"> end
</span><span class="cx"> 
</span><del>-macro doCallToJavaScript(makeCall, doReturn)
</del><ins>+macro moveStackPointerForCallframe(codeblock)
+    loadi CodeBlock::m_numCalleeRegisters[codeblock], t1
+    lshiftp 3, t1
+    subp cfr, t1, sp
+end
+
+macro prepareStackPointerForJSCall(calleeFramePtr)
+    addp 16, calleeFramePtr, sp
+end
+
+macro restoreStackPointerAfterJSCall()
+    loadp CodeBlock[cfr], t1
+    loadi CodeBlock::m_numCalleeRegisters[t1], t1
+    lshiftp 3, t1
+    subp cfr, t1, sp
+end
+
+macro doCallToJavaScript(makeCall)
</ins><span class="cx">     if X86_64
</span><span class="cx">         const entry = t5
</span><span class="cx">         const vmTopCallFrame = t4
</span><span class="cx">         const protoCallFrame = t1
</span><span class="cx">         const topOfStack = t2
</span><span class="cx"> 
</span><del>-        const extraStackSpace = 8
</del><ins>+        const extraStackSpace = 16
</ins><span class="cx">         const previousCFR = t0
</span><span class="cx">         const previousPC = t6
</span><span class="cx">         const temp1 = t0
</span><span class="lines">@@ -144,31 +194,31 @@
</span><span class="cx">         loadp [sp], previousPC
</span><span class="cx">     end
</span><span class="cx">     move cfr, previousCFR
</span><del>-    functionPrologue(extraStackSpace)
</del><ins>+    callToJavaScriptPrologue(extraStackSpace)
</ins><span class="cx"> 
</span><del>-    move topOfStack, cfr
</del><ins>+    checkStackPointerAlignment(temp2, 0xbad0dc01)
+
+    move sp, cfr
</ins><span class="cx">     subp (CallFrameHeaderSlots-1)*8, cfr
</span><span class="cx">     storep 0, ArgumentCount[cfr]
</span><span class="cx">     storep vmTopCallFrame, Callee[cfr]
</span><del>-    loadp [vmTopCallFrame], temp1
-    storep temp1, ScopeChain[cfr]
</del><ins>+    loadp [vmTopCallFrame], temp2
+    storep temp2, ScopeChain[cfr]
</ins><span class="cx">     storep 1, CodeBlock[cfr]
</span><span class="cx">     storep previousPC, ReturnPC[cfr]
</span><span class="cx">     storep previousCFR, CallerFrame[cfr]
</span><del>-    move cfr, temp1
</del><span class="cx"> 
</span><span class="cx">     loadi ProtoCallFrame::paddedArgCount[protoCallFrame], temp2
</span><span class="cx">     addp CallFrameHeaderSlots, temp2, temp2
</span><span class="cx">     lshiftp 3, temp2
</span><del>-    subp temp2, cfr
-    storep temp1, CallerFrame[cfr]
</del><ins>+    subp cfr, temp2, sp
</ins><span class="cx"> 
</span><span class="cx">     move 5, temp1
</span><span class="cx"> 
</span><span class="cx"> .copyHeaderLoop:
</span><span class="cx">     subi 1, temp1
</span><span class="cx">     loadp [protoCallFrame, temp1, 8], temp3
</span><del>-    storep temp3, CodeBlock[cfr, temp1, 8]
</del><ins>+    storep temp3, CodeBlock[sp, temp1, 8]
</ins><span class="cx">     btinz temp1, .copyHeaderLoop
</span><span class="cx"> 
</span><span class="cx">     loadi ProtoCallFrame::argCountAndCodeOriginValue[protoCallFrame], temp2
</span><span class="lines">@@ -180,7 +230,7 @@
</span><span class="cx">     move ValueUndefined, temp1
</span><span class="cx"> .fillExtraArgsLoop:
</span><span class="cx">     subi 1, temp3
</span><del>-    storep temp1, ThisArgumentOffset+8[cfr, temp3, 8]
</del><ins>+    storep temp1, ThisArgumentOffset+8[sp, temp3, 8]
</ins><span class="cx">     bineq temp2, temp3, .fillExtraArgsLoop
</span><span class="cx"> 
</span><span class="cx"> .copyArgs:
</span><span class="lines">@@ -190,17 +240,21 @@
</span><span class="cx">     btiz temp2, .copyArgsDone
</span><span class="cx">     subi 1, temp2
</span><span class="cx">     loadp [temp1, temp2, 8], temp3
</span><del>-    storep temp3, ThisArgumentOffset+8[cfr, temp2, 8]
</del><ins>+    storep temp3, ThisArgumentOffset+8[sp, temp2, 8]
</ins><span class="cx">     jmp .copyArgsLoop
</span><span class="cx"> 
</span><span class="cx"> .copyArgsDone:
</span><del>-    storep cfr, [vmTopCallFrame]
</del><ins>+    storep sp, [vmTopCallFrame]
</ins><span class="cx"> 
</span><span class="cx">     move 0xffff000000000000, csr1
</span><span class="cx">     addp 2, csr1, csr2
</span><span class="cx"> 
</span><ins>+    checkStackPointerAlignment(temp3, 0xbad0dc02)
+
</ins><span class="cx">     makeCall(entry, temp1)
</span><span class="cx"> 
</span><ins>+    checkStackPointerAlignment(temp3, 0xbad0dc03)
+
</ins><span class="cx">     bpeq CodeBlock[cfr], 1, .calleeFramePopped
</span><span class="cx">     loadp CallerFrame[cfr], cfr
</span><span class="cx"> 
</span><span class="lines">@@ -209,34 +263,50 @@
</span><span class="cx">     loadp ScopeChain[cfr], temp3
</span><span class="cx">     storep temp3, [temp2]
</span><span class="cx"> 
</span><del>-    doReturn(extraStackSpace)
</del><ins>+    checkStackPointerAlignment(temp3, 0xbad0dc04)
+
+    callToJavaScriptEpilogue(extraStackSpace)
+    ret
</ins><span class="cx"> end
</span><span class="cx"> 
</span><ins>+
</ins><span class="cx"> macro makeJavaScriptCall(entry, temp)
</span><ins>+    addp 16, sp
</ins><span class="cx">     call entry
</span><ins>+    subp 16, sp
</ins><span class="cx"> end
</span><span class="cx"> 
</span><ins>+
</ins><span class="cx"> macro makeHostFunctionCall(entry, temp)
</span><span class="cx">     move entry, temp
</span><span class="cx">     if X86_64
</span><del>-        move cfr, t5
</del><ins>+        move sp, t5
</ins><span class="cx">     elsif ARM64 or C_LOOP
</span><del>-        move cfr, a0
</del><ins>+        move sp, a0
</ins><span class="cx">     end
</span><ins>+    addp 16, sp
</ins><span class="cx">     call temp
</span><ins>+    subp 16, sp
</ins><span class="cx"> end
</span><span class="cx"> 
</span><del>-macro doReturnFromJavaScript(extraStackSpace)
</del><ins>+
</ins><span class="cx"> _returnFromJavaScript:
</span><del>-    functionEpilogue(extraStackSpace)
-    ret
-end
</del><ins>+    subp 16, sp
</ins><span class="cx"> 
</span><del>-macro doReturnFromHostFunction(extraStackSpace)
-    functionEpilogue(extraStackSpace)
</del><ins>+    checkStackPointerAlignment(t3, 0xbad0eeee)
+
+    bpeq CodeBlock[cfr], 1, .calleeFramePopped
+    loadp CallerFrame[cfr], cfr
+
+.calleeFramePopped:
+    loadp Callee[cfr], t3 # VM.topCallFrame
+    loadp ScopeChain[cfr], t6
+    storep t6, [t3]
+
+    callToJavaScriptEpilogue(16)
</ins><span class="cx">     ret
</span><del>-end
</del><span class="cx"> 
</span><ins>+
</ins><span class="cx"> macro prepareStateForCCall()
</span><span class="cx">     leap [PB, PC, 8], PC
</span><span class="cx">     move PB, t3
</span><span class="lines">@@ -273,7 +343,6 @@
</span><span class="cx">     storei PC, ArgumentCount + TagOffset[cfr]
</span><span class="cx">     prepareStateForCCall()
</span><span class="cx">     cCall2(slowPath, cfr, PC)
</span><del>-    move t1, cfr
</del><span class="cx">     action(t0)
</span><span class="cx"> end
</span><span class="cx"> 
</span><span class="lines">@@ -1674,10 +1743,8 @@
</span><span class="cx">     storeq t0, ScopeChain[t3]
</span><span class="cx">     loadisFromInstruction(3, t2)
</span><span class="cx">     storei PC, ArgumentCount + TagOffset[cfr]
</span><del>-    storeq cfr, CallerFrame[t3]
</del><span class="cx">     storei t2, ArgumentCount + PayloadOffset[t3]
</span><del>-    move t3, cfr
-    callTargetFunction(t1)
</del><ins>+    callTargetFunction(t1,t3)
</ins><span class="cx"> 
</span><span class="cx"> .opCallSlow:
</span><span class="cx">     slowPathForCall(slowPath)
</span><span class="lines">@@ -1831,11 +1898,13 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> _llint_throw_during_call_trampoline:
</span><del>-    preserveReturnAddressAfterCall(t2)
</del><ins>+    pop t2
</ins><span class="cx">     jmp _llint_throw_from_slow_path_trampoline
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> macro nativeCallTrampoline(executableOffsetToFunction)
</span><ins>+
+    functionPrologue(0)
</ins><span class="cx">     storep 0, CodeBlock[cfr]
</span><span class="cx">     if X86_64
</span><span class="cx">         loadp ScopeChain[cfr], t0
</span><span class="lines">@@ -1845,15 +1914,11 @@
</span><span class="cx">         loadp CallerFrame[cfr], t0
</span><span class="cx">         loadq ScopeChain[t0], t1
</span><span class="cx">         storeq t1, ScopeChain[cfr]
</span><del>-        peek 0, t1
-        storep t1, ReturnPC[cfr]
</del><span class="cx">         move cfr, t5  # t5 = rdi
</span><del>-        subp 16 - 8, sp
</del><span class="cx">         loadp Callee[cfr], t4 # t4 = rsi
</span><span class="cx">         loadp JSFunction::m_executable[t4], t1
</span><del>-        move t0, cfr # Restore cfr to avoid loading from stack
</del><ins>+        checkStackPointerAlignment(t3, 0xdead0001)
</ins><span class="cx">         call executableOffsetToFunction[t1]
</span><del>-        addp 16 - 8, sp
</del><span class="cx">         loadp ScopeChain[cfr], t3
</span><span class="cx">         andp MarkedBlockMask, t3
</span><span class="cx">         loadp MarkedBlock::m_weakSet + WeakSet::m_vm[t3], t3
</span><span class="lines">@@ -1904,9 +1969,12 @@
</span><span class="cx">     end
</span><span class="cx"> 
</span><span class="cx">     btqnz VM::m_exception[t3], .exception
</span><ins>+    functionEpilogue(0)
</ins><span class="cx">     ret
</span><span class="cx"> .exception:
</span><del>-    preserveReturnAddressAfterCall(t1) # This is really only needed on X86_64
</del><ins>+    if X86_64
+        pop t1
+    end
</ins><span class="cx">     loadi ArgumentCount + TagOffset[cfr], PC
</span><span class="cx">     loadp CodeBlock[cfr], PB
</span><span class="cx">     loadp CodeBlock::m_vm[PB], t0
</span></span></pre>
</div>
</div>

</body>
</html>