Source/JavaScriptCore/ChangeLog

 12015-10-29 Filip Pizlo <fpizlo@apple.com>
 2
 3 B3::LowerToAir::imm() should work for both 32-bit and 64-bit immediates
 4 https://bugs.webkit.org/show_bug.cgi?id=150685
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 In B3, a constant must match the type of its use. In Air, immediates don't have type, they
 9 only have representation. A 32-bit immediate (i.e. Arg::imm) can be used either for 32-bit
 10 operations or for 64-bit operations. The only difference from a Arg::imm64 is that it
 11 requires fewer bits.
 12
 13 In the B3->Air lowering, we have a lot of code that is effectively polymorphic over integer
 14 type. That code should still be able to use Arg::imm, and it should work even for 64-bit
 15 immediates - so long as they are representable as 32-bit immediates. Therefore, the imm()
 16 helper should happily accept either Const32Value or Const64Value.
 17
 18 We already sort of had this with immAnyType(), but it just turns out that anyone using
 19 immAnyType() should really be using imm().
 20
 21 * b3/B3LowerToAir.cpp:
 22 (JSC::B3::Air::LowerToAir::imm):
 23 (JSC::B3::Air::LowerToAir::tryStore):
 24 (JSC::B3::Air::LowerToAir::tryConst64):
 25 (JSC::B3::Air::LowerToAir::immAnyInt): Deleted.
 26 * b3/testb3.cpp:
 27 (JSC::B3::testAdd1):
 28 (JSC::B3::testAdd1Ptr):
 29 (JSC::B3::testStoreAddLoad):
 30 (JSC::B3::run):
 31
1322015-10-29 Alex Christensen <achristensen@webkit.org>
233
334 Fix Mac CMake build
191749

Source/JavaScriptCore/b3/B3LowerToAir.cpp

@@public:
188188
189189 Arg imm(Value* value)
190190 {
191  if (value->hasInt32())
192  return Arg::imm(value->asInt32());
193  return Arg();
194  }
195 
196  Arg immAnyInt(Value* value)
197  {
198191 if (value->hasInt()) {
199192 int64_t fullValue = value->asInt();
200193 int32_t immediateValue = static_cast<int32_t>(fullValue);

@@public:
574567 Air::Opcode move = moveForType(value->type());
575568 Arg destination = effectiveAddr(address);
576569
577  Arg imm = immAnyInt(value);
578  if (imm && isValidForm(move, Arg::Imm, destination.kind())) {
579  append(moveForType(value->type()), imm, effectiveAddr(address, currentValue));
 570 if (imm(value) && isValidForm(move, Arg::Imm, destination.kind())) {
 571 append(moveForType(value->type()), imm(value), effectiveAddr(address, currentValue));
580572 return true;
581573 }
582574

@@public:
616608
617609 bool tryConst64()
618610 {
 611 if (imm(currentValue)) {
 612 append(Move, imm(currentValue), tmp(currentValue));
 613 return true;
 614 }
619615 append(Move, Arg::imm64(currentValue->asInt64()), tmp(currentValue));
620616 return true;
621617 }
191746

Source/JavaScriptCore/b3/testb3.cpp

@@void testAdd1(int value)
214214 CHECK(compileAndRun<int>(proc, value) == value + 1);
215215}
216216
 217void testAdd1Ptr(intptr_t value)
 218{
 219 Procedure proc;
 220 BasicBlock* root = proc.addBlock();
 221 root->appendNew<ControlValue>(
 222 proc, Return, Origin(),
 223 root->appendNew<Value>(
 224 proc, Add, Origin(),
 225 root->appendNew<ArgumentRegValue>(proc, Origin(), GPRInfo::argumentGPR0),
 226 root->appendNew<ConstPtrValue>(proc, Origin(), 1)));
 227
 228 CHECK(compileAndRun<intptr_t>(proc, value) == value + 1);
 229}
 230
217231void testStoreAddLoad(int amount)
218232{
219233 Procedure proc;

@@void run()
442456 RUN(testStoreConstantPtr(49));
443457 RUN(testTrunc((static_cast<int64_t>(1) << 40) + 42));
444458 RUN(testAdd1(45));
 459 RUN(testAdd1Ptr(51));
 460 RUN(testAdd1Ptr(bitwise_cast<intptr_t>(vm)));
445461 RUN(testStoreAddLoad(46));
446462 RUN(testStoreAddAndLoad(47, 0xffff));
447463 RUN(testStoreAddAndLoad(470000, 0xffff));
191746