Changeset 191763 in webkit


Ignore:
Timestamp:
Oct 29, 2015 4:43:42 PM (9 years ago)
Author:
fpizlo@apple.com
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):

Location:
trunk/Source/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r191762 r191763  
     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 Geoffrey Garen.
     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  Filip Pizlo  <fpizlo@apple.com>
    233
  • trunk/Source/JavaScriptCore/b3/B3LowerToAir.cpp

    r191762 r191763  
    218218    Arg imm(Value* value)
    219219    {
    220         if (value->hasInt32())
    221             return Arg::imm(value->asInt32());
    222         return Arg();
    223     }
    224 
    225     Arg immAnyInt(Value* value)
    226     {
    227220        if (value->hasInt()) {
    228221            int64_t fullValue = value->asInt();
     
    601594        Arg destination = effectiveAddr(address);
    602595
    603         Arg imm = immAnyInt(value);
    604         if (imm && isValidForm(move, Arg::Imm, destination.kind())) {
    605             append(moveForType(value->type()), imm, effectiveAddr(address, currentValue));
     596        if (imm(value) && isValidForm(move, Arg::Imm, destination.kind())) {
     597            append(moveForType(value->type()), imm(value), effectiveAddr(address, currentValue));
    606598            return true;
    607599        }
     
    643635    bool tryConst64()
    644636    {
     637        if (imm(currentValue)) {
     638            append(Move, imm(currentValue), tmp(currentValue));
     639            return true;
     640        }
    645641        append(Move, Arg::imm64(currentValue->asInt64()), tmp(currentValue));
    646642        return true;
  • trunk/Source/JavaScriptCore/b3/testb3.cpp

    r191762 r191763  
    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{
     
    503517    RUN(testTrunc((static_cast<int64_t>(1) << 40) + 42));
    504518    RUN(testAdd1(45));
     519    RUN(testAdd1Ptr(51));
     520    RUN(testAdd1Ptr(bitwise_cast<intptr_t>(vm)));
    505521    RUN(testStoreAddLoad(46));
    506522    RUN(testStoreAddLoadInterference(52));
Note: See TracChangeset for help on using the changeset viewer.