Changeset 37812 in webkit for trunk/JavaScriptCore/kjs


Ignore:
Timestamp:
Oct 23, 2008, 8:55:41 AM (17 years ago)
Author:
Darin Adler
Message:

JavaScriptCore:

2008-10-23 Darin Adler <Darin Adler>

1) slowness under MSVC, since it doesn't handle a

class with a single pointer in it as efficiently
as a pointer

2) uninitialized pointers in Vector

  • API/APICast.h: (toRef):
  • VM/CTI.cpp: (JSC::CTI::asInteger):
  • VM/CodeGenerator.cpp: (JSC::CodeGenerator::addConstant):
  • VM/CodeGenerator.h: (JSC::CodeGenerator::JSValueHashTraits::constructDeletedValue): (JSC::CodeGenerator::JSValueHashTraits::isDeletedValue):
  • VM/Machine.cpp: (JSC::Machine::cti_op_add): (JSC::Machine::cti_op_pre_inc): (JSC::Machine::cti_op_get_by_id): (JSC::Machine::cti_op_get_by_id_second): (JSC::Machine::cti_op_get_by_id_generic): (JSC::Machine::cti_op_get_by_id_fail): (JSC::Machine::cti_op_instanceof): (JSC::Machine::cti_op_del_by_id): (JSC::Machine::cti_op_mul): (JSC::Machine::cti_op_call_NotJSFunction): (JSC::Machine::cti_op_resolve): (JSC::Machine::cti_op_construct_NotJSConstruct): (JSC::Machine::cti_op_get_by_val): (JSC::Machine::cti_op_sub): (JSC::Machine::cti_op_lesseq): (JSC::Machine::cti_op_negate): (JSC::Machine::cti_op_resolve_base): (JSC::Machine::cti_op_resolve_skip): (JSC::Machine::cti_op_resolve_global): (JSC::Machine::cti_op_div): (JSC::Machine::cti_op_pre_dec): (JSC::Machine::cti_op_not): (JSC::Machine::cti_op_eq): (JSC::Machine::cti_op_lshift): (JSC::Machine::cti_op_bitand): (JSC::Machine::cti_op_rshift): (JSC::Machine::cti_op_bitnot): (JSC::Machine::cti_op_mod): (JSC::Machine::cti_op_less): (JSC::Machine::cti_op_neq): (JSC::Machine::cti_op_urshift): (JSC::Machine::cti_op_bitxor): (JSC::Machine::cti_op_bitor): (JSC::Machine::cti_op_call_eval): (JSC::Machine::cti_op_throw): (JSC::Machine::cti_op_next_pname): (JSC::Machine::cti_op_typeof): (JSC::Machine::cti_op_is_undefined): (JSC::Machine::cti_op_is_boolean): (JSC::Machine::cti_op_is_number): (JSC::Machine::cti_op_is_string): (JSC::Machine::cti_op_is_object): (JSC::Machine::cti_op_is_function): (JSC::Machine::cti_op_stricteq): (JSC::Machine::cti_op_nstricteq): (JSC::Machine::cti_op_to_jsnumber): (JSC::Machine::cti_op_in): (JSC::Machine::cti_op_del_by_val): (JSC::Machine::cti_vm_throw): Removed calls to payload functions.
  • VM/Register.h: (JSC::Register::Register): Removed overload for JSCell and call to payload function.
  • kjs/JSCell.h: Changed JSCell to derive from JSValue again. Removed JSValuePtr constructor. (JSC::asCell): Changed cast from reinterpret_cast to static_cast.
  • kjs/JSImmediate.h: Removed JSValuePtr class. Added typedef back.
  • kjs/JSValue.h: (JSC::JSValue::JSValue): Added empty protected inline constructor back. (JSC::JSValue::~JSValue): Same for destructor. Removed == and != operator for JSValuePtr.
  • kjs/PropertySlot.h: (JSC::PropertySlot::PropertySlot): Chnaged argument to const JSValue* and added a const_cast.
  • kjs/protect.h: Removed overloads and specialization for JSValuePtr.

JavaScriptGlue:

2008-10-23 Darin Adler <Darin Adler>

  • JSValueWrapper.cpp: (JSValueWrapper::GetValue): Added missing call to .get().
  • JSValueWrapper.h: ProtectedPtr<JSValue> instead of ProtectedPtr<JSValuePtr>.

WebCore:

2008-10-23 Darin Adler <Darin Adler>

  • bindings/js/ScheduledAction.h:
  • inspector/InspectorController.cpp: ProtectedPtr<JSValue> instead of ProtectedPtr<JSValuePtr>.
