<!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>[192619] 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/192619">192619</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2015-11-19 00:38:17 -0800 (Thu, 19 Nov 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>[JSC] Add bitwise Double-Int conversion to B3
https://bugs.webkit.org/show_bug.cgi?id=151432
Patch by Benjamin Poulain <bpoulain@apple.com> on 2015-11-19
Reviewed by Filip Pizlo.
This is needed for boxing/unboxing doubles.
* b3/B3Const64Value.cpp:
(JSC::B3::Const64Value::bitwiseCastConstant):
* b3/B3Const64Value.h:
* b3/B3ConstDoubleValue.cpp:
(JSC::B3::ConstDoubleValue::bitwiseCastConstant):
* b3/B3ConstDoubleValue.h:
* b3/B3LowerToAir.cpp:
(JSC::B3::Air::LowerToAir::lower):
* b3/B3Opcode.cpp:
(WTF::printInternal):
* b3/B3Opcode.h:
* b3/B3ReduceStrength.cpp:
* b3/B3Validate.cpp:
* b3/B3Value.cpp:
(JSC::B3::Value::bitwiseCastConstant):
(JSC::B3::Value::effects):
(JSC::B3::Value::typeFor):
* b3/B3Value.h:
* b3/air/AirOpcode.opcodes:
* b3/testb3.cpp:
(JSC::B3::testDoubleArgToInt64BitwiseCast):
(JSC::B3::testDoubleImmToInt64BitwiseCast):
(JSC::B3::testTwoBitwiseCastOnDouble):
(JSC::B3::testBitwiseCastOnDoubleInMemory):
(JSC::B3::testInt64BArgToDoubleBitwiseCast):
(JSC::B3::testInt64BImmToDoubleBitwiseCast):
(JSC::B3::testTwoBitwiseCastOnInt64):
(JSC::B3::testBitwiseCastOnInt64InMemory):
(JSC::B3::int64Operands):
(JSC::B3::run):
* ftl/FTLB3Output.h:
(JSC::FTL::Output::bitCast):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreb3B3Const64Valuecpp">trunk/Source/JavaScriptCore/b3/B3Const64Value.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreb3B3Const64Valueh">trunk/Source/JavaScriptCore/b3/B3Const64Value.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreb3B3ConstDoubleValuecpp">trunk/Source/JavaScriptCore/b3/B3ConstDoubleValue.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreb3B3ConstDoubleValueh">trunk/Source/JavaScriptCore/b3/B3ConstDoubleValue.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreb3B3LowerToAircpp">trunk/Source/JavaScriptCore/b3/B3LowerToAir.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreb3B3Opcodecpp">trunk/Source/JavaScriptCore/b3/B3Opcode.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreb3B3Opcodeh">trunk/Source/JavaScriptCore/b3/B3Opcode.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreb3B3ReduceStrengthcpp">trunk/Source/JavaScriptCore/b3/B3ReduceStrength.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreb3B3Validatecpp">trunk/Source/JavaScriptCore/b3/B3Validate.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreb3B3Valuecpp">trunk/Source/JavaScriptCore/b3/B3Value.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreb3B3Valueh">trunk/Source/JavaScriptCore/b3/B3Value.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreb3airAirOpcodeopcodes">trunk/Source/JavaScriptCore/b3/air/AirOpcode.opcodes</a></li>
<li><a href="#trunkSourceJavaScriptCoreb3testb3cpp">trunk/Source/JavaScriptCore/b3/testb3.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreftlFTLB3Outputh">trunk/Source/JavaScriptCore/ftl/FTLB3Output.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (192618 => 192619)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2015-11-19 08:19:56 UTC (rev 192618)
+++ trunk/Source/JavaScriptCore/ChangeLog        2015-11-19 08:38:17 UTC (rev 192619)
</span><span class="lines">@@ -1,3 +1,45 @@
</span><ins>+2015-11-19 Benjamin Poulain <bpoulain@apple.com>
+
+ [JSC] Add bitwise Double-Int conversion to B3
+ https://bugs.webkit.org/show_bug.cgi?id=151432
+
+ Reviewed by Filip Pizlo.
+
+ This is needed for boxing/unboxing doubles.
+
+ * b3/B3Const64Value.cpp:
+ (JSC::B3::Const64Value::bitwiseCastConstant):
+ * b3/B3Const64Value.h:
+ * b3/B3ConstDoubleValue.cpp:
+ (JSC::B3::ConstDoubleValue::bitwiseCastConstant):
+ * b3/B3ConstDoubleValue.h:
+ * b3/B3LowerToAir.cpp:
+ (JSC::B3::Air::LowerToAir::lower):
+ * b3/B3Opcode.cpp:
+ (WTF::printInternal):
+ * b3/B3Opcode.h:
+ * b3/B3ReduceStrength.cpp:
+ * b3/B3Validate.cpp:
+ * b3/B3Value.cpp:
+ (JSC::B3::Value::bitwiseCastConstant):
+ (JSC::B3::Value::effects):
+ (JSC::B3::Value::typeFor):
+ * b3/B3Value.h:
+ * b3/air/AirOpcode.opcodes:
+ * b3/testb3.cpp:
+ (JSC::B3::testDoubleArgToInt64BitwiseCast):
+ (JSC::B3::testDoubleImmToInt64BitwiseCast):
+ (JSC::B3::testTwoBitwiseCastOnDouble):
+ (JSC::B3::testBitwiseCastOnDoubleInMemory):
+ (JSC::B3::testInt64BArgToDoubleBitwiseCast):
+ (JSC::B3::testInt64BImmToDoubleBitwiseCast):
+ (JSC::B3::testTwoBitwiseCastOnInt64):
+ (JSC::B3::testBitwiseCastOnInt64InMemory):
+ (JSC::B3::int64Operands):
+ (JSC::B3::run):
+ * ftl/FTLB3Output.h:
+ (JSC::FTL::Output::bitCast):
+
</ins><span class="cx"> 2015-11-18 Benjamin Poulain <bpoulain@apple.com>
</span><span class="cx">
</span><span class="cx"> [JSC] Add some missing load/store to FTLB3Output
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreb3B3Const64Valuecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/b3/B3Const64Value.cpp (192618 => 192619)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/b3/B3Const64Value.cpp        2015-11-19 08:19:56 UTC (rev 192618)
+++ trunk/Source/JavaScriptCore/b3/B3Const64Value.cpp        2015-11-19 08:38:17 UTC (rev 192619)
</span><span class="lines">@@ -154,6 +154,11 @@
</span><span class="cx"> return proc.add<Const64Value>(origin(), static_cast<int64_t>(static_cast<uint64_t>(m_value) >> (other->asInt32() & 63)));
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+Value* Const64Value::bitwiseCastConstant(Procedure& proc) const
+{
+ return proc.add<ConstDoubleValue>(origin(), bitwise_cast<double>(m_value));
+}
+
</ins><span class="cx"> TriState Const64Value::equalConstant(const Value* other) const
</span><span class="cx"> {
</span><span class="cx"> if (!other->hasInt64())
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreb3B3Const64Valueh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/b3/B3Const64Value.h (192618 => 192619)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/b3/B3Const64Value.h        2015-11-19 08:19:56 UTC (rev 192618)
+++ trunk/Source/JavaScriptCore/b3/B3Const64Value.h        2015-11-19 08:38:17 UTC (rev 192619)
</span><span class="lines">@@ -56,6 +56,7 @@
</span><span class="cx"> Value* shlConstant(Procedure&, const Value* other) const override;
</span><span class="cx"> Value* sShrConstant(Procedure&, const Value* other) const override;
</span><span class="cx"> Value* zShrConstant(Procedure&, const Value* other) const override;
</span><ins>+ Value* bitwiseCastConstant(Procedure&) const override;
</ins><span class="cx">
</span><span class="cx"> TriState equalConstant(const Value* other) const override;
</span><span class="cx"> TriState notEqualConstant(const Value* other) const override;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreb3B3ConstDoubleValuecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/b3/B3ConstDoubleValue.cpp (192618 => 192619)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/b3/B3ConstDoubleValue.cpp        2015-11-19 08:19:56 UTC (rev 192618)
+++ trunk/Source/JavaScriptCore/b3/B3ConstDoubleValue.cpp        2015-11-19 08:38:17 UTC (rev 192619)
</span><span class="lines">@@ -68,6 +68,11 @@
</span><span class="cx"> return proc.add<ConstDoubleValue>(origin(), m_value * other->asDouble());
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+Value* ConstDoubleValue::bitwiseCastConstant(Procedure& proc) const
+{
+ return proc.add<Const64Value>(origin(), bitwise_cast<int64_t>(m_value));
+}
+
</ins><span class="cx"> Value* ConstDoubleValue::divConstant(Procedure& proc, const Value* other) const
</span><span class="cx"> {
</span><span class="cx"> if (!other->hasDouble())
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreb3B3ConstDoubleValueh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/b3/B3ConstDoubleValue.h (192618 => 192619)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/b3/B3ConstDoubleValue.h        2015-11-19 08:19:56 UTC (rev 192618)
+++ trunk/Source/JavaScriptCore/b3/B3ConstDoubleValue.h        2015-11-19 08:38:17 UTC (rev 192619)
</span><span class="lines">@@ -46,6 +46,7 @@
</span><span class="cx"> Value* subConstant(Procedure&, const Value* other) const override;
</span><span class="cx"> Value* divConstant(Procedure&, const Value* other) const override;
</span><span class="cx"> Value* mulConstant(Procedure&, const Value* other) const override;
</span><ins>+ Value* bitwiseCastConstant(Procedure&) const override;
</ins><span class="cx">
</span><span class="cx"> TriState equalConstant(const Value* other) const override;
</span><span class="cx"> TriState notEqualConstant(const Value* other) const override;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreb3B3LowerToAircpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/b3/B3LowerToAir.cpp (192618 => 192619)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/b3/B3LowerToAir.cpp        2015-11-19 08:19:56 UTC (rev 192618)
+++ trunk/Source/JavaScriptCore/b3/B3LowerToAir.cpp        2015-11-19 08:38:17 UTC (rev 192619)
</span><span class="lines">@@ -1344,6 +1344,11 @@
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ case BitwiseCast: {
+ appendUnOp<Air::Oops, Move64ToDouble, MoveDoubleTo64>(m_value->child(0));
+ return;
+ }
+
</ins><span class="cx"> case Store: {
</span><span class="cx"> Value* valueToStore = m_value->child(0);
</span><span class="cx"> if (canBeInternal(valueToStore)) {
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreb3B3Opcodecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/b3/B3Opcode.cpp (192618 => 192619)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/b3/B3Opcode.cpp        2015-11-19 08:19:56 UTC (rev 192618)
+++ trunk/Source/JavaScriptCore/b3/B3Opcode.cpp        2015-11-19 08:38:17 UTC (rev 192619)
</span><span class="lines">@@ -137,6 +137,9 @@
</span><span class="cx"> case ZShr:
</span><span class="cx"> out.print("ZShr");
</span><span class="cx"> return;
</span><ins>+ case BitwiseCast:
+ out.print("BitwiseCast");
+ return;
</ins><span class="cx"> case SExt8:
</span><span class="cx"> out.print("SExt8");
</span><span class="cx"> return;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreb3B3Opcodeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/b3/B3Opcode.h (192618 => 192619)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/b3/B3Opcode.h        2015-11-19 08:19:56 UTC (rev 192618)
+++ trunk/Source/JavaScriptCore/b3/B3Opcode.h        2015-11-19 08:38:17 UTC (rev 192619)
</span><span class="lines">@@ -82,6 +82,8 @@
</span><span class="cx"> ZShr, // Logical Shift.
</span><span class="cx">
</span><span class="cx"> // Casts and such.
</span><ins>+ // Bitwise Cast of Double->Int64 or Int64->Double
+ BitwiseCast,
</ins><span class="cx"> // Takes and returns Int32:
</span><span class="cx"> SExt8,
</span><span class="cx"> SExt16,
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreb3B3ReduceStrengthcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/b3/B3ReduceStrength.cpp (192618 => 192619)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/b3/B3ReduceStrength.cpp        2015-11-19 08:19:56 UTC (rev 192618)
+++ trunk/Source/JavaScriptCore/b3/B3ReduceStrength.cpp        2015-11-19 08:38:17 UTC (rev 192619)
</span><span class="lines">@@ -464,6 +464,24 @@
</span><span class="cx">
</span><span class="cx"> break;
</span><span class="cx">
</span><ins>+ case BitwiseCast:
+ // Turn this: BitwiseCast(constant)
+ // Into this: bitwise_cast<value->type()>(constant)
+ if (Value* constant = m_value->child(0)->bitwiseCastConstant(m_proc)) {
+ replaceWithNewValue(constant);
+ break;
+ }
+
+ // Turn this: BitwiseCast(BitwiseCast(value))
+ // Into this: value
+ if (m_value->child(0)->opcode() == BitwiseCast) {
+ m_value->replaceWithIdentity(m_value->child(0)->child(0));
+ m_changed = true;
+ break;
+ }
+
+ break;
+
</ins><span class="cx"> case Load8Z:
</span><span class="cx"> case Load8S:
</span><span class="cx"> case Load16Z:
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreb3B3Validatecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/b3/B3Validate.cpp (192618 => 192619)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/b3/B3Validate.cpp        2015-11-19 08:19:56 UTC (rev 192618)
+++ trunk/Source/JavaScriptCore/b3/B3Validate.cpp        2015-11-19 08:38:17 UTC (rev 192619)
</span><span class="lines">@@ -172,6 +172,14 @@
</span><span class="cx"> VALIDATE(value->child(1)->type() == Int32, ("At ", *value));
</span><span class="cx"> VALIDATE(isInt(value->type()), ("At ", *value));
</span><span class="cx"> break;
</span><ins>+ case BitwiseCast:
+ VALIDATE(value->numChildren() == 1, ("At ", *value));
+ VALIDATE(value->type() != value->child(0)->type(), ("At ", *value));
+ VALIDATE(
+ (value->type() == Int64 && value->child(0)->type() == Double)
+ || (value->type() == Double && value->child(0)->type() == Int64),
+ ("At ", *value));
+ break;
</ins><span class="cx"> case SExt8:
</span><span class="cx"> case SExt16:
</span><span class="cx"> VALIDATE(value->numChildren() == 1, ("At ", *value));
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreb3B3Valuecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/b3/B3Value.cpp (192618 => 192619)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/b3/B3Value.cpp        2015-11-19 08:19:56 UTC (rev 192618)
+++ trunk/Source/JavaScriptCore/b3/B3Value.cpp        2015-11-19 08:38:17 UTC (rev 192619)
</span><span class="lines">@@ -194,6 +194,11 @@
</span><span class="cx"> return nullptr;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+Value* Value::bitwiseCastConstant(Procedure&) const
+{
+ return nullptr;
+}
+
</ins><span class="cx"> TriState Value::equalConstant(const Value*) const
</span><span class="cx"> {
</span><span class="cx"> return MixedTriState;
</span><span class="lines">@@ -320,6 +325,7 @@
</span><span class="cx"> case Shl:
</span><span class="cx"> case SShr:
</span><span class="cx"> case ZShr:
</span><ins>+ case BitwiseCast:
</ins><span class="cx"> case SExt8:
</span><span class="cx"> case SExt16:
</span><span class="cx"> case SExt32:
</span><span class="lines">@@ -514,6 +520,13 @@
</span><span class="cx"> case FRound:
</span><span class="cx"> case IToD:
</span><span class="cx"> return Double;
</span><ins>+ case BitwiseCast:
+ if (firstChild->type() == Int64)
+ return Double;
+ if (firstChild->type() == Double)
+ return Int64;
+ ASSERT_NOT_REACHED();
+ return Void;
</ins><span class="cx"> case Nop:
</span><span class="cx"> return Void;
</span><span class="cx"> default:
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreb3B3Valueh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/b3/B3Value.h (192618 => 192619)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/b3/B3Value.h        2015-11-19 08:19:56 UTC (rev 192618)
+++ trunk/Source/JavaScriptCore/b3/B3Value.h        2015-11-19 08:38:17 UTC (rev 192619)
</span><span class="lines">@@ -127,6 +127,7 @@
</span><span class="cx"> virtual Value* shlConstant(Procedure&, const Value* other) const;
</span><span class="cx"> virtual Value* sShrConstant(Procedure&, const Value* other) const;
</span><span class="cx"> virtual Value* zShrConstant(Procedure&, const Value* other) const;
</span><ins>+ virtual Value* bitwiseCastConstant(Procedure&) const;
</ins><span class="cx">
</span><span class="cx"> virtual TriState equalConstant(const Value* other) const;
</span><span class="cx"> virtual TriState notEqualConstant(const Value* other) const;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreb3airAirOpcodeopcodes"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/b3/air/AirOpcode.opcodes (192618 => 192619)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/b3/air/AirOpcode.opcodes        2015-11-19 08:19:56 UTC (rev 192618)
+++ trunk/Source/JavaScriptCore/b3/air/AirOpcode.opcodes        2015-11-19 08:38:17 UTC (rev 192619)
</span><span class="lines">@@ -237,9 +237,11 @@
</span><span class="cx">
</span><span class="cx"> Move64ToDouble U:G, D:F
</span><span class="cx"> Tmp, Tmp
</span><ins>+ Addr, Tmp as loadDouble
</ins><span class="cx">
</span><span class="cx"> MoveDoubleTo64 U:F, D:G
</span><span class="cx"> Tmp, Tmp
</span><ins>+ Addr, Tmp as load64
</ins><span class="cx">
</span><span class="cx"> Load8 U:G, D:G
</span><span class="cx"> Addr, Tmp
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreb3testb3cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/b3/testb3.cpp (192618 => 192619)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/b3/testb3.cpp        2015-11-19 08:19:56 UTC (rev 192618)
+++ trunk/Source/JavaScriptCore/b3/testb3.cpp        2015-11-19 08:38:17 UTC (rev 192619)
</span><span class="lines">@@ -1729,6 +1729,110 @@
</span><span class="cx"> CHECK(compileAndRun<uint32_t>(proc, a) == (a >> b));
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void testDoubleArgToInt64BitwiseCast(double value)
+{
+ Procedure proc;
+ BasicBlock* root = proc.addBlock();
+ Value* argument = root->appendNew<ArgumentRegValue>(proc, Origin(), FPRInfo::argumentFPR0);
+
+ root->appendNew<ControlValue>(
+ proc, Return, Origin(),
+ root->appendNew<Value>(
+ proc, BitwiseCast, Origin(), argument));
+
+ CHECK(isIdentical(compileAndRun<int64_t>(proc, value), bitwise_cast<int64_t>(value)));
+}
+
+void testDoubleImmToInt64BitwiseCast(double value)
+{
+ Procedure proc;
+ BasicBlock* root = proc.addBlock();
+ Value* argument = root->appendNew<ConstDoubleValue>(proc, Origin(), value);
+
+ root->appendNew<ControlValue>(
+ proc, Return, Origin(),
+ root->appendNew<Value>(
+ proc, BitwiseCast, Origin(), argument));
+
+ CHECK(isIdentical(compileAndRun<int64_t>(proc), bitwise_cast<int64_t>(value)));
+}
+
+void testTwoBitwiseCastOnDouble(double value)
+{
+ Procedure proc;
+ BasicBlock* root = proc.addBlock();
+ Value* argument = root->appendNew<ArgumentRegValue>(proc, Origin(), FPRInfo::argumentFPR0);
+ Value* first = root->appendNew<Value>(proc, BitwiseCast, Origin(), argument);
+ Value* second = root->appendNew<Value>(proc, BitwiseCast, Origin(), first);
+ root->appendNew<ControlValue>(proc, Return, Origin(), second);
+
+ CHECK(isIdentical(compileAndRun<double>(proc, value), value));
+}
+
+void testBitwiseCastOnDoubleInMemory(double value)
+{
+ Procedure proc;
+ BasicBlock* root = proc.addBlock();
+ Value* address = root->appendNew<ArgumentRegValue>(proc, Origin(), GPRInfo::argumentGPR0);
+ MemoryValue* loadDouble = root->appendNew<MemoryValue>(proc, Load, Double, Origin(), address);
+ Value* cast = root->appendNew<Value>(proc, BitwiseCast, Origin(), loadDouble);
+ root->appendNew<ControlValue>(proc, Return, Origin(), cast);
+
+ CHECK(isIdentical(compileAndRun<int64_t>(proc, &value), bitwise_cast<int64_t>(value)));
+}
+
+void testInt64BArgToDoubleBitwiseCast(int64_t value)
+{
+ Procedure proc;
+ BasicBlock* root = proc.addBlock();
+ Value* argument = root->appendNew<ArgumentRegValue>(proc, Origin(), GPRInfo::argumentGPR0);
+
+ root->appendNew<ControlValue>(
+ proc, Return, Origin(),
+ root->appendNew<Value>(
+ proc, BitwiseCast, Origin(), argument));
+
+ CHECK(isIdentical(compileAndRun<double>(proc, value), bitwise_cast<double>(value)));
+}
+
+void testInt64BImmToDoubleBitwiseCast(int64_t value)
+{
+ Procedure proc;
+ BasicBlock* root = proc.addBlock();
+ Value* argument = root->appendNew<Const64Value>(proc, Origin(), value);
+
+ root->appendNew<ControlValue>(
+ proc, Return, Origin(),
+ root->appendNew<Value>(
+ proc, BitwiseCast, Origin(), argument));
+
+ CHECK(isIdentical(compileAndRun<double>(proc), bitwise_cast<double>(value)));
+}
+
+void testTwoBitwiseCastOnInt64(int64_t value)
+{
+ Procedure proc;
+ BasicBlock* root = proc.addBlock();
+ Value* argument = root->appendNew<ArgumentRegValue>(proc, Origin(), GPRInfo::argumentGPR0);
+ Value* first = root->appendNew<Value>(proc, BitwiseCast, Origin(), argument);
+ Value* second = root->appendNew<Value>(proc, BitwiseCast, Origin(), first);
+ root->appendNew<ControlValue>(proc, Return, Origin(), second);
+
+ CHECK(isIdentical(compileAndRun<int64_t>(proc, value), value));
+}
+
+void testBitwiseCastOnInt64InMemory(int64_t value)
+{
+ Procedure proc;
+ BasicBlock* root = proc.addBlock();
+ Value* address = root->appendNew<ArgumentRegValue>(proc, Origin(), GPRInfo::argumentGPR0);
+ MemoryValue* loadDouble = root->appendNew<MemoryValue>(proc, Load, Int64, Origin(), address);
+ Value* cast = root->appendNew<Value>(proc, BitwiseCast, Origin(), loadDouble);
+ root->appendNew<ControlValue>(proc, Return, Origin(), cast);
+
+ CHECK(isIdentical(compileAndRun<double>(proc, &value), bitwise_cast<double>(value)));
+}
+
</ins><span class="cx"> void testStore(int value)
</span><span class="cx"> {
</span><span class="cx"> Procedure proc;
</span><span class="lines">@@ -4547,12 +4651,15 @@
</span><span class="cx"> return -std::numeric_limits<double>::infinity();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-
-struct DoubleOperand {
</del><ins>+template<typename Type>
+struct Operand {
</ins><span class="cx"> const char* name;
</span><del>- double value;
</del><ins>+ Type value;
</ins><span class="cx"> };
</span><span class="cx">
</span><ins>+typedef Operand<double> DoubleOperand;
+typedef Operand<int64_t> Int64Operand;
+
</ins><span class="cx"> static const std::array<DoubleOperand, 9>& doubleOperands()
</span><span class="cx"> {
</span><span class="cx"> static const std::array<DoubleOperand, 9> operands = {{
</span><span class="lines">@@ -4569,6 +4676,14 @@
</span><span class="cx"> return operands;
</span><span class="cx"> };
</span><span class="cx">
</span><ins>+static Vector<Int64Operand> int64Operands()
+{
+ Vector<Int64Operand> operands;
+ for (DoubleOperand doubleOperand : doubleOperands())
+ operands.append({ doubleOperand.name, bitwise_cast<int64_t>(doubleOperand.value) });
+ return operands;
+}
+
</ins><span class="cx"> #define RUN(test) do { \
</span><span class="cx"> if (!shouldRun(#test)) \
</span><span class="cx"> break; \
</span><span class="lines">@@ -5052,6 +5167,15 @@
</span><span class="cx"> RUN(testZShrArgImm32(0xffffffff, 1));
</span><span class="cx"> RUN(testZShrArgImm32(0xffffffff, 63));
</span><span class="cx">
</span><ins>+ RUN_UNARY(testDoubleArgToInt64BitwiseCast, doubleOperands());
+ RUN_UNARY(testDoubleImmToInt64BitwiseCast, doubleOperands());
+ RUN_UNARY(testTwoBitwiseCastOnDouble, doubleOperands());
+ RUN_UNARY(testBitwiseCastOnDoubleInMemory, doubleOperands());
+ RUN_UNARY(testInt64BArgToDoubleBitwiseCast, int64Operands());
+ RUN_UNARY(testInt64BImmToDoubleBitwiseCast, int64Operands());
+ RUN_UNARY(testTwoBitwiseCastOnInt64, int64Operands());
+ RUN_UNARY(testBitwiseCastOnInt64InMemory, int64Operands());
+
</ins><span class="cx"> RUN(testStore(44));
</span><span class="cx"> RUN(testStoreConstant(49));
</span><span class="cx"> RUN(testStoreConstantPtr(49));
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreftlFTLB3Outputh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ftl/FTLB3Output.h (192618 => 192619)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ftl/FTLB3Output.h        2015-11-19 08:19:56 UTC (rev 192618)
+++ trunk/Source/JavaScriptCore/ftl/FTLB3Output.h        2015-11-19 08:38:17 UTC (rev 192619)
</span><span class="lines">@@ -189,7 +189,7 @@
</span><span class="cx"> LValue fpCast(LValue value, LType type) { CRASH(); }
</span><span class="cx"> LValue intToPtr(LValue value, LType type) { CRASH(); }
</span><span class="cx"> LValue ptrToInt(LValue value, LType type) { CRASH(); }
</span><del>- LValue bitCast(LValue value, LType type) { CRASH(); }
</del><ins>+ LValue bitCast(LValue, LType);
</ins><span class="cx">
</span><span class="cx"> LValue fround(LValue doubleValue) { CRASH(); }
</span><span class="cx">
</span><span class="lines">@@ -412,6 +412,11 @@
</span><span class="cx"> addIncomingToPhi(phi, theRest...);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+inline LValue Output::bitCast(LValue value, LType type)
+{
+ ASSERT_UNUSED(type, type == int64 || type == doubleType);
+ return m_block->appendNew<B3::Value>(m_proc, B3::BitwiseCast, origin(), value);
+}
</ins><span class="cx">
</span><span class="cx"> #if COMPILER(CLANG)
</span><span class="cx"> #pragma clang diagnostic pop
</span></span></pre>
</div>
</div>
</body>
</html>