Changeset 185768 in webkit


Ignore:
Timestamp:
Jun 19, 2015, 2:17:54 PM (10 years ago)
Author:
mark.lam@apple.com
Message:

Employ explicit operator bool() instead of using the UnspecifiedBoolType workaround.
https://bugs.webkit.org/show_bug.cgi?id=146154

Reviewed by Darin Adler.

  • assembler/MacroAssemblerCodeRef.h:

(JSC::MacroAssemblerCodePtr::dataLocation):
(JSC::MacroAssemblerCodePtr::operator bool):
(JSC::MacroAssemblerCodePtr::operator==):
(JSC::MacroAssemblerCodeRef::tryToDisassemble):
(JSC::MacroAssemblerCodeRef::operator bool):
(JSC::MacroAssemblerCodeRef::dump):
(JSC::MacroAssemblerCodePtr::operator UnspecifiedBoolType*): Deleted.
(JSC::MacroAssemblerCodeRef::operator UnspecifiedBoolType*): Deleted.

  • bytecode/CodeOrigin.cpp:

(JSC::CodeOrigin::isApproximatelyEqualTo):

  • Fixed a bug here where we were expecting to compare Executable pointers, but ended up comparing a (UnspecifiedBoolType*)1 with another (UnspecifiedBoolType*)1.
  • bytecode/LLIntCallLinkInfo.h:

(JSC::LLIntCallLinkInfo::~LLIntCallLinkInfo):
(JSC::LLIntCallLinkInfo::isLinked):
(JSC::LLIntCallLinkInfo::unlink):

  • dfg/DFGBlockWorklist.h:

(JSC::DFG::BlockWith::BlockWith):
(JSC::DFG::BlockWith::operator bool):
(JSC::DFG::BlockWithOrder::BlockWithOrder):
(JSC::DFG::BlockWithOrder::operator bool):
(JSC::DFG::BlockWith::operator UnspecifiedBoolType*): Deleted.
(JSC::DFG::BlockWithOrder::operator UnspecifiedBoolType*): Deleted.

  • dfg/DFGIntegerRangeOptimizationPhase.cpp:
  • dfg/DFGLazyNode.h:

(JSC::DFG::LazyNode::operator!):
(JSC::DFG::LazyNode::operator bool):
(JSC::DFG::LazyNode::operator UnspecifiedBoolType*): Deleted.

  • heap/CopyWriteBarrier.h:

(JSC::CopyWriteBarrier::operator!):
(JSC::CopyWriteBarrier::operator bool):
(JSC::CopyWriteBarrier::get):
(JSC::CopyWriteBarrier::operator UnspecifiedBoolType*): Deleted.

  • heap/Handle.h:

(JSC::HandleBase::operator!):
(JSC::HandleBase::operator bool):
(JSC::HandleBase::slot):
(JSC::HandleBase::operator UnspecifiedBoolType*): Deleted.

  • heap/Strong.h:

(JSC::Strong::operator!):
(JSC::Strong::operator bool):
(JSC::Strong::swap):
(JSC::Strong::operator UnspecifiedBoolType*): Deleted.

  • jit/JITWriteBarrier.h:

(JSC::JITWriteBarrierBase::operator bool):
(JSC::JITWriteBarrierBase::operator!):
(JSC::JITWriteBarrierBase::setFlagOnBarrier):
(JSC::JITWriteBarrierBase::operator UnspecifiedBoolType*): Deleted.

  • runtime/JSArray.cpp:

(JSC::JSArray::setLengthWithArrayStorage):

  • runtime/JSCJSValue.h:
  • runtime/JSCJSValueInlines.h:

(JSC::JSValue::JSValue):
(JSC::JSValue::operator bool):
(JSC::JSValue::operator==):
(JSC::JSValue::operator UnspecifiedBoolType*): Deleted.

  • runtime/JSObject.h:

(JSC::JSObject::hasSparseMap):

  • runtime/PropertyDescriptor.h:

