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

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

<h3>Log Message</h3>
<pre>MathICs should be able to take and dump stats about code size
https://bugs.webkit.org/show_bug.cgi?id=160148

Reviewed by Filip Pizlo.

This will make testing changes on MathIC going forward much easier.
We will be able to easily see if modifications to MathIC will lead
to us generating smaller code. We now only dump average size when we
regenerate any MathIC. This works out for large tests/pages, but is not
great for testing small programs. We can add more dump points later if
we find that we want to dump stats while running small small programs.

* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::jitSoon):
(JSC::CodeBlock::dumpMathICStats):
* bytecode/CodeBlock.h:
(JSC::CodeBlock::isStrictMode):
(JSC::CodeBlock::ecmaMode):
* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileMathIC):
* ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::compileMathIC):
* jit/JITArithmetic.cpp:
(JSC::JIT::emitMathICFast):
(JSC::JIT::emitMathICSlow):
* jit/JITMathIC.h:
(JSC::JITMathIC::finalizeInlineCode):
(JSC::JITMathIC::codeSize):
* jit/JITOperations.cpp:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecodeCodeBlockcpp">trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecodeCodeBlockh">trunk/Source/JavaScriptCore/bytecode/CodeBlock.h</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGSpeculativeJITcpp">trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreftlFTLLowerDFGToB3cpp">trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorejitJITArithmeticcpp">trunk/Source/JavaScriptCore/jit/JITArithmetic.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorejitJITMathICh">trunk/Source/JavaScriptCore/jit/JITMathIC.h</a></li>
<li><a href="#trunkSourceJavaScriptCorejitJITOperationscpp">trunk/Source/JavaScriptCore/jit/JITOperations.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (203696 => 203697)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-07-25 20:35:16 UTC (rev 203696)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-07-25 20:40:39 UTC (rev 203697)
</span><span class="lines">@@ -1,5 +1,37 @@
</span><span class="cx"> 2016-07-25  Saam Barati  &lt;sbarati@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        MathICs should be able to take and dump stats about code size
+        https://bugs.webkit.org/show_bug.cgi?id=160148
+
+        Reviewed by Filip Pizlo.
+
+        This will make testing changes on MathIC going forward much easier.
+        We will be able to easily see if modifications to MathIC will lead
+        to us generating smaller code. We now only dump average size when we
+        regenerate any MathIC. This works out for large tests/pages, but is not
+        great for testing small programs. We can add more dump points later if
+        we find that we want to dump stats while running small small programs.
+
+        * bytecode/CodeBlock.cpp:
+        (JSC::CodeBlock::jitSoon):
+        (JSC::CodeBlock::dumpMathICStats):
+        * bytecode/CodeBlock.h:
+        (JSC::CodeBlock::isStrictMode):
+        (JSC::CodeBlock::ecmaMode):
+        * dfg/DFGSpeculativeJIT.cpp:
+        (JSC::DFG::SpeculativeJIT::compileMathIC):
+        * ftl/FTLLowerDFGToB3.cpp:
+        (JSC::FTL::DFG::LowerDFGToB3::compileMathIC):
+        * jit/JITArithmetic.cpp:
+        (JSC::JIT::emitMathICFast):
+        (JSC::JIT::emitMathICSlow):
+        * jit/JITMathIC.h:
+        (JSC::JITMathIC::finalizeInlineCode):
+        (JSC::JITMathIC::codeSize):
+        * jit/JITOperations.cpp:
+
+2016-07-25  Saam Barati  &lt;sbarati@apple.com&gt;
+
</ins><span class="cx">         op_mul/ArithMul(Untyped,Untyped) should be an IC
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=160108
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecodeCodeBlockcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp (203696 => 203697)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp        2016-07-25 20:35:16 UTC (rev 203696)
+++ trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp        2016-07-25 20:40:39 UTC (rev 203697)
</span><span class="lines">@@ -4573,4 +4573,39 @@
</span><span class="cx">     m_llintExecuteCounter.setNewThreshold(thresholdForJIT(Options::thresholdForJITSoon()), this);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void CodeBlock::dumpMathICStats()
+{
+#if ENABLE(MATH_IC_STATS)
+    double numAdds = 0.0;
+    double totalAddSize = 0.0;
+    double numMuls = 0.0;
+    double totalMulSize = 0.0;
+
+    auto countICs = [&amp;] (CodeBlock* codeBlock) {
+        for (JITAddIC* addIC : codeBlock-&gt;m_addICs) {
+            numAdds++;
+            totalAddSize += addIC-&gt;codeSize();
+        }
+
+        for (JITMulIC* mulIC : codeBlock-&gt;m_mulICs) {
+            numMuls++;
+            totalMulSize += mulIC-&gt;codeSize();
+        }
+
+        return false;
+    };
+    heap()-&gt;forEachCodeBlock(countICs);
+
+    dataLog(&quot;Num Adds: &quot;, numAdds, &quot;\n&quot;);
+    dataLog(&quot;Total Add size in bytes: &quot;, totalAddSize, &quot;\n&quot;);
+    dataLog(&quot;Average Add size: &quot;, totalAddSize / numAdds, &quot;\n&quot;);
+    dataLog(&quot;\n&quot;);
+    dataLog(&quot;Num Muls: &quot;, numMuls, &quot;\n&quot;);
+    dataLog(&quot;Total Mul size in bytes: &quot;, totalMulSize, &quot;\n&quot;);
+    dataLog(&quot;Average Mul size: &quot;, totalMulSize / numMuls, &quot;\n&quot;);
+
+    dataLog(&quot;-----------------------\n&quot;);
+#endif
+}
+
</ins><span class="cx"> } // namespace JSC
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecodeCodeBlockh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecode/CodeBlock.h (203696 => 203697)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecode/CodeBlock.h        2016-07-25 20:35:16 UTC (rev 203696)
+++ trunk/Source/JavaScriptCore/bytecode/CodeBlock.h        2016-07-25 20:40:39 UTC (rev 203697)
</span><span class="lines">@@ -205,6 +205,8 @@
</span><span class="cx">     void printStructures(PrintStream&amp;, const Instruction*);
</span><span class="cx">     void printStructure(PrintStream&amp;, const char* name, const Instruction*, int operand);
</span><span class="cx"> 
</span><ins>+    void dumpMathICStats();
+
</ins><span class="cx">     bool isStrictMode() const { return m_isStrictMode; }
</span><span class="cx">     ECMAMode ecmaMode() const { return isStrictMode() ? StrictMode : NotStrictMode; }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGSpeculativeJITcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp (203696 => 203697)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp        2016-07-25 20:35:16 UTC (rev 203696)
+++ trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp        2016-07-25 20:40:39 UTC (rev 203697)
</span><span class="lines">@@ -3423,6 +3423,10 @@
</span><span class="cx">         rightRegs = right-&gt;jsValueRegs();
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+#if ENABLE(MATH_IC_STATS)
+    auto inlineStart = m_jit.label();
+#endif
+
</ins><span class="cx">     Box&lt;MathICGenerationState&gt; addICGenerationState = Box&lt;MathICGenerationState&gt;::create();
</span><span class="cx">     ArithProfile* arithProfile = m_jit.graph().baselineCodeBlockFor(node-&gt;origin.semantic)-&gt;arithProfileForBytecodeOffset(node-&gt;origin.semantic.bytecodeIndex);
</span><span class="cx">     mathIC-&gt;m_generator = Generator(leftOperand, rightOperand, resultRegs, leftRegs, rightRegs, leftFPR, rightFPR, scratchGPR, scratchFPR, arithProfile);
</span><span class="lines">@@ -3441,6 +3445,9 @@
</span><span class="cx">         addSlowPathGenerator([=, savePlans = WTFMove(savePlans)] () {
</span><span class="cx">             addICGenerationState-&gt;slowPathJumps.link(&amp;m_jit);
</span><span class="cx">             addICGenerationState-&gt;slowPathStart = m_jit.label();
</span><ins>+#if ENABLE(MATH_IC_STATS)
+            auto slowPathStart = m_jit.label();
+#endif
</ins><span class="cx"> 
</span><span class="cx">             silentSpill(savePlans);
</span><span class="cx"> 
</span><span class="lines">@@ -3466,6 +3473,15 @@
</span><span class="cx">             m_jit.addLinkTask([=] (LinkBuffer&amp; linkBuffer) {
</span><span class="cx">                 mathIC-&gt;finalizeInlineCode(*addICGenerationState, linkBuffer);
</span><span class="cx">             });
</span><ins>+
+#if ENABLE(MATH_IC_STATS)
+            auto slowPathEnd = m_jit.label();
+            m_jit.addLinkTask([=] (LinkBuffer&amp; linkBuffer) {
+                size_t size = static_cast&lt;char*&gt;(linkBuffer.locationOf(slowPathEnd).executableAddress()) - static_cast&lt;char*&gt;(linkBuffer.locationOf(slowPathStart).executableAddress());
+                mathIC-&gt;m_generatedCodeSize += size;
+            });
+#endif
+
</ins><span class="cx">         });
</span><span class="cx">     } else {
</span><span class="cx">         if (mathIC-&gt;isLeftOperandValidConstant()) {
</span><span class="lines">@@ -3481,6 +3497,14 @@
</span><span class="cx">         m_jit.exceptionCheck();
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+#if ENABLE(MATH_IC_STATS)
+    auto inlineEnd = m_jit.label();
+    m_jit.addLinkTask([=] (LinkBuffer&amp; linkBuffer) {
+        size_t size = static_cast&lt;char*&gt;(linkBuffer.locationOf(inlineEnd).executableAddress()) - static_cast&lt;char*&gt;(linkBuffer.locationOf(inlineStart).executableAddress());
+        mathIC-&gt;m_generatedCodeSize += size;
+    });
+#endif
+
</ins><span class="cx">     jsValueResult(resultRegs, node);
</span><span class="cx">     return;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreftlFTLLowerDFGToB3cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp (203696 => 203697)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp        2016-07-25 20:35:16 UTC (rev 203696)
+++ trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp        2016-07-25 20:40:39 UTC (rev 203697)
</span><span class="lines">@@ -1574,6 +1574,10 @@
</span><span class="cx">                 Box&lt;CCallHelpers::JumpList&gt; exceptions =
</span><span class="cx">                     exceptionHandle-&gt;scheduleExitCreation(params)-&gt;jumps(jit);
</span><span class="cx"> 
</span><ins>+#if ENABLE(MATH_IC_STATS)
+                auto inlineStart = jit.label();
+#endif
+
</ins><span class="cx">                 Box&lt;MathICGenerationState&gt; mathICGenerationState = Box&lt;MathICGenerationState&gt;::create();
</span><span class="cx">                 ArithProfile* arithProfile = state-&gt;graph.baselineCodeBlockFor(node-&gt;origin.semantic)-&gt;arithProfileForBytecodeOffset(node-&gt;origin.semantic.bytecodeIndex);
</span><span class="cx">                 mathIC-&gt;m_generator = Generator(leftOperand, rightOperand, JSValueRegs(params[0].gpr()),
</span><span class="lines">@@ -1590,6 +1594,9 @@
</span><span class="cx">                         AllowMacroScratchRegisterUsage allowScratch(jit);
</span><span class="cx">                         mathICGenerationState-&gt;slowPathJumps.link(&amp;jit);
</span><span class="cx">                         mathICGenerationState-&gt;slowPathStart = jit.label();
</span><ins>+#if ENABLE(MATH_IC_STATS)
+                        auto slowPathStart = jit.label();
+#endif
</ins><span class="cx"> 
</span><span class="cx">                         if (mathICGenerationState-&gt;shouldSlowPathRepatch) {
</span><span class="cx">                             SlowPathCall call = callOperation(*state, params.unavailableRegisters(), jit, node-&gt;origin.semantic, exceptions.get(),
</span><span class="lines">@@ -1605,6 +1612,14 @@
</span><span class="cx">                         jit.addLinkTask([=] (LinkBuffer&amp; linkBuffer) {
</span><span class="cx">                             mathIC-&gt;finalizeInlineCode(*mathICGenerationState, linkBuffer);
</span><span class="cx">                         });
</span><ins>+
+#if ENABLE(MATH_IC_STATS)
+                        auto slowPathEnd = jit.label();
+                        jit.addLinkTask([=] (LinkBuffer&amp; linkBuffer) {
+                            size_t size = static_cast&lt;char*&gt;(linkBuffer.locationOf(slowPathEnd).executableAddress()) - static_cast&lt;char*&gt;(linkBuffer.locationOf(slowPathStart).executableAddress());
+                            mathIC-&gt;m_generatedCodeSize += size;
+                        });
+#endif
</ins><span class="cx">                     });
</span><span class="cx">                 } else {
</span><span class="cx">                     callOperation(
</span><span class="lines">@@ -1611,6 +1626,14 @@
</span><span class="cx">                         *state, params.unavailableRegisters(), jit, node-&gt;origin.semantic, exceptions.get(),
</span><span class="cx">                         nonRepatchingFunction, params[0].gpr(), params[1].gpr(), params[2].gpr());
</span><span class="cx">                 }
</span><ins>+
+#if ENABLE(MATH_IC_STATS)
+                auto inlineEnd = jit.label();
+                jit.addLinkTask([=] (LinkBuffer&amp; linkBuffer) {
+                    size_t size = static_cast&lt;char*&gt;(linkBuffer.locationOf(inlineEnd).executableAddress()) - static_cast&lt;char*&gt;(linkBuffer.locationOf(inlineStart).executableAddress());
+                    mathIC-&gt;m_generatedCodeSize += size;
+                });
+#endif
</ins><span class="cx">             });
</span><span class="cx"> 
</span><span class="cx">         setJSValue(patchpoint);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitJITArithmeticcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/JITArithmetic.cpp (203696 => 203697)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/JITArithmetic.cpp        2016-07-25 20:35:16 UTC (rev 203696)
+++ trunk/Source/JavaScriptCore/jit/JITArithmetic.cpp        2016-07-25 20:40:39 UTC (rev 203697)
</span><span class="lines">@@ -739,6 +739,10 @@
</span><span class="cx">     if (!mathIC-&gt;isRightOperandValidConstant())
</span><span class="cx">         emitGetVirtualRegister(op2, rightRegs);
</span><span class="cx"> 
</span><ins>+#if ENABLE(MATH_IC_STATS)
+    auto inlineStart = label();
+#endif
+
</ins><span class="cx">     MathICGenerationState&amp; mathICGenerationState = m_instructionToMathICGenerationState.add(currentInstruction, MathICGenerationState()).iterator-&gt;value;
</span><span class="cx"> 
</span><span class="cx">     mathIC-&gt;m_generator = Generator(leftOperand, rightOperand, resultRegs, leftRegs, rightRegs, fpRegT0, fpRegT1, scratchGPR, scratchFPR, arithProfile);
</span><span class="lines">@@ -755,6 +759,15 @@
</span><span class="cx">             callOperation(nonProfiledFunction, resultRegs, leftRegs, rightRegs);
</span><span class="cx">     } else
</span><span class="cx">         addSlowCase(mathICGenerationState.slowPathJumps);
</span><ins>+
+#if ENABLE(MATH_IC_STATS)
+    auto inlineEnd = label();
+    addLinkTask([=] (LinkBuffer&amp; linkBuffer) {
+        size_t size = static_cast&lt;char*&gt;(linkBuffer.locationOf(inlineEnd).executableAddress()) - static_cast&lt;char*&gt;(linkBuffer.locationOf(inlineStart).executableAddress());
+        mathIC-&gt;m_generatedCodeSize += size;
+    });
+#endif
+
</ins><span class="cx">     emitPutVirtualRegister(result, resultRegs);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -793,6 +806,10 @@
</span><span class="cx">     if (mathIC-&gt;isRightOperandValidConstant())
</span><span class="cx">         emitGetVirtualRegister(op2, rightRegs);
</span><span class="cx"> 
</span><ins>+#if ENABLE(MATH_IC_STATS)
+    auto slowPathStart = label();
+#endif
+
</ins><span class="cx">     if (shouldEmitProfiling()) {
</span><span class="cx">         ArithProfile&amp; arithProfile = m_codeBlock-&gt;arithProfileForPC(currentInstruction);
</span><span class="cx">         if (mathICGenerationState.shouldSlowPathRepatch)
</span><span class="lines">@@ -801,6 +818,15 @@
</span><span class="cx">             mathICGenerationState.slowPathCall = callOperation(profiledFunction, resultRegs, leftRegs, rightRegs, &amp;arithProfile);
</span><span class="cx">     } else
</span><span class="cx">         mathICGenerationState.slowPathCall = callOperation(bitwise_cast&lt;J_JITOperation_EJJMic&gt;(repatchFunction), resultRegs, leftRegs, rightRegs, TrustedImmPtr(mathIC));
</span><ins>+
+#if ENABLE(MATH_IC_STATS)
+    auto slowPathEnd = label();
+    addLinkTask([=] (LinkBuffer&amp; linkBuffer) {
+        size_t size = static_cast&lt;char*&gt;(linkBuffer.locationOf(slowPathEnd).executableAddress()) - static_cast&lt;char*&gt;(linkBuffer.locationOf(slowPathStart).executableAddress());
+        mathIC-&gt;m_generatedCodeSize += size;
+    });
+#endif
+
</ins><span class="cx">     emitPutVirtualRegister(result, resultRegs);
</span><span class="cx"> 
</span><span class="cx">     addLinkTask([=] (LinkBuffer&amp; linkBuffer) {
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitJITMathICh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/JITMathIC.h (203696 => 203697)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/JITMathIC.h        2016-07-25 20:35:16 UTC (rev 203696)
+++ trunk/Source/JavaScriptCore/jit/JITMathIC.h        2016-07-25 20:40:39 UTC (rev 203697)
</span><span class="lines">@@ -48,6 +48,8 @@
</span><span class="cx">     bool shouldSlowPathRepatch;
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+#define ENABLE_MATH_IC_STATS 0
+
</ins><span class="cx"> template &lt;typename GeneratorType&gt;
</span><span class="cx"> class JITMathIC {
</span><span class="cx"> public:
</span><span class="lines">@@ -154,6 +156,17 @@
</span><span class="cx">             start, linkBuffer.locationOf(state.slowPathStart));
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+#if ENABLE(MATH_IC_STATS)
+    size_t m_generatedCodeSize { 0 };
+    size_t codeSize() const
+    {
+        size_t result = m_generatedCodeSize;
+        if (m_code)
+            result += m_code.size();
+        return result;
+    }
+#endif
+
</ins><span class="cx">     MacroAssemblerCodeRef m_code;
</span><span class="cx">     CodeLocationLabel m_inlineStart;
</span><span class="cx">     int32_t m_inlineSize;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitJITOperationscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/JITOperations.cpp (203696 => 203697)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/JITOperations.cpp        2016-07-25 20:35:16 UTC (rev 203696)
+++ trunk/Source/JavaScriptCore/jit/JITOperations.cpp        2016-07-25 20:40:39 UTC (rev 203697)
</span><span class="lines">@@ -2298,6 +2298,10 @@
</span><span class="cx">     arithProfile-&gt;observeLHSAndRHS(op1, op2);
</span><span class="cx">     auto nonOptimizeVariant = operationValueAddProfiledNoOptimize;
</span><span class="cx">     addIC-&gt;generateOutOfLine(*vm, exec-&gt;codeBlock(), nonOptimizeVariant);
</span><ins>+
+#if ENABLE(MATH_IC_STATS)
+    exec-&gt;codeBlock()-&gt;dumpMathICStats();
+#endif
</ins><span class="cx">     
</span><span class="cx">     JSValue result = jsAdd(exec, op1, op2);
</span><span class="cx">     arithProfile-&gt;observeResult(result);
</span><span class="lines">@@ -2318,6 +2322,10 @@
</span><span class="cx">     auto nonOptimizeVariant = operationValueAddNoOptimize;
</span><span class="cx">     addIC-&gt;generateOutOfLine(*vm, exec-&gt;codeBlock(), nonOptimizeVariant);
</span><span class="cx"> 
</span><ins>+#if ENABLE(MATH_IC_STATS)
+    exec-&gt;codeBlock()-&gt;dumpMathICStats();
+#endif
+
</ins><span class="cx">     JSValue op1 = JSValue::decode(encodedOp1);
</span><span class="cx">     JSValue op2 = JSValue::decode(encodedOp2);
</span><span class="cx">     return JSValue::encode(jsAdd(exec, op1, op2));
</span><span class="lines">@@ -2386,6 +2394,10 @@
</span><span class="cx">     auto nonOptimizeVariant = operationValueMulNoOptimize;
</span><span class="cx">     mulIC-&gt;generateOutOfLine(*vm, exec-&gt;codeBlock(), nonOptimizeVariant);
</span><span class="cx"> 
</span><ins>+#if ENABLE(MATH_IC_STATS)
+    exec-&gt;codeBlock()-&gt;dumpMathICStats();
+#endif
+
</ins><span class="cx">     return unprofiledMul(exec, encodedOp1, encodedOp2);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -2406,6 +2418,10 @@
</span><span class="cx">     auto nonOptimizeVariant = operationValueMulProfiledNoOptimize;
</span><span class="cx">     mulIC-&gt;generateOutOfLine(*vm, exec-&gt;codeBlock(), nonOptimizeVariant);
</span><span class="cx"> 
</span><ins>+#if ENABLE(MATH_IC_STATS)
+    exec-&gt;codeBlock()-&gt;dumpMathICStats();
+#endif
+
</ins><span class="cx">     return profiledMul(exec, encodedOp1, encodedOp2, arithProfile, false);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>