<!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>[160980] 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/160980">160980</a></dd>
<dt>Author</dt> <dd>fpizlo@apple.com</dd>
<dt>Date</dt> <dd>2013-12-22 10:42:09 -0800 (Sun, 22 Dec 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>It should be possible to run the full version of V8v7/crypto with the FTL and call IC's
https://bugs.webkit.org/show_bug.cgi?id=126116

Not yet reviewed.
        
This involved a number of minor fixes:
        
- CallLinkInfo::unlink() was assuming that repatchBuffer.codeBlock() is the caller.
  It's actually the callee. So, to determine if the caller requires register
  preservation, we need an extra bit to say whether the CallLinkInfo belongs to an FTL
  JITCode.
        
- A lot of bugs arise from us incorrectly preserving (or failing to preserve)
  registers. This adds a bunch of jitAssertTagsInPlace() assertion that helps to catch
  a bunch of those bugs.
        
- Apparently the __compact_unwind sometimes has garbage after its one entry. This
  changes our unwind parser so that it doesn't assert that the second entry is null,
  but it does assert that the first entry corresponds to our generated function.
        
- The native function thunks assume that tags are set up and that they can clobber any
  registers. This breaks if we call the thunks from the FTL. This patch fixes the bug
  by wrapping just those thunks in a DirectJITCode, which has the register preservation
  wrappers. This probably ends up making sense because the FTL *really* should have
  intrinsics for all of those thunks. As part of this change, I refactored how
  NativeExecutable gets its JITCode to make things somewhat more explicit.
        
We still have a bunch of known performance bugs to fix, but the FTL is already at near
parity with the DFG on V8v7/crypto. This is pretty cool considering the FTL's other
speed-ups, and the fact that crypto has been our primary DFG tuning test for the past
2.5 years.

* bytecode/CallLinkInfo.cpp:
(JSC::CallLinkInfo::unlink):
* bytecode/CallLinkInfo.h:
(JSC::CallLinkInfo::CallLinkInfo):
* dfg/DFGJITCompiler.cpp:
(JSC::DFG::JITCompiler::compileEntry):
* dfg/DFGOSRExitCompiler64.cpp:
(JSC::DFG::OSRExitCompiler::compileExit):
* dfg/DFGOSRExitCompilerCommon.cpp:
(JSC::DFG::adjustAndJumpToTarget):
* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileCurrentBlock):
* ftl/FTLCompile.cpp:
(JSC::FTL::compile):
* ftl/FTLJSCall.cpp:
(JSC::FTL::JSCall::link):
* ftl/FTLUnwindInfo.cpp:
(JSC::FTL::UnwindInfo::parse):
* ftl/FTLUnwindInfo.h:
* jit/AssemblyHelpers.cpp:
(JSC::AssemblyHelpers::jitAssertTagsInPlace):
* jit/AssemblyHelpers.h:
(JSC::AssemblyHelpers::jitAssertTagsInPlace):
* jit/JIT.cpp:
(JSC::JIT::privateCompileMainPass):
* jit/JITCode.cpp:
* jit/JITCode.h:
* jit/JITThunks.cpp:
(JSC::JITThunks::hostFunctionStub):
* jit/RegisterPreservationWrapperGenerator.cpp:
(JSC::generateRegisterPreservationWrapper):
* runtime/Executable.h:
(JSC::NativeExecutable::create):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchesjsCStackSourceJavaScriptCoreChangeLog">branches/jsCStack/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCorebytecodeCallLinkInfocpp">branches/jsCStack/Source/JavaScriptCore/bytecode/CallLinkInfo.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCorebytecodeCallLinkInfoh">branches/jsCStack/Source/JavaScriptCore/bytecode/CallLinkInfo.h</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoredfgDFGJITCompilercpp">branches/jsCStack/Source/JavaScriptCore/dfg/DFGJITCompiler.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoredfgDFGOSRExitCompiler64cpp">branches/jsCStack/Source/JavaScriptCore/dfg/DFGOSRExitCompiler64.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoredfgDFGOSRExitCompilerCommoncpp">branches/jsCStack/Source/JavaScriptCore/dfg/DFGOSRExitCompilerCommon.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoredfgDFGSpeculativeJITcpp">branches/jsCStack/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreftlFTLCompilecpp">branches/jsCStack/Source/JavaScriptCore/ftl/FTLCompile.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreftlFTLJSCallcpp">branches/jsCStack/Source/JavaScriptCore/ftl/FTLJSCall.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreftlFTLUnwindInfocpp">branches/jsCStack/Source/JavaScriptCore/ftl/FTLUnwindInfo.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreftlFTLUnwindInfoh">branches/jsCStack/Source/JavaScriptCore/ftl/FTLUnwindInfo.h</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCorejitAssemblyHelperscpp">branches/jsCStack/Source/JavaScriptCore/jit/AssemblyHelpers.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="#branchesjsCStackSourceJavaScriptCorejitJITCodecpp">branches/jsCStack/Source/JavaScriptCore/jit/JITCode.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCorejitJITCodeh">branches/jsCStack/Source/JavaScriptCore/jit/JITCode.h</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCorejitJITThunkscpp">branches/jsCStack/Source/JavaScriptCore/jit/JITThunks.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCorejitRegisterPreservationWrapperGeneratorcpp">branches/jsCStack/Source/JavaScriptCore/jit/RegisterPreservationWrapperGenerator.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreruntimeExecutableh">branches/jsCStack/Source/JavaScriptCore/runtime/Executable.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchesjsCStackSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/ChangeLog (160979 => 160980)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/ChangeLog        2013-12-22 18:15:41 UTC (rev 160979)
+++ branches/jsCStack/Source/JavaScriptCore/ChangeLog        2013-12-22 18:42:09 UTC (rev 160980)
</span><span class="lines">@@ -1,3 +1,71 @@
</span><ins>+2013-12-22  Filip Pizlo  &lt;fpizlo@apple.com&gt;
+
+        It should be possible to run the full version of V8v7/crypto with the FTL and call IC's
+        https://bugs.webkit.org/show_bug.cgi?id=126116
+
+        Not yet reviewed.
+        
+        This involved a number of minor fixes:
+        
+        - CallLinkInfo::unlink() was assuming that repatchBuffer.codeBlock() is the caller.
+          It's actually the callee. So, to determine if the caller requires register
+          preservation, we need an extra bit to say whether the CallLinkInfo belongs to an FTL
+          JITCode.
+        
+        - A lot of bugs arise from us incorrectly preserving (or failing to preserve)
+          registers. This adds a bunch of jitAssertTagsInPlace() assertion that helps to catch
+          a bunch of those bugs.
+        
+        - Apparently the __compact_unwind sometimes has garbage after its one entry. This
+          changes our unwind parser so that it doesn't assert that the second entry is null,
+          but it does assert that the first entry corresponds to our generated function.
+        
+        - The native function thunks assume that tags are set up and that they can clobber any
+          registers. This breaks if we call the thunks from the FTL. This patch fixes the bug
+          by wrapping just those thunks in a DirectJITCode, which has the register preservation
+          wrappers. This probably ends up making sense because the FTL *really* should have
+          intrinsics for all of those thunks. As part of this change, I refactored how
+          NativeExecutable gets its JITCode to make things somewhat more explicit.
+        
+        We still have a bunch of known performance bugs to fix, but the FTL is already at near
+        parity with the DFG on V8v7/crypto. This is pretty cool considering the FTL's other
+        speed-ups, and the fact that crypto has been our primary DFG tuning test for the past
+        2.5 years.
+
+        * bytecode/CallLinkInfo.cpp:
+        (JSC::CallLinkInfo::unlink):
+        * bytecode/CallLinkInfo.h:
+        (JSC::CallLinkInfo::CallLinkInfo):
+        * dfg/DFGJITCompiler.cpp:
+        (JSC::DFG::JITCompiler::compileEntry):
+        * dfg/DFGOSRExitCompiler64.cpp:
+        (JSC::DFG::OSRExitCompiler::compileExit):
+        * dfg/DFGOSRExitCompilerCommon.cpp:
+        (JSC::DFG::adjustAndJumpToTarget):
+        * dfg/DFGSpeculativeJIT.cpp:
+        (JSC::DFG::SpeculativeJIT::compileCurrentBlock):
+        * ftl/FTLCompile.cpp:
+        (JSC::FTL::compile):
+        * ftl/FTLJSCall.cpp:
+        (JSC::FTL::JSCall::link):
+        * ftl/FTLUnwindInfo.cpp:
+        (JSC::FTL::UnwindInfo::parse):
+        * ftl/FTLUnwindInfo.h:
+        * jit/AssemblyHelpers.cpp:
+        (JSC::AssemblyHelpers::jitAssertTagsInPlace):
+        * jit/AssemblyHelpers.h:
+        (JSC::AssemblyHelpers::jitAssertTagsInPlace):
+        * jit/JIT.cpp:
+        (JSC::JIT::privateCompileMainPass):
+        * jit/JITCode.cpp:
+        * jit/JITCode.h:
+        * jit/JITThunks.cpp:
+        (JSC::JITThunks::hostFunctionStub):
+        * jit/RegisterPreservationWrapperGenerator.cpp:
+        (JSC::generateRegisterPreservationWrapper):
+        * runtime/Executable.h:
+        (JSC::NativeExecutable::create):
+
</ins><span class="cx"> 2013-12-21  Mark Lam  &lt;mark.lam@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         CStack: Update the VMEntryScope's stack limit when the VM enters/exits ErrorMode.
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCorebytecodeCallLinkInfocpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/bytecode/CallLinkInfo.cpp (160979 => 160980)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/bytecode/CallLinkInfo.cpp        2013-12-22 18:15:41 UTC (rev 160979)
+++ branches/jsCStack/Source/JavaScriptCore/bytecode/CallLinkInfo.cpp        2013-12-22 18:42:09 UTC (rev 160980)
</span><span class="lines">@@ -38,14 +38,14 @@
</span><span class="cx">     ASSERT(isLinked());
</span><span class="cx">     
</span><span class="cx">     if (Options::showDisassembly())
</span><del>-        dataLog(&quot;Unlinking call in &quot;, *repatchBuffer.codeBlock(), &quot; at &quot;, codeOrigin, &quot;\n&quot;);
-    
</del><ins>+        dataLog(&quot;Unlinking call from &quot;, callReturnLocation, &quot; to &quot;, pointerDump(repatchBuffer.codeBlock()), &quot;\n&quot;);
+
</ins><span class="cx">     repatchBuffer.revertJumpReplacementToBranchPtrWithPatch(RepatchBuffer::startOfBranchPtrWithPatchOnRegister(hotPathBegin), static_cast&lt;MacroAssembler::RegisterID&gt;(calleeGPR), 0);
</span><span class="cx">     repatchBuffer.relink(
</span><span class="cx">         callReturnLocation,
</span><span class="cx">         vm.getCTIStub(linkThunkGeneratorFor(
</span><span class="cx">             callType == Construct ? CodeForConstruct : CodeForCall,
</span><del>-            repatchBuffer.codeBlock()-&gt;jitType() == JITCode::FTLJIT ? MustPreserveRegisters : RegisterPreservationNotRequired)).code());
</del><ins>+            isFTL ? MustPreserveRegisters : RegisterPreservationNotRequired)).code());
</ins><span class="cx">     hasSeenShouldRepatch = false;
</span><span class="cx">     callee.clear();
</span><span class="cx">     stub.clear();
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCorebytecodeCallLinkInfoh"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/bytecode/CallLinkInfo.h (160979 => 160980)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/bytecode/CallLinkInfo.h        2013-12-22 18:15:41 UTC (rev 160979)
+++ branches/jsCStack/Source/JavaScriptCore/bytecode/CallLinkInfo.h        2013-12-22 18:42:09 UTC (rev 160980)
</span><span class="lines">@@ -55,7 +55,8 @@
</span><span class="cx">     }
</span><span class="cx">         
</span><span class="cx">     CallLinkInfo()
</span><del>-        : hasSeenShouldRepatch(false)
</del><ins>+        : isFTL(false)
+        , hasSeenShouldRepatch(false)
</ins><span class="cx">         , hasSeenClosure(false)
</span><span class="cx">         , callType(None)
</span><span class="cx">     {
</span><span class="lines">@@ -78,6 +79,7 @@
</span><span class="cx">     JITWriteBarrier&lt;JSFunction&gt; callee;
</span><span class="cx">     WriteBarrier&lt;JSFunction&gt; lastSeenCallee;
</span><span class="cx">     RefPtr&lt;ClosureCallStubRoutine&gt; stub;
</span><ins>+    bool isFTL : 1;
</ins><span class="cx">     bool hasSeenShouldRepatch : 1;
</span><span class="cx">     bool hasSeenClosure : 1;
</span><span class="cx">     unsigned callType : 5; // CallType
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoredfgDFGJITCompilercpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/dfg/DFGJITCompiler.cpp (160979 => 160980)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/dfg/DFGJITCompiler.cpp        2013-12-22 18:15:41 UTC (rev 160979)
+++ branches/jsCStack/Source/JavaScriptCore/dfg/DFGJITCompiler.cpp        2013-12-22 18:42:09 UTC (rev 160980)
</span><span class="lines">@@ -100,6 +100,7 @@
</span><span class="cx">     // both normal return code and when jumping to an exception handler).
</span><span class="cx">     emitFunctionPrologue();
</span><span class="cx">     emitPutImmediateToCallFrameHeader(m_codeBlock, JSStack::CodeBlock);
</span><ins>+    jitAssertTagsInPlace();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void JITCompiler::compileBody()
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoredfgDFGOSRExitCompiler64cpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/dfg/DFGOSRExitCompiler64.cpp (160979 => 160980)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/dfg/DFGOSRExitCompiler64.cpp        2013-12-22 18:15:41 UTC (rev 160979)
+++ branches/jsCStack/Source/JavaScriptCore/dfg/DFGOSRExitCompiler64.cpp        2013-12-22 18:42:09 UTC (rev 160980)
</span><span class="lines">@@ -39,6 +39,8 @@
</span><span class="cx"> 
</span><span class="cx"> void OSRExitCompiler::compileExit(const OSRExit&amp; exit, const Operands&lt;ValueRecovery&gt;&amp; operands, SpeculationRecovery* recovery)
</span><span class="cx"> {
</span><ins>+    m_jit.jitAssertTagsInPlace();
+
</ins><span class="cx">     // 1) Pro-forma stuff.
</span><span class="cx">     if (Options::printEachOSRExit()) {
</span><span class="cx">         SpeculationFailureDebugInfo* debugInfo = new SpeculationFailureDebugInfo;
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoredfgDFGOSRExitCompilerCommoncpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/dfg/DFGOSRExitCompilerCommon.cpp (160979 => 160980)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/dfg/DFGOSRExitCompilerCommon.cpp        2013-12-22 18:15:41 UTC (rev 160979)
+++ branches/jsCStack/Source/JavaScriptCore/dfg/DFGOSRExitCompilerCommon.cpp        2013-12-22 18:42:09 UTC (rev 160980)
</span><span class="lines">@@ -176,6 +176,8 @@
</span><span class="cx">     void* jumpTarget = baselineCodeBlock-&gt;jitCode()-&gt;executableAddressAtOffset(mapping-&gt;m_machineCodeOffset);
</span><span class="cx"> 
</span><span class="cx">     jit.addPtr(AssemblyHelpers::TrustedImm32(JIT::stackPointerOffsetFor(baselineCodeBlock) * sizeof(Register)), GPRInfo::callFrameRegister, AssemblyHelpers::stackPointerRegister);
</span><ins>+    
+    jit.jitAssertTagsInPlace();
</ins><span class="cx"> 
</span><span class="cx">     jit.move(AssemblyHelpers::TrustedImmPtr(jumpTarget), GPRInfo::regT2);
</span><span class="cx">     jit.jump(GPRInfo::regT2);
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoredfgDFGSpeculativeJITcpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp (160979 => 160980)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp        2013-12-22 18:15:41 UTC (rev 160979)
+++ branches/jsCStack/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp        2013-12-22 18:42:09 UTC (rev 160980)
</span><span class="lines">@@ -1466,6 +1466,7 @@
</span><span class="cx">     m_stream-&gt;appendAndLog(VariableEvent::reset());
</span><span class="cx">     
</span><span class="cx">     m_jit.jitAssertHasValidCallFrame();
</span><ins>+    m_jit.jitAssertTagsInPlace();
</ins><span class="cx"> 
</span><span class="cx">     for (size_t i = 0; i &lt; m_block-&gt;variablesAtHead.numberOfArguments(); ++i) {
</span><span class="cx">         m_stream-&gt;appendAndLog(
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreftlFTLCompilecpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/ftl/FTLCompile.cpp (160979 => 160980)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/ftl/FTLCompile.cpp        2013-12-22 18:15:41 UTC (rev 160979)
+++ branches/jsCStack/Source/JavaScriptCore/ftl/FTLCompile.cpp        2013-12-22 18:42:09 UTC (rev 160980)
</span><span class="lines">@@ -458,7 +458,8 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     
</span><del>-    state.jitCode-&gt;unwindInfo.parse(state.compactUnwind, state.compactUnwindSize);
</del><ins>+    state.jitCode-&gt;unwindInfo.parse(
+        state.compactUnwind, state.compactUnwindSize, state.generatedFunction);
</ins><span class="cx">     if (DFG::shouldShowDisassembly())
</span><span class="cx">         dataLog(&quot;Unwind info for &quot;, CodeBlockWithJITType(state.graph.m_codeBlock, JITCode::FTLJIT), &quot;:\n    &quot;, state.jitCode-&gt;unwindInfo, &quot;\n&quot;);
</span><span class="cx">     
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreftlFTLJSCallcpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/ftl/FTLJSCall.cpp (160979 => 160980)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/ftl/FTLJSCall.cpp        2013-12-22 18:15:41 UTC (rev 160979)
+++ branches/jsCStack/Source/JavaScriptCore/ftl/FTLJSCall.cpp        2013-12-22 18:42:09 UTC (rev 160980)
</span><span class="lines">@@ -72,6 +72,7 @@
</span><span class="cx">     linkBuffer.link(
</span><span class="cx">         m_slowCall, FunctionPtr(vm.getCTIStub(generator).code().executableAddress()));
</span><span class="cx">     
</span><ins>+    callInfo.isFTL = true;
</ins><span class="cx">     callInfo.callType = m_node-&gt;op() == DFG::Construct ? CallLinkInfo::Construct : CallLinkInfo::Call;
</span><span class="cx">     callInfo.codeOrigin = m_node-&gt;codeOrigin;
</span><span class="cx">     callInfo.callReturnLocation = linkBuffer.locationOfNearCall(m_slowCall);
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreftlFTLUnwindInfocpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/ftl/FTLUnwindInfo.cpp (160979 => 160980)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/ftl/FTLUnwindInfo.cpp        2013-12-22 18:15:41 UTC (rev 160979)
+++ branches/jsCStack/Source/JavaScriptCore/ftl/FTLUnwindInfo.cpp        2013-12-22 18:42:09 UTC (rev 160980)
</span><span class="lines">@@ -48,7 +48,7 @@
</span><span class="cx"> 
</span><span class="cx"> } // anonymous namespace
</span><span class="cx"> 
</span><del>-void UnwindInfo::parse(void* section, size_t size)
</del><ins>+void UnwindInfo::parse(void* section, size_t size, GeneratedFunction generatedFunction)
</ins><span class="cx"> {
</span><span class="cx">     m_registers.clear();
</span><span class="cx">     
</span><span class="lines">@@ -59,7 +59,7 @@
</span><span class="cx">     
</span><span class="cx">     RELEASE_ASSERT(!data-&gt;personality); // We don't know how to handle this.
</span><span class="cx">     RELEASE_ASSERT(!data-&gt;lsda); // We don't know how to handle this.
</span><del>-    RELEASE_ASSERT(size == sizeof(CompactUnwind) || !data[1].function); // There will only be one function.
</del><ins>+    RELEASE_ASSERT(data-&gt;function == generatedFunction); // The unwind data better be for our function.
</ins><span class="cx">     
</span><span class="cx">     compact_unwind_encoding_t encoding = data-&gt;encoding;
</span><span class="cx">     RELEASE_ASSERT(!(encoding &amp; UNWIND_IS_NOT_FUNCTION_START));
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreftlFTLUnwindInfoh"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/ftl/FTLUnwindInfo.h (160979 => 160980)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/ftl/FTLUnwindInfo.h        2013-12-22 18:15:41 UTC (rev 160979)
+++ branches/jsCStack/Source/JavaScriptCore/ftl/FTLUnwindInfo.h        2013-12-22 18:42:09 UTC (rev 160980)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(FTL_JIT)
</span><span class="cx"> 
</span><ins>+#include &quot;FTLGeneratedFunction.h&quot;
</ins><span class="cx"> #include &quot;FTLRegisterAtOffset.h&quot;
</span><span class="cx"> 
</span><span class="cx"> namespace JSC { namespace FTL {
</span><span class="lines">@@ -36,7 +37,7 @@
</span><span class="cx">     UnwindInfo();
</span><span class="cx">     ~UnwindInfo();
</span><span class="cx">     
</span><del>-    void parse(void*, size_t);
</del><ins>+    void parse(void*, size_t, GeneratedFunction);
</ins><span class="cx">     
</span><span class="cx">     void dump(PrintStream&amp;) const;
</span><span class="cx">     
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCorejitAssemblyHelperscpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/jit/AssemblyHelpers.cpp (160979 => 160980)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/jit/AssemblyHelpers.cpp        2013-12-22 18:15:41 UTC (rev 160979)
+++ branches/jsCStack/Source/JavaScriptCore/jit/AssemblyHelpers.cpp        2013-12-22 18:42:09 UTC (rev 160980)
</span><span class="lines">@@ -110,6 +110,17 @@
</span><span class="cx">     breakpoint();
</span><span class="cx">     checkCell.link(this);
</span><span class="cx"> }
</span><ins>+
+void AssemblyHelpers::jitAssertTagsInPlace()
+{
+    Jump ok = branch64(Equal, GPRInfo::tagTypeNumberRegister, TrustedImm64(TagTypeNumber));
+    breakpoint();
+    ok.link(this);
+    
+    ok = branch64(Equal, GPRInfo::tagMaskRegister, TrustedImm64(TagMask));
+    breakpoint();
+    ok.link(this);
+}
</ins><span class="cx"> #elif USE(JSVALUE32_64)
</span><span class="cx"> void AssemblyHelpers::jitAssertIsInt32(GPRReg gpr)
</span><span class="cx"> {
</span><span class="lines">@@ -145,6 +156,10 @@
</span><span class="cx">     breakpoint();
</span><span class="cx">     checkCell.link(this);
</span><span class="cx"> }
</span><ins>+
+void AssemblyHelpers::jitAssertTagsInPlace()
+{
+}
</ins><span class="cx"> #endif // USE(JSVALUE32_64)
</span><span class="cx"> 
</span><span class="cx"> void AssemblyHelpers::jitAssertHasValidCallFrame()
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCorejitAssemblyHelpersh"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/jit/AssemblyHelpers.h (160979 => 160980)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/jit/AssemblyHelpers.h        2013-12-22 18:15:41 UTC (rev 160979)
+++ branches/jsCStack/Source/JavaScriptCore/jit/AssemblyHelpers.h        2013-12-22 18:42:09 UTC (rev 160980)
</span><span class="lines">@@ -343,6 +343,7 @@
</span><span class="cx">     void jitAssertIsCell(GPRReg);
</span><span class="cx">     void jitAssertHasValidCallFrame();
</span><span class="cx">     void jitAssertIsNull(GPRReg);
</span><ins>+    void jitAssertTagsInPlace();
</ins><span class="cx"> #else
</span><span class="cx">     void jitAssertIsInt32(GPRReg) { }
</span><span class="cx">     void jitAssertIsJSInt32(GPRReg) { }
</span><span class="lines">@@ -351,6 +352,7 @@
</span><span class="cx">     void jitAssertIsCell(GPRReg) { }
</span><span class="cx">     void jitAssertHasValidCallFrame() { }
</span><span class="cx">     void jitAssertIsNull(GPRReg) { }
</span><ins>+    void jitAssertTagsInPlace() { }
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     // These methods convert between doubles, and doubles boxed and JSValues.
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCorejitJITcpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/jit/JIT.cpp (160979 => 160980)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/jit/JIT.cpp        2013-12-22 18:15:41 UTC (rev 160979)
+++ branches/jsCStack/Source/JavaScriptCore/jit/JIT.cpp        2013-12-22 18:42:09 UTC (rev 160980)
</span><span class="lines">@@ -134,6 +134,8 @@
</span><span class="cx"> 
</span><span class="cx"> void JIT::privateCompileMainPass()
</span><span class="cx"> {
</span><ins>+    jitAssertTagsInPlace();
+    
</ins><span class="cx">     Instruction* instructionsBegin = m_codeBlock-&gt;instructions().begin();
</span><span class="cx">     unsigned instructionCount = m_codeBlock-&gt;instructions().size();
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCorejitJITCodecpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/jit/JITCode.cpp (160979 => 160980)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/jit/JITCode.cpp        2013-12-22 18:15:41 UTC (rev 160979)
+++ branches/jsCStack/Source/JavaScriptCore/jit/JITCode.cpp        2013-12-22 18:42:09 UTC (rev 160980)
</span><span class="lines">@@ -72,11 +72,6 @@
</span><span class="cx">     return 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-PassRefPtr&lt;JITCode&gt; JITCode::hostFunction(JITCode::CodeRef code)
-{
-    return adoptRef(new NativeJITCode(code, HostCallThunk));
-}
-
</del><span class="cx"> JITCodeWithCodeRef::JITCodeWithCodeRef(JITType jitType)
</span><span class="cx">     : JITCode(jitType)
</span><span class="cx"> {
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCorejitJITCodeh"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/jit/JITCode.h (160979 => 160980)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/jit/JITCode.h        2013-12-22 18:15:41 UTC (rev 160979)
+++ branches/jsCStack/Source/JavaScriptCore/jit/JITCode.h        2013-12-22 18:42:09 UTC (rev 160980)
</span><span class="lines">@@ -183,8 +183,6 @@
</span><span class="cx">     
</span><span class="cx">     virtual bool contains(void*) = 0;
</span><span class="cx"> 
</span><del>-    static PassRefPtr&lt;JITCode&gt; hostFunction(CodeRef);
-
</del><span class="cx"> private:
</span><span class="cx">     JITType m_jitType;
</span><span class="cx"> };
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCorejitJITThunkscpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/jit/JITThunks.cpp (160979 => 160980)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/jit/JITThunks.cpp        2013-12-22 18:15:41 UTC (rev 160979)
+++ branches/jsCStack/Source/JavaScriptCore/jit/JITThunks.cpp        2013-12-22 18:42:09 UTC (rev 160980)
</span><span class="lines">@@ -87,7 +87,12 @@
</span><span class="cx">     if (NativeExecutable* nativeExecutable = m_hostFunctionStubMap-&gt;get(std::make_pair(function, constructor)))
</span><span class="cx">         return nativeExecutable;
</span><span class="cx"> 
</span><del>-    NativeExecutable* nativeExecutable = NativeExecutable::create(*vm, JIT::compileCTINativeCall(vm, function), function, MacroAssemblerCodeRef::createSelfManagedCodeRef(ctiNativeConstruct(vm)), constructor, NoIntrinsic);
</del><ins>+    NativeExecutable* nativeExecutable = NativeExecutable::create(
+        *vm,
+        adoptRef(new NativeJITCode(JIT::compileCTINativeCall(vm, function), JITCode::HostCallThunk)),
+        function,
+        adoptRef(new NativeJITCode(MacroAssemblerCodeRef::createSelfManagedCodeRef(ctiNativeConstruct(vm)), JITCode::HostCallThunk)),
+        constructor, NoIntrinsic);
</ins><span class="cx">     weakAdd(*m_hostFunctionStubMap, std::make_pair(function, constructor), Weak&lt;NativeExecutable&gt;(nativeExecutable));
</span><span class="cx">     return nativeExecutable;
</span><span class="cx"> }
</span><span class="lines">@@ -99,16 +104,18 @@
</span><span class="cx">     if (NativeExecutable* nativeExecutable = m_hostFunctionStubMap-&gt;get(std::make_pair(function, &amp;callHostFunctionAsConstructor)))
</span><span class="cx">         return nativeExecutable;
</span><span class="cx"> 
</span><del>-    MacroAssemblerCodeRef code;
</del><ins>+    RefPtr&lt;JITCode&gt; forCall;
</ins><span class="cx">     if (generator) {
</span><del>-        if (vm-&gt;canUseJIT())
-            code = generator(vm);
-        else
-            code = MacroAssemblerCodeRef();
</del><ins>+        if (vm-&gt;canUseJIT()) {
+            MacroAssemblerCodeRef entry = generator(vm);
+            forCall = adoptRef(new DirectJITCode(entry, entry.code(), JITCode::HostCallThunk));
+        }
</ins><span class="cx">     } else
</span><del>-        code = JIT::compileCTINativeCall(vm, function);
-
-    NativeExecutable* nativeExecutable = NativeExecutable::create(*vm, code, function, MacroAssemblerCodeRef::createSelfManagedCodeRef(ctiNativeConstruct(vm)), callHostFunctionAsConstructor, intrinsic);
</del><ins>+        forCall = adoptRef(new NativeJITCode(JIT::compileCTINativeCall(vm, function), JITCode::HostCallThunk));
+    
+    RefPtr&lt;JITCode&gt; forConstruct = adoptRef(new NativeJITCode(MacroAssemblerCodeRef::createSelfManagedCodeRef(ctiNativeConstruct(vm)), JITCode::HostCallThunk));
+    
+    NativeExecutable* nativeExecutable = NativeExecutable::create(*vm, forCall, function, forConstruct, callHostFunctionAsConstructor, intrinsic);
</ins><span class="cx">     weakAdd(*m_hostFunctionStubMap, std::make_pair(function, &amp;callHostFunctionAsConstructor), Weak&lt;NativeExecutable&gt;(nativeExecutable));
</span><span class="cx">     return nativeExecutable;
</span><span class="cx"> }
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCorejitRegisterPreservationWrapperGeneratorcpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/jit/RegisterPreservationWrapperGenerator.cpp (160979 => 160980)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/jit/RegisterPreservationWrapperGenerator.cpp        2013-12-22 18:15:41 UTC (rev 160979)
+++ branches/jsCStack/Source/JavaScriptCore/jit/RegisterPreservationWrapperGenerator.cpp        2013-12-22 18:42:09 UTC (rev 160980)
</span><span class="lines">@@ -62,8 +62,6 @@
</span><span class="cx"> {
</span><span class="cx"> #if ENABLE(FTL_JIT)
</span><span class="cx">     // We shouldn't ever be generating wrappers for native functions.
</span><del>-    ScriptExecutable* scriptExecutable = jsCast&lt;ScriptExecutable*&gt;(executable);
-    
</del><span class="cx">     RegisterSet toSave = registersToPreserve();
</span><span class="cx">     ptrdiff_t offset = registerPreservationOffset();
</span><span class="cx">     
</span><span class="lines">@@ -119,7 +117,7 @@
</span><span class="cx">     LinkBuffer linkBuffer(vm, &amp;jit, GLOBAL_THUNK_ID);
</span><span class="cx">     linkBuffer.link(call, CodeLocationLabel(target));
</span><span class="cx">     
</span><del>-    return FINALIZE_DFG_CODE(linkBuffer, (&quot;Register preservation wrapper for %s/%s, %p&quot;, toCString(scriptExecutable-&gt;hashFor(CodeForCall)).data(), toCString(scriptExecutable-&gt;hashFor(CodeForConstruct)).data(), target.executableAddress()));
</del><ins>+    return FINALIZE_DFG_CODE(linkBuffer, (&quot;Register preservation wrapper for %s/%s, %p&quot;, toCString(executable-&gt;hashFor(CodeForCall)).data(), toCString(executable-&gt;hashFor(CodeForConstruct)).data(), target.executableAddress()));
</ins><span class="cx"> #else // ENABLE(FTL_JIT)
</span><span class="cx">     UNUSED_PARAM(vm);
</span><span class="cx">     UNUSED_PARAM(executable);
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreruntimeExecutableh"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/runtime/Executable.h (160979 => 160980)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/runtime/Executable.h        2013-12-22 18:15:41 UTC (rev 160979)
+++ branches/jsCStack/Source/JavaScriptCore/runtime/Executable.h        2013-12-22 18:42:09 UTC (rev 160980)
</span><span class="lines">@@ -288,14 +288,11 @@
</span><span class="cx"> public:
</span><span class="cx">     typedef ExecutableBase Base;
</span><span class="cx"> 
</span><del>-    static NativeExecutable* create(VM&amp; vm, MacroAssemblerCodeRef callThunk, NativeFunction function, MacroAssemblerCodeRef constructThunk, NativeFunction constructor, Intrinsic intrinsic)
</del><ins>+    static NativeExecutable* create(VM&amp; vm, PassRefPtr&lt;JITCode&gt; callThunk, NativeFunction function, PassRefPtr&lt;JITCode&gt; constructThunk, NativeFunction constructor, Intrinsic intrinsic)
</ins><span class="cx">     {
</span><span class="cx">         NativeExecutable* executable;
</span><span class="cx">         executable = new (NotNull, allocateCell&lt;NativeExecutable&gt;(vm.heap)) NativeExecutable(vm, function, constructor);
</span><del>-        if (!callThunk)
-            executable-&gt;finishCreation(vm, 0, 0, intrinsic);
-        else
-            executable-&gt;finishCreation(vm, JITCode::hostFunction(callThunk), JITCode::hostFunction(constructThunk), intrinsic);
</del><ins>+        executable-&gt;finishCreation(vm, callThunk, constructThunk, intrinsic);
</ins><span class="cx">         return executable;
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>