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

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

<h3>Log Message</h3>
<pre>FTL should work with the bytecode profiler
https://bugs.webkit.org/show_bug.cgi?id=126804

Source/JavaScriptCore: 

Reviewed by Sam Weinig.
        
Implement CountExecution in FTL and make the FTL report a compilation with some kind
of description to the database. This still leaves a lot to be desired; for example
the descriptions we report don't have disassembly. But, this small step already
allows for some basic profiling.

* dfg/DFGPlan.cpp:
(JSC::DFG::profilerCompilationKindForMode):
(JSC::DFG::Plan::Plan):
* ftl/FTLCapabilities.cpp:
(JSC::FTL::canCompile):
* ftl/FTLJITFinalizer.cpp:
(JSC::FTL::JITFinalizer::finalizeFunction):
* ftl/FTLLink.cpp:
(JSC::FTL::link):
* ftl/FTLLowerDFGToLLVM.cpp:
(JSC::FTL::LowerDFGToLLVM::compileNode):
(JSC::FTL::LowerDFGToLLVM::compileCountExecution):
* profiler/ProfilerCompilation.cpp:
(JSC::Profiler::Compilation::addDescription):
* profiler/ProfilerCompilation.h:
* profiler/ProfilerCompilationKind.cpp:
(WTF::printInternal):
* profiler/ProfilerCompilationKind.h:

Tools: 

Reviewed by Sam Weinig.
        
Teach this that there are more JITs.

