Title: [191763] trunk/Source/_javascript_Core
- Revision
- 191763
- Author
- fpi...@apple.com
- Date
- 2015-10-29 16:43:42 -0700 (Thu, 29 Oct 2015)
Log Message
B3::LowerToAir::imm() should work for both 32-bit and 64-bit immediates
https://bugs.webkit.org/show_bug.cgi?id=150685
Reviewed by Geoffrey Garen.
In B3, a constant must match the type of its use. In Air, immediates don't have type, they
only have representation. A 32-bit immediate (i.e. Arg::imm) can be used either for 32-bit
operations or for 64-bit operations. The only difference from a Arg::imm64 is that it
requires fewer bits.
In the B3->Air lowering, we have a lot of code that is effectively polymorphic over integer
type. That code should still be able to use Arg::imm, and it should work even for 64-bit
immediates - so long as they are representable as 32-bit immediates. Therefore, the imm()
helper should happily accept either Const32Value or Const64Value.
We already sort of had this with immAnyType(), but it just turns out that anyone using
immAnyType() should really be using imm().
* b3/B3LowerToAir.cpp:
(JSC::B3::Air::LowerToAir::imm):
(JSC::B3::Air::LowerToAir::tryStore):
(JSC::B3::Air::LowerToAir::tryConst64):
(JSC::B3::Air::LowerToAir::immAnyInt): Deleted.
* b3/testb3.cpp:
(JSC::B3::testAdd1):
(JSC::B3::testAdd1Ptr):
(JSC::B3::testStoreAddLoad):
(JSC::B3::run):
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (191762 => 191763)
--- trunk/Source/_javascript_Core/ChangeLog 2015-10-29 23:42:04 UTC (rev 191762)
+++ trunk/Source/_javascript_Core/ChangeLog 2015-10-29 23:43:42 UTC (rev 191763)
@@ -1,5 +1,36 @@
2015-10-29 Filip Pizlo <fpi...@apple.com>
+ B3::LowerToAir::imm() should work for both 32-bit and 64-bit immediates
+ https://bugs.webkit.org/show_bug.cgi?id=150685
+
+ Reviewed by Geoffrey Garen.
+
+ In B3, a constant must match the type of its use. In Air, immediates don't have type, they
+ only have representation. A 32-bit immediate (i.e. Arg::imm) can be used either for 32-bit
+ operations or for 64-bit operations. The only difference from a Arg::imm64 is that it
+ requires fewer bits.
+
+ In the B3->Air lowering, we have a lot of code that is effectively polymorphic over integer
+ type. That code should still be able to use Arg::imm, and it should work even for 64-bit
+ immediates - so long as they are representable as 32-bit immediates. Therefore, the imm()
+ helper should happily accept either Const32Value or Const64Value.
+
+ We already sort of had this with immAnyType(), but it just turns out that anyone using
+ immAnyType() should really be using imm().
+
+ * b3/B3LowerToAir.cpp:
+ (JSC::B3::Air::LowerToAir::imm):
+ (JSC::B3::Air::LowerToAir::tryStore):
+ (JSC::B3::Air::LowerToAir::tryConst64):
+ (JSC::B3::Air::LowerToAir::immAnyInt): Deleted.
+ * b3/testb3.cpp:
+ (JSC::B3::testAdd1):
+ (JSC::B3::testAdd1Ptr):
+ (JSC::B3::testStoreAddLoad):
+ (JSC::B3::run):
+
+2015-10-29 Filip Pizlo <fpi...@apple.com>
+
StoreOpLoad pattern matching should check effects between the Store and Load
https://bugs.webkit.org/show_bug.cgi?id=150534
Modified: trunk/Source/_javascript_Core/b3/B3LowerToAir.cpp (191762 => 191763)
--- trunk/Source/_javascript_Core/b3/B3LowerToAir.cpp 2015-10-29 23:42:04 UTC (rev 191762)
+++ trunk/Source/_javascript_Core/b3/B3LowerToAir.cpp 2015-10-29 23:43:42 UTC (rev 191763)
@@ -217,13 +217,6 @@
Arg imm(Value* value)
{
- if (value->hasInt32())
- return Arg::imm(value->asInt32());
- return Arg();
- }
-
- Arg immAnyInt(Value* value)
- {
if (value->hasInt()) {
int64_t fullValue = value->asInt();
int32_t immediateValue = static_cast<int32_t>(fullValue);
@@ -600,9 +593,8 @@
Air::Opcode move = moveForType(value->type());
Arg destination = effectiveAddr(address);
- Arg imm = immAnyInt(value);
- if (imm && isValidForm(move, Arg::Imm, destination.kind())) {
- append(moveForType(value->type()), imm, effectiveAddr(address, currentValue));
+ if (imm(value) && isValidForm(move, Arg::Imm, destination.kind())) {
+ append(moveForType(value->type()), imm(value), effectiveAddr(address, currentValue));
return true;
}
@@ -642,6 +634,10 @@
bool tryConst64()
{
+ if (imm(currentValue)) {
+ append(Move, imm(currentValue), tmp(currentValue));
+ return true;
+ }
append(Move, Arg::imm64(currentValue->asInt64()), tmp(currentValue));
return true;
}
Modified: trunk/Source/_javascript_Core/b3/testb3.cpp (191762 => 191763)
--- trunk/Source/_javascript_Core/b3/testb3.cpp 2015-10-29 23:42:04 UTC (rev 191762)
+++ trunk/Source/_javascript_Core/b3/testb3.cpp 2015-10-29 23:43:42 UTC (rev 191763)
@@ -214,6 +214,20 @@
CHECK(compileAndRun<int>(proc, value) == value + 1);
}
+void testAdd1Ptr(intptr_t value)
+{
+ Procedure proc;
+ BasicBlock* root = proc.addBlock();
+ root->appendNew<ControlValue>(
+ proc, Return, Origin(),
+ root->appendNew<Value>(
+ proc, Add, Origin(),
+ root->appendNew<ArgumentRegValue>(proc, Origin(), GPRInfo::argumentGPR0),
+ root->appendNew<ConstPtrValue>(proc, Origin(), 1)));
+
+ CHECK(compileAndRun<intptr_t>(proc, value) == value + 1);
+}
+
void testStoreAddLoad(int amount)
{
Procedure proc;
@@ -502,6 +516,8 @@
RUN(testStoreConstantPtr(49));
RUN(testTrunc((static_cast<int64_t>(1) << 40) + 42));
RUN(testAdd1(45));
+ RUN(testAdd1Ptr(51));
+ RUN(testAdd1Ptr(bitwise_cast<intptr_t>(vm)));
RUN(testStoreAddLoad(46));
RUN(testStoreAddLoadInterference(52));
RUN(testStoreAddAndLoad(47, 0xffff));
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes