<!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>[179479] trunk</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/179479">179479</a></dd>
<dt>Author</dt> <dd>saambarati1@gmail.com</dd>
<dt>Date</dt> <dd>2015-02-02 11:05:46 -0800 (Mon, 02 Feb 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Create tests for JSC's Control Flow Profiler
https://bugs.webkit.org/show_bug.cgi?id=141123

Reviewed by Filip Pizlo.

Source/JavaScriptCore:

This patch creates a control flow profiler testing API in jsc.cpp 
that accepts a function and a string as arguments. The string must 
be a substring of the text of the function argument. The API returns 
a boolean indicating whether or not the basic block that encloses the 
substring has executed.

This patch uses this API to test that the control flow profiler
behaves as expected on basic block boundaries. These tests do not
provide full coverage for all JavaScript statements that can create
basic blocks boundaries. Full coverage will come in a later patch.

* jsc.cpp:
(GlobalObject::finishCreation):
(functionHasBasicBlockExecuted):
* runtime/ControlFlowProfiler.cpp:
(JSC::ControlFlowProfiler::hasBasicBlockAtTextOffsetBeenExecuted):
* runtime/ControlFlowProfiler.h:
* tests/controlFlowProfiler: Added.
* tests/controlFlowProfiler.yaml: Added.
* tests/controlFlowProfiler/driver: Added.
* tests/controlFlowProfiler/driver/driver.js: Added.
(assert):
* tests/controlFlowProfiler/if-statement.js: Added.
(testIf):
(noMatches):
* tests/controlFlowProfiler/loop-statements.js: Added.
(forRegular):
(forIn):
(forOf):
(whileLoop):
* tests/controlFlowProfiler/switch-statements.js: Added.
(testSwitch):
* tests/controlFlowProfiler/test-jit.js: Added.
(tierUpToBaseline):
(tierUpToDFG):
(baselineTest):
(dfgTest):

Tools:

* Scripts/run-javascriptcore-tests:
(runJSCStressTests):
* Scripts/run-jsc-stress-tests:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCorejsccpp">trunk/Source/JavaScriptCore/jsc.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeControlFlowProfilercpp">trunk/Source/JavaScriptCore/runtime/ControlFlowProfiler.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeControlFlowProfilerh">trunk/Source/JavaScriptCore/runtime/ControlFlowProfiler.h</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsScriptsrunjavascriptcoretests">trunk/Tools/Scripts/run-javascriptcore-tests</a></li>
<li><a href="#trunkToolsScriptsrunjscstresstests">trunk/Tools/Scripts/run-jsc-stress-tests</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li>trunk/Source/JavaScriptCore/tests/controlFlowProfiler/</li>
<li>trunk/Source/JavaScriptCore/tests/controlFlowProfiler/driver/</li>
<li><a href="#trunkSourceJavaScriptCoretestscontrolFlowProfilerdriverdriverjs">trunk/Source/JavaScriptCore/tests/controlFlowProfiler/driver/driver.js</a></li>
<li><a href="#trunkSourceJavaScriptCoretestscontrolFlowProfilerifstatementjs">trunk/Source/JavaScriptCore/tests/controlFlowProfiler/if-statement.js</a></li>
<li><a href="#trunkSourceJavaScriptCoretestscontrolFlowProfilerloopstatementsjs">trunk/Source/JavaScriptCore/tests/controlFlowProfiler/loop-statements.js</a></li>
<li><a href="#trunkSourceJavaScriptCoretestscontrolFlowProfilerswitchstatementsjs">trunk/Source/JavaScriptCore/tests/controlFlowProfiler/switch-statements.js</a></li>
<li><a href="#trunkSourceJavaScriptCoretestscontrolFlowProfilertestjitjs">trunk/Source/JavaScriptCore/tests/controlFlowProfiler/test-jit.js</a></li>
<li><a href="#trunkSourceJavaScriptCoretestscontrolFlowProfileryaml">trunk/Source/JavaScriptCore/tests/controlFlowProfiler.yaml</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (179478 => 179479)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2015-02-02 18:38:08 UTC (rev 179478)
+++ trunk/Source/JavaScriptCore/ChangeLog        2015-02-02 19:05:46 UTC (rev 179479)
</span><span class="lines">@@ -1,3 +1,48 @@
</span><ins>+2015-02-02  Saam Barati  &lt;saambarati1@gmail.com&gt;
+
+        Create tests for JSC's Control Flow Profiler
+        https://bugs.webkit.org/show_bug.cgi?id=141123
+
+        Reviewed by Filip Pizlo.
+
+        This patch creates a control flow profiler testing API in jsc.cpp 
+        that accepts a function and a string as arguments. The string must 
+        be a substring of the text of the function argument. The API returns 
+        a boolean indicating whether or not the basic block that encloses the 
+        substring has executed.
+
+        This patch uses this API to test that the control flow profiler
+        behaves as expected on basic block boundaries. These tests do not
+        provide full coverage for all JavaScript statements that can create
+        basic blocks boundaries. Full coverage will come in a later patch.
+
+        * jsc.cpp:
+        (GlobalObject::finishCreation):
+        (functionHasBasicBlockExecuted):
+        * runtime/ControlFlowProfiler.cpp:
+        (JSC::ControlFlowProfiler::hasBasicBlockAtTextOffsetBeenExecuted):
+        * runtime/ControlFlowProfiler.h:
+        * tests/controlFlowProfiler: Added.
+        * tests/controlFlowProfiler.yaml: Added.
+        * tests/controlFlowProfiler/driver: Added.
+        * tests/controlFlowProfiler/driver/driver.js: Added.
+        (assert):
+        * tests/controlFlowProfiler/if-statement.js: Added.
+        (testIf):
+        (noMatches):
+        * tests/controlFlowProfiler/loop-statements.js: Added.
+        (forRegular):
+        (forIn):
+        (forOf):
+        (whileLoop):
+        * tests/controlFlowProfiler/switch-statements.js: Added.
+        (testSwitch):
+        * tests/controlFlowProfiler/test-jit.js: Added.
+        (tierUpToBaseline):
+        (tierUpToDFG):
+        (baselineTest):
+        (dfgTest):
+
</ins><span class="cx"> 2015-01-28  Filip Pizlo  &lt;fpizlo@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Polymorphic call inlining should be based on polymorphic call inline caching rather than logging
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejsccpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jsc.cpp (179478 => 179479)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jsc.cpp        2015-02-02 18:38:08 UTC (rev 179478)
+++ trunk/Source/JavaScriptCore/jsc.cpp        2015-02-02 19:05:46 UTC (rev 179479)
</span><span class="lines">@@ -482,6 +482,7 @@
</span><span class="cx"> static EncodedJSValue JSC_HOST_CALL functionFindTypeForExpression(ExecState*);
</span><span class="cx"> static EncodedJSValue JSC_HOST_CALL functionReturnTypeFor(ExecState*);
</span><span class="cx"> static EncodedJSValue JSC_HOST_CALL functionDumpBasicBlockExecutionRanges(ExecState*);
</span><ins>+static EncodedJSValue JSC_HOST_CALL functionHasBasicBlockExecuted(ExecState*);
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(SAMPLING_FLAGS)
</span><span class="cx"> static EncodedJSValue JSC_HOST_CALL functionSetSamplingFlags(ExecState*);
</span><span class="lines">@@ -638,6 +639,7 @@
</span><span class="cx">         addFunction(vm, &quot;returnTypeFor&quot;, functionReturnTypeFor, 1);
</span><span class="cx"> 
</span><span class="cx">         addFunction(vm, &quot;dumpBasicBlockExecutionRanges&quot;, functionDumpBasicBlockExecutionRanges , 0);
</span><ins>+        addFunction(vm, &quot;hasBasicBlockExecuted&quot;, functionHasBasicBlockExecuted, 2);
</ins><span class="cx">         
</span><span class="cx">         JSArray* array = constructEmptyArray(globalExec(), 0);
</span><span class="cx">         for (size_t i = 0; i &lt; arguments.size(); ++i)
</span><span class="lines">@@ -1114,6 +1116,23 @@
</span><span class="cx">     return JSValue::encode(jsUndefined());
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+EncodedJSValue JSC_HOST_CALL functionHasBasicBlockExecuted(ExecState* exec)
+{
+    RELEASE_ASSERT(exec-&gt;vm().controlFlowProfiler());
+
+    JSValue functionValue = exec-&gt;argument(0);
+    RELEASE_ASSERT(functionValue.isFunction());
+    FunctionExecutable* executable = (jsDynamicCast&lt;JSFunction*&gt;(functionValue.asCell()-&gt;getObject()))-&gt;jsExecutable();
+
+    RELEASE_ASSERT(exec-&gt;argument(1).isString());
+    String substring = exec-&gt;argument(1).getString(exec);
+    String sourceCodeText = executable-&gt;source().toString();
+    int offset = sourceCodeText.find(substring) + executable-&gt;source().startOffset();
+    
+    bool hasExecuted = exec-&gt;vm().controlFlowProfiler()-&gt;hasBasicBlockAtTextOffsetBeenExecuted(offset, executable-&gt;sourceID(), exec-&gt;vm());
+    return JSValue::encode(jsBoolean(hasExecuted));
+}
+
</ins><span class="cx"> // Use SEH for Release builds only to get rid of the crash report dialog
</span><span class="cx"> // (luckily the same tests fail in Release and Debug builds so far). Need to
</span><span class="cx"> // be in a separate main function because the jscmain function requires object
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeControlFlowProfilercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/ControlFlowProfiler.cpp (179478 => 179479)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/ControlFlowProfiler.cpp        2015-02-02 18:38:08 UTC (rev 179478)
+++ trunk/Source/JavaScriptCore/runtime/ControlFlowProfiler.cpp        2015-02-02 19:05:46 UTC (rev 179479)
</span><span class="lines">@@ -98,4 +98,23 @@
</span><span class="cx">     return result;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool ControlFlowProfiler::hasBasicBlockAtTextOffsetBeenExecuted(int offset, intptr_t sourceID, VM&amp; vm)
+{
+    const Vector&lt;BasicBlockRange&gt;&amp; blocks = getBasicBlocksForSourceID(sourceID, vm);
+    int bestDistance = INT_MAX;
+    BasicBlockRange bestRange;
+    bestRange.m_startOffset = bestRange.m_endOffset = -1;
+    // Because some ranges may overlap because of function boundaries, make sure to find the smallest range enclosing the offset.
+    for (BasicBlockRange range : blocks) {
+        if (range.m_startOffset &lt;= offset &amp;&amp; offset &lt;= range.m_endOffset &amp;&amp; (range.m_endOffset - range.m_startOffset) &lt; bestDistance) {
+            RELEASE_ASSERT(range.m_endOffset - range.m_startOffset &gt;= 0);
+            bestDistance = range.m_endOffset - range.m_startOffset;
+            bestRange = range;
+        }
+    }
+
+    RELEASE_ASSERT(bestRange.m_startOffset != -1 &amp;&amp; bestRange.m_endOffset != -1);
+    return bestRange.m_hasExecuted;
+}
+
</ins><span class="cx"> } // namespace JSC
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeControlFlowProfilerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/ControlFlowProfiler.h (179478 => 179479)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/ControlFlowProfiler.h        2015-02-02 18:38:08 UTC (rev 179478)
+++ trunk/Source/JavaScriptCore/runtime/ControlFlowProfiler.h        2015-02-02 19:05:46 UTC (rev 179479)
</span><span class="lines">@@ -97,6 +97,7 @@
</span><span class="cx">     JS_EXPORT_PRIVATE void dumpData() const;
</span><span class="cx">     Vector&lt;BasicBlockRange&gt; getBasicBlocksForSourceID(intptr_t sourceID, VM&amp;) const;
</span><span class="cx">     BasicBlockLocation* dummyBasicBlock() { return &amp;m_dummyBasicBlock; }
</span><ins>+    JS_EXPORT_PRIVATE bool hasBasicBlockAtTextOffsetBeenExecuted(int, intptr_t, VM&amp;); // This function exists for testing.
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     typedef HashMap&lt;BasicBlockKey, BasicBlockLocation*&gt; BlockLocationCache;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretestscontrolFlowProfilerdriverdriverjs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/controlFlowProfiler/driver/driver.js (0 => 179479)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/controlFlowProfiler/driver/driver.js                                (rev 0)
+++ trunk/Source/JavaScriptCore/tests/controlFlowProfiler/driver/driver.js        2015-02-02 19:05:46 UTC (rev 179479)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+function assert(condition, reason) {
+    if (!condition)
+        throw new Error(reason);
+}
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoretestscontrolFlowProfilerifstatementjs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/controlFlowProfiler/if-statement.js (0 => 179479)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/controlFlowProfiler/if-statement.js                                (rev 0)
+++ trunk/Source/JavaScriptCore/tests/controlFlowProfiler/if-statement.js        2015-02-02 19:05:46 UTC (rev 179479)
</span><span class="lines">@@ -0,0 +1,56 @@
</span><ins>+load(&quot;./driver/driver.js&quot;);
+
+var a, b, c, d;
+
+function testIf(x) {
+    if (x &gt; 10 &amp;&amp; x &lt; 20) {
+        return a;
+    } else if (x &gt; 20 &amp;&amp; x &lt; 30) {
+        return b;
+    } else if (x &gt; 30 &amp;&amp; x &lt; 40) {
+        return c;
+    } else {
+        return d;
+    }
+
+    return null;
+}
+
+function noMatches(x) {
+    if (x &gt; 10 &amp;&amp; x &lt; 20) {
+        return a;
+    } else if (x &gt; 20 &amp;&amp; x &lt; 30) {
+        return b;
+    } else {
+        return c;
+    }
+}
+
+assert(!hasBasicBlockExecuted(testIf, &quot;return a&quot;), &quot;should not have executed yet.&quot;);
+assert(!hasBasicBlockExecuted(testIf, &quot;return b&quot;), &quot;should not have executed yet.&quot;);
+assert(!hasBasicBlockExecuted(testIf, &quot;return c&quot;), &quot;should not have executed yet.&quot;);
+assert(!hasBasicBlockExecuted(testIf, &quot;return d&quot;), &quot;should not have executed yet.&quot;);
+
+testIf(11);
+assert(hasBasicBlockExecuted(testIf, &quot;return a&quot;), &quot;should have executed.&quot;);
+assert(hasBasicBlockExecuted(testIf, &quot;x &gt; 10&quot;), &quot;should have executed.&quot;);
+assert(!hasBasicBlockExecuted(testIf, &quot;return b&quot;), &quot;should not have executed yet.&quot;);
+
+testIf(21);
+assert(hasBasicBlockExecuted(testIf, &quot;return b&quot;), &quot;should have executed.&quot;);
+assert(!hasBasicBlockExecuted(testIf, &quot;return c&quot;), &quot;should not have executed yet.&quot;);
+
+testIf(31);
+assert(hasBasicBlockExecuted(testIf, &quot;return c&quot;), &quot;should have executed.&quot;);
+assert(!hasBasicBlockExecuted(testIf, &quot;return d&quot;), &quot;should not have executed yet.&quot;);
+
+testIf(0);
+assert(hasBasicBlockExecuted(testIf, &quot;return d&quot;), &quot;should have executed.&quot;);
+
+
+noMatches(0);
+assert(!hasBasicBlockExecuted(noMatches, &quot;return a&quot;), &quot;should not have executed yet.&quot;);
+assert(hasBasicBlockExecuted(noMatches, &quot;x &gt; 10&quot;), &quot;should have executed.&quot;);
+assert(!hasBasicBlockExecuted(noMatches, &quot;return b&quot;), &quot;should not have executed yet.&quot;);
+assert(hasBasicBlockExecuted(noMatches, &quot;x &gt; 20&quot;), &quot;should have executed.&quot;);
+assert(hasBasicBlockExecuted(noMatches, &quot;return c&quot;), &quot;should have executed.&quot;);
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoretestscontrolFlowProfilerloopstatementsjs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/controlFlowProfiler/loop-statements.js (0 => 179479)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/controlFlowProfiler/loop-statements.js                                (rev 0)
+++ trunk/Source/JavaScriptCore/tests/controlFlowProfiler/loop-statements.js        2015-02-02 19:05:46 UTC (rev 179479)
</span><span class="lines">@@ -0,0 +1,76 @@
</span><ins>+load(&quot;./driver/driver.js&quot;);
+
+function forRegular(limit) {
+    var sum = 0;
+    for (var i = 0; i &lt; limit; i++) {
+        sum += i;
+    }
+
+    return sum;
+}
+
+function forIn(o) {
+    var s = &quot;&quot;;
+    var p;
+    for (p in o) {
+        s += p;
+    }
+}
+
+function forOf(a) {
+    var s = &quot;&quot;;
+    var p;
+    for (p of a) {
+        s += p;
+    }
+}
+
+function whileLoop(limit) {
+    var i = 0;
+    var sum = 0;
+    while (i &lt; limit) {
+        sum += i;
+        i++;
+    }
+
+    return sum;
+}
+
+assert(!hasBasicBlockExecuted(forRegular, &quot;var sum&quot;), &quot;should not have executed yet.&quot;);
+
+forRegular(0);
+assert(hasBasicBlockExecuted(forRegular, &quot;var sum&quot;), &quot;should have executed.&quot;);
+assert(!hasBasicBlockExecuted(forRegular, &quot;sum += i&quot;), &quot;should not have executed yet.&quot;);
+
+forRegular(1);
+assert(hasBasicBlockExecuted(forRegular, &quot;sum += i&quot;), &quot;should have executed.&quot;);
+
+
+assert(!hasBasicBlockExecuted(forIn, &quot;var s&quot;), &quot;should not have executed yet.&quot;);
+
+forIn({});
+assert(hasBasicBlockExecuted(forIn, &quot;var s&quot;), &quot;should have executed.&quot;);
+assert(!hasBasicBlockExecuted(forIn, &quot;s += p&quot;), &quot;should not have executed yet.&quot;);
+
+forIn({foo: &quot;bar&quot;});
+assert(hasBasicBlockExecuted(forIn, &quot;s += p&quot;), &quot;should have executed.&quot;);
+
+
+assert(!hasBasicBlockExecuted(forOf, &quot;var s&quot;), &quot;should not have executed yet.&quot;);
+
+forOf([]);
+assert(hasBasicBlockExecuted(forOf, &quot;var s&quot;), &quot;should have executed.&quot;);
+assert(!hasBasicBlockExecuted(forOf, &quot;s += p&quot;), &quot;should not have executed yet.&quot;);
+
+forOf([&quot;a&quot;]);
+assert(hasBasicBlockExecuted(forOf, &quot;s += p&quot;), &quot;should have executed.&quot;);
+
+
+assert(!hasBasicBlockExecuted(whileLoop, &quot;var sum&quot;), &quot;should not have executed yet.&quot;);
+
+whileLoop(0);
+assert(hasBasicBlockExecuted(whileLoop, &quot;var sum&quot;), &quot;should have executed.&quot;);
+assert(!hasBasicBlockExecuted(whileLoop, &quot;sum += i&quot;), &quot;should not have executed yet.&quot;);
+
+whileLoop(1);
+assert(hasBasicBlockExecuted(whileLoop, &quot;sum += i&quot;), &quot;should have executed.&quot;);
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoretestscontrolFlowProfilerswitchstatementsjs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/controlFlowProfiler/switch-statements.js (0 => 179479)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/controlFlowProfiler/switch-statements.js                                (rev 0)
+++ trunk/Source/JavaScriptCore/tests/controlFlowProfiler/switch-statements.js        2015-02-02 19:05:46 UTC (rev 179479)
</span><span class="lines">@@ -0,0 +1,28 @@
</span><ins>+load(&quot;./driver/driver.js&quot;);
+
+var a, b, c;
+function testSwitch(s) {
+    switch (s) {
+    case &quot;foo&quot;:
+        return a;
+    case &quot;bar&quot;:
+        return b;
+    default:
+        return c;
+    }
+}
+
+assert(!hasBasicBlockExecuted(testSwitch, &quot;switch&quot;), &quot;should not have executed yet.&quot;);
+
+testSwitch(&quot;foo&quot;);
+assert(hasBasicBlockExecuted(testSwitch, &quot;switch&quot;), &quot;should have executed.&quot;);
+assert(hasBasicBlockExecuted(testSwitch, &quot;return a&quot;), &quot;should have executed.&quot;);
+assert(!hasBasicBlockExecuted(testSwitch, &quot;return b&quot;), &quot;should not have executed yet.&quot;);
+assert(!hasBasicBlockExecuted(testSwitch, &quot;return c&quot;), &quot;should not have executed yet.&quot;);
+
+testSwitch(&quot;bar&quot;);
+assert(hasBasicBlockExecuted(testSwitch, &quot;return b&quot;), &quot;should have executed.&quot;);
+assert(!hasBasicBlockExecuted(testSwitch, &quot;return c&quot;), &quot;should not have executed yet.&quot;);
+
+testSwitch(&quot;&quot;);
+assert(hasBasicBlockExecuted(testSwitch, &quot;return c&quot;), &quot;should have executed.&quot;);
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoretestscontrolFlowProfilertestjitjs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/controlFlowProfiler/test-jit.js (0 => 179479)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/controlFlowProfiler/test-jit.js                                (rev 0)
+++ trunk/Source/JavaScriptCore/tests/controlFlowProfiler/test-jit.js        2015-02-02 19:05:46 UTC (rev 179479)
</span><span class="lines">@@ -0,0 +1,46 @@
</span><ins>+load(&quot;./driver/driver.js&quot;);
+
+function tierUpToBaseline(func, arg) 
+{
+    for (var i = 0; i &lt; 50; i++)
+        func(arg);
+}
+
+function tierUpToDFG(func, arg) 
+{
+    for (var i = 0; i &lt; 50; i++)
+        func(arg);
+}
+
+function baselineTest(arg) {
+    if (arg &gt; 20) {
+        return 20;
+    } else {
+        return 30;
+    }
+}
+
+function dfgTest(arg) {
+    if (arg &gt; 20) {
+        return 20;
+    } else {
+        return 30;
+    }
+}
+
+noInline(baselineTest);
+noInline(dfgTest);
+
+tierUpToBaseline(baselineTest, 10);
+tierUpToDFG(dfgTest, 10);
+
+assert(!hasBasicBlockExecuted(baselineTest, &quot;return 20&quot;), &quot;should not have executed yet.&quot;);
+assert(hasBasicBlockExecuted(baselineTest, &quot;return 30&quot;), &quot;should have executed.&quot;);
+baselineTest(25);
+assert(hasBasicBlockExecuted(baselineTest, &quot;return 20&quot;), &quot;should have executed.&quot;);
+
+assert(!hasBasicBlockExecuted(dfgTest, &quot;return 20&quot;), &quot;should not have executed yet.&quot;);
+assert(hasBasicBlockExecuted(dfgTest, &quot;return 30&quot;), &quot;should have executed.&quot;);
+dfgTest(25);
+assert(hasBasicBlockExecuted(dfgTest, &quot;return 20&quot;), &quot;should have executed.&quot;);
+
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoretestscontrolFlowProfileryaml"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/controlFlowProfiler.yaml (0 => 179479)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/controlFlowProfiler.yaml                                (rev 0)
+++ trunk/Source/JavaScriptCore/tests/controlFlowProfiler.yaml        2015-02-02 19:05:46 UTC (rev 179479)
</span><span class="lines">@@ -0,0 +1,26 @@
</span><ins>+# Copyright (C) 2015 Apple Inc. All rights reserved.
+# Copyright (C) Saam Barati &lt;saambarati1@gmail.com&gt;. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1.  Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer. 
+# 2.  Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution. 
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS &quot;AS IS&quot; AND ANY
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+- path: controlFlowProfiler
+  cmd: runControlFlowProfiler
</ins></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (179478 => 179479)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2015-02-02 18:38:08 UTC (rev 179478)
+++ trunk/Tools/ChangeLog        2015-02-02 19:05:46 UTC (rev 179479)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2015-02-02  Saam Barati  &lt;saambarati1@gmail.com&gt;
+
+        Create tests for JSC's Control Flow Profiler
+        https://bugs.webkit.org/show_bug.cgi?id=141123
+
+        Reviewed by Filip Pizlo.
+
+        * Scripts/run-javascriptcore-tests:
+        (runJSCStressTests):
+        * Scripts/run-jsc-stress-tests:
+
</ins><span class="cx"> 2015-02-02  Csaba Osztrogonác  &lt;ossy@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Remove copy/paste code from run-jsc-stress-tests to determine numberOfTests
</span></span></pre></div>
<a id="trunkToolsScriptsrunjavascriptcoretests"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/run-javascriptcore-tests (179478 => 179479)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/run-javascriptcore-tests        2015-02-02 18:38:08 UTC (rev 179478)
+++ trunk/Tools/Scripts/run-javascriptcore-tests        2015-02-02 19:05:46 UTC (rev 179479)
</span><span class="lines">@@ -264,7 +264,8 @@
</span><span class="cx">         &quot;LayoutTests/js/regress/script-tests&quot;,
</span><span class="cx">         &quot;PerformanceTests/SunSpider/profiler-test.yaml&quot;,
</span><span class="cx">         &quot;LayoutTests/jsc-layout-tests.yaml&quot;,
</span><del>-        &quot;Source/JavaScriptCore/tests/typeProfiler.yaml&quot;
</del><ins>+        &quot;Source/JavaScriptCore/tests/typeProfiler.yaml&quot;,
+        &quot;Source/JavaScriptCore/tests/controlFlowProfiler.yaml&quot;
</ins><span class="cx">     );
</span><span class="cx">     if ($enableFTL) {
</span><span class="cx">         push(@jscStressDriverCmd, &quot;--ftl-jit&quot;);
</span></span></pre></div>
<a id="trunkToolsScriptsrunjscstresstests"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/run-jsc-stress-tests (179478 => 179479)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/run-jsc-stress-tests        2015-02-02 18:38:08 UTC (rev 179478)
+++ trunk/Tools/Scripts/run-jsc-stress-tests        2015-02-02 19:05:46 UTC (rev 179479)
</span><span class="lines">@@ -727,10 +727,18 @@
</span><span class="cx">     if $enableFTL
</span><span class="cx">         run(&quot;ftl-no-cjit-type-profiler&quot;, &quot;--enableTypeProfiler=true&quot;, *(FTL_OPTIONS + NO_CJIT_OPTIONS))
</span><span class="cx">     else
</span><del>-       run(&quot;no-cjit-type-profiler&quot;, &quot;--enableTypeProfiler=true&quot;, *NO_CJIT_OPTIONS)
</del><ins>+        run(&quot;no-cjit-type-profiler&quot;, &quot;--enableTypeProfiler=true&quot;, *NO_CJIT_OPTIONS)
</ins><span class="cx">     end
</span><span class="cx"> end
</span><span class="cx"> 
</span><ins>+def runControlFlowProfiler
+    if $enableFTL
+        run(&quot;ftl-no-cjit-type-profiler&quot;, &quot;--enableControlFlowProfiler=true&quot;, *(FTL_OPTIONS + NO_CJIT_OPTIONS))
+    else
+        run(&quot;no-cjit-type-profiler&quot;, &quot;--enableControlFlowProfiler=true&quot;, *NO_CJIT_OPTIONS)
+    end
+end
+
</ins><span class="cx"> def runLayoutTest(kind, *options)
</span><span class="cx">     raise unless $benchmark.to_s =~ /\.js$/
</span><span class="cx">     testName = $~.pre_match
</span></span></pre>
</div>
</div>

</body>
</html>