Changeset 184624 in webkit


Ignore:
Timestamp:
May 20, 2015 12:55:58 AM (9 years ago)
Author:
bshafiei@apple.com
Message:

Merged r184540. rdar://problem/20679710

Location:
branches/safari-601.1.32-branch/Source/JavaScriptCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-601.1.32-branch/Source/JavaScriptCore/ChangeLog

    r184562 r184624  
     12015-05-20  Babak Shafiei  <bshafiei@apple.com>
     2
     3        Merge r184540.
     4
     5    2015-05-18  Filip Pizlo  <fpizlo@apple.com>
     6
     7            Add SpecBoolInt32 type that means "I'm an int and I'm either 0 or 1"
     8            https://bugs.webkit.org/show_bug.cgi?id=145137
     9
     10            Reviewed by Benjamin Poulain.
     11
     12            It's super useful to know if an integer value could be either zero or one. We have an
     13            immediate need for this because of Int32|Boolean uses, where knowing that the Int32 is
     14            either 0 or 1 means that there is no actual polymorphism if you just look at the low bit
     15            (1 behaves like true, 0 behaves like false, and the low bit of 1|true is 1, and the low
     16            bit of 0|false is 0).
     17
     18            We do this by splitting the SpecInt32 type into SpecBoolInt32 and SpecNonBoolInt32. This
     19            change doesn't have any effect on behavior, yet. But it does give us the ability to
     20            predict and prove when values are SpecBoolInt32; it's just we don't leverage this yet.
     21
     22            This is perf-neutral.
     23
     24            * bytecode/SpeculatedType.cpp:
     25            (JSC::dumpSpeculation):
     26            (JSC::speculationToAbbreviatedString):
     27            (JSC::speculationFromValue):
     28            * bytecode/SpeculatedType.h:
     29            (JSC::isStringOrStringObjectSpeculation):
     30            (JSC::isBoolInt32Speculation):
     31            (JSC::isInt32Speculation):
     32            (JSC::isInt32OrBooleanSpeculation):
     33            * dfg/DFGAbstractInterpreterInlines.h:
     34            (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects):
     35
    1362015-05-18  Matthew Hanson  <matthew_hanson@apple.com>
    237
  • branches/safari-601.1.32-branch/Source/JavaScriptCore/bytecode/SpeculatedType.cpp

    r182971 r184624  
    159159    }
    160160   
    161     if (value & SpecInt32)
     161    if (value == SpecInt32)
    162162        myOut.print("Int32");
    163     else
    164         isTop = false;
     163    else {
     164        if (value & SpecBoolInt32)
     165            myOut.print("Boolint32");
     166        else
     167            isTop = false;
     168       
     169        if (value & SpecNonBoolInt32)
     170            myOut.print("Nonboolint32");
     171        else
     172            isTop = false;
     173    }
    165174   
    166175    if (value & SpecInt52)
     
    250259    if (isCellSpeculation(prediction))
    251260        return "<Cell>";
     261    if (isBoolInt32Speculation(prediction))
     262        return "<BoolInt32>";
    252263    if (isInt32Speculation(prediction))
    253264        return "<Int32>";
     
    357368    if (value.isEmpty())
    358369        return SpecEmpty;
    359     if (value.isInt32())
    360         return SpecInt32;
     370    if (value.isInt32()) {
     371        if (value.asInt32() & ~1)
     372            return SpecNonBoolInt32;
     373        return SpecBoolInt32;
     374    }
    361375    if (value.isDouble()) {
    362376        double number = value.asNumber();
  • branches/safari-601.1.32-branch/Source/JavaScriptCore/bytecode/SpeculatedType.h

    r181993 r184624  
    6363static const SpeculatedType SpecCellOther          = 0x00040000; // It's definitely a JSCell but not a subclass of JSObject and definitely not a JSString. FIXME: This shouldn't be part of heap-top or bytecode-top. https://bugs.webkit.org/show_bug.cgi?id=133078
    6464static const SpeculatedType SpecCell               = 0x0007ffff; // It's definitely a JSCell.
    65 static const SpeculatedType SpecInt32              = 0x00200000; // It's definitely an Int32.
     65static const SpeculatedType SpecBoolInt32          = 0x00100000; // It's definitely an Int32 with value 0 or 1.
     66static const SpeculatedType SpecNonBoolInt32       = 0x00200000; // It's definitely an Int32 with value other than 0 or 1.
     67static const SpeculatedType SpecInt32              = 0x00300000; // It's definitely an Int32.
    6668static const SpeculatedType SpecInt52              = 0x00400000; // It's definitely an Int52 and we intend it to unbox it.
    67 static const SpeculatedType SpecMachineInt         = 0x00600000; // It's something that we can do machine int arithmetic on.
     69static const SpeculatedType SpecMachineInt         = 0x00700000; // It's something that we can do machine int arithmetic on.
    6870static const SpeculatedType SpecInt52AsDouble      = 0x00800000; // It's definitely an Int52 and it's inside a double.
    69 static const SpeculatedType SpecInteger            = 0x00e00000; // It's definitely some kind of integer.
     71static const SpeculatedType SpecInteger            = 0x00f00000; // It's definitely some kind of integer.
    7072static const SpeculatedType SpecNonIntAsDouble     = 0x01000000; // It's definitely not an Int52 but it's a real number and it's a double.
    7173static const SpeculatedType SpecDoubleReal         = 0x01800000; // It's definitely a non-NaN double.
     
    7577static const SpeculatedType SpecBytecodeDouble     = 0x03800000; // It's either a non-NaN or a NaN double, but it's definitely not impure NaN.
    7678static const SpeculatedType SpecFullDouble         = 0x07800000; // It's either a non-NaN or a NaN double.
    77 static const SpeculatedType SpecBytecodeRealNumber = 0x01a00000; // It's either an Int32 or a DoubleReal.
    78 static const SpeculatedType SpecFullRealNumber     = 0x01e00000; // It's either an Int32 or a DoubleReal, or a Int52.
    79 static const SpeculatedType SpecBytecodeNumber     = 0x03a00000; // It's either an Int32 or a Double, and the Double cannot be an impure NaN.
    80 static const SpeculatedType SpecFullNumber         = 0x07e00000; // It's either an Int32, Int52, or a Double, and the Double can be impure NaN.
     79static const SpeculatedType SpecBytecodeRealNumber = 0x01b00000; // It's either an Int32 or a DoubleReal.
     80static const SpeculatedType SpecFullRealNumber     = 0x01f00000; // It's either an Int32 or a DoubleReal, or a Int52.
     81static const SpeculatedType SpecBytecodeNumber     = 0x03b00000; // It's either an Int32 or a Double, and the Double cannot be an impure NaN.
     82static const SpeculatedType SpecFullNumber         = 0x07f00000; // It's either an Int32, Int52, or a Double, and the Double can be impure NaN.
    8183static const SpeculatedType SpecBoolean            = 0x10000000; // It's definitely a Boolean.
    8284static const SpeculatedType SpecOther              = 0x20000000; // It's definitely either Null or Undefined.
     
    257259}
    258260
     261inline bool isBoolInt32Speculation(SpeculatedType value)
     262{
     263    return value == SpecBoolInt32;
     264}
     265
    259266inline bool isInt32Speculation(SpeculatedType value)
    260267{
    261     return value == SpecInt32;
     268    return value && !(value & ~SpecInt32);
    262269}
    263270
  • branches/safari-601.1.32-branch/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h

    r184525 r184624  
    258258            break;
    259259        }
     260       
     261        if (node->op() == BitAnd
     262            && (isBoolInt32Speculation(forNode(node->child1()).m_type) ||
     263                isBoolInt32Speculation(forNode(node->child2()).m_type))) {
     264            forNode(node).setType(SpecBoolInt32);
     265            break;
     266        }
     267       
    260268        forNode(node).setType(SpecInt32);
    261269        break;
     
    298306            m_state.setFoundConstants(true);
    299307        if (value.m_type & SpecBoolean) {
    300             value.merge(SpecInt32);
     308            value.merge(SpecBoolInt32);
    301309            value.filter(~SpecBoolean);
    302310        }
     
    336344                break;
    337345            }
     346        }
     347       
     348        if (isBooleanSpeculation(forNode(node->child1()).m_type)) {
     349            forNode(node).setType(SpecBoolInt32);
     350            break;
    338351        }
    339352       
Note: See TracChangeset for help on using the changeset viewer.