<!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>[191905] 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/191905">191905</a></dd>
<dt>Author</dt> <dd>mark.lam@apple.com</dd>
<dt>Date</dt> <dd>2015-11-02 13:10:36 -0800 (Mon, 02 Nov 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Snippefy op_add for the baseline JIT.
https://bugs.webkit.org/show_bug.cgi?id=150129

Reviewed by Geoffrey Garen and Saam Barati.

Performance is neutral for both 32-bit and 64-bit on X86_64.

* CMakeLists.txt:
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters:
* JavaScriptCore.xcodeproj/project.pbxproj:
* jit/JIT.h:
(JSC::JIT::getOperandConstantInt):
- Move getOperandConstantInt() from the JSVALUE64 section to the common section
  because the snippet needs it.

* jit/JITAddGenerator.cpp: Added.
(JSC::JITAddGenerator::generateFastPath):
* jit/JITAddGenerator.h: Added.
(JSC::JITAddGenerator::JITAddGenerator):
(JSC::JITAddGenerator::endJumpList):
(JSC::JITAddGenerator::slowPathJumpList):
- JITAddGenerator implements an optimization for the case where 1 of the 2 operands
  is a constant int32_t.  It does not implement an optimization for the case where
  both operands are constant int32_t.  This is because:
  1. For the baseline JIT, the ASTBuilder will fold the 2 constants together.
  2. For the DFG, the AbstractInterpreter will also fold the 2 constants.

  Hence, such an optimization path (for 2 constant int32_t operands) would never
  be taken, and is why we won't implement it.

* jit/JITArithmetic.cpp:
(JSC::JIT::compileBinaryArithOp):
(JSC::JIT::compileBinaryArithOpSlowCase):
- Removed op_add cases.  These are no longer used by the op_add emitters.

(JSC::JIT::emit_op_add):
(JSC::JIT::emitSlow_op_add):
- Moved out from the JSVALUE64 section to the common section, and reimplemented
  using the snippet.

* jit/JITArithmetic32_64.cpp:
(JSC::JIT::emitBinaryDoubleOp):
(JSC::JIT::emit_op_add): Deleted.
(JSC::JIT::emitAdd32Constant): Deleted.
(JSC::JIT::emitSlow_op_add): Deleted.
- Remove 32-bit specific version of op_add.  The snippet serves both 32-bit
  and 64-bit implementations.

* jit/JITInlines.h:
(JSC::JIT::getOperandConstantInt):
- Move getOperandConstantInt() from the JSVALUE64 section to the common section
  because the snippet needs it.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreCMakeListstxt">trunk/Source/JavaScriptCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreJavaScriptCorevcxprojJavaScriptCorevcxproj">trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj</a></li>
<li><a href="#trunkSourceJavaScriptCoreJavaScriptCorevcxprojJavaScriptCorevcxprojfilters">trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters</a></li>
<li><a href="#trunkSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj">trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceJavaScriptCorejitJITh">trunk/Source/JavaScriptCore/jit/JIT.h</a></li>
<li><a href="#trunkSourceJavaScriptCorejitJITArithmeticcpp">trunk/Source/JavaScriptCore/jit/JITArithmetic.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorejitJITArithmetic32_64cpp">trunk/Source/JavaScriptCore/jit/JITArithmetic32_64.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorejitJITInlinesh">trunk/Source/JavaScriptCore/jit/JITInlines.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCorejitJITAddGeneratorcpp">trunk/Source/JavaScriptCore/jit/JITAddGenerator.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorejitJITAddGeneratorh">trunk/Source/JavaScriptCore/jit/JITAddGenerator.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/CMakeLists.txt (191904 => 191905)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/CMakeLists.txt        2015-11-02 20:29:38 UTC (rev 191904)
+++ trunk/Source/JavaScriptCore/CMakeLists.txt        2015-11-02 21:10:36 UTC (rev 191905)
</span><span class="lines">@@ -430,6 +430,7 @@
</span><span class="cx">     jit/HostCallReturnValue.cpp
</span><span class="cx">     jit/IntrinsicEmitter.cpp
</span><span class="cx">     jit/JIT.cpp
</span><ins>+    jit/JITAddGenerator.cpp
</ins><span class="cx">     jit/JITArithmetic.cpp
</span><span class="cx">     jit/JITArithmetic32_64.cpp
</span><span class="cx">     jit/JITCall.cpp
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (191904 => 191905)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2015-11-02 20:29:38 UTC (rev 191904)
+++ trunk/Source/JavaScriptCore/ChangeLog        2015-11-02 21:10:36 UTC (rev 191905)
</span><span class="lines">@@ -1,3 +1,59 @@
</span><ins>+2015-11-02  Mark Lam  &lt;mark.lam@apple.com&gt;
+
+        Snippefy op_add for the baseline JIT.
+        https://bugs.webkit.org/show_bug.cgi?id=150129
+
+        Reviewed by Geoffrey Garen and Saam Barati.
+
+        Performance is neutral for both 32-bit and 64-bit on X86_64.
+
+        * CMakeLists.txt:
+        * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
+        * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters:
+        * JavaScriptCore.xcodeproj/project.pbxproj:
+        * jit/JIT.h:
+        (JSC::JIT::getOperandConstantInt):
+        - Move getOperandConstantInt() from the JSVALUE64 section to the common section
+          because the snippet needs it.
+
+        * jit/JITAddGenerator.cpp: Added.
+        (JSC::JITAddGenerator::generateFastPath):
+        * jit/JITAddGenerator.h: Added.
+        (JSC::JITAddGenerator::JITAddGenerator):
+        (JSC::JITAddGenerator::endJumpList):
+        (JSC::JITAddGenerator::slowPathJumpList):
+        - JITAddGenerator implements an optimization for the case where 1 of the 2 operands
+          is a constant int32_t.  It does not implement an optimization for the case where
+          both operands are constant int32_t.  This is because:
+          1. For the baseline JIT, the ASTBuilder will fold the 2 constants together.
+          2. For the DFG, the AbstractInterpreter will also fold the 2 constants.
+
+          Hence, such an optimization path (for 2 constant int32_t operands) would never
+          be taken, and is why we won't implement it.
+
+        * jit/JITArithmetic.cpp:
+        (JSC::JIT::compileBinaryArithOp):
+        (JSC::JIT::compileBinaryArithOpSlowCase):
+        - Removed op_add cases.  These are no longer used by the op_add emitters.
+
+        (JSC::JIT::emit_op_add):
+        (JSC::JIT::emitSlow_op_add):
+        - Moved out from the JSVALUE64 section to the common section, and reimplemented
+          using the snippet.
+
+        * jit/JITArithmetic32_64.cpp:
+        (JSC::JIT::emitBinaryDoubleOp):
+        (JSC::JIT::emit_op_add): Deleted.
+        (JSC::JIT::emitAdd32Constant): Deleted.
+        (JSC::JIT::emitSlow_op_add): Deleted.
+        - Remove 32-bit specific version of op_add.  The snippet serves both 32-bit
+          and 64-bit implementations.
+
+        * jit/JITInlines.h:
+        (JSC::JIT::getOperandConstantInt):
+        - Move getOperandConstantInt() from the JSVALUE64 section to the common section
+          because the snippet needs it.
+
</ins><span class="cx"> 2015-11-02  Brian Burg  &lt;bburg@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Run sort-Xcode-project-file for the JavaScriptCore project.
</span><span class="lines">@@ -3518,7 +3574,6 @@
</span><span class="cx">         (JSC::GCAwareJITStubRoutineWithExceptionHandler::~GCAwareJITStubRoutineWithExceptionHandler): Deleted.
</span><span class="cx">         * jit/GCAwareJITStubRoutine.h:
</span><span class="cx"> 
</span><del>-&gt;&gt;&gt;&gt;&gt;&gt;&gt; .r191351
</del><span class="cx"> 2015-10-20  Tim Horton  &lt;timothy_horton@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Try to fix the build by disabling MAC_GESTURE_EVENTS on 10.9 and 10.10
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreJavaScriptCorevcxprojJavaScriptCorevcxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj (191904 => 191905)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj        2015-11-02 20:29:38 UTC (rev 191904)
+++ trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj        2015-11-02 21:10:36 UTC (rev 191905)
</span><span class="lines">@@ -638,6 +638,7 @@
</span><span class="cx">     &lt;ClCompile Include=&quot;..\jit\HostCallReturnValue.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\jit\IntrinsicEmitter.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\jit\JIT.cpp&quot; /&gt;
</span><ins>+    &lt;ClCompile Include=&quot;..\jit\JITAddGenerator.cpp&quot; /&gt;
</ins><span class="cx">     &lt;ClCompile Include=&quot;..\jit\JITArithmetic.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\jit\JITArithmetic32_64.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\jit\JITCall.cpp&quot; /&gt;
</span><span class="lines">@@ -1455,6 +1456,7 @@
</span><span class="cx">     &lt;ClInclude Include=&quot;..\jit\GPRInfo.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\jit\HostCallReturnValue.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\jit\JIT.h&quot; /&gt;
</span><ins>+    &lt;ClInclude Include=&quot;..\jit\JITAddGenerator.h&quot; /&gt;
</ins><span class="cx">     &lt;ClInclude Include=&quot;..\jit\JITCode.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\jit\JITCompilationEffort.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\jit\JITDisassembler.h&quot; /&gt;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreJavaScriptCorevcxprojJavaScriptCorevcxprojfilters"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters (191904 => 191905)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters        2015-11-02 20:29:38 UTC (rev 191904)
+++ trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters        2015-11-02 21:10:36 UTC (rev 191905)
</span><span class="lines">@@ -420,6 +420,9 @@
</span><span class="cx">     &lt;ClCompile Include=&quot;..\jit\JIT.cpp&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;jit&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClCompile&gt;
</span><ins>+    &lt;ClCompile Include=&quot;..\jit\JITAddGenerator.cpp&quot;&gt;
+      &lt;Filter&gt;jit&lt;/Filter&gt;
+    &lt;/ClCompile&gt;
</ins><span class="cx">     &lt;ClCompile Include=&quot;..\jit\JITArithmetic.cpp&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;jit&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClCompile&gt;
</span><span class="lines">@@ -2492,6 +2495,9 @@
</span><span class="cx">     &lt;ClInclude Include=&quot;..\jit\JIT.h&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;jit&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClInclude&gt;
</span><ins>+    &lt;ClInclude Include=&quot;..\jit\JITAddGenerator.h&quot;&gt;
+      &lt;Filter&gt;jit&lt;/Filter&gt;
+    &lt;/ClInclude&gt;
</ins><span class="cx">     &lt;ClInclude Include=&quot;..\jit\JITCode.h&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;jit&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClInclude&gt;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj (191904 => 191905)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2015-11-02 20:29:38 UTC (rev 191904)
+++ trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2015-11-02 21:10:36 UTC (rev 191905)
</span><span class="lines">@@ -1924,6 +1924,8 @@
</span><span class="cx">                 E49DC16D12EF295300184A1F /* SourceProviderCacheItem.h in Headers */ = {isa = PBXBuildFile; fileRef = E49DC14912EF261A00184A1F /* SourceProviderCacheItem.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 FE0D4A061AB8DD0A002F54BF /* ExecutionTimeLimitTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE0D4A041AB8DD0A002F54BF /* ExecutionTimeLimitTest.cpp */; };
</span><span class="cx">                 FE0D4A091ABA2437002F54BF /* GlobalContextWithFinalizerTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE0D4A071ABA2437002F54BF /* GlobalContextWithFinalizerTest.cpp */; };
</span><ins>+                FE1220271BE7F58C0039E6F2 /* JITAddGenerator.h in Headers */ = {isa = PBXBuildFile; fileRef = FE1220261BE7F5640039E6F2 /* JITAddGenerator.h */; settings = {ASSET_TAGS = (); }; };
+                FE1220281BE7F5910039E6F2 /* JITAddGenerator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE1220251BE7F5640039E6F2 /* JITAddGenerator.cpp */; settings = {ASSET_TAGS = (); }; };
</ins><span class="cx">                 FE1C0FFD1B193E9800B53FCA /* Exception.h in Headers */ = {isa = PBXBuildFile; fileRef = FE1C0FFC1B193E9800B53FCA /* Exception.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 FE1C0FFF1B194FD100B53FCA /* Exception.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE1C0FFE1B194FD100B53FCA /* Exception.cpp */; };
</span><span class="cx">                 FE20CE9D15F04A9500DF3430 /* LLIntCLoop.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE20CE9B15F04A9500DF3430 /* LLIntCLoop.cpp */; };
</span><span class="lines">@@ -4016,6 +4018,8 @@
</span><span class="cx">                 FE0D4A051AB8DD0A002F54BF /* ExecutionTimeLimitTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ExecutionTimeLimitTest.h; path = API/tests/ExecutionTimeLimitTest.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 FE0D4A071ABA2437002F54BF /* GlobalContextWithFinalizerTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = GlobalContextWithFinalizerTest.cpp; path = API/tests/GlobalContextWithFinalizerTest.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 FE0D4A081ABA2437002F54BF /* GlobalContextWithFinalizerTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GlobalContextWithFinalizerTest.h; path = API/tests/GlobalContextWithFinalizerTest.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                FE1220251BE7F5640039E6F2 /* JITAddGenerator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JITAddGenerator.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                FE1220261BE7F5640039E6F2 /* JITAddGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JITAddGenerator.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 FE1C0FFC1B193E9800B53FCA /* Exception.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Exception.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 FE1C0FFE1B194FD100B53FCA /* Exception.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Exception.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 FE20CE9B15F04A9500DF3430 /* LLIntCLoop.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LLIntCLoop.cpp; path = llint/LLIntCLoop.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -4651,6 +4655,8 @@
</span><span class="cx">                                 DE5A09FF1BA3AC3E003D4424 /* IntrinsicEmitter.cpp */,
</span><span class="cx">                                 1429D92D0ED22D7000B89619 /* JIT.cpp */,
</span><span class="cx">                                 1429D92E0ED22D7000B89619 /* JIT.h */,
</span><ins>+                                FE1220251BE7F5640039E6F2 /* JITAddGenerator.cpp */,
+                                FE1220261BE7F5640039E6F2 /* JITAddGenerator.h */,
</ins><span class="cx">                                 86A90ECF0EE7D51F00AB350D /* JITArithmetic.cpp */,
</span><span class="cx">                                 A75706DD118A2BCF0057F88F /* JITArithmetic32_64.cpp */,
</span><span class="cx">                                 86CC85A20EE79B7400288682 /* JITCall.cpp */,
</span><span class="lines">@@ -7242,6 +7248,7 @@
</span><span class="cx">                                 BC18C4260E16F5CD00B34460 /* JSRetainPtr.h in Headers */,
</span><span class="cx">                                 14874AE615EBDE4A002E3587 /* JSScope.h in Headers */,
</span><span class="cx">                                 A7C0C4AC168103020017011D /* JSScriptRefPrivate.h in Headers */,
</span><ins>+                                FE1220271BE7F58C0039E6F2 /* JITAddGenerator.h in Headers */,
</ins><span class="cx">                                 0F919D11157F332C004A4E7D /* JSSegmentedVariableObject.h in Headers */,
</span><span class="cx">                                 A7299D9E17D12837005F5FF9 /* JSSet.h in Headers */,
</span><span class="cx">                                 A790DD70182F499700588807 /* JSSetIterator.h in Headers */,
</span><span class="lines">@@ -8296,6 +8303,7 @@
</span><span class="cx">                                 0F300B7B18AB1B1400A6D72E /* DFGIntegerCheckCombiningPhase.cpp in Sources */,
</span><span class="cx">                                 0F898F311B27689F0083A33C /* DFGIntegerRangeOptimizationPhase.cpp in Sources */,
</span><span class="cx">                                 0FC97F3D18202119002C9B26 /* DFGInvalidationPointInjectionPhase.cpp in Sources */,
</span><ins>+                                FE1220281BE7F5910039E6F2 /* JITAddGenerator.cpp in Sources */,
</ins><span class="cx">                                 0FEA0A33170D40BF00BB722C /* DFGJITCode.cpp in Sources */,
</span><span class="cx">                                 86EC9DCB1328DF82002B2AD7 /* DFGJITCompiler.cpp in Sources */,
</span><span class="cx">                                 A78A9778179738B8009DF744 /* DFGJITFinalizer.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitJITh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/JIT.h (191904 => 191905)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/JIT.h        2015-11-02 20:29:38 UTC (rev 191904)
+++ trunk/Source/JavaScriptCore/jit/JIT.h        2015-11-02 21:10:36 UTC (rev 191905)
</span><span class="lines">@@ -403,6 +403,8 @@
</span><span class="cx">         void emitGetVirtualRegister(int src, JSValueRegs dst);
</span><span class="cx">         void emitPutVirtualRegister(int dst, JSValueRegs src);
</span><span class="cx"> 
</span><ins>+        int32_t getOperandConstantInt(int src);
+
</ins><span class="cx"> #if USE(JSVALUE32_64)
</span><span class="cx">         bool getOperandConstantInt(int op1, int op2, int&amp; op, int32_t&amp; constant);
</span><span class="cx"> 
</span><span class="lines">@@ -427,7 +429,6 @@
</span><span class="cx">         void compileGetByIdHotPath(const Identifier*);
</span><span class="cx"> 
</span><span class="cx">         // Arithmetic opcode helpers
</span><del>-        void emitAdd32Constant(int dst, int op, int32_t constant, ResultType opType);
</del><span class="cx">         void emitSub32Constant(int dst, int op, int32_t constant, ResultType opType);
</span><span class="cx">         void emitBinaryDoubleOp(OpcodeID, int dst, int op1, int op2, OperandTypes, JumpList&amp; notInt32Op1, JumpList&amp; notInt32Op2, bool op1IsInRegisters = true, bool op2IsInRegisters = true);
</span><span class="cx"> 
</span><span class="lines">@@ -447,8 +448,6 @@
</span><span class="cx">             emitPutVirtualRegister(dst, payload);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        int32_t getOperandConstantInt(int src);
-
</del><span class="cx">         Jump emitJumpIfJSCell(RegisterID);
</span><span class="cx">         Jump emitJumpIfBothJSCells(RegisterID, RegisterID, RegisterID);
</span><span class="cx">         void emitJumpSlowCaseIfJSCell(RegisterID);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitJITAddGeneratorcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/jit/JITAddGenerator.cpp (0 => 191905)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/JITAddGenerator.cpp                                (rev 0)
+++ trunk/Source/JavaScriptCore/jit/JITAddGenerator.cpp        2015-11-02 21:10:36 UTC (rev 191905)
</span><span class="lines">@@ -0,0 +1,130 @@
</span><ins>+/*
+ * Copyright (C) 2015 Apple Inc. 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 INC. ``AS IS'' 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 INC. OR
+ * 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.
+ */
+
+#include &quot;config.h&quot;
+
+#if ENABLE(JIT)
+#include &quot;JITAddGenerator.h&quot;
+
+namespace JSC {
+
+void JITAddGenerator::generateFastPath(CCallHelpers&amp; jit)
+{
+    ASSERT(m_scratchGPR != InvalidGPRReg);
+    ASSERT(m_scratchGPR != m_left.payloadGPR());
+    ASSERT(m_scratchGPR != m_right.payloadGPR());
+#if ENABLE(JSVALUE32_64)
+    ASSERT(m_scratchGPR != m_left.tagGPR());x
+    ASSERT(m_scratchGPR != m_right.tagGPR());
+    ASSERT(m_scratchFPR != InvalidFPRReg);
+#endif
+
+    if (!m_leftType.mightBeNumber() || !m_rightType.mightBeNumber()) {
+        m_slowPathJumpList.append(jit.jump());
+        return;
+    }
+
+    if (m_operandsConstness == RightIsConstInt32) {
+        // Try to do intVar + intConstant.
+        CCallHelpers::Jump notInt32 = jit.branchIfNotInt32(m_left);
+
+        m_slowPathJumpList.append(jit.branchAdd32(CCallHelpers::Overflow, m_left.payloadGPR(), CCallHelpers::Imm32(m_rightConstInt32), m_scratchGPR));
+
+        jit.boxInt32(m_scratchGPR, m_result);
+        m_endJumpList.append(jit.jump());
+
+        if (!jit.supportsFloatingPoint()) {
+            m_slowPathJumpList.append(notInt32);
+            return;
+        }
+
+        // Try to do doubleVar + double(intConstant).
+        notInt32.link(&amp;jit);
+        if (!m_leftType.definitelyIsNumber())
+            m_slowPathJumpList.append(jit.branchIfNotNumber(m_left, m_scratchGPR));
+
+        jit.unboxDoubleNonDestructive(m_left, m_leftFPR, m_scratchGPR, m_scratchFPR);
+
+        jit.move(CCallHelpers::Imm32(m_rightConstInt32), m_scratchGPR);
+        jit.convertInt32ToDouble(m_scratchGPR, m_rightFPR);
+
+        // Fall thru to doubleVar + doubleVar.
+
+    } else {
+        ASSERT(m_operandsConstness == NeitherAreConstInt32);
+        CCallHelpers::Jump leftNotInt;
+        CCallHelpers::Jump rightNotInt;
+
+        // Try to do intVar + intVar.
+        leftNotInt = jit.branchIfNotInt32(m_left);
+        rightNotInt = jit.branchIfNotInt32(m_right);
+
+        m_slowPathJumpList.append(jit.branchAdd32(CCallHelpers::Overflow, m_right.payloadGPR(), m_left.payloadGPR(), m_scratchGPR));
+
+        jit.boxInt32(m_scratchGPR, m_result);
+        m_endJumpList.append(jit.jump());
+
+        if (!jit.supportsFloatingPoint()) {
+            m_slowPathJumpList.append(leftNotInt);
+            m_slowPathJumpList.append(rightNotInt);
+            return;
+        }
+
+        leftNotInt.link(&amp;jit);
+        if (!m_leftType.definitelyIsNumber())
+            m_slowPathJumpList.append(jit.branchIfNotNumber(m_left, m_scratchGPR));
+        if (!m_rightType.definitelyIsNumber())
+            m_slowPathJumpList.append(jit.branchIfNotNumber(m_right, m_scratchGPR));
+
+        jit.unboxDoubleNonDestructive(m_left, m_leftFPR, m_scratchGPR, m_scratchFPR);
+        CCallHelpers::Jump rightIsDouble = jit.branchIfNotInt32(m_right);
+
+        jit.convertInt32ToDouble(m_right.payloadGPR(), m_rightFPR);
+        CCallHelpers::Jump rightWasInteger = jit.jump();
+
+        rightNotInt.link(&amp;jit);
+        if (!m_rightType.definitelyIsNumber())
+            m_slowPathJumpList.append(jit.branchIfNotNumber(m_right, m_scratchGPR));
+
+        jit.convertInt32ToDouble(m_left.payloadGPR(), m_leftFPR);
+
+        rightIsDouble.link(&amp;jit);
+        jit.unboxDoubleNonDestructive(m_right, m_rightFPR, m_scratchGPR, m_scratchFPR);
+
+        rightWasInteger.link(&amp;jit);
+
+        // Fall thru to doubleVar + doubleVar.
+    }
+
+    // Do doubleVar + doubleVar.
+    jit.addDouble(m_rightFPR, m_leftFPR);
+    jit.boxDouble(m_leftFPR, m_result);
+
+    m_endJumpList.append(jit.jump());
+}
+
+} // namespace JSC
+
+#endif // ENABLE(JIT)
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCorejitJITAddGeneratorh"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/jit/JITAddGenerator.h (0 => 191905)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/JITAddGenerator.h                                (rev 0)
+++ trunk/Source/JavaScriptCore/jit/JITAddGenerator.h        2015-11-02 21:10:36 UTC (rev 191905)
</span><span class="lines">@@ -0,0 +1,95 @@
</span><ins>+/*
+ * Copyright (C) 2015 Apple Inc. 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 INC. ``AS IS'' 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 INC. OR
+ * 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.
+ */
+
+#ifndef JITAddGenerator_h
+#define JITAddGenerator_h
+
+#if ENABLE(JIT)
+
+#include &quot;CCallHelpers.h&quot;
+#include &quot;ResultType.h&quot;
+
+namespace JSC {
+
+class JITAddGenerator {
+public:
+    enum OperandsConstness {
+        NeitherAreConstInt32,
+
+        // Since addition is commutative, it doesn't matter which operand we make the
+        // ConstInt32. Let's always put the const in the right, and the variable operand
+        // in the left.
+        RightIsConstInt32,
+
+        // We choose not to implement any optimization for the case where both operands
+        // are ConstInt32 here. The client may choose to do that optimzation and not
+        // invoke this snippet generator, or may load both operands into registers
+        // and pass them as variables to the snippet generator instead.
+    };
+
+    JITAddGenerator(JSValueRegs result, JSValueRegs left, JSValueRegs right,
+        OperandsConstness operandsConstness, int32_t rightConstInt32,
+        ResultType leftType, ResultType rightType, FPRReg leftFPR, FPRReg rightFPR,
+        GPRReg scratchGPR, FPRReg scratchFPR)
+        : m_result(result)
+        , m_left(left)
+        , m_right(right)
+        , m_operandsConstness(operandsConstness)
+        , m_rightConstInt32(rightConstInt32)
+        , m_leftType(leftType)
+        , m_rightType(rightType)
+        , m_leftFPR(leftFPR)
+        , m_rightFPR(rightFPR)
+        , m_scratchGPR(scratchGPR)
+        , m_scratchFPR(scratchFPR)
+    { }
+
+    void generateFastPath(CCallHelpers&amp;);
+
+    CCallHelpers::JumpList endJumpList() { return m_endJumpList; }
+    CCallHelpers::JumpList slowPathJumpList() { return m_slowPathJumpList; }
+
+private:
+    JSValueRegs m_result;
+    JSValueRegs m_left;
+    JSValueRegs m_right;
+    OperandsConstness m_operandsConstness;
+    int32_t m_rightConstInt32;
+    ResultType m_leftType;
+    ResultType m_rightType;
+    FPRReg m_leftFPR;
+    FPRReg m_rightFPR;
+    GPRReg m_scratchGPR;
+    FPRReg m_scratchFPR;
+
+    CCallHelpers::JumpList m_endJumpList;
+    CCallHelpers::JumpList m_slowPathJumpList;
+};
+
+} // namespace JSC
+
+#endif // ENABLE(JIT)
+
+#endif // JITAddGenerator_h
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCorejitJITArithmeticcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/JITArithmetic.cpp (191904 => 191905)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/JITArithmetic.cpp        2015-11-02 20:29:38 UTC (rev 191904)
+++ trunk/Source/JavaScriptCore/jit/JITArithmetic.cpp        2015-11-02 21:10:36 UTC (rev 191905)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #include &quot;JIT.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;CodeBlock.h&quot;
</span><ins>+#include &quot;JITAddGenerator.h&quot;
</ins><span class="cx"> #include &quot;JITInlines.h&quot;
</span><span class="cx"> #include &quot;JITOperations.h&quot;
</span><span class="cx"> #include &quot;JITSubGenerator.h&quot;
</span><span class="lines">@@ -666,33 +667,29 @@
</span><span class="cx">     emitGetVirtualRegisters(op1, regT0, op2, regT1);
</span><span class="cx">     emitJumpSlowCaseIfNotInt(regT0);
</span><span class="cx">     emitJumpSlowCaseIfNotInt(regT1);
</span><del>-    if (opcodeID == op_add)
-        addSlowCase(branchAdd32(Overflow, regT1, regT0));
-    else {
-        ASSERT(opcodeID == op_mul);
-        if (shouldEmitProfiling()) {
-            // We want to be able to measure if this is taking the slow case just
-            // because of negative zero. If this produces positive zero, then we
-            // don't want the slow case to be taken because that will throw off
-            // speculative compilation.
-            move(regT0, regT2);
-            addSlowCase(branchMul32(Overflow, regT1, regT2));
-            JumpList done;
-            done.append(branchTest32(NonZero, regT2));
-            Jump negativeZero = branch32(LessThan, regT0, TrustedImm32(0));
-            done.append(branch32(GreaterThanOrEqual, regT1, TrustedImm32(0)));
-            negativeZero.link(this);
-            // We only get here if we have a genuine negative zero. Record this,
-            // so that the speculative JIT knows that we failed speculation
-            // because of a negative zero.
-            add32(TrustedImm32(1), AbsoluteAddress(&amp;m_codeBlock-&gt;addSpecialFastCaseProfile(m_bytecodeOffset)-&gt;m_counter));
-            addSlowCase(jump());
-            done.link(this);
-            move(regT2, regT0);
-        } else {
-            addSlowCase(branchMul32(Overflow, regT1, regT0));
-            addSlowCase(branchTest32(Zero, regT0));
-        }
</del><ins>+    ASSERT_UNUSED(opcodeID, opcodeID == op_mul);
+    if (shouldEmitProfiling()) {
+        // We want to be able to measure if this is taking the slow case just
+        // because of negative zero. If this produces positive zero, then we
+        // don't want the slow case to be taken because that will throw off
+        // speculative compilation.
+        move(regT0, regT2);
+        addSlowCase(branchMul32(Overflow, regT1, regT2));
+        JumpList done;
+        done.append(branchTest32(NonZero, regT2));
+        Jump negativeZero = branch32(LessThan, regT0, TrustedImm32(0));
+        done.append(branch32(GreaterThanOrEqual, regT1, TrustedImm32(0)));
+        negativeZero.link(this);
+        // We only get here if we have a genuine negative zero. Record this,
+        // so that the speculative JIT knows that we failed speculation
+        // because of a negative zero.
+        add32(TrustedImm32(1), AbsoluteAddress(&amp;m_codeBlock-&gt;addSpecialFastCaseProfile(m_bytecodeOffset)-&gt;m_counter));
+        addSlowCase(jump());
+        done.link(this);
+        move(regT2, regT0);
+    } else {
+        addSlowCase(branchMul32(Overflow, regT1, regT0));
+        addSlowCase(branchTest32(Zero, regT0));
</ins><span class="cx">     }
</span><span class="cx">     emitTagInt(regT0, regT0);
</span><span class="cx"> }
</span><span class="lines">@@ -719,7 +716,7 @@
</span><span class="cx"> 
</span><span class="cx">     Label stubFunctionCall(this);
</span><span class="cx"> 
</span><del>-    JITSlowPathCall slowPathCall(this, currentInstruction, opcodeID == op_add ? slow_path_add : slow_path_mul);
</del><ins>+    JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_mul);
</ins><span class="cx">     slowPathCall.call();
</span><span class="cx">     Jump end = jump();
</span><span class="cx"> 
</span><span class="lines">@@ -763,9 +760,7 @@
</span><span class="cx">         op2wasInteger.link(this);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (opcodeID == op_add)
-        addDouble(fpRegT2, fpRegT1);
-    else if (opcodeID == op_mul)
</del><ins>+    if (opcodeID == op_mul)
</ins><span class="cx">         mulDouble(fpRegT2, fpRegT1);
</span><span class="cx">     else {
</span><span class="cx">         ASSERT(opcodeID == op_div);
</span><span class="lines">@@ -778,49 +773,6 @@
</span><span class="cx">     end.link(this);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void JIT::emit_op_add(Instruction* currentInstruction)
-{
-    int result = currentInstruction[1].u.operand;
-    int op1 = currentInstruction[2].u.operand;
-    int op2 = currentInstruction[3].u.operand;
-    OperandTypes types = OperandTypes::fromInt(currentInstruction[4].u.operand);
-
-    if (!types.first().mightBeNumber() || !types.second().mightBeNumber()) {
-        JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_add);
-        slowPathCall.call();
-        return;
-    }
-
-    if (isOperandConstantInt(op1)) {
-        emitGetVirtualRegister(op2, regT0);
-        emitJumpSlowCaseIfNotInt(regT0);
-        addSlowCase(branchAdd32(Overflow, regT0, Imm32(getOperandConstantInt(op1)), regT1));
-        emitTagInt(regT1, regT0);
-    } else if (isOperandConstantInt(op2)) {
-        emitGetVirtualRegister(op1, regT0);
-        emitJumpSlowCaseIfNotInt(regT0);
-        addSlowCase(branchAdd32(Overflow, regT0, Imm32(getOperandConstantInt(op2)), regT1));
-        emitTagInt(regT1, regT0);
-    } else
-        compileBinaryArithOp(op_add, result, op1, op2, types);
-
-    emitPutVirtualRegister(result);
-}
-
-void JIT::emitSlow_op_add(Instruction* currentInstruction, Vector&lt;SlowCaseEntry&gt;::iterator&amp; iter)
-{
-    int result = currentInstruction[1].u.operand;
-    int op1 = currentInstruction[2].u.operand;
-    int op2 = currentInstruction[3].u.operand;
-    OperandTypes types = OperandTypes::fromInt(currentInstruction[4].u.operand);
-
-    RELEASE_ASSERT(types.first().mightBeNumber() &amp;&amp; types.second().mightBeNumber());
-
-    bool op1HasImmediateIntFastCase = isOperandConstantInt(op1);
-    bool op2HasImmediateIntFastCase = !op1HasImmediateIntFastCase &amp;&amp; isOperandConstantInt(op2);
-    compileBinaryArithOpSlowCase(currentInstruction, op_add, iter, result, op1, op2, types, op1HasImmediateIntFastCase, op2HasImmediateIntFastCase);
-}
-
</del><span class="cx"> void JIT::emit_op_mul(Instruction* currentInstruction)
</span><span class="cx"> {
</span><span class="cx">     int result = currentInstruction[1].u.operand;
</span><span class="lines">@@ -959,6 +911,77 @@
</span><span class="cx"> 
</span><span class="cx"> #endif // USE(JSVALUE64)
</span><span class="cx"> 
</span><ins>+void JIT::emit_op_add(Instruction* currentInstruction)
+{
+    int result = currentInstruction[1].u.operand;
+    int op1 = currentInstruction[2].u.operand;
+    int op2 = currentInstruction[3].u.operand;
+    OperandTypes types = OperandTypes::fromInt(currentInstruction[4].u.operand);
+
+#if USE(JSVALUE64)
+    JSValueRegs leftRegs = JSValueRegs(regT0);
+    JSValueRegs rightRegs = JSValueRegs(regT1);
+    JSValueRegs resultRegs = leftRegs;
+    GPRReg scratchGPR = regT2;
+    FPRReg scratchFPR = InvalidFPRReg;
+#else
+    JSValueRegs leftRegs = JSValueRegs(regT1, regT0);
+    JSValueRegs rightRegs = JSValueRegs(regT3, regT2);
+    JSValueRegs resultRegs = leftRegs;
+    GPRReg scratchGPR = regT4;
+    FPRReg scratchFPR = fpRegT2;
+#endif
+
+    emitGetVirtualRegister(op1, leftRegs);
+    emitGetVirtualRegister(op2, rightRegs);
+
+    bool leftIsConstInt32 = isOperandConstantInt(op1);
+    bool rightIsConstInt32 = isOperandConstantInt(op2);
+    JITAddGenerator::OperandsConstness operandsConstness;
+    int32_t rightConstInt32 = 0;
+    ResultType leftType = types.first();
+    ResultType rightType = types.second();
+
+    ASSERT(!leftIsConstInt32 || !rightIsConstInt32);
+
+    if (leftIsConstInt32) {
+        // JITAddGenerator expects the const value in the right operand.
+        // Let's swap the operands.
+        operandsConstness = JITAddGenerator::RightIsConstInt32;
+        rightConstInt32 = getOperandConstantInt(op1);
+        rightType = types.first();
+        emitGetVirtualRegister(op2, leftRegs);
+        leftType = types.second();
+    } else if (rightIsConstInt32) {
+        operandsConstness = JITAddGenerator::RightIsConstInt32;
+        rightConstInt32 = getOperandConstantInt(op2);
+        emitGetVirtualRegister(op1, leftRegs);
+    } else {
+        operandsConstness = JITAddGenerator::NeitherAreConstInt32;
+        emitGetVirtualRegister(op1, leftRegs);
+        emitGetVirtualRegister(op2, rightRegs);
+    }
+
+    JITAddGenerator gen(resultRegs, leftRegs, rightRegs,
+        operandsConstness, rightConstInt32,
+        leftType, rightType,
+        fpRegT0, fpRegT1, scratchGPR, scratchFPR);
+
+    gen.generateFastPath(*this);
+    gen.endJumpList().link(this);
+    emitPutVirtualRegister(result, resultRegs);
+
+    addSlowCase(gen.slowPathJumpList());
+}
+
+void JIT::emitSlow_op_add(Instruction* currentInstruction, Vector&lt;SlowCaseEntry&gt;::iterator&amp; iter)
+{
+    linkAllSlowCasesForBytecodeOffset(m_slowCases, iter, m_bytecodeOffset);
+
+    JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_add);
+    slowPathCall.call();
+}
+
</ins><span class="cx"> void JIT::emit_op_sub(Instruction* currentInstruction)
</span><span class="cx"> {
</span><span class="cx">     int result = currentInstruction[1].u.operand;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitJITArithmetic32_64cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/JITArithmetic32_64.cpp (191904 => 191905)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/JITArithmetic32_64.cpp        2015-11-02 20:29:38 UTC (rev 191904)
+++ trunk/Source/JavaScriptCore/jit/JITArithmetic32_64.cpp        2015-11-02 21:10:36 UTC (rev 191905)
</span><span class="lines">@@ -480,119 +480,6 @@
</span><span class="cx"> 
</span><span class="cx"> // Addition (+)
</span><span class="cx"> 
</span><del>-void JIT::emit_op_add(Instruction* currentInstruction)
-{
-    int dst = currentInstruction[1].u.operand;
-    int op1 = currentInstruction[2].u.operand;
-    int op2 = currentInstruction[3].u.operand;
-    OperandTypes types = OperandTypes::fromInt(currentInstruction[4].u.operand);
-
-    if (!types.first().mightBeNumber() || !types.second().mightBeNumber()) {
-        JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_add);
-        slowPathCall.call();
-        return;
-    }
-
-    JumpList notInt32Op1;
-    JumpList notInt32Op2;
-
-    int op;
-    int32_t constant;
-    if (getOperandConstantInt(op1, op2, op, constant)) {
-        emitAdd32Constant(dst, op, constant, op == op1 ? types.first() : types.second());
-        return;
-    }
-
-    emitLoad2(op1, regT1, regT0, op2, regT3, regT2);
-    notInt32Op1.append(branch32(NotEqual, regT1, TrustedImm32(JSValue::Int32Tag)));
-    notInt32Op2.append(branch32(NotEqual, regT3, TrustedImm32(JSValue::Int32Tag)));
-
-    // Int32 case.
-    addSlowCase(branchAdd32(Overflow, regT2, regT0));
-    emitStoreInt32(dst, regT0, (op1 == dst || op2 == dst));
-
-    if (!supportsFloatingPoint()) {
-        addSlowCase(notInt32Op1);
-        addSlowCase(notInt32Op2);
-        return;
-    }
-    Jump end = jump();
-
-    // Double case.
-    emitBinaryDoubleOp(op_add, dst, op1, op2, types, notInt32Op1, notInt32Op2);
-    end.link(this);
-}
-
-void JIT::emitAdd32Constant(int dst, int op, int32_t constant, ResultType opType)
-{
-    // Int32 case.
-    emitLoad(op, regT1, regT2);
-    Jump notInt32 = branch32(NotEqual, regT1, TrustedImm32(JSValue::Int32Tag));
-    addSlowCase(branchAdd32(Overflow, regT2, Imm32(constant), regT0));
-    emitStoreInt32(dst, regT0, (op == dst));
-
-    // Double case.
-    if (!supportsFloatingPoint()) {
-        addSlowCase(notInt32);
-        return;
-    }
-    Jump end = jump();
-
-    notInt32.link(this);
-    if (!opType.definitelyIsNumber())
-        addSlowCase(branch32(Above, regT1, TrustedImm32(JSValue::LowestTag)));
-    move(Imm32(constant), regT2);
-    convertInt32ToDouble(regT2, fpRegT0);
-    emitLoadDouble(op, fpRegT1);
-    addDouble(fpRegT1, fpRegT0);
-    emitStoreDouble(dst, fpRegT0);
-
-    end.link(this);
-}
-
-void JIT::emitSlow_op_add(Instruction* currentInstruction, Vector&lt;SlowCaseEntry&gt;::iterator&amp; iter)
-{
-    int op1 = currentInstruction[2].u.operand;
-    int op2 = currentInstruction[3].u.operand;
-    OperandTypes types = OperandTypes::fromInt(currentInstruction[4].u.operand);
-
-    RELEASE_ASSERT(types.first().mightBeNumber() &amp;&amp; types.second().mightBeNumber());
-
-    int op;
-    int32_t constant;
-    if (getOperandConstantInt(op1, op2, op, constant)) {
-        linkSlowCase(iter); // overflow check
-
-        if (!supportsFloatingPoint())
-            linkSlowCase(iter); // non-sse case
-        else {
-            ResultType opType = op == op1 ? types.first() : types.second();
-            if (!opType.definitelyIsNumber())
-                linkSlowCase(iter); // double check
-        }
-    } else {
-        linkSlowCase(iter); // overflow check
-
-        if (!supportsFloatingPoint()) {
-            linkSlowCase(iter); // int32 check
-            linkSlowCase(iter); // int32 check
-        } else {
-            if (!types.first().definitelyIsNumber())
-                linkSlowCase(iter); // double check
-
-            if (!types.second().definitelyIsNumber()) {
-                linkSlowCase(iter); // int32 check
-                linkSlowCase(iter); // double check
-            }
-        }
-    }
-
-    JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_add);
-    slowPathCall.call();
-}
-
-// Subtraction (-)
-
</del><span class="cx"> void JIT::emitBinaryDoubleOp(OpcodeID opcodeID, int dst, int op1, int op2, OperandTypes types, JumpList&amp; notInt32Op1, JumpList&amp; notInt32Op2, bool op1IsInRegisters, bool op2IsInRegisters)
</span><span class="cx"> {
</span><span class="cx">     JumpList end;
</span><span class="lines">@@ -630,11 +517,6 @@
</span><span class="cx">                 mulDouble(fpRegT2, fpRegT0);
</span><span class="cx">                 emitStoreDouble(dst, fpRegT0);
</span><span class="cx">                 break;
</span><del>-            case op_add:
-                emitLoadDouble(op1, fpRegT2);
-                addDouble(fpRegT2, fpRegT0);
-                emitStoreDouble(dst, fpRegT0);
-                break;
</del><span class="cx">             case op_div: {
</span><span class="cx">                 emitLoadDouble(op1, fpRegT1);
</span><span class="cx">                 divDouble(fpRegT0, fpRegT1);
</span><span class="lines">@@ -726,11 +608,6 @@
</span><span class="cx">                 mulDouble(fpRegT2, fpRegT0);
</span><span class="cx">                 emitStoreDouble(dst, fpRegT0);
</span><span class="cx">                 break;
</span><del>-            case op_add:
-                emitLoadDouble(op2, fpRegT2);
-                addDouble(fpRegT2, fpRegT0);
-                emitStoreDouble(dst, fpRegT0);
-                break;
</del><span class="cx">             case op_div: {
</span><span class="cx">                 emitLoadDouble(op2, fpRegT2);
</span><span class="cx">                 divDouble(fpRegT2, fpRegT0);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitJITInlinesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/JITInlines.h (191904 => 191905)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/JITInlines.h        2015-11-02 20:29:38 UTC (rev 191904)
+++ trunk/Source/JavaScriptCore/jit/JITInlines.h        2015-11-02 21:10:36 UTC (rev 191905)
</span><span class="lines">@@ -975,6 +975,11 @@
</span><span class="cx">     return JITContiguous;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+ALWAYS_INLINE int32_t JIT::getOperandConstantInt(int src)
+{
+    return getConstantOperand(src).asInt32();
+}
+
</ins><span class="cx"> #if USE(JSVALUE32_64)
</span><span class="cx"> 
</span><span class="cx"> inline void JIT::emitLoadTag(int index, RegisterID tag)
</span><span class="lines">@@ -1192,11 +1197,6 @@
</span><span class="cx">     emitGetVirtualRegisters(src1.offset(), dst1, src2.offset(), dst2);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-ALWAYS_INLINE int32_t JIT::getOperandConstantInt(int src)
-{
-    return getConstantOperand(src).asInt32();
-}
-
</del><span class="cx"> ALWAYS_INLINE bool JIT::isOperandConstantInt(int src)
</span><span class="cx"> {
</span><span class="cx">     return m_codeBlock-&gt;isConstantRegisterIndex(src) &amp;&amp; getConstantOperand(src).isInt32();
</span></span></pre>
</div>
</div>

</body>
</html>