<!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>[193989] 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/193989">193989</a></dd>
<dt>Author</dt> <dd>benjamin@webkit.org</dd>
<dt>Date</dt> <dd>2015-12-11 15:45:04 -0800 (Fri, 11 Dec 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>[JSC] Add an implementation of pow() taking an integer exponent to B3
https://bugs.webkit.org/show_bug.cgi?id=152165

Reviewed by Mark Lam.

LLVM has this really neat optimized opcode for
raising the power of something by an integer exponent.

There is no such native instruction so we need to extend
the existing FTLOutput API to something efficient.

DFG has a pretty competitive implementation. In this patch,
I added a version of it to B3.
I created powDoubleInt32() instead of putting the code directly
in FTL for easier testing and optimization.

* CMakeLists.txt:
* JavaScriptCore.xcodeproj/project.pbxproj:
* b3/B3MathExtras.cpp: Added.
(JSC::B3::powDoubleInt32):
* b3/B3MathExtras.h: Added.
* b3/B3MemoryValue.h:
* b3/testb3.cpp:
(JSC::B3::testPowDoubleByIntegerLoop):
(JSC::B3::run):
* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::compileArithPowIntegerFastPath):
* ftl/FTLB3Output.cpp:
(JSC::FTL::Output::doublePowi):
* ftl/FTLB3Output.h:
(JSC::FTL::Output::doublePowi): Deleted.</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="#trunkSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj">trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceJavaScriptCoreb3B3MemoryValueh">trunk/Source/JavaScriptCore/b3/B3MemoryValue.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreb3testb3cpp">trunk/Source/JavaScriptCore/b3/testb3.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGSpeculativeJITcpp">trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreftlFTLB3Outputcpp">trunk/Source/JavaScriptCore/ftl/FTLB3Output.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreftlFTLB3Outputh">trunk/Source/JavaScriptCore/ftl/FTLB3Output.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreb3B3MathExtrascpp">trunk/Source/JavaScriptCore/b3/B3MathExtras.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreb3B3MathExtrash">trunk/Source/JavaScriptCore/b3/B3MathExtras.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 (193988 => 193989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/CMakeLists.txt        2015-12-11 23:30:34 UTC (rev 193988)
+++ trunk/Source/JavaScriptCore/CMakeLists.txt        2015-12-11 23:45:04 UTC (rev 193989)
</span><span class="lines">@@ -115,6 +115,7 @@
</span><span class="cx">     b3/B3InsertionSet.cpp
</span><span class="cx">     b3/B3LowerMacros.cpp
</span><span class="cx">     b3/B3LowerToAir.cpp
</span><ins>+    b3/B3MathExtras.cpp
</ins><span class="cx">     b3/B3MemoryValue.cpp
</span><span class="cx">     b3/B3MoveConstants.cpp
</span><span class="cx">     b3/B3OpaqueByproducts.cpp
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (193988 => 193989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2015-12-11 23:30:34 UTC (rev 193988)
+++ trunk/Source/JavaScriptCore/ChangeLog        2015-12-11 23:45:04 UTC (rev 193989)
</span><span class="lines">@@ -1,3 +1,37 @@
</span><ins>+2015-12-11  Benjamin Poulain  &lt;benjamin@webkit.org&gt;
+
+        [JSC] Add an implementation of pow() taking an integer exponent to B3
+        https://bugs.webkit.org/show_bug.cgi?id=152165
+
+        Reviewed by Mark Lam.
+
+        LLVM has this really neat optimized opcode for
+        raising the power of something by an integer exponent.
+
+        There is no such native instruction so we need to extend
+        the existing FTLOutput API to something efficient.
+
+        DFG has a pretty competitive implementation. In this patch,
+        I added a version of it to B3.
+        I created powDoubleInt32() instead of putting the code directly
+        in FTL for easier testing and optimization.
+
+        * CMakeLists.txt:
+        * JavaScriptCore.xcodeproj/project.pbxproj:
+        * b3/B3MathExtras.cpp: Added.
+        (JSC::B3::powDoubleInt32):
+        * b3/B3MathExtras.h: Added.
+        * b3/B3MemoryValue.h:
+        * b3/testb3.cpp:
+        (JSC::B3::testPowDoubleByIntegerLoop):
+        (JSC::B3::run):
+        * dfg/DFGSpeculativeJIT.cpp:
+        (JSC::DFG::compileArithPowIntegerFastPath):
+        * ftl/FTLB3Output.cpp:
+        (JSC::FTL::Output::doublePowi):
+        * ftl/FTLB3Output.h:
+        (JSC::FTL::Output::doublePowi): Deleted.
+
</ins><span class="cx"> 2015-12-11  Filip Pizlo  &lt;fpizlo@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         B3 should have CSE
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj (193988 => 193989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2015-12-11 23:30:34 UTC (rev 193988)
+++ trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2015-12-11 23:45:04 UTC (rev 193989)
</span><span class="lines">@@ -1135,6 +1135,8 @@
</span><span class="cx">                 43422A631C158E6D00E2EB98 /* B3ConstFloatValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 43422A611C15871B00E2EB98 /* B3ConstFloatValue.h */; };
</span><span class="cx">                 43422A661C16267500E2EB98 /* B3ReduceDoubleToFloat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43422A641C16221E00E2EB98 /* B3ReduceDoubleToFloat.cpp */; };
</span><span class="cx">                 43422A671C16267800E2EB98 /* B3ReduceDoubleToFloat.h in Headers */ = {isa = PBXBuildFile; fileRef = 43422A651C16221E00E2EB98 /* B3ReduceDoubleToFloat.h */; };
</span><ins>+                43AB26C61C1A535900D82AE6 /* B3MathExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = 43AB26C51C1A52F700D82AE6 /* B3MathExtras.h */; };
+                43AB26C71C1A535C00D82AE6 /* B3MathExtras.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43AB26C41C1A52F700D82AE6 /* B3MathExtras.cpp */; };
</ins><span class="cx">                 4443AE3316E188D90076F110 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 51F0EB6105C86C6B00E6DF1B /* Foundation.framework */; };
</span><span class="cx">                 451539B912DC994500EF7AC4 /* Yarr.h in Headers */ = {isa = PBXBuildFile; fileRef = 451539B812DC994500EF7AC4 /* Yarr.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 52678F8E1A031009006A306D /* BasicBlockLocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 52678F8C1A031009006A306D /* BasicBlockLocation.cpp */; };
</span><span class="lines">@@ -2015,17 +2017,17 @@
</span><span class="cx">                 FE3913541B794F6E00EDAF71 /* LiveObjectList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE3913521B794AC900EDAF71 /* LiveObjectList.cpp */; };
</span><span class="cx">                 FE3913551B794F8A00EDAF71 /* LiveObjectData.h in Headers */ = {isa = PBXBuildFile; fileRef = FE3913511B794AC900EDAF71 /* LiveObjectData.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 FE3913561B794F8F00EDAF71 /* LiveObjectList.h in Headers */ = {isa = PBXBuildFile; fileRef = FE3913531B794AC900EDAF71 /* LiveObjectList.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><del>-                FE3A06A61C10B72D00390FDD /* JITBitOrGenerator.h in Headers */ = {isa = PBXBuildFile; fileRef = FE3A06A41C10B70800390FDD /* JITBitOrGenerator.h */; settings = {ASSET_TAGS = (); }; };
-                FE3A06A81C10BC8100390FDD /* JITBitBinaryOpGenerator.h in Headers */ = {isa = PBXBuildFile; fileRef = FE3A06A71C10BC7400390FDD /* JITBitBinaryOpGenerator.h */; settings = {ASSET_TAGS = (); }; };
-                FE3A06AC1C10C39E00390FDD /* JITBitOrGenerator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE3A06A31C10B70800390FDD /* JITBitOrGenerator.cpp */; settings = {ASSET_TAGS = (); }; };
-                FE3A06B11C10CB8400390FDD /* JITBitAndGenerator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE3A06AD1C10CB6F00390FDD /* JITBitAndGenerator.cpp */; settings = {ASSET_TAGS = (); }; };
-                FE3A06B21C10CB8900390FDD /* JITBitAndGenerator.h in Headers */ = {isa = PBXBuildFile; fileRef = FE3A06AE1C10CB6F00390FDD /* JITBitAndGenerator.h */; settings = {ASSET_TAGS = (); }; };
-                FE3A06B31C10CB8E00390FDD /* JITBitXorGenerator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE3A06AF1C10CB6F00390FDD /* JITBitXorGenerator.cpp */; settings = {ASSET_TAGS = (); }; };
-                FE3A06B41C10CB9300390FDD /* JITBitXorGenerator.h in Headers */ = {isa = PBXBuildFile; fileRef = FE3A06B01C10CB6F00390FDD /* JITBitXorGenerator.h */; settings = {ASSET_TAGS = (); }; };
-                FE3A06BD1C11040D00390FDD /* JITLeftShiftGenerator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE3A06B61C1103D900390FDD /* JITLeftShiftGenerator.cpp */; settings = {ASSET_TAGS = (); }; };
-                FE3A06BE1C11041200390FDD /* JITLeftShiftGenerator.h in Headers */ = {isa = PBXBuildFile; fileRef = FE3A06B71C1103D900390FDD /* JITLeftShiftGenerator.h */; settings = {ASSET_TAGS = (); }; };
-                FE3A06BF1C11041600390FDD /* JITRightShiftGenerator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE3A06B81C1103D900390FDD /* JITRightShiftGenerator.cpp */; settings = {ASSET_TAGS = (); }; };
-                FE3A06C01C11041A00390FDD /* JITRightShiftGenerator.h in Headers */ = {isa = PBXBuildFile; fileRef = FE3A06B91C1103D900390FDD /* JITRightShiftGenerator.h */; settings = {ASSET_TAGS = (); }; };
</del><ins>+                FE3A06A61C10B72D00390FDD /* JITBitOrGenerator.h in Headers */ = {isa = PBXBuildFile; fileRef = FE3A06A41C10B70800390FDD /* JITBitOrGenerator.h */; };
+                FE3A06A81C10BC8100390FDD /* JITBitBinaryOpGenerator.h in Headers */ = {isa = PBXBuildFile; fileRef = FE3A06A71C10BC7400390FDD /* JITBitBinaryOpGenerator.h */; };
+                FE3A06AC1C10C39E00390FDD /* JITBitOrGenerator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE3A06A31C10B70800390FDD /* JITBitOrGenerator.cpp */; };
+                FE3A06B11C10CB8400390FDD /* JITBitAndGenerator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE3A06AD1C10CB6F00390FDD /* JITBitAndGenerator.cpp */; };
+                FE3A06B21C10CB8900390FDD /* JITBitAndGenerator.h in Headers */ = {isa = PBXBuildFile; fileRef = FE3A06AE1C10CB6F00390FDD /* JITBitAndGenerator.h */; };
+                FE3A06B31C10CB8E00390FDD /* JITBitXorGenerator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE3A06AF1C10CB6F00390FDD /* JITBitXorGenerator.cpp */; };
+                FE3A06B41C10CB9300390FDD /* JITBitXorGenerator.h in Headers */ = {isa = PBXBuildFile; fileRef = FE3A06B01C10CB6F00390FDD /* JITBitXorGenerator.h */; };
+                FE3A06BD1C11040D00390FDD /* JITLeftShiftGenerator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE3A06B61C1103D900390FDD /* JITLeftShiftGenerator.cpp */; };
+                FE3A06BE1C11041200390FDD /* JITLeftShiftGenerator.h in Headers */ = {isa = PBXBuildFile; fileRef = FE3A06B71C1103D900390FDD /* JITLeftShiftGenerator.h */; };
+                FE3A06BF1C11041600390FDD /* JITRightShiftGenerator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE3A06B81C1103D900390FDD /* JITRightShiftGenerator.cpp */; };
+                FE3A06C01C11041A00390FDD /* JITRightShiftGenerator.h in Headers */ = {isa = PBXBuildFile; fileRef = FE3A06B91C1103D900390FDD /* JITRightShiftGenerator.h */; };
</ins><span class="cx">                 FE4238901BE18C3C00514737 /* JITSubGenerator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE42388F1BE18C1200514737 /* JITSubGenerator.cpp */; };
</span><span class="cx">                 FE4BFF2B1AD476E700088F87 /* FunctionOverrides.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE4BFF291AD476E700088F87 /* FunctionOverrides.cpp */; };
</span><span class="cx">                 FE4BFF2C1AD476E700088F87 /* FunctionOverrides.h in Headers */ = {isa = PBXBuildFile; fileRef = FE4BFF2A1AD476E700088F87 /* FunctionOverrides.h */; };
</span><span class="lines">@@ -3211,6 +3213,8 @@
</span><span class="cx">                 43422A611C15871B00E2EB98 /* B3ConstFloatValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = B3ConstFloatValue.h; path = b3/B3ConstFloatValue.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 43422A641C16221E00E2EB98 /* B3ReduceDoubleToFloat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = B3ReduceDoubleToFloat.cpp; path = b3/B3ReduceDoubleToFloat.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 43422A651C16221E00E2EB98 /* B3ReduceDoubleToFloat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = B3ReduceDoubleToFloat.h; path = b3/B3ReduceDoubleToFloat.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                43AB26C41C1A52F700D82AE6 /* B3MathExtras.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = B3MathExtras.cpp; path = b3/B3MathExtras.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                43AB26C51C1A52F700D82AE6 /* B3MathExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = B3MathExtras.h; path = b3/B3MathExtras.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 449097EE0F8F81B50076A327 /* FeatureDefines.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = FeatureDefines.xcconfig; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 451539B812DC994500EF7AC4 /* Yarr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Yarr.h; path = yarr/Yarr.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 45E12D8806A49B0F00E9DF84 /* jsc.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsc.cpp; sourceTree = &quot;&lt;group&gt;&quot;; tabWidth = 4; };
</span><span class="lines">@@ -4636,6 +4640,8 @@
</span><span class="cx">                                 0F338E1A1BF286EA0013C88F /* B3LowerMacros.h */,
</span><span class="cx">                                 0FEC84D31BDACDAC0080FF74 /* B3LowerToAir.cpp */,
</span><span class="cx">                                 0FEC84D41BDACDAC0080FF74 /* B3LowerToAir.h */,
</span><ins>+                                43AB26C41C1A52F700D82AE6 /* B3MathExtras.cpp */,
+                                43AB26C51C1A52F700D82AE6 /* B3MathExtras.h */,
</ins><span class="cx">                                 0FEC84D51BDACDAC0080FF74 /* B3MemoryValue.cpp */,
</span><span class="cx">                                 0FEC84D61BDACDAC0080FF74 /* B3MemoryValue.h */,
</span><span class="cx">                                 0F338E031BF0276C0013C88F /* B3MoveConstants.cpp */,
</span><span class="lines">@@ -7564,6 +7570,7 @@
</span><span class="cx">                                 70EC0EC31AA0D7DA00B6AAFA /* JSStringIterator.h in Headers */,
</span><span class="cx">                                 2600B5A7152BAAA70091EE5F /* JSStringJoiner.h in Headers */,
</span><span class="cx">                                 BC18C4280E16F5CD00B34460 /* JSStringRef.h in Headers */,
</span><ins>+                                43AB26C61C1A535900D82AE6 /* B3MathExtras.h in Headers */,
</ins><span class="cx">                                 BC18C4290E16F5CD00B34460 /* JSStringRefCF.h in Headers */,
</span><span class="cx">                                 1A28D4A8177B71C80007FA3C /* JSStringRefPrivate.h in Headers */,
</span><span class="cx">                                 0F919D0D157EE0A2004A4E7D /* JSSymbolTableObject.h in Headers */,
</span><span class="lines">@@ -8437,6 +8444,7 @@
</span><span class="cx">                                 0FEC85731BDACDC70080FF74 /* AirCCallSpecial.cpp in Sources */,
</span><span class="cx">                                 0FEC85751BDACDC70080FF74 /* AirCode.cpp in Sources */,
</span><span class="cx">                                 0F4570381BE44C910062A629 /* AirEliminateDeadCode.cpp in Sources */,
</span><ins>+                                43AB26C71C1A535C00D82AE6 /* B3MathExtras.cpp in Sources */,
</ins><span class="cx">                                 0FEC85781BDACDC70080FF74 /* AirGenerate.cpp in Sources */,
</span><span class="cx">                                 0FEC85931BDB1E100080FF74 /* AirGenerated.cpp in Sources */,
</span><span class="cx">                                 0FEC857B1BDACDC70080FF74 /* AirHandleCalleeSaves.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreb3B3MathExtrascpp"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/b3/B3MathExtras.cpp (0 => 193989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/b3/B3MathExtras.cpp                                (rev 0)
+++ trunk/Source/JavaScriptCore/b3/B3MathExtras.cpp        2015-12-11 23:45:04 UTC (rev 193989)
</span><span class="lines">@@ -0,0 +1,126 @@
</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;
+#include &quot;B3MathExtras.h&quot;
+
+#if ENABLE(B3_JIT)
+
+#include &quot;B3BasicBlockInlines.h&quot;
+#include &quot;B3CCallValue.h&quot;
+#include &quot;B3Const32Value.h&quot;
+#include &quot;B3ConstDoubleValue.h&quot;
+#include &quot;B3ConstPtrValue.h&quot;
+#include &quot;B3ControlValue.h&quot;
+#include &quot;B3UpsilonValue.h&quot;
+#include &quot;B3ValueInlines.h&quot;
+
+namespace JSC { namespace B3 {
+
+std::pair&lt;BasicBlock*, Value*&gt; powDoubleInt32(Procedure&amp; procedure, BasicBlock* start, Origin origin, Value* x, Value* y)
+{
+    BasicBlock* functionCallCase = procedure.addBlock();
+    BasicBlock* loopPreHeaderCase = procedure.addBlock();
+    BasicBlock* loopTestForEvenCase = procedure.addBlock();
+    BasicBlock* loopOdd = procedure.addBlock();
+    BasicBlock* loopEvenOdd = procedure.addBlock();
+    BasicBlock* continuation = procedure.addBlock();
+
+    Value* shouldGoSlowPath = start-&gt;appendNew&lt;Value&gt;(procedure, Above, origin,
+        y,
+        start-&gt;appendNew&lt;Const32Value&gt;(procedure, origin, 1000));
+    start-&gt;appendNew&lt;ControlValue&gt;(
+        procedure, Branch, origin,
+        shouldGoSlowPath,
+        FrequentedBlock(functionCallCase), FrequentedBlock(loopPreHeaderCase));
+
+    // Function call.
+    Value* yAsDouble = functionCallCase-&gt;appendNew&lt;Value&gt;(procedure, IToD, origin, y);
+    Value* powResult = functionCallCase-&gt;appendNew&lt;CCallValue&gt;(
+        procedure, Double, origin,
+        functionCallCase-&gt;appendNew&lt;ConstPtrValue&gt;(procedure, origin, bitwise_cast&lt;void*&gt;(pow)),
+        x, yAsDouble);
+    UpsilonValue* powResultUpsilon = functionCallCase-&gt;appendNew&lt;UpsilonValue&gt;(procedure, origin, powResult);
+    functionCallCase-&gt;appendNew&lt;ControlValue&gt;(procedure, Jump, origin, FrequentedBlock(continuation));
+
+    // Loop pre-header.
+    Value* initialResult = loopPreHeaderCase-&gt;appendNew&lt;ConstDoubleValue&gt;(procedure, origin, 1.);
+    UpsilonValue* initialLoopValue = loopPreHeaderCase-&gt;appendNew&lt;UpsilonValue&gt;(procedure, origin, initialResult);
+    UpsilonValue* initialResultValue = loopPreHeaderCase-&gt;appendNew&lt;UpsilonValue&gt;(procedure, origin, initialResult);
+    UpsilonValue* initialSquaredInput = loopPreHeaderCase-&gt;appendNew&lt;UpsilonValue&gt;(procedure, origin, x);
+    UpsilonValue* initialLoopCounter = loopPreHeaderCase-&gt;appendNew&lt;UpsilonValue&gt;(procedure, origin, y);
+    loopPreHeaderCase-&gt;appendNew&lt;ControlValue&gt;(procedure, Jump, origin, FrequentedBlock(loopTestForEvenCase));
+
+    // Test if what is left of the counter is even.
+    Value* inLoopCounter = loopTestForEvenCase-&gt;appendNew&lt;Value&gt;(procedure, Phi, Int32, origin);
+    Value* inLoopSquaredInput = loopTestForEvenCase-&gt;appendNew&lt;Value&gt;(procedure, Phi, Double, origin);
+    Value* lastCounterBit = loopTestForEvenCase-&gt;appendNew&lt;Value&gt;(procedure, BitAnd, origin,
+        inLoopCounter,
+        loopTestForEvenCase-&gt;appendNew&lt;Const32Value&gt;(procedure, origin, 1));
+    loopTestForEvenCase-&gt;appendNew&lt;ControlValue&gt;(
+        procedure, Branch, origin,
+        lastCounterBit,
+        FrequentedBlock(loopOdd), FrequentedBlock(loopEvenOdd));
+
+    // Counter is odd.
+    Value* inLoopResult = loopOdd-&gt;appendNew&lt;Value&gt;(procedure, Phi, Double, origin);
+    Value* updatedResult = loopOdd-&gt;appendNew&lt;Value&gt;(procedure, Mul, origin, inLoopResult, inLoopSquaredInput);
+    UpsilonValue* updatedLoopResultUpsilon = loopOdd-&gt;appendNew&lt;UpsilonValue&gt;(procedure, origin, updatedResult);
+    initialLoopValue-&gt;setPhi(inLoopResult);
+    updatedLoopResultUpsilon-&gt;setPhi(inLoopResult);
+    UpsilonValue* updatedLoopResult = loopOdd-&gt;appendNew&lt;UpsilonValue&gt;(procedure, origin, updatedResult);
+
+    loopOdd-&gt;appendNew&lt;ControlValue&gt;(procedure, Jump, origin, FrequentedBlock(loopEvenOdd));
+
+    // Even value and following the Odd.
+    Value* squaredInput = loopEvenOdd-&gt;appendNew&lt;Value&gt;(procedure, Mul, origin, inLoopSquaredInput, inLoopSquaredInput);
+    UpsilonValue* squaredInputUpsilon = loopEvenOdd-&gt;appendNew&lt;UpsilonValue&gt;(procedure, origin, squaredInput);
+    initialSquaredInput-&gt;setPhi(inLoopSquaredInput);
+    squaredInputUpsilon-&gt;setPhi(inLoopSquaredInput);
+
+    Value* updatedCounter = loopEvenOdd-&gt;appendNew&lt;Value&gt;(procedure, ZShr, origin,
+        inLoopCounter,
+        loopEvenOdd-&gt;appendNew&lt;Const32Value&gt;(procedure, origin, 1));
+    UpsilonValue* updatedCounterUpsilon = loopEvenOdd-&gt;appendNew&lt;UpsilonValue&gt;(procedure, origin, updatedCounter);
+    initialLoopCounter-&gt;setPhi(inLoopCounter);
+    updatedCounterUpsilon-&gt;setPhi(inLoopCounter);
+
+    loopEvenOdd-&gt;appendNew&lt;ControlValue&gt;(
+        procedure, Branch, origin,
+        updatedCounter,
+        FrequentedBlock(loopTestForEvenCase), FrequentedBlock(continuation));
+
+    // Inline loop.
+    Value* finalResultPhi = continuation-&gt;appendNew&lt;Value&gt;(procedure, Phi, Double, origin);
+    powResultUpsilon-&gt;setPhi(finalResultPhi);
+    initialResultValue-&gt;setPhi(finalResultPhi);
+    updatedLoopResult-&gt;setPhi(finalResultPhi);
+    return std::make_pair(continuation, finalResultPhi);
+}
+
+} } // namespace JSC::B3
+
+#endif // ENABLE(B3_JIT)
+
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreb3B3MathExtrash"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/b3/B3MathExtras.h (0 => 193989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/b3/B3MathExtras.h                                (rev 0)
+++ trunk/Source/JavaScriptCore/b3/B3MathExtras.h        2015-12-11 23:45:04 UTC (rev 193989)
</span><span class="lines">@@ -0,0 +1,48 @@
</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 B3MathExtras_h
+#define B3MathExtras_h
+
+#if ENABLE(B3_JIT)
+
+#include &quot;B3Origin.h&quot;
+
+namespace JSC { namespace B3 {
+
+class BasicBlock;
+class Procedure;
+class Value;
+
+// Raise &quot;x&quot; to &quot;y&quot; power.
+// Return a new block continuing the flow and the value representing the result.
+JS_EXPORT_PRIVATE std::pair&lt;BasicBlock*, Value*&gt; powDoubleInt32(Procedure&amp;, BasicBlock*, Origin, Value* x, Value* y);
+
+} } // namespace JSC::B3
+
+#endif // ENABLE(B3_JIT)
+
+#endif // B3MathExtras_h
+
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreb3B3MemoryValueh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/b3/B3MemoryValue.h (193988 => 193989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/b3/B3MemoryValue.h        2015-12-11 23:30:34 UTC (rev 193988)
+++ trunk/Source/JavaScriptCore/b3/B3MemoryValue.h        2015-12-11 23:45:04 UTC (rev 193989)
</span><span class="lines">@@ -20,7 +20,7 @@
</span><span class="cx">  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
</span><span class="cx">  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
</span><span class="cx">  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
</span><del>- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
</del><ins>+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> #ifndef B3MemoryValue_h
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreb3testb3cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/b3/testb3.cpp (193988 => 193989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/b3/testb3.cpp        2015-12-11 23:30:34 UTC (rev 193988)
+++ trunk/Source/JavaScriptCore/b3/testb3.cpp        2015-12-11 23:45:04 UTC (rev 193989)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx"> #include &quot;B3ConstPtrValue.h&quot;
</span><span class="cx"> #include &quot;B3ControlValue.h&quot;
</span><span class="cx"> #include &quot;B3Effects.h&quot;
</span><ins>+#include &quot;B3MathExtras.h&quot;
</ins><span class="cx"> #include &quot;B3MemoryValue.h&quot;
</span><span class="cx"> #include &quot;B3Procedure.h&quot;
</span><span class="cx"> #include &quot;B3StackSlotValue.h&quot;
</span><span class="lines">@@ -7111,6 +7112,21 @@
</span><span class="cx">     CHECK(invoke&lt;intptr_t&gt;(*code, 43, 642462, 32533) == 32533);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void testPowDoubleByIntegerLoop(double xOperand, int32_t yOperand)
+{
+    Procedure proc;
+    BasicBlock* root = proc.addBlock();
+
+    Value* x = root-&gt;appendNew&lt;ArgumentRegValue&gt;(proc, Origin(), FPRInfo::argumentFPR0);
+    Value* y = root-&gt;appendNew&lt;Value&gt;(proc, Trunc, Origin(),
+        root-&gt;appendNew&lt;ArgumentRegValue&gt;(proc, Origin(), GPRInfo::argumentGPR0));
+    auto result = powDoubleInt32(proc, root, Origin(), x, y);
+    BasicBlock* continuation = result.first;
+    continuation-&gt;appendNew&lt;ControlValue&gt;(proc, Return, Origin(), result.second);
+
+    CHECK(isIdentical(compileAndRun&lt;double&gt;(proc, xOperand, yOperand), pow(xOperand, yOperand)));
+}
+
</ins><span class="cx"> // Make sure the compiler does not try to optimize anything out.
</span><span class="cx"> NEVER_INLINE double zero()
</span><span class="cx"> {
</span><span class="lines">@@ -8056,6 +8072,7 @@
</span><span class="cx">     RUN(testSelectFold(42));
</span><span class="cx">     RUN(testSelectFold(43));
</span><span class="cx">     RUN(testSelectInvert());
</span><ins>+    RUN_BINARY(testPowDoubleByIntegerLoop, floatingPointOperands&lt;double&gt;(), int64Operands());
</ins><span class="cx"> 
</span><span class="cx">     if (tasks.isEmpty())
</span><span class="cx">         usage();
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGSpeculativeJITcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp (193988 => 193989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp        2015-12-11 23:30:34 UTC (rev 193988)
+++ trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp        2015-12-11 23:45:04 UTC (rev 193989)
</span><span class="lines">@@ -4223,8 +4223,7 @@
</span><span class="cx"> static MacroAssembler::Jump compileArithPowIntegerFastPath(JITCompiler&amp; assembler, FPRReg xOperand, GPRReg yOperand, FPRReg result)
</span><span class="cx"> {
</span><span class="cx">     MacroAssembler::JumpList skipFastPath;
</span><del>-    skipFastPath.append(assembler.branch32(MacroAssembler::LessThan, yOperand, MacroAssembler::TrustedImm32(0)));
-    skipFastPath.append(assembler.branch32(MacroAssembler::GreaterThan, yOperand, MacroAssembler::TrustedImm32(1000)));
</del><ins>+    skipFastPath.append(assembler.branch32(MacroAssembler::Above, yOperand, MacroAssembler::TrustedImm32(1000)));
</ins><span class="cx"> 
</span><span class="cx">     static const double oneConstant = 1.0;
</span><span class="cx">     assembler.loadDouble(MacroAssembler::TrustedImmPtr(&amp;oneConstant), result);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreftlFTLB3Outputcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ftl/FTLB3Output.cpp (193988 => 193989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ftl/FTLB3Output.cpp        2015-12-11 23:30:34 UTC (rev 193988)
+++ trunk/Source/JavaScriptCore/ftl/FTLB3Output.cpp        2015-12-11 23:45:04 UTC (rev 193989)
</span><span class="lines">@@ -29,6 +29,8 @@
</span><span class="cx"> #if ENABLE(FTL_JIT)
</span><span class="cx"> #if FTL_USES_B3
</span><span class="cx"> 
</span><ins>+#include &quot;B3MathExtras.h&quot;
+
</ins><span class="cx"> namespace JSC { namespace FTL {
</span><span class="cx"> 
</span><span class="cx"> Output::Output(State&amp; state)
</span><span class="lines">@@ -69,6 +71,13 @@
</span><span class="cx">     return load;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+LValue Output::doublePowi(LValue x, LValue y)
+{
+    auto result = powDoubleInt32(m_proc, m_block, origin(), x, y);
+    m_block = result.first;
+    return result.second;
+}
+
</ins><span class="cx"> LValue Output::load8SignExt32(TypedPointer pointer)
</span><span class="cx"> {
</span><span class="cx">     LValue load = m_block-&gt;appendNew&lt;B3::MemoryValue&gt;(m_proc, B3::Load8S, B3::Int32, origin(), pointer.value());
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreftlFTLB3Outputh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ftl/FTLB3Output.h (193988 => 193989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ftl/FTLB3Output.h        2015-12-11 23:30:34 UTC (rev 193988)
+++ trunk/Source/JavaScriptCore/ftl/FTLB3Output.h        2015-12-11 23:45:04 UTC (rev 193989)
</span><span class="lines">@@ -169,7 +169,7 @@
</span><span class="cx"> 
</span><span class="cx">     LValue doublePow(LValue xOperand, LValue yOperand) { return callWithoutSideEffects(B3::Double, pow, xOperand, yOperand); }
</span><span class="cx"> 
</span><del>-    LValue doublePowi(LValue xOperand, LValue yOperand) { CRASH(); }
</del><ins>+    LValue doublePowi(LValue xOperand, LValue yOperand);
</ins><span class="cx"> 
</span><span class="cx">     LValue doubleSqrt(LValue value) { return m_block-&gt;appendNew&lt;B3::Value&gt;(m_proc, B3::Sqrt, origin(), value); }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>