(JSC::PropertyDescriptor::writablePresent):
(JSC::PropertyDescriptor::enumerablePresent):
(JSC::PropertyDescriptor::configurablePresent):
(JSC::PropertyDescriptor::setterPresent):
(JSC::PropertyDescriptor::getterPresent):

  • runtime/WriteBarrier.h:

(JSC::WriteBarrierBase::slot):
(JSC::WriteBarrierBase::operator bool):
(JSC::WriteBarrierBase::operator!):
(JSC::WriteBarrierBase<Unknown>::tagPointer):
(JSC::WriteBarrierBase<Unknown>::payloadPointer):
(JSC::WriteBarrierBase<Unknown>::operator bool):
(JSC::WriteBarrierBase<Unknown>::operator!):
(JSC::WriteBarrierBase::operator UnspecifiedBoolType*): Deleted.
(JSC::WriteBarrierBase<Unknown>::operator UnspecifiedBoolType*): Deleted.

Location:
trunk/Source/JavaScriptCore
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r185765 r185768  
     12015-06-19  Mark Lam  <mark.lam@apple.com>
     2
     3        Employ explicit operator bool() instead of using the UnspecifiedBoolType workaround.
     4        https://bugs.webkit.org/show_bug.cgi?id=146154
     5
     6        Reviewed by Darin Adler.
     7
     8        * assembler/MacroAssemblerCodeRef.h:
     9        (JSC::MacroAssemblerCodePtr::dataLocation):
     10        (JSC::MacroAssemblerCodePtr::operator bool):
     11        (JSC::MacroAssemblerCodePtr::operator==):
     12        (JSC::MacroAssemblerCodeRef::tryToDisassemble):
     13        (JSC::MacroAssemblerCodeRef::operator bool):
     14        (JSC::MacroAssemblerCodeRef::dump):
     15        (JSC::MacroAssemblerCodePtr::operator UnspecifiedBoolType*): Deleted.
     16        (JSC::MacroAssemblerCodeRef::operator UnspecifiedBoolType*): Deleted.
     17
     18        * bytecode/CodeOrigin.cpp:
     19        (JSC::CodeOrigin::isApproximatelyEqualTo):
     20        - Fixed a bug here where we were expecting to compare Executable pointers, but
     21          ended up comparing a (UnspecifiedBoolType*)1 with another
     22          (UnspecifiedBoolType*)1.
     23
     24        * bytecode/LLIntCallLinkInfo.h:
     25        (JSC::LLIntCallLinkInfo::~LLIntCallLinkInfo):
     26        (JSC::LLIntCallLinkInfo::isLinked):
     27        (JSC::LLIntCallLinkInfo::unlink):
     28        * dfg/DFGBlockWorklist.h:
     29        (JSC::DFG::BlockWith::BlockWith):
     30        (JSC::DFG::BlockWith::operator bool):
     31        (JSC::DFG::BlockWithOrder::BlockWithOrder):
     32        (JSC::DFG::BlockWithOrder::operator bool):
     33        (JSC::DFG::BlockWith::operator UnspecifiedBoolType*): Deleted.
     34        (JSC::DFG::BlockWithOrder::operator UnspecifiedBoolType*): Deleted.
     35        * dfg/DFGIntegerRangeOptimizationPhase.cpp:
     36        * dfg/DFGLazyNode.h:
     37        (JSC::DFG::LazyNode::operator!):
     38        (JSC::DFG::LazyNode::operator bool):
     39        (JSC::DFG::LazyNode::operator UnspecifiedBoolType*): Deleted.
     40        * heap/CopyWriteBarrier.h:
     41        (JSC::CopyWriteBarrier::operator!):
     42        (JSC::CopyWriteBarrier::operator bool):
     43        (JSC::CopyWriteBarrier::get):
     44        (JSC::CopyWriteBarrier::operator UnspecifiedBoolType*): Deleted.
     45        * heap/Handle.h:
     46        (JSC::HandleBase::operator!):
     47        (JSC::HandleBase::operator bool):
     48        (JSC::HandleBase::slot):
     49        (JSC::HandleBase::operator UnspecifiedBoolType*): Deleted.
     50        * heap/Strong.h:
     51        (JSC::Strong::operator!):
     52        (JSC::Strong::operator bool):
     53        (JSC::Strong::swap):
     54        (JSC::Strong::operator UnspecifiedBoolType*): Deleted.
     55        * jit/JITWriteBarrier.h:
     56        (JSC::JITWriteBarrierBase::operator bool):
     57        (JSC::JITWriteBarrierBase::operator!):
     58        (JSC::JITWriteBarrierBase::setFlagOnBarrier):
     59        (JSC::JITWriteBarrierBase::operator UnspecifiedBoolType*): Deleted.
     60        * runtime/JSArray.cpp:
     61        (JSC::JSArray::setLengthWithArrayStorage):
     62        * runtime/JSCJSValue.h:
     63        * runtime/JSCJSValueInlines.h:
     64        (JSC::JSValue::JSValue):
     65        (JSC::JSValue::operator bool):
     66        (JSC::JSValue::operator==):
     67        (JSC::JSValue::operator UnspecifiedBoolType*): Deleted.
     68        * runtime/JSObject.h:
     69        (JSC::JSObject::hasSparseMap):
     70        * runtime/PropertyDescriptor.h:
     71        (JSC::PropertyDescriptor::writablePresent):
     72        (JSC::PropertyDescriptor::enumerablePresent):
     73        (JSC::PropertyDescriptor::configurablePresent):
     74        (JSC::PropertyDescriptor::setterPresent):
     75        (JSC::PropertyDescriptor::getterPresent):
     76        * runtime/WriteBarrier.h:
     77        (JSC::WriteBarrierBase::slot):
     78        (JSC::WriteBarrierBase::operator bool):
     79        (JSC::WriteBarrierBase::operator!):
     80        (JSC::WriteBarrierBase<Unknown>::tagPointer):
     81        (JSC::WriteBarrierBase<Unknown>::payloadPointer):
     82        (JSC::WriteBarrierBase<Unknown>::operator bool):
     83        (JSC::WriteBarrierBase<Unknown>::operator!):
     84        (JSC::WriteBarrierBase::operator UnspecifiedBoolType*): Deleted.
     85        (JSC::WriteBarrierBase<Unknown>::operator UnspecifiedBoolType*): Deleted.
     86
    1872015-06-19  Anders Carlsson  <andersca@apple.com>
    288
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerCodeRef.h

    r175762 r185768  
    319319#endif
    320320
    321     typedef void* (MacroAssemblerCodePtr::*UnspecifiedBoolType);
    322     operator UnspecifiedBoolType*() const
    323     {
    324         return !!m_value ? reinterpret_cast<UnspecifiedBoolType*>(1) : 0;
    325     }
     321    explicit operator bool() const { return m_value; }
    326322   
    327323    bool operator==(const MacroAssemblerCodePtr& other) const
     
    443439    }
    444440   
    445     typedef void* (MacroAssemblerCodeRef::*UnspecifiedBoolType);
    446     operator UnspecifiedBoolType*() const
    447     {
    448         return !!m_codePtr ? reinterpret_cast<UnspecifiedBoolType*>(1) : 0;
    449     }
     441    explicit operator bool() const { return !!m_codePtr; }
    450442   
    451443    void dump(PrintStream& out) const
  • trunk/Source/JavaScriptCore/bytecode/CodeOrigin.cpp

    r183072 r185768  
    7575            return true;
    7676       
    77         if (a.inlineCallFrame->executable != b.inlineCallFrame->executable)
     77        if (a.inlineCallFrame->executable.get() != b.inlineCallFrame->executable.get())
    7878            return false;
    7979       
  • trunk/Source/JavaScriptCore/bytecode/LLIntCallLinkInfo.h

    r108444 r185768  
    4646    }
    4747   
    48     bool isLinked() { return callee; }
     48    bool isLinked() { return !!callee; }
    4949   
    5050    void unlink()
  • trunk/Source/JavaScriptCore/dfg/DFGBlockWorklist.h

    r173072 r185768  
    6666    }
    6767   
    68     typedef void* (BlockWith<T>::*UnspecifiedBoolType);
    69     operator UnspecifiedBoolType*() const
    70     {
    71         return block ? reinterpret_cast<UnspecifiedBoolType*>(1) : nullptr;
    72     }
     68    explicit operator bool() const { return block; }
    7369
    7470    BasicBlock* block;
     
    142138    }
    143139   
    144     typedef void* (BlockWithOrder::*UnspecifiedBoolType);
    145     operator UnspecifiedBoolType*() const
    146     {
    147         return block ? reinterpret_cast<UnspecifiedBoolType*>(1) : nullptr;
    148     }
     140    explicit operator bool() const { return block; }
    149141
    150142    BasicBlock* block;
  • trunk/Source/JavaScriptCore/dfg/DFGIntegerRangeOptimizationPhase.cpp

    r185646 r185768  
    115115    typedef void* (Relationship::*UnspecifiedBoolType);
    116116
    117     operator UnspecifiedBoolType*() const
    118     {
    119         return m_left ? reinterpret_cast<UnspecifiedBoolType*>(1) : 0;
    120     }
     117    explicit operator bool() const { return m_left; }
    121118   
    122119    Node* left() const { return m_left; }
  • trunk/Source/JavaScriptCore/dfg/DFGLazyNode.h

    r184927 r185768  
    142142    bool operator!() const { return !asValue() && !asNode(); }
    143143
    144     typedef void* (LazyNode::*UnspecifiedBoolType);
    145 
    146     operator UnspecifiedBoolType*() const
    147     {
    148         return !!*this ? reinterpret_cast<UnspecifiedBoolType*>(1) : 0;
    149     }
     144    explicit operator bool() const { return !!*this; }
    150145
    151146    void dump(PrintStream& out) const;
  • trunk/Source/JavaScriptCore/heap/CopyWriteBarrier.h

    r163576 r185768  
    5151    bool operator!() const { return !m_value; }
    5252   
    53     typedef T* (CopyWriteBarrier::*UnspecifiedBoolType);
    54     operator UnspecifiedBoolType*() const { return m_value ? reinterpret_cast<UnspecifiedBoolType*>(1) : 0; }
     53    explicit operator bool() const { return m_value; }
    5554   
    5655    T* get() const
  • trunk/Source/JavaScriptCore/heap/Handle.h

    r142966 r185768  
    5353    bool operator!() const { return !m_slot || !*m_slot; }
    5454
    55     // This conversion operator allows implicit conversion to bool but not to other integer types.
    56     typedef JSValue (HandleBase::*UnspecifiedBoolType);
    57     operator UnspecifiedBoolType*() const { return (m_slot && *m_slot) ? reinterpret_cast<UnspecifiedBoolType*>(1) : 0; }
     55    explicit operator bool() const { return m_slot && *m_slot; }
    5856
    5957    HandleSlot slot() const { return m_slot; }
  • trunk/Source/JavaScriptCore/heap/Strong.h

    r157653 r185768  
    8585    bool operator!() const { return !slot() || !*slot(); }
    8686
    87     // This conversion operator allows implicit conversion to bool but not to other integer types.
    88     typedef JSValue (HandleBase::*UnspecifiedBoolType);
    89     operator UnspecifiedBoolType*() const { return !!*this ? reinterpret_cast<UnspecifiedBoolType*>(1) : 0; }
     87    explicit operator bool() const { return !!*this; }
    9088
    9189    void swap(Strong& other)
  • trunk/Source/JavaScriptCore/jit/JITWriteBarrier.h

    r179478 r185768  
    4444class JITWriteBarrierBase {
    4545public:
    46     typedef void* (JITWriteBarrierBase::*UnspecifiedBoolType);
    47     operator UnspecifiedBoolType*() const { return get() ? reinterpret_cast<UnspecifiedBoolType*>(1) : 0; }
     46    explicit operator bool() const { return get(); }
    4847    bool operator!() const { return !get(); }
    4948
  • trunk/Source/JavaScriptCore/runtime/JSArray.cpp

    r184767 r185768  
    377377        for (unsigned i = newLength; i < usedVectorLength; ++i) {
    378378            WriteBarrier<Unknown>& valueSlot = storage->m_vector[i];
    379             bool hadValue = valueSlot;
     379            bool hadValue  { valueSlot };
    380380            valueSlot.clear();
    381381            storage->m_numValuesInVector -= hadValue;
  • trunk/Source/JavaScriptCore/runtime/JSCJSValue.h

    r182057 r185768  
    196196    explicit JSValue(unsigned long long);
    197197
    198     typedef void* (JSValue::*UnspecifiedBoolType);
    199     operator UnspecifiedBoolType*() const;
     198    explicit operator bool() const;
    200199    bool operator==(const JSValue& other) const;
    201200    bool operator!=(const JSValue& other) const;
  • trunk/Source/JavaScriptCore/runtime/JSCJSValueInlines.h

    r184983 r185768  
    214214}
    215215
    216 inline JSValue::operator UnspecifiedBoolType*() const
     216inline JSValue::operator bool() const
    217217{
    218218    ASSERT(tag() != DeletedValueTag);
    219     return tag() != EmptyValueTag ? reinterpret_cast<UnspecifiedBoolType*>(1) : 0;
     219    return tag() != EmptyValueTag;
    220220}
    221221
     
    363363}
    364364
    365 inline JSValue::operator UnspecifiedBoolType*() const
    366 {
    367     return u.asInt64 ? reinterpret_cast<UnspecifiedBoolType*>(1) : 0;
     365inline JSValue::operator bool() const
     366{
     367    return u.asInt64;
    368368}
    369369
  • trunk/Source/JavaScriptCore/runtime/JSObject.h

    r185597 r185768  
    430430            return false;
    431431        case ALL_ARRAY_STORAGE_INDEXING_TYPES:
    432             return m_butterfly->arrayStorage()->m_sparseMap;
     432            return !!m_butterfly->arrayStorage()->m_sparseMap;
    433433        default:
    434434            RELEASE_ASSERT_NOT_REACHED();
  • trunk/Source/JavaScriptCore/runtime/PropertyDescriptor.h

    r173269 r185768  
    7878    bool enumerablePresent() const { return m_seenAttributes & EnumerablePresent; }
    7979    bool configurablePresent() const { return m_seenAttributes & ConfigurablePresent; }
    80     bool setterPresent() const { return m_setter; }
    81     bool getterPresent() const { return m_getter; }
     80    bool setterPresent() const { return !!m_setter; }
     81    bool getterPresent() const { return !!m_getter; }
    8282    bool equalTo(ExecState*, const PropertyDescriptor& other) const;
    8383    bool attributesEqual(const PropertyDescriptor& other) const;
  • trunk/Source/JavaScriptCore/runtime/WriteBarrier.h

    r184328 r185768  
    114114    T** slot() { return reinterpret_cast<T**>(&m_cell); }
    115115   
    116     typedef T* (WriteBarrierBase::*UnspecifiedBoolType);
    117     operator UnspecifiedBoolType*() const { return m_cell ? reinterpret_cast<UnspecifiedBoolType*>(1) : 0; }
     116    explicit operator bool() const { return m_cell; }
    118117   
    119118    bool operator!() const { return !m_cell; }
     
    166165    int32_t* payloadPointer() { return &bitwise_cast<EncodedValueDescriptor*>(&m_value)->asBits.payload; }
    167166   
    168     typedef JSValue (WriteBarrierBase::*UnspecifiedBoolType);
    169     operator UnspecifiedBoolType*() const { return get() ? reinterpret_cast<UnspecifiedBoolType*>(1) : 0; }
     167    explicit operator bool() const { return !!get(); }
    170168    bool operator!() const { return !get(); }
    171169   
Note: See TracChangeset for help on using the changeset viewer.