<!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>[197520] 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/197520">197520</a></dd>
<dt>Author</dt> <dd>fpizlo@apple.com</dd>
<dt>Date</dt> <dd>2016-03-03 15:30:49 -0800 (Thu, 03 Mar 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>DFG should be able to compile StringReplace
https://bugs.webkit.org/show_bug.cgi?id=154979

Reviewed by Benjamin Poulain.

Source/JavaScriptCore:

Adds support for StringReplace to the DFG tier. This is a 3% speed-up on Octane/regexp.

* dfg/DFGByteCodeParser.cpp:
(JSC::DFG::ByteCodeParser::handleIntrinsicCall):
* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::speculateFinalObject):
(JSC::DFG::SpeculativeJIT::speculateRegExpObject):
(JSC::DFG::SpeculativeJIT::speculateObjectOrOther):
* dfg/DFGSpeculativeJIT.h:
(JSC::DFG::SpeculativeJIT::callOperation):
* dfg/DFGSpeculativeJIT32_64.cpp:
(JSC::DFG::SpeculativeJIT::compile):
* dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::compile):
* jit/JITOperations.h:

LayoutTests:

Add a microbenchmark for a case of StringReplace that we hadn't covered with a microbenchmark
yet: using something absurd for the replace value. This is interesting for implementing the
32_64 version of StringReplace, which gets really weird in the absurd case because of how it
consumes the entire register file while making the call on x86-32.