* Scripts/display-profiler-output:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchesjsCStackSourceJavaScriptCoreChangeLog">branches/jsCStack/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoredfgDFGPlancpp">branches/jsCStack/Source/JavaScriptCore/dfg/DFGPlan.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreftlFTLCapabilitiescpp">branches/jsCStack/Source/JavaScriptCore/ftl/FTLCapabilities.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreftlFTLJITFinalizercpp">branches/jsCStack/Source/JavaScriptCore/ftl/FTLJITFinalizer.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreftlFTLLinkcpp">branches/jsCStack/Source/JavaScriptCore/ftl/FTLLink.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreftlFTLLowerDFGToLLVMcpp">branches/jsCStack/Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreprofilerProfilerCompilationcpp">branches/jsCStack/Source/JavaScriptCore/profiler/ProfilerCompilation.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreprofilerProfilerCompilationh">branches/jsCStack/Source/JavaScriptCore/profiler/ProfilerCompilation.h</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreprofilerProfilerCompilationKindcpp">branches/jsCStack/Source/JavaScriptCore/profiler/ProfilerCompilationKind.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreprofilerProfilerCompilationKindh">branches/jsCStack/Source/JavaScriptCore/profiler/ProfilerCompilationKind.h</a></li>
<li><a href="#branchesjsCStackToolsChangeLog">branches/jsCStack/Tools/ChangeLog</a></li>
<li><a href="#branchesjsCStackToolsScriptsdisplayprofileroutput">branches/jsCStack/Tools/Scripts/display-profiler-output</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchesjsCStackSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/ChangeLog (161736 => 161737)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/ChangeLog        2014-01-11 05:45:18 UTC (rev 161736)
+++ branches/jsCStack/Source/JavaScriptCore/ChangeLog        2014-01-11 05:48:20 UTC (rev 161737)
</span><span class="lines">@@ -1,5 +1,36 @@
</span><span class="cx"> 2014-01-10  Filip Pizlo  &lt;fpizlo@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        FTL should work with the bytecode profiler
+        https://bugs.webkit.org/show_bug.cgi?id=126804
+
+        Reviewed by Sam Weinig.
+        
+        Implement CountExecution in FTL and make the FTL report a compilation with some kind
+        of description to the database. This still leaves a lot to be desired; for example
+        the descriptions we report don't have disassembly. But, this small step already
+        allows for some basic profiling.
+
+        * dfg/DFGPlan.cpp:
+        (JSC::DFG::profilerCompilationKindForMode):
+        (JSC::DFG::Plan::Plan):
+        * ftl/FTLCapabilities.cpp:
+        (JSC::FTL::canCompile):
+        * ftl/FTLJITFinalizer.cpp:
+        (JSC::FTL::JITFinalizer::finalizeFunction):
+        * ftl/FTLLink.cpp:
+        (JSC::FTL::link):
+        * ftl/FTLLowerDFGToLLVM.cpp:
+        (JSC::FTL::LowerDFGToLLVM::compileNode):
+        (JSC::FTL::LowerDFGToLLVM::compileCountExecution):
+        * profiler/ProfilerCompilation.cpp:
+        (JSC::Profiler::Compilation::addDescription):
+        * profiler/ProfilerCompilation.h:
+        * profiler/ProfilerCompilationKind.cpp:
+        (WTF::printInternal):
+        * profiler/ProfilerCompilationKind.h:
+
+2014-01-10  Filip Pizlo  &lt;fpizlo@apple.com&gt;
+
</ins><span class="cx">         Unreviewed, unbreak all tests by undoing some assertions junk in
</span><span class="cx">         http://trac.webkit.org/changeset/161732 and changing typo &quot;node-&gt;function()&quot;
</span><span class="cx">         which should have been &quot;node-&gt;executable()&quot;.
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoredfgDFGPlancpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/dfg/DFGPlan.cpp (161736 => 161737)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/dfg/DFGPlan.cpp        2014-01-11 05:45:18 UTC (rev 161736)
+++ branches/jsCStack/Source/JavaScriptCore/dfg/DFGPlan.cpp        2014-01-11 05:48:20 UTC (rev 161737)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2013 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2013, 2014 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -89,6 +89,23 @@
</span><span class="cx">         validate(graph, modeForFinalValidate);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static Profiler::CompilationKind profilerCompilationKindForMode(CompilationMode mode)
+{
+    switch (mode) {
+    case InvalidCompilationMode:
+        RELEASE_ASSERT_NOT_REACHED();
+        return Profiler::DFG;
+    case DFGMode:
+        return Profiler::DFG;
+    case FTLMode:
+        return Profiler::FTL;
+    case FTLForOSREntryMode:
+        return Profiler::FTLForOSREntry;
+    }
+    RELEASE_ASSERT_NOT_REACHED();
+    return Profiler::DFG;
+}
+
</ins><span class="cx"> Plan::Plan(
</span><span class="cx">     PassRefPtr&lt;CodeBlock&gt; passedCodeBlock, CompilationMode mode,
</span><span class="cx">     unsigned osrEntryBytecodeIndex, const Operands&lt;JSValue&gt;&amp; mustHandleValues)
</span><span class="lines">@@ -97,7 +114,7 @@
</span><span class="cx">     , mode(mode)
</span><span class="cx">     , osrEntryBytecodeIndex(osrEntryBytecodeIndex)
</span><span class="cx">     , mustHandleValues(mustHandleValues)
</span><del>-    , compilation(codeBlock-&gt;vm()-&gt;m_perBytecodeProfiler ? adoptRef(new Profiler::Compilation(codeBlock-&gt;vm()-&gt;m_perBytecodeProfiler-&gt;ensureBytecodesFor(codeBlock.get()), Profiler::DFG)) : 0)
</del><ins>+    , compilation(codeBlock-&gt;vm()-&gt;m_perBytecodeProfiler ? adoptRef(new Profiler::Compilation(codeBlock-&gt;vm()-&gt;m_perBytecodeProfiler-&gt;ensureBytecodesFor(codeBlock.get()), profilerCompilationKindForMode(mode))) : 0)
</ins><span class="cx">     , identifiers(codeBlock.get())
</span><span class="cx">     , weakReferences(codeBlock.get())
</span><span class="cx">     , isCompiled(false)
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreftlFTLCapabilitiescpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/ftl/FTLCapabilities.cpp (161736 => 161737)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/ftl/FTLCapabilities.cpp        2014-01-11 05:45:18 UTC (rev 161736)
+++ branches/jsCStack/Source/JavaScriptCore/ftl/FTLCapabilities.cpp        2014-01-11 05:48:20 UTC (rev 161737)
</span><span class="lines">@@ -116,6 +116,7 @@
</span><span class="cx">     case CheckInBounds:
</span><span class="cx">     case ConstantStoragePointer:
</span><span class="cx">     case Check:
</span><ins>+    case CountExecution:
</ins><span class="cx">     case CheckExecutable:
</span><span class="cx">     case GetScope:
</span><span class="cx">         // These are OK.
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreftlFTLJITFinalizercpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/ftl/FTLJITFinalizer.cpp (161736 => 161737)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/ftl/FTLJITFinalizer.cpp        2014-01-11 05:45:18 UTC (rev 161736)
+++ branches/jsCStack/Source/JavaScriptCore/ftl/FTLJITFinalizer.cpp        2014-01-11 05:48:20 UTC (rev 161737)
</span><span class="lines">@@ -110,6 +110,9 @@
</span><span class="cx">     
</span><span class="cx">     m_plan.codeBlock-&gt;setJITCode(jitCode);
</span><span class="cx">     
</span><ins>+    if (m_plan.compilation)
+        m_plan.vm.m_perBytecodeProfiler-&gt;addCompilation(m_plan.compilation);
+    
</ins><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreftlFTLLinkcpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/ftl/FTLLink.cpp (161736 => 161737)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/ftl/FTLLink.cpp        2014-01-11 05:45:18 UTC (rev 161736)
+++ branches/jsCStack/Source/JavaScriptCore/ftl/FTLLink.cpp        2014-01-11 05:48:20 UTC (rev 161737)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2013 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2013, 2014 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -38,6 +38,7 @@
</span><span class="cx"> #include &quot;JITStubs.h&quot;
</span><span class="cx"> #include &quot;LLVMAPI.h&quot;
</span><span class="cx"> #include &quot;LinkBuffer.h&quot;
</span><ins>+#include &quot;ProfilerCompilation.h&quot;
</ins><span class="cx"> #include &quot;VirtualRegister.h&quot;
</span><span class="cx"> 
</span><span class="cx"> namespace JSC { namespace FTL {
</span><span class="lines">@@ -46,8 +47,9 @@
</span><span class="cx"> 
</span><span class="cx"> void link(State&amp; state)
</span><span class="cx"> {
</span><del>-    CodeBlock* codeBlock = state.graph.m_codeBlock;
-    VM&amp; vm = state.graph.m_vm;
</del><ins>+    Graph&amp; graph = state.graph;
+    CodeBlock* codeBlock = graph.m_codeBlock;
+    VM&amp; vm = graph.m_vm;
</ins><span class="cx">     
</span><span class="cx">     // LLVM will create its own jump tables as needed.
</span><span class="cx">     codeBlock-&gt;clearSwitchJumpTables();
</span><span class="lines">@@ -56,10 +58,10 @@
</span><span class="cx">     // https://bugs.webkit.org/show_bug.cgi?id=125727
</span><span class="cx">     state.jitCode-&gt;common.frameRegisterCount = 1000;
</span><span class="cx">     
</span><del>-    state.jitCode-&gt;common.requiredRegisterCountForExit = state.graph.requiredRegisterCountForExit();
</del><ins>+    state.jitCode-&gt;common.requiredRegisterCountForExit = graph.requiredRegisterCountForExit();
</ins><span class="cx">     
</span><del>-    if (!state.graph.m_inlineCallFrames-&gt;isEmpty())
-        state.jitCode-&gt;common.inlineCallFrames = std::move(state.graph.m_inlineCallFrames);
</del><ins>+    if (!graph.m_inlineCallFrames-&gt;isEmpty())
+        state.jitCode-&gt;common.inlineCallFrames = std::move(graph.m_inlineCallFrames);
</ins><span class="cx">     
</span><span class="cx">     // Create the entrypoint. Note that we use this entrypoint totally differently
</span><span class="cx">     // depending on whether we're doing OSR entry or not.
</span><span class="lines">@@ -71,7 +73,62 @@
</span><span class="cx">     CCallHelpers::Address frame = CCallHelpers::Address(
</span><span class="cx">         CCallHelpers::stackPointerRegister, -static_cast&lt;int32_t&gt;(sizeof(void*)));
</span><span class="cx">     
</span><del>-    switch (state.graph.m_plan.mode) {
</del><ins>+    if (Profiler::Compilation* compilation = graph.compilation()) {
+        compilation-&gt;addDescription(
+            Profiler::OriginStack(),
+            toCString(&quot;Generated FTL JIT code for &quot;, CodeBlockWithJITType(codeBlock, JITCode::FTLJIT), &quot;, instruction count = &quot;, graph.m_codeBlock-&gt;instructionCount(), &quot;:\n&quot;));
+        
+        graph.m_dominators.computeIfNecessary(graph);
+        graph.m_naturalLoops.computeIfNecessary(graph);
+        
+        const char* prefix = &quot;    &quot;;
+        
+        DumpContext dumpContext;
+        StringPrintStream out;
+        Node* lastNode = 0;
+        for (size_t blockIndex = 0; blockIndex &lt; graph.numBlocks(); ++blockIndex) {
+            BasicBlock* block = graph.block(blockIndex);
+            if (!block)
+                continue;
+            
+            graph.dumpBlockHeader(out, prefix, block, Graph::DumpLivePhisOnly, &amp;dumpContext);
+            compilation-&gt;addDescription(Profiler::OriginStack(), out.toCString());
+            out.reset();
+            
+            for (size_t nodeIndex = 0; nodeIndex &lt; block-&gt;size(); ++nodeIndex) {
+                Node* node = block-&gt;at(nodeIndex);
+                if (!node-&gt;willHaveCodeGenOrOSR() &amp;&amp; !Options::showAllDFGNodes())
+                    continue;
+                
+                Profiler::OriginStack stack;
+                
+                if (node-&gt;codeOrigin.isSet()) {
+                    stack = Profiler::OriginStack(
+                        *vm.m_perBytecodeProfiler, codeBlock, node-&gt;codeOrigin);
+                }
+                
+                if (graph.dumpCodeOrigin(out, prefix, lastNode, node, &amp;dumpContext)) {
+                    compilation-&gt;addDescription(stack, out.toCString());
+                    out.reset();
+                }
+                
+                graph.dump(out, prefix, node, &amp;dumpContext);
+                compilation-&gt;addDescription(stack, out.toCString());
+                out.reset();
+                
+                if (node-&gt;codeOrigin.isSet())
+                    lastNode = node;
+            }
+        }
+        
+        dumpContext.dump(out, prefix);
+        compilation-&gt;addDescription(Profiler::OriginStack(), out.toCString());
+        out.reset();
+        
+        state.jitCode-&gt;common.compilation = compilation;
+    }
+    
+    switch (graph.m_plan.mode) {
</ins><span class="cx">     case FTLMode: {
</span><span class="cx">         CCallHelpers::JumpList mainPathJumps;
</span><span class="cx">     
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreftlFTLLowerDFGToLLVMcpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp (161736 => 161737)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp        2014-01-11 05:45:18 UTC (rev 161736)
+++ branches/jsCStack/Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp        2014-01-11 05:48:20 UTC (rev 161737)
</span><span class="lines">@@ -503,6 +503,9 @@
</span><span class="cx">         case Int52ToValue:
</span><span class="cx">             compileInt52ToValue();
</span><span class="cx">             break;
</span><ins>+        case CountExecution:
+            compileCountExecution();
+            break;
</ins><span class="cx">         case Flush:
</span><span class="cx">         case PhantomLocal:
</span><span class="cx">         case SetArgument:
</span><span class="lines">@@ -2790,6 +2793,12 @@
</span><span class="cx">         info.m_isInvalidationPoint = true;
</span><span class="cx">     }
</span><span class="cx">     
</span><ins>+    void compileCountExecution()
+    {
+        TypedPointer counter = m_out.absolute(m_node-&gt;executionCounter()-&gt;address());
+        m_out.store64(m_out.add(m_out.load64(counter), m_out.constInt64(1)), counter);
+    }
+    
</ins><span class="cx">     TypedPointer baseIndex(IndexedAbstractHeap&amp; heap, LValue storage, LValue index, Edge edge)
</span><span class="cx">     {
</span><span class="cx">         return m_out.baseIndex(
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreprofilerProfilerCompilationcpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/profiler/ProfilerCompilation.cpp (161736 => 161737)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/profiler/ProfilerCompilation.cpp        2014-01-11 05:45:18 UTC (rev 161736)
+++ branches/jsCStack/Source/JavaScriptCore/profiler/ProfilerCompilation.cpp        2014-01-11 05:48:20 UTC (rev 161737)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2012, 2013, 2014 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -67,6 +67,11 @@
</span><span class="cx">     m_descriptions.append(compiledBytecode);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void Compilation::addDescription(const OriginStack&amp; stack, const CString&amp; description)
+{
+    addDescription(CompiledBytecode(stack, description));
+}
+
</ins><span class="cx"> ExecutionCounter* Compilation::executionCounterFor(const OriginStack&amp; origin)
</span><span class="cx"> {
</span><span class="cx">     std::unique_ptr&lt;ExecutionCounter&gt;&amp; counter = m_counters.add(origin, nullptr).iterator-&gt;value;
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreprofilerProfilerCompilationh"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/profiler/ProfilerCompilation.h (161736 => 161737)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/profiler/ProfilerCompilation.h        2014-01-11 05:45:18 UTC (rev 161736)
+++ branches/jsCStack/Source/JavaScriptCore/profiler/ProfilerCompilation.h        2014-01-11 05:48:20 UTC (rev 161737)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2012, 2013, 2014 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -63,6 +63,7 @@
</span><span class="cx">     CompilationKind kind() const { return m_kind; }
</span><span class="cx">     
</span><span class="cx">     void addDescription(const CompiledBytecode&amp;);
</span><ins>+    void addDescription(const OriginStack&amp;, const CString&amp; description);
</ins><span class="cx">     ExecutionCounter* executionCounterFor(const OriginStack&amp;);
</span><span class="cx">     void addOSRExitSite(const Vector&lt;const void*&gt;&amp; codeAddresses);
</span><span class="cx">     OSRExit* addOSRExit(unsigned id, const OriginStack&amp;, ExitKind, bool isWatchpoint);
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreprofilerProfilerCompilationKindcpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/profiler/ProfilerCompilationKind.cpp (161736 => 161737)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/profiler/ProfilerCompilationKind.cpp        2014-01-11 05:45:18 UTC (rev 161736)
+++ branches/jsCStack/Source/JavaScriptCore/profiler/ProfilerCompilationKind.cpp        2014-01-11 05:48:20 UTC (rev 161737)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2012 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2012, 2014 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -42,6 +42,12 @@
</span><span class="cx">     case JSC::Profiler::DFG:
</span><span class="cx">         out.print(&quot;DFG&quot;);
</span><span class="cx">         return;
</span><ins>+    case JSC::Profiler::FTL:
+        out.print(&quot;FTL&quot;);
+        return;
+    case JSC::Profiler::FTLForOSREntry:
+        out.print(&quot;FTLForOSREntry&quot;);
+        return;
</ins><span class="cx">     default:
</span><span class="cx">         CRASH();
</span><span class="cx">         return;
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreprofilerProfilerCompilationKindh"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/profiler/ProfilerCompilationKind.h (161736 => 161737)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/profiler/ProfilerCompilationKind.h        2014-01-11 05:45:18 UTC (rev 161736)
+++ branches/jsCStack/Source/JavaScriptCore/profiler/ProfilerCompilationKind.h        2014-01-11 05:48:20 UTC (rev 161737)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2012 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2012, 2014 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -31,7 +31,9 @@
</span><span class="cx"> enum CompilationKind {
</span><span class="cx">     LLInt,
</span><span class="cx">     Baseline,
</span><del>-    DFG
</del><ins>+    DFG,
+    FTL,
+    FTLForOSREntry
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } } // namespace JSC::Profiler
</span></span></pre></div>
<a id="branchesjsCStackToolsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Tools/ChangeLog (161736 => 161737)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Tools/ChangeLog        2014-01-11 05:45:18 UTC (rev 161736)
+++ branches/jsCStack/Tools/ChangeLog        2014-01-11 05:48:20 UTC (rev 161737)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2014-01-10  Filip Pizlo  &lt;fpizlo@apple.com&gt;
+
+        FTL should work with the bytecode profiler
+        https://bugs.webkit.org/show_bug.cgi?id=126804
+
+        Reviewed by Sam Weinig.
+        
+        Teach this that there are more JITs.
+
+        * Scripts/display-profiler-output:
+
</ins><span class="cx"> 2014-01-06  Filip Pizlo  &lt;fpizlo@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Merge trunk r160411.
</span></span></pre></div>
<a id="branchesjsCStackToolsScriptsdisplayprofileroutput"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Tools/Scripts/display-profiler-output (161736 => 161737)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Tools/Scripts/display-profiler-output        2014-01-11 05:45:18 UTC (rev 161736)
+++ branches/jsCStack/Tools/Scripts/display-profiler-output        2014-01-11 05:48:20 UTC (rev 161737)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> #!/usr/bin/env ruby
</span><span class="cx"> 
</span><del>-# Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
</del><ins>+# Copyright (C) 2012, 2013, 2014 Apple Inc. All rights reserved.
</ins><span class="cx"> #
</span><span class="cx"> # Redistribution and use in source and binary forms, with or without
</span><span class="cx"> # modification, are permitted provided that the following conditions
</span><span class="lines">@@ -437,8 +437,12 @@
</span><span class="cx">     | subJson |
</span><span class="cx">     Compilation.new(subJson)
</span><span class="cx"> }
</span><del>-$engines = [&quot;Baseline&quot;, &quot;DFG&quot;]
</del><ins>+$engines = [&quot;Baseline&quot;, &quot;DFG&quot;, &quot;FTL&quot;, &quot;FTLForOSREntry&quot;]
</ins><span class="cx"> 
</span><ins>+def isOptimizing(engine)
+    engine == &quot;DFG&quot; or engine == &quot;FTL&quot; or engine == &quot;FTLForOSREntry&quot;
+end
+
</ins><span class="cx"> $showCounts = true
</span><span class="cx"> $sortMode = :time
</span><span class="cx"> 
</span><span class="lines">@@ -572,9 +576,9 @@
</span><span class="cx">     if mode == :full
</span><span class="cx">         print(&quot; &quot; + (&quot; &quot; * instructionCountCols))
</span><span class="cx">     end
</span><del>-    print(&quot; &quot; + center(&quot;Base/DFG&quot;, countCols))
</del><ins>+    print(&quot; &quot; + center(&quot;Base/DFG/FTL/FTLOSR&quot;, countCols))
</ins><span class="cx">     if mode == :full
</span><del>-        print(&quot; &quot; + center(&quot;Base/DFG&quot;, machineCountCols))
</del><ins>+        print(&quot; &quot; + center(&quot;Base/DFG/FTL/FTLOSR&quot;, machineCountCols))
</ins><span class="cx">         print(&quot; &quot; + (&quot; &quot; * compilationsCols))
</span><span class="cx">         print(&quot; &quot; + center(&quot;Src/Total&quot;, inlinesCols))
</span><span class="cx">         print(&quot; &quot; + (&quot; &quot; * exitCountCols))
</span><span class="lines">@@ -674,7 +678,7 @@
</span><span class="cx">             if $showCounts
</span><span class="cx">                 puts(center(&quot;Source Counts&quot;, countCols) + &quot; &quot; + center(&quot;Machine Counts&quot;, machineCols) +
</span><span class="cx">                      (&quot; &quot; * pad) + center(&quot;Bytecode for #{bytecodes}&quot;, screenWidth - pad - countCols - 1 - machineCols))
</span><del>-                puts(center(&quot;Base/DFG&quot;, countCols) + &quot; &quot; + center(&quot;Base/DFG&quot;, countCols))
</del><ins>+                puts(center(&quot;Base/DFG/FTL/FTLOSR&quot;, countCols) + &quot; &quot; + center(&quot;Base/DFG/FTL/FTLOSR&quot;, countCols))
</ins><span class="cx">             else
</span><span class="cx">                 puts(&quot;Bytecode for #{bytecodes}:&quot;)
</span><span class="cx">             end
</span><span class="lines">@@ -894,7 +898,7 @@
</span><span class="cx">             puts(&quot;Compilation #{compilation}:&quot;)
</span><span class="cx">             if $showCounts
</span><span class="cx">                 puts(center(&quot;Actual Counts&quot;, actualCountCols) + &quot; &quot; + center(&quot;Source Counts&quot;, sourceCountCols) + &quot; &quot; + center(&quot;Disassembly in #{compilation.engine}&quot;, screenWidth - 1 - sourceCountCols - 1 - actualCountCols))
</span><del>-                puts((&quot; &quot; * actualCountCols) + &quot; &quot; + center(&quot;Base/DFG&quot;, sourceCountCols))
</del><ins>+                puts((&quot; &quot; * actualCountCols) + &quot; &quot; + center(&quot;Base/DFG/FTL/FTLOSR&quot;, sourceCountCols))
</ins><span class="cx">             else
</span><span class="cx">                 puts(&quot;Disassembly in #{compilation.engine}&quot;)
</span><span class="cx">             end
</span><span class="lines">@@ -905,11 +909,15 @@
</span><span class="cx">                 | description |
</span><span class="cx">                 # FIXME: We should have a better way of detecting things like CountExecution nodes
</span><span class="cx">                 # and slow path entries in the baseline JIT.
</span><del>-                if description.description =~ /CountExecution\(/ and compilation.engine == &quot;DFG&quot;
</del><ins>+                if description.description =~ /CountExecution\(/ and isOptimizing(compilation.engine)
</ins><span class="cx">                     shouldShow = false
</span><span class="cx">                 else
</span><span class="cx">                     shouldShow = true
</span><span class="cx">                 end
</span><ins>+                if not description.origin.empty? and not description.origin[-1]
+                    p description.origin
+                    p description.description
+                end
</ins><span class="cx">                 if description.origin.empty? or not description.origin[-1].shouldHaveCounts? or (compilation.engine == &quot;Baseline&quot; and description.description =~ /^\s*\(S\)/)
</span><span class="cx">                     actualCountsString = &quot;&quot;
</span><span class="cx">                     sourceCountsString = &quot;&quot;
</span></span></pre>
</div>
</div>

</body>
</html>