Location:
trunk/JavaScriptCore/kjs
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/JSCell.h

    r37799 r37812  
    3030namespace JSC {
    3131
    32     class JSCell : Noncopyable {
     32    class JSCell : public JSValue {
    3333        friend class CTI;
    3434        friend class GetterSetter;
     
    113113    {
    114114        ASSERT(!JSImmediate::isImmediate(value));
    115         return reinterpret_cast<JSCell*>(value.payload());
     115        return static_cast<JSCell*>(value);
    116116    }
    117117
     
    168168        return globalData->heap.allocate(size);
    169169#endif
    170     }
    171 
    172     // --- JSValuePtr inlines ----------------------------
    173 
    174     inline JSValuePtr::JSValuePtr(const JSCell* cell)
    175         : m_payload(reinterpret_cast<JSValue*>(const_cast<JSCell*>(cell)))
    176     {
    177170    }
    178171
  • trunk/JavaScriptCore/kjs/JSImmediate.h

    r37712 r37812  
    4040    class UString;
    4141
    42     class JSValuePtr {
    43     public:
    44         JSValuePtr() { } // uninitialized (not zero)
    45         JSValuePtr(const JSValue* payload) : m_payload(const_cast<JSValue*>(payload)) { }
    46         JSValuePtr(const JSCell*);
    47 
    48         JSValue* payload() const { return m_payload; }
    49         JSValue** payloadPtr() { return &m_payload; }
    50 
    51         bool operator!() const { return !payload(); }
    52    
    53         // This conversion operator allows implicit conversion to bool but not to other integer types.
    54         typedef JSValue* JSValuePtr::*UnspecifiedBoolType;
    55         operator UnspecifiedBoolType() const { return payload() ? &JSValuePtr::m_payload : 0; }
    56 
    57         JSValue* operator->() const { return payload(); }
    58 
    59     private:
    60         JSValue* m_payload;
    61     };
     42    typedef JSValue* JSValuePtr;
    6243
    6344    inline JSValuePtr noValue() { return static_cast<JSValue*>(0); }
    64     inline void* asPointer(JSValuePtr value) { return value.payload(); }
     45    inline void* asPointer(JSValuePtr value) { return value; }
    6546
    6647    /*
     
    322303        static ALWAYS_INLINE uintptr_t rawValue(JSValuePtr v)
    323304        {
    324             return reinterpret_cast<uintptr_t>(v.payload());
     305            return reinterpret_cast<uintptr_t>(v);
    325306        }
    326307
  • trunk/JavaScriptCore/kjs/JSValue.h

    r37714 r37812  
    4747
    4848    class JSValue : Noncopyable {
    49     private:
    50         JSValue();
    51         ~JSValue();
     49    protected:
     50        JSValue() { }
     51        virtual ~JSValue() { }
    5252
    5353    public:
     
    137137    };
    138138
    139     bool operator==(JSValuePtr, JSValuePtr);
    140     bool operator!=(JSValuePtr, JSValuePtr);
    141 
    142139    // These are identical logic to the JSValue functions above, and faster than jsNumber(number)->toInt32().
    143140    int32_t toInt32(double);
     
    242239    }
    243240
    244     inline bool operator==(JSValuePtr a, JSValuePtr b)
    245     {
    246         return a.payload() == b.payload();
    247     }
    248 
    249     inline bool operator!=(JSValuePtr a, JSValuePtr b)
    250     {
    251         return a.payload() != b.payload();
    252     }
    253 
    254241} // namespace JSC
    255242
  • trunk/JavaScriptCore/kjs/PropertySlot.h

    r37712 r37812  
    4545        }
    4646
    47         explicit PropertySlot(JSValuePtr base)
    48             : m_slotBase(base)
     47        explicit PropertySlot(const JSValue* base)
     48            : m_slotBase(const_cast<JSValue*>(base))
    4949            , m_offset(WTF::notFound)
    5050        {
  • trunk/JavaScriptCore/kjs/protect.h

    r37712 r37812  
    9090       
    9191        T* get() const { return m_ptr; }
    92         operator JSValuePtr() const { return m_ptr; }
    9392        operator T*() const { return m_ptr; }
    9493        T* operator->() const { return m_ptr; }
     
    101100    private:
    102101        T* m_ptr;
    103     };
    104 
    105     template <> class ProtectedPtr<JSValuePtr> {
    106     public:
    107         ProtectedPtr() : m_ptr(0) { }
    108         ProtectedPtr(JSValuePtr);
    109         ProtectedPtr(const ProtectedPtr&);
    110         ~ProtectedPtr();
    111 
    112         template <class U> ProtectedPtr(const ProtectedPtr<U>&);
    113        
    114         JSValue* get() const { return m_ptr; }
    115         operator JSValuePtr() const { return m_ptr; }
    116         operator JSValue*() const { return m_ptr; }
    117         JSValue* operator->() const { return m_ptr; }
    118        
    119         bool operator!() const { return !m_ptr; }
    120 
    121         ProtectedPtr& operator=(JSValuePtr);
    122         ProtectedPtr& operator=(const ProtectedPtr&);
    123        
    124     private:
    125         JSValue* m_ptr;
    126102    };
    127103
     
    166142    }
    167143
    168     inline ProtectedPtr<JSValuePtr>::ProtectedPtr(JSValuePtr ptr)
    169         : m_ptr(ptr.payload())
    170     {
    171         gcProtectNullTolerant(m_ptr);
    172     }
    173 
    174     inline ProtectedPtr<JSValuePtr>::ProtectedPtr(const ProtectedPtr& o)
    175         : m_ptr(o.m_ptr)
    176     {
    177         gcProtectNullTolerant(m_ptr);
    178     }
    179 
    180     inline ProtectedPtr<JSValuePtr>::~ProtectedPtr()
    181     {
    182         gcUnprotectNullTolerant(m_ptr);
    183     }
    184 
    185     inline ProtectedPtr<JSValuePtr>& ProtectedPtr<JSValuePtr>::operator=(const ProtectedPtr& o)
    186     {
    187         JSValuePtr optr = o.m_ptr;
    188         gcProtectNullTolerant(optr);
    189         gcUnprotectNullTolerant(m_ptr);
    190         m_ptr = optr.payload();
    191         return *this;
    192     }
    193 
    194     inline ProtectedPtr<JSValuePtr>& ProtectedPtr<JSValuePtr>::operator=(JSValuePtr ptr)
    195     {
    196         gcProtectNullTolerant(ptr);
    197         gcUnprotectNullTolerant(m_ptr);
    198         m_ptr = ptr.payload();
    199         return *this;
    200     }
    201 
    202144    template <class T> inline bool operator==(const ProtectedPtr<T>& a, const ProtectedPtr<T>& b) { return a.get() == b.get(); }
    203145    template <class T> inline bool operator==(const ProtectedPtr<T>& a, const T* b) { return a.get() == b; }
Note: See TracChangeset for help on using the changeset viewer.