* js/regress/script-tests/string-replace-generic.js: Added.
* js/regress/string-replace-generic-expected.txt: Added.
* js/regress/string-replace-generic.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGByteCodeParsercpp">trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGSpeculativeJITcpp">trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGSpeculativeJITh">trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGSpeculativeJIT32_64cpp">trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGSpeculativeJIT64cpp">trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorejitJITOperationsh">trunk/Source/JavaScriptCore/jit/JITOperations.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsjsregressscripttestsstringreplacegenericjs">trunk/LayoutTests/js/regress/script-tests/string-replace-generic.js</a></li>
<li><a href="#trunkLayoutTestsjsregressstringreplacegenericexpectedtxt">trunk/LayoutTests/js/regress/string-replace-generic-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsregressstringreplacegenerichtml">trunk/LayoutTests/js/regress/string-replace-generic.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (197519 => 197520)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-03-03 21:49:32 UTC (rev 197519)
+++ trunk/LayoutTests/ChangeLog        2016-03-03 23:30:49 UTC (rev 197520)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2016-03-03  Filip Pizlo  &lt;fpizlo@apple.com&gt;
+
+        DFG should be able to compile StringReplace
+        https://bugs.webkit.org/show_bug.cgi?id=154979
+
+        Reviewed by Benjamin Poulain.
+
+        Add a microbenchmark for a case of StringReplace that we hadn't covered with a microbenchmark
+        yet: using something absurd for the replace value. This is interesting for implementing the
+        32_64 version of StringReplace, which gets really weird in the absurd case because of how it
+        consumes the entire register file while making the call on x86-32.
+
+        * js/regress/script-tests/string-replace-generic.js: Added.
+        * js/regress/string-replace-generic-expected.txt: Added.
+        * js/regress/string-replace-generic.html: Added.
+
</ins><span class="cx"> 2016-03-03  Dave Hyatt  &lt;hyatt@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Add support for the &quot;last&quot; value of hanging-punctuation
</span></span></pre></div>
<a id="trunkLayoutTestsjsregressscripttestsstringreplacegenericjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/regress/script-tests/string-replace-generic.js (0 => 197520)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/regress/script-tests/string-replace-generic.js                                (rev 0)
+++ trunk/LayoutTests/js/regress/script-tests/string-replace-generic.js        2016-03-03 23:30:49 UTC (rev 197520)
</span><span class="lines">@@ -0,0 +1,8 @@
</span><ins>+(function() {
+    var result;
+    for (var i = 0; i &lt; 400000; ++i) {
+        result = &quot;foo&quot;.replace(/f/g, 42);
+    }
+    if (result != &quot;42oo&quot;)
+        throw &quot;Error: bad result: &quot;+ result;
+})();
</ins></span></pre></div>
<a id="trunkLayoutTestsjsregressstringreplacegenericexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/regress/string-replace-generic-expected.txt (0 => 197520)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/regress/string-replace-generic-expected.txt                                (rev 0)
+++ trunk/LayoutTests/js/regress/string-replace-generic-expected.txt        2016-03-03 23:30:49 UTC (rev 197520)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+JSRegress/string-replace-generic
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsjsregressstringreplacegenerichtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/regress/string-replace-generic.html (0 => 197520)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/regress/string-replace-generic.html                                (rev 0)
+++ trunk/LayoutTests/js/regress/string-replace-generic.html        2016-03-03 23:30:49 UTC (rev 197520)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+&lt;!DOCTYPE HTML PUBLIC &quot;-//IETF//DTD HTML//EN&quot;&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;script src=&quot;../../resources/regress-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;script-tests/string-replace-generic.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../resources/regress-post.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (197519 => 197520)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-03-03 21:49:32 UTC (rev 197519)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-03-03 23:30:49 UTC (rev 197520)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2016-03-03  Filip Pizlo  &lt;fpizlo@apple.com&gt;
+
+        DFG should be able to compile StringReplace
+        https://bugs.webkit.org/show_bug.cgi?id=154979
+
+        Reviewed by Benjamin Poulain.
+
+        Adds support for StringReplace to the DFG tier. This is a 3% speed-up on Octane/regexp.
+
+        * dfg/DFGByteCodeParser.cpp:
+        (JSC::DFG::ByteCodeParser::handleIntrinsicCall):
+        * dfg/DFGSpeculativeJIT.cpp:
+        (JSC::DFG::SpeculativeJIT::speculateFinalObject):
+        (JSC::DFG::SpeculativeJIT::speculateRegExpObject):
+        (JSC::DFG::SpeculativeJIT::speculateObjectOrOther):
+        * dfg/DFGSpeculativeJIT.h:
+        (JSC::DFG::SpeculativeJIT::callOperation):
+        * dfg/DFGSpeculativeJIT32_64.cpp:
+        (JSC::DFG::SpeculativeJIT::compile):
+        * dfg/DFGSpeculativeJIT64.cpp:
+        (JSC::DFG::SpeculativeJIT::compile):
+        * jit/JITOperations.h:
+
</ins><span class="cx"> 2016-03-03  Saam barati  &lt;sbarati@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [[SetPrototypeOf]] isn't properly implemented everywhere
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGByteCodeParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp (197519 => 197520)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp        2016-03-03 21:49:32 UTC (rev 197519)
+++ trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp        2016-03-03 23:30:49 UTC (rev 197520)
</span><span class="lines">@@ -2190,12 +2190,6 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     case StringPrototypeReplaceIntrinsic: {
</span><del>-        if (!isFTL(m_graph.m_plan.mode)) {
-            // This is a marginally profitable intrinsic. We've only the work to make it an
-            // intrinsic on the fourth tier.
-            return false;
-        }
-
</del><span class="cx">         if (argumentCountIncludingThis != 3)
</span><span class="cx">             return false;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGSpeculativeJITcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp (197519 => 197520)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp        2016-03-03 21:49:32 UTC (rev 197519)
+++ trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp        2016-03-03 23:30:49 UTC (rev 197520)
</span><span class="lines">@@ -6623,13 +6623,18 @@
</span><span class="cx">     speculateCellType(edge, operand.gpr(), SpecFinalObject, FinalObjectType);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void SpeculativeJIT::speculateRegExpObject(Edge edge, GPRReg cell)
+{
+    speculateCellType(edge, cell, SpecRegExpObject, RegExpObjectType);
+}
+
</ins><span class="cx"> void SpeculativeJIT::speculateRegExpObject(Edge edge)
</span><span class="cx"> {
</span><span class="cx">     if (!needsTypeCheck(edge, SpecRegExpObject))
</span><span class="cx">         return;
</span><span class="cx">     
</span><span class="cx">     SpeculateCellOperand operand(this, edge);
</span><del>-    speculateCellType(edge, operand.gpr(), SpecRegExpObject, RegExpObjectType);
</del><ins>+    speculateRegExpObject(edge, operand.gpr());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void SpeculativeJIT::speculateObjectOrOther(Edge edge)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGSpeculativeJITh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h (197519 => 197520)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h        2016-03-03 21:49:32 UTC (rev 197519)
+++ trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h        2016-03-03 23:30:49 UTC (rev 197520)
</span><span class="lines">@@ -1272,6 +1272,16 @@
</span><span class="cx">         m_jit.setupArgumentsWithExecState(arg1, arg2);
</span><span class="cx">         return appendCallSetResult(operation, result);
</span><span class="cx">     }
</span><ins>+    JITCompiler::Call callOperation(J_JITOperation_EJssReo operation, GPRReg result, GPRReg arg1, GPRReg arg2)
+    {
+        m_jit.setupArgumentsWithExecState(arg1, arg2);
+        return appendCallSetResult(operation, result);
+    }
+    JITCompiler::Call callOperation(J_JITOperation_EJssReoJss operation, GPRReg result, GPRReg arg1, GPRReg arg2, GPRReg arg3)
+    {
+        m_jit.setupArgumentsWithExecState(arg1, arg2, arg3);
+        return appendCallSetResult(operation, result);
+    }
</ins><span class="cx">     JITCompiler::Call callOperation(J_JITOperation_EJssZ operation, GPRReg result, GPRReg arg1, GPRReg arg2)
</span><span class="cx">     {
</span><span class="cx">         m_jit.setupArgumentsWithExecState(arg1, arg2);
</span><span class="lines">@@ -1435,20 +1445,25 @@
</span><span class="cx">         m_jit.setupArgumentsWithExecState(arg1, arg2);
</span><span class="cx">         return appendCallSetResult(operation, result);
</span><span class="cx">     }
</span><del>-    JITCompiler::Call callOperation(J_JITOperation_EJJ operation, GPRReg result, GPRReg arg1, MacroAssembler::TrustedImm32 imm)
</del><ins>+    JITCompiler::Call callOperation(J_JITOperation_EJJ operation, GPRReg result, GPRReg arg1, int32_t imm)
</ins><span class="cx">     {
</span><del>-        m_jit.setupArgumentsWithExecState(arg1, MacroAssembler::TrustedImm64(JSValue::encode(jsNumber(imm.m_value))));
</del><ins>+        m_jit.setupArgumentsWithExecState(arg1, MacroAssembler::TrustedImm64(JSValue::encode(jsNumber(imm))));
</ins><span class="cx">         return appendCallSetResult(operation, result);
</span><span class="cx">     }
</span><del>-    JITCompiler::Call callOperation(J_JITOperation_EJJ operation, GPRReg result, MacroAssembler::TrustedImm32 imm, GPRReg arg2)
</del><ins>+    JITCompiler::Call callOperation(J_JITOperation_EJJ operation, GPRReg result, int32_t imm, GPRReg arg2)
</ins><span class="cx">     {
</span><del>-        m_jit.setupArgumentsWithExecState(MacroAssembler::TrustedImm64(JSValue::encode(jsNumber(imm.m_value))), arg2);
</del><ins>+        m_jit.setupArgumentsWithExecState(MacroAssembler::TrustedImm64(JSValue::encode(jsNumber(imm))), arg2);
</ins><span class="cx">         return appendCallSetResult(operation, result);
</span><span class="cx">     }
</span><span class="cx">     JITCompiler::Call callOperation(J_JITOperation_EJJ operation, JSValueRegs result, JSValueRegs arg1, JSValueRegs arg2)
</span><span class="cx">     {
</span><span class="cx">         return callOperation(operation, result.payloadGPR(), arg1.payloadGPR(), arg2.payloadGPR());
</span><span class="cx">     }
</span><ins>+    JITCompiler::Call callOperation(J_JITOperation_EJJJ operation, GPRReg result, GPRReg arg1, GPRReg arg2, GPRReg arg3)
+    {
+        m_jit.setupArgumentsWithExecState(arg1, arg2, arg3);
+        return appendCallSetResult(operation, result);
+    }
</ins><span class="cx">     JITCompiler::Call callOperation(J_JITOperation_ECC operation, GPRReg result, GPRReg arg1, GPRReg arg2)
</span><span class="cx">     {
</span><span class="cx">         m_jit.setupArgumentsWithExecState(arg1, arg2);
</span><span class="lines">@@ -1634,6 +1649,16 @@
</span><span class="cx">         m_jit.setupArgumentsWithExecState(arg1, arg2);
</span><span class="cx">         return appendCallSetResult(operation, resultPayload, resultTag);
</span><span class="cx">     }
</span><ins>+    JITCompiler::Call callOperation(J_JITOperation_EJssReo operation, GPRReg resultTag, GPRReg resultPayload, GPRReg arg1, GPRReg arg2)
+    {
+        m_jit.setupArgumentsWithExecState(arg1, arg2);
+        return appendCallSetResult(operation, resultPayload, resultTag);
+    }
+    JITCompiler::Call callOperation(J_JITOperation_EJssReoJss operation, GPRReg resultTag, GPRReg resultPayload, GPRReg arg1, GPRReg arg2, GPRReg arg3)
+    {
+        m_jit.setupArgumentsWithExecState(arg1, arg2, arg3);
+        return appendCallSetResult(operation, resultPayload, resultTag);
+    }
</ins><span class="cx">     JITCompiler::Call callOperation(J_JITOperation_EPS operation, GPRReg resultTag, GPRReg resultPayload, void* pointer, size_t size)
</span><span class="cx">     {
</span><span class="cx">         m_jit.setupArgumentsWithExecState(TrustedImmPtr(pointer), TrustedImmPtr(size));
</span><span class="lines">@@ -1791,6 +1816,11 @@
</span><span class="cx">     {
</span><span class="cx">         return callOperation(operation, result.tagGPR(), result.payloadGPR(), arg1.tagGPR(), arg1.payloadGPR(), arg2.tagGPR(), arg2.payloadGPR());
</span><span class="cx">     }
</span><ins>+    JITCompiler::Call callOperation(J_JITOperation_EJJJ operation, GPRReg resultTag, GPRReg resultPayload, GPRReg arg1Tag, GPRReg arg1Payload, GPRReg arg2Tag, GPRReg arg2Payload, GPRReg arg3Tag, GPRReg arg3Payload)
+    {
+        m_jit.setupArgumentsWithExecState(EABI_32BIT_DUMMY_ARG arg1Payload, arg1Tag, arg2Payload, arg2Tag, arg3Payload, arg3Tag);
+        return appendCallSetResult(operation, resultPayload, resultTag);
+    }
</ins><span class="cx"> 
</span><span class="cx">     JITCompiler::Call callOperation(J_JITOperation_ECJ operation, GPRReg resultTag, GPRReg resultPayload, GPRReg arg1, GPRReg arg2Tag, GPRReg arg2Payload)
</span><span class="cx">     {
</span><span class="lines">@@ -2470,6 +2500,7 @@
</span><span class="cx">     void speculateObject(Edge);
</span><span class="cx">     void speculateFunction(Edge);
</span><span class="cx">     void speculateFinalObject(Edge);
</span><ins>+    void speculateRegExpObject(Edge, GPRReg cell);
</ins><span class="cx">     void speculateRegExpObject(Edge);
</span><span class="cx">     void speculateObjectOrOther(Edge);
</span><span class="cx">     void speculateString(Edge edge, GPRReg cell);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGSpeculativeJIT32_64cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp (197519 => 197520)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp        2016-03-03 21:49:32 UTC (rev 197519)
+++ trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp        2016-03-03 23:30:49 UTC (rev 197520)
</span><span class="lines">@@ -2902,7 +2902,75 @@
</span><span class="cx">         booleanResult(result.gpr(), node);
</span><span class="cx">         break;
</span><span class="cx">     }
</span><ins>+
+    case StringReplace: {
+        if (node-&gt;child1().useKind() == StringUse
+            &amp;&amp; node-&gt;child2().useKind() == RegExpObjectUse
+            &amp;&amp; node-&gt;child3().useKind() == StringUse) {
+            if (JSString* replace = node-&gt;child3()-&gt;dynamicCastConstant&lt;JSString*&gt;()) {
+                if (!replace-&gt;length()) {
+                    SpeculateCellOperand string(this, node-&gt;child1());
+                    SpeculateCellOperand regExp(this, node-&gt;child2());
+                    GPRReg stringGPR = string.gpr();
+                    GPRReg regExpGPR = regExp.gpr();
+                    speculateString(node-&gt;child1(), stringGPR);
+                    speculateRegExpObject(node-&gt;child2(), regExpGPR);
+
+                    flushRegisters();
+                    GPRFlushedCallResult2 resultTag(this);
+                    GPRFlushedCallResult resultPayload(this);
+                    callOperation(
+                        operationStringProtoFuncReplaceRegExpEmptyStr, resultTag.gpr(),
+                        resultPayload.gpr(), stringGPR, regExpGPR);
+                    m_jit.exceptionCheck();
+                    cellResult(resultPayload.gpr(), node);
+                    break;
+                }
+            }
+            
+            SpeculateCellOperand string(this, node-&gt;child1());
+            SpeculateCellOperand regExp(this, node-&gt;child2());
+            SpeculateCellOperand replace(this, node-&gt;child3());
+            GPRReg stringGPR = string.gpr();
+            GPRReg regExpGPR = regExp.gpr();
+            GPRReg replaceGPR = replace.gpr();
+            speculateString(node-&gt;child1(), stringGPR);
+            speculateRegExpObject(node-&gt;child2(), regExpGPR);
+            speculateString(node-&gt;child3(), replaceGPR);
+            
+            flushRegisters();
+            GPRFlushedCallResult2 resultTag(this);
+            GPRFlushedCallResult resultPayload(this);
+            callOperation(
+                operationStringProtoFuncReplaceRegExpString, resultTag.gpr(), resultPayload.gpr(),
+                stringGPR, regExpGPR, replaceGPR);
+            m_jit.exceptionCheck();
+            cellResult(resultPayload.gpr(), node);
+            break;
+        }
</ins><span class="cx">         
</span><ins>+        JSValueOperand string(this, node-&gt;child1());
+        JSValueOperand regExp(this, node-&gt;child2());
+        JSValueOperand replace(this, node-&gt;child3());
+        GPRReg stringTagGPR = string.tagGPR();
+        GPRReg stringPayloadGPR = string.payloadGPR();
+        GPRReg regExpTagGPR = regExp.tagGPR();
+        GPRReg regExpPayloadGPR = regExp.payloadGPR();
+        GPRReg replaceTagGPR = replace.tagGPR();
+        GPRReg replacePayloadGPR = replace.payloadGPR();
+        
+        flushRegisters();
+        GPRFlushedCallResult2 resultTag(this);
+        GPRFlushedCallResult resultPayload(this);
+        callOperation(
+            operationStringProtoFuncReplaceGeneric, resultTag.gpr(), resultPayload.gpr(),
+            stringTagGPR, stringPayloadGPR, regExpTagGPR, regExpPayloadGPR, replaceTagGPR,
+            replacePayloadGPR);
+        m_jit.exceptionCheck();
+        cellResult(resultPayload.gpr(), node);
+        break;
+    }
+        
</ins><span class="cx">     case ArrayPush: {
</span><span class="cx">         ASSERT(node-&gt;arrayMode().isJSArray());
</span><span class="cx">         
</span><span class="lines">@@ -4864,7 +4932,6 @@
</span><span class="cx">     case KillStack:
</span><span class="cx">     case GetStack:
</span><span class="cx">     case GetMyArgumentByVal:
</span><del>-    case StringReplace:
</del><span class="cx">         DFG_CRASH(m_jit.graph(), node, &quot;unexpected node in DFG backend&quot;);
</span><span class="cx">         break;
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGSpeculativeJIT64cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp (197519 => 197520)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp        2016-03-03 21:49:32 UTC (rev 197519)
+++ trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp        2016-03-03 23:30:49 UTC (rev 197520)
</span><span class="lines">@@ -44,6 +44,7 @@
</span><span class="cx"> #include &quot;ObjectPrototype.h&quot;
</span><span class="cx"> #include &quot;SetupVarargsFrame.h&quot;
</span><span class="cx"> #include &quot;SpillRegistersMode.h&quot;
</span><ins>+#include &quot;StringPrototype.h&quot;
</ins><span class="cx"> #include &quot;TypeProfilerLog.h&quot;
</span><span class="cx"> #include &quot;Watchdog.h&quot;
</span><span class="cx"> 
</span><span class="lines">@@ -3025,7 +3026,68 @@
</span><span class="cx">         jsValueResult(result.gpr(), node, DataFormatJSBoolean);
</span><span class="cx">         break;
</span><span class="cx">     }
</span><ins>+
+    case StringReplace: {
+        if (node-&gt;child1().useKind() == StringUse
+            &amp;&amp; node-&gt;child2().useKind() == RegExpObjectUse
+            &amp;&amp; node-&gt;child3().useKind() == StringUse) {
+            if (JSString* replace = node-&gt;child3()-&gt;dynamicCastConstant&lt;JSString*&gt;()) {
+                if (!replace-&gt;length()) {
+                    SpeculateCellOperand string(this, node-&gt;child1());
+                    SpeculateCellOperand regExp(this, node-&gt;child2());
+                    GPRReg stringGPR = string.gpr();
+                    GPRReg regExpGPR = regExp.gpr();
+                    speculateString(node-&gt;child1(), stringGPR);
+                    speculateRegExpObject(node-&gt;child2(), regExpGPR);
+
+                    flushRegisters();
+                    GPRFlushedCallResult result(this);
+                    callOperation(
+                        operationStringProtoFuncReplaceRegExpEmptyStr, result.gpr(), stringGPR,
+                        regExpGPR);
+                    m_jit.exceptionCheck();
+                    cellResult(result.gpr(), node);
+                    break;
+                }
+            }
+            
+            SpeculateCellOperand string(this, node-&gt;child1());
+            SpeculateCellOperand regExp(this, node-&gt;child2());
+            SpeculateCellOperand replace(this, node-&gt;child3());
+            GPRReg stringGPR = string.gpr();
+            GPRReg regExpGPR = regExp.gpr();
+            GPRReg replaceGPR = replace.gpr();
+            speculateString(node-&gt;child1(), stringGPR);
+            speculateRegExpObject(node-&gt;child2(), regExpGPR);
+            speculateString(node-&gt;child3(), replaceGPR);
+            
+            flushRegisters();
+            GPRFlushedCallResult result(this);
+            callOperation(
+                operationStringProtoFuncReplaceRegExpString, result.gpr(), stringGPR, regExpGPR,
+                replaceGPR);
+            m_jit.exceptionCheck();
+            cellResult(result.gpr(), node);
+            break;
+        }
</ins><span class="cx">         
</span><ins>+        JSValueOperand string(this, node-&gt;child1());
+        JSValueOperand regExp(this, node-&gt;child2());
+        JSValueOperand replace(this, node-&gt;child3());
+        GPRReg stringGPR = string.gpr();
+        GPRReg regExpGPR = regExp.gpr();
+        GPRReg replaceGPR = replace.gpr();
+        
+        flushRegisters();
+        GPRFlushedCallResult result(this);
+        callOperation(
+            operationStringProtoFuncReplaceGeneric, result.gpr(), stringGPR, regExpGPR,
+            replaceGPR);
+        m_jit.exceptionCheck();
+        cellResult(result.gpr(), node);
+        break;
+    }
+        
</ins><span class="cx">     case ArrayPush: {
</span><span class="cx">         ASSERT(node-&gt;arrayMode().isJSArray());
</span><span class="cx">         
</span><span class="lines">@@ -4916,7 +4978,6 @@
</span><span class="cx">     case PutStack:
</span><span class="cx">     case KillStack:
</span><span class="cx">     case GetStack:
</span><del>-    case StringReplace:
</del><span class="cx">         DFG_CRASH(m_jit.graph(), node, &quot;Unexpected node&quot;);
</span><span class="cx">         break;
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitJITOperationsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/JITOperations.h (197519 => 197520)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/JITOperations.h        2016-03-03 21:49:32 UTC (rev 197519)
+++ trunk/Source/JavaScriptCore/jit/JITOperations.h        2016-03-03 23:30:49 UTC (rev 197520)
</span><span class="lines">@@ -45,6 +45,7 @@
</span><span class="cx"> class JSFunction;
</span><span class="cx"> class JSLexicalEnvironment;
</span><span class="cx"> class JSScope;
</span><ins>+class RegExpObject;
</ins><span class="cx"> class Register;
</span><span class="cx"> class StructureStubInfo;
</span><span class="cx"> class SymbolTable;
</span><span class="lines">@@ -94,6 +95,7 @@
</span><span class="cx">     Pc: Instruction* i.e. bytecode PC
</span><span class="cx">     Q: int64_t
</span><span class="cx">     R: Register
</span><ins>+    Reo: RegExpObject*
</ins><span class="cx">     S: size_t
</span><span class="cx">     Sprt: SlowPathReturnType
</span><span class="cx">     Ssi: StructureStubInfo*
</span><span class="lines">@@ -128,9 +130,13 @@
</span><span class="cx"> typedef EncodedJSValue JIT_OPERATION (*J_JITOperation_EJI)(ExecState*, EncodedJSValue, UniquedStringImpl*);
</span><span class="cx"> typedef EncodedJSValue JIT_OPERATION (*J_JITOperation_EJIdc)(ExecState*, EncodedJSValue, const Identifier*);
</span><span class="cx"> typedef EncodedJSValue JIT_OPERATION (*J_JITOperation_EJJ)(ExecState*, EncodedJSValue, EncodedJSValue);
</span><ins>+typedef EncodedJSValue JIT_OPERATION (*J_JITOperation_EJJJ)(ExecState*, EncodedJSValue, EncodedJSValue, EncodedJSValue);
</ins><span class="cx"> typedef EncodedJSValue JIT_OPERATION (*J_JITOperation_EJJAp)(ExecState*, EncodedJSValue, EncodedJSValue, ArrayProfile*);
</span><span class="cx"> typedef EncodedJSValue JIT_OPERATION (*J_JITOperation_EJJBy)(ExecState*, EncodedJSValue, EncodedJSValue, ByValInfo*);
</span><ins>+typedef EncodedJSValue JIT_OPERATION (*J_JITOperation_EJJJ)(ExecState*, EncodedJSValue, EncodedJSValue, EncodedJSValue);
</ins><span class="cx"> typedef EncodedJSValue JIT_OPERATION (*J_JITOperation_EJssZ)(ExecState*, JSString*, int32_t);
</span><ins>+typedef EncodedJSValue JIT_OPERATION (*J_JITOperation_EJssReo)(ExecState*, JSString*, RegExpObject*);
+typedef EncodedJSValue JIT_OPERATION (*J_JITOperation_EJssReoJss)(ExecState*, JSString*, RegExpObject*, JSString*);
</ins><span class="cx"> typedef EncodedJSValue JIT_OPERATION (*J_JITOperation_EJP)(ExecState*, EncodedJSValue, void*);
</span><span class="cx"> typedef EncodedJSValue JIT_OPERATION (*J_JITOperation_EP)(ExecState*, void*);
</span><span class="cx"> typedef EncodedJSValue JIT_OPERATION (*J_JITOperation_EPP)(ExecState*, void*, void*);
</span></span></pre>
</div>
</div>

</body>
</html>