<!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>[195296] 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/195296">195296</a></dd>
<dt>Author</dt> <dd>fpizlo@apple.com</dd>
<dt>Date</dt> <dd>2016-01-19 10:34:19 -0800 (Tue, 19 Jan 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Fix Air shuffling assertions
https://bugs.webkit.org/show_bug.cgi?id=153213
Reviewed by Saam Barati.
Fixes some assertions that I was seeing running JSC tests. Adds a new Air test.
* assembler/MacroAssemblerX86Common.h:
(JSC::MacroAssemblerX86Common::store8):
(JSC::MacroAssemblerX86Common::getUnusedRegister):
* b3/air/AirEmitShuffle.cpp:
(JSC::B3::Air::emitShuffle):
* b3/air/AirLowerAfterRegAlloc.cpp:
(JSC::B3::Air::lowerAfterRegAlloc):
* b3/air/testair.cpp:
(JSC::B3::Air::testShuffleRotateWithFringe):
(JSC::B3::Air::testShuffleRotateWithFringeInWeirdOrder):
(JSC::B3::Air::testShuffleRotateWithLongFringe):
(JSC::B3::Air::run):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreassemblerMacroAssemblerX86Commonh">trunk/Source/JavaScriptCore/assembler/MacroAssemblerX86Common.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreb3airAirEmitShufflecpp">trunk/Source/JavaScriptCore/b3/air/AirEmitShuffle.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreb3airAirLowerAfterRegAlloccpp">trunk/Source/JavaScriptCore/b3/air/AirLowerAfterRegAlloc.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreb3airtestaircpp">trunk/Source/JavaScriptCore/b3/air/testair.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGCommonh">trunk/Source/JavaScriptCore/dfg/DFGCommon.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (195295 => 195296)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-01-19 18:21:26 UTC (rev 195295)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-01-19 18:34:19 UTC (rev 195296)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2016-01-18 Filip Pizlo <fpizlo@apple.com>
+
+ Fix Air shuffling assertions
+ https://bugs.webkit.org/show_bug.cgi?id=153213
+
+ Reviewed by Saam Barati.
+
+ Fixes some assertions that I was seeing running JSC tests. Adds a new Air test.
+
+ * assembler/MacroAssemblerX86Common.h:
+ (JSC::MacroAssemblerX86Common::store8):
+ (JSC::MacroAssemblerX86Common::getUnusedRegister):
+ * b3/air/AirEmitShuffle.cpp:
+ (JSC::B3::Air::emitShuffle):
+ * b3/air/AirLowerAfterRegAlloc.cpp:
+ (JSC::B3::Air::lowerAfterRegAlloc):
+ * b3/air/testair.cpp:
+ (JSC::B3::Air::testShuffleRotateWithFringe):
+ (JSC::B3::Air::testShuffleRotateWithFringeInWeirdOrder):
+ (JSC::B3::Air::testShuffleRotateWithLongFringe):
+ (JSC::B3::Air::run):
+
</ins><span class="cx"> 2016-01-19 Konstantin Tokarev <annulen@yandex.ru>
</span><span class="cx">
</span><span class="cx"> [mips] Logical instructions allow immediates in range 0..0xffff, not 0x7fff
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreassemblerMacroAssemblerX86Commonh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/assembler/MacroAssemblerX86Common.h (195295 => 195296)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/assembler/MacroAssemblerX86Common.h        2016-01-19 18:21:26 UTC (rev 195295)
+++ trunk/Source/JavaScriptCore/assembler/MacroAssemblerX86Common.h        2016-01-19 18:34:19 UTC (rev 195296)
</span><span class="lines">@@ -733,14 +733,12 @@
</span><span class="cx">
</span><span class="cx"> void store8(TrustedImm32 imm, Address address)
</span><span class="cx"> {
</span><del>- ASSERT(-128 <= imm.m_value && imm.m_value < 128);
- m_assembler.movb_i8m(imm.m_value, address.offset, address.base);
</del><ins>+ m_assembler.movb_i8m(static_cast<int8_t>(imm.m_value), address.offset, address.base);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void store8(TrustedImm32 imm, BaseIndex address)
</span><span class="cx"> {
</span><del>- ASSERT(-128 <= imm.m_value && imm.m_value < 128);
- m_assembler.movb_i8m(imm.m_value, address.offset, address.base, address.index, address.scale);
</del><ins>+ m_assembler.movb_i8m(static_cast<int8_t>(imm.m_value), address.offset, address.base, address.index, address.scale);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static ALWAYS_INLINE RegisterID getUnusedRegister(BaseIndex address)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreb3airAirEmitShufflecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/b3/air/AirEmitShuffle.cpp (195295 => 195296)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/b3/air/AirEmitShuffle.cpp        2016-01-19 18:21:26 UTC (rev 195295)
+++ trunk/Source/JavaScriptCore/b3/air/AirEmitShuffle.cpp        2016-01-19 18:34:19 UTC (rev 195296)
</span><span class="lines">@@ -73,6 +73,12 @@
</span><span class="cx"> Vector<Inst> emitShuffle(
</span><span class="cx"> Vector<ShufflePair> pairs, std::array<Arg, 2> scratches, Arg::Type type, Value* origin)
</span><span class="cx"> {
</span><ins>+ if (verbose) {
+ dataLog(
+ "Dealing with pairs: ", listDump(pairs), " and scratches ", scratches[0], ", ",
+ scratches[1], "\n");
+ }
+
</ins><span class="cx"> pairs.removeAllMatching(
</span><span class="cx"> [&] (const ShufflePair& pair) -> bool {
</span><span class="cx"> return pair.src() == pair.dst();
</span><span class="lines">@@ -170,10 +176,18 @@
</span><span class="cx"> if (verbose)
</span><span class="cx"> dataLog("It's a rotate.\n");
</span><span class="cx"> Rotate rotate;
</span><ins>+
+ // The common case is that the rotate does not have fringe. The only way to
+ // check for this is to examine the whole rotate.
+ bool ok;
+ if (currentPairs.last().dst() == originalSrc) {
+ ok = true;
+ for (unsigned i = currentPairs.size() - 1; i--;)
+ ok &= currentPairs[i].dst() == currentPairs[i + 1].src();
+ } else
+ ok = false;
</ins><span class="cx">
</span><del>- // The common case is that the rotate does not have fringe. When this happens, the
- // last destination is the first source.
- if (currentPairs.last().dst() == originalSrc)
</del><ins>+ if (ok)
</ins><span class="cx"> rotate.loop = WTFMove(currentPairs);
</span><span class="cx"> else {
</span><span class="cx"> // This is the slow path. The rotate has fringe.
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreb3airAirLowerAfterRegAlloccpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/b3/air/AirLowerAfterRegAlloc.cpp (195295 => 195296)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/b3/air/AirLowerAfterRegAlloc.cpp        2016-01-19 18:21:26 UTC (rev 195295)
+++ trunk/Source/JavaScriptCore/b3/air/AirLowerAfterRegAlloc.cpp        2016-01-19 18:34:19 UTC (rev 195296)
</span><span class="lines">@@ -211,6 +211,11 @@
</span><span class="cx"> pairs.append(pair);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ // For finding scratch registers, we need to account for the possibility that
+ // the result is dead.
+ if (originalResult.isReg())
+ liveRegs.set(originalResult.reg());
+
</ins><span class="cx"> gpScratch = getScratches(liveRegs, Arg::GP);
</span><span class="cx"> fpScratch = getScratches(liveRegs, Arg::FP);
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreb3airtestaircpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/b3/air/testair.cpp (195295 => 195296)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/b3/air/testair.cpp        2016-01-19 18:21:26 UTC (rev 195295)
+++ trunk/Source/JavaScriptCore/b3/air/testair.cpp        2016-01-19 18:34:19 UTC (rev 195296)
</span><span class="lines">@@ -676,6 +676,51 @@
</span><span class="cx"> CHECK(things[5] == 3);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void testShuffleRotateWithFringeInWeirdOrder()
+{
+ B3::Procedure proc;
+ Code& code = proc.code();
+
+ BasicBlock* root = code.addBlock();
+ loadConstant(root, 1, Tmp(GPRInfo::regT0));
+ loadConstant(root, 2, Tmp(GPRInfo::regT1));
+ loadConstant(root, 3, Tmp(GPRInfo::regT2));
+ loadConstant(root, 4, Tmp(GPRInfo::regT3));
+ loadConstant(root, 5, Tmp(GPRInfo::regT4));
+ loadConstant(root, 6, Tmp(GPRInfo::regT5));
+ root->append(
+ Shuffle, nullptr,
+ Tmp(GPRInfo::regT0), Tmp(GPRInfo::regT3), Arg::widthArg(Arg::Width32),
+ Tmp(GPRInfo::regT0), Tmp(GPRInfo::regT1), Arg::widthArg(Arg::Width32),
+ Tmp(GPRInfo::regT1), Tmp(GPRInfo::regT4), Arg::widthArg(Arg::Width32),
+ Tmp(GPRInfo::regT2), Tmp(GPRInfo::regT0), Arg::widthArg(Arg::Width32),
+ Tmp(GPRInfo::regT2), Tmp(GPRInfo::regT5), Arg::widthArg(Arg::Width32),
+ Tmp(GPRInfo::regT1), Tmp(GPRInfo::regT2), Arg::widthArg(Arg::Width32));
+
+ int32_t things[6];
+ Tmp base = code.newTmp(Arg::GP);
+ root->append(Move, nullptr, Arg::imm64(bitwise_cast<intptr_t>(&things)), base);
+ root->append(Move32, nullptr, Tmp(GPRInfo::regT0), Arg::addr(base, 0 * sizeof(int32_t)));
+ root->append(Move32, nullptr, Tmp(GPRInfo::regT1), Arg::addr(base, 1 * sizeof(int32_t)));
+ root->append(Move32, nullptr, Tmp(GPRInfo::regT2), Arg::addr(base, 2 * sizeof(int32_t)));
+ root->append(Move32, nullptr, Tmp(GPRInfo::regT3), Arg::addr(base, 3 * sizeof(int32_t)));
+ root->append(Move32, nullptr, Tmp(GPRInfo::regT4), Arg::addr(base, 4 * sizeof(int32_t)));
+ root->append(Move32, nullptr, Tmp(GPRInfo::regT5), Arg::addr(base, 5 * sizeof(int32_t)));
+ root->append(Move, nullptr, Arg::imm(0), Tmp(GPRInfo::returnValueGPR));
+ root->append(Ret32, nullptr, Tmp(GPRInfo::returnValueGPR));
+
+ memset(things, 0, sizeof(things));
+
+ CHECK(!compileAndRun<int>(proc));
+
+ CHECK(things[0] == 3);
+ CHECK(things[1] == 1);
+ CHECK(things[2] == 2);
+ CHECK(things[3] == 1);
+ CHECK(things[4] == 2);
+ CHECK(things[5] == 3);
+}
+
</ins><span class="cx"> void testShuffleRotateWithLongFringe()
</span><span class="cx"> {
</span><span class="cx"> B3::Procedure proc;
</span><span class="lines">@@ -1625,6 +1670,7 @@
</span><span class="cx"> RUN(testShuffleTreeShiftOtherBackward());
</span><span class="cx"> RUN(testShuffleMultipleShifts());
</span><span class="cx"> RUN(testShuffleRotateWithFringe());
</span><ins>+ RUN(testShuffleRotateWithFringeInWeirdOrder());
</ins><span class="cx"> RUN(testShuffleRotateWithLongFringe());
</span><span class="cx"> RUN(testShuffleMultipleRotates());
</span><span class="cx"> RUN(testShuffleShiftAndRotate());
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGCommonh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGCommon.h (195295 => 195296)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGCommon.h        2016-01-19 18:21:26 UTC (rev 195295)
+++ trunk/Source/JavaScriptCore/dfg/DFGCommon.h        2016-01-19 18:34:19 UTC (rev 195296)
</span><span class="lines">@@ -38,7 +38,7 @@
</span><span class="cx"> // We are in the middle of an experimental transition from LLVM to B3 as the backend for the FTL. We don't
</span><span class="cx"> // yet know how it will turn out. For now, this flag will control whether FTL uses B3. Remember to set this
</span><span class="cx"> // to 0 before committing!
</span><del>-#define FTL_USES_B3 0
</del><ins>+#define FTL_USES_B3 1
</ins><span class="cx">
</span><span class="cx"> struct Node;
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>