Changeset 11773 in webkit for trunk/JavaScriptCore/kjs/object.h


Ignore:
Timestamp:
Dec 27, 2005, 1:24:14 AM (19 years ago)
Author:
mjs
Message:

Reviewed by Darin and Geoff.

Changes by me and Anders.

  • also fixed some warnings reported by -Winline
  • JavaScriptCorePrefix.h: Move new and delete definitions higher so there aren't conflicts with use in standard C++ headers
  • kjs/object.cpp: (KJS::throwSetterError): Moved this piece of put into a seprate function to avoid the PIC branch. (KJS::JSObject::put): Use hasGetterSetterProperties to avoid expensive stuff when not needed. Also use GetterSetter properties attribute. (KJS::JSObject::deleteProperty): Recompute whether any properties are getter/setter properties any more, if this one was one. (KJS::JSObject::defineGetter): Let the PropertyMap know that it has getter/setter properties now (and use the new attribute). (KJS::JSObject::defineSetter): Ditto. (KJS::JSObject::fillGetterPropertySlot): Out-of-line helper for getOwnPropertySlot, to avoid global variable access in the hot code path.
  • kjs/object.h: (KJS::): Added GetterSetter attribute. (KJS::JSCell::isObject): Moved lower to be after inline methods it uses. (KJS::JSValue::isObject): ditto (KJS::JSObject::getOwnPropertySlot): try to avoid impact of getters and setters as much as possible in the case where they are not being used
  • kjs/property_map.cpp: (KJS::PropertyMap::containsGettersOrSetters): New method to help with this
  • kjs/property_map.h: (KJS::PropertyMap::hasGetterSetterProperties): Ditto (KJS::PropertyMap::setHasGetterSetterProperties): Ditto (KJS::PropertyMap::PropertyMap): Added a crazy hack to store the global "has getter/setter properties" flag in the property map single entry, to avoid making objects any bigger.
  • kjs/value.h: Moved some things to object.h to make -Winline happier
File:
1 edited

Legend:

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

    r11566 r11773  
    5151  // ECMA 262-3 8.6.1
    5252  // Property attributes
    53   enum Attribute { None       = 0,
    54                    ReadOnly   = 1 << 1, // property can be only read, not written
    55                    DontEnum   = 1 << 2, // property doesn't appear in (for .. in ..)
    56                    DontDelete = 1 << 3, // property can't be deleted
    57                    Internal   = 1 << 4, // an internal property, set to bypass checks
    58                    Function   = 1 << 5 }; // property is a function - only used by static hashtables
     53  enum Attribute { None         = 0,
     54                   ReadOnly     = 1 << 1, // property can be only read, not written
     55                   DontEnum     = 1 << 2, // property doesn't appear in (for .. in ..)
     56                   DontDelete   = 1 << 3, // property can't be deleted
     57                   Internal     = 1 << 4, // an internal property, set to bypass checks
     58                   Function     = 1 << 5, // property is a function - only used by static hashtables
     59                   GetterSetter = 1 << 6 }; // property is a getter or setter
    5960
    6061  /**
     
    503504    void putDirect(const Identifier &propertyName, JSValue *value, int attr = 0);
    504505    void putDirect(const Identifier &propertyName, int value, int attr = 0);
    505    
     506
     507    void fillGetterPropertySlot(PropertySlot& slot, JSValue **location);
     508
    506509    void defineGetter(ExecState *exec, const Identifier& propertyName, JSObject *getterFunc);
    507510    void defineSetter(ExecState *exec, const Identifier& propertyName, JSObject *setterFunc);
     
    567570JSObject *throwError(ExecState *, ErrorType, const char *message);
    568571JSObject *throwError(ExecState *, ErrorType);
    569  
    570 inline bool JSCell::isObject(const ClassInfo *info) const
    571 {
    572     return isObject() && static_cast<const JSObject *>(this)->inherits(info);
    573 }
    574572
    575573inline JSObject::JSObject(JSObject *proto)
     
    613611}
    614612
     613// this method is here to be after the inline declaration of JSObject::inherits
     614inline bool JSCell::isObject(const ClassInfo *info) const
     615{
     616    return isObject() && static_cast<const JSObject *>(this)->inherits(info);
     617}
     618
     619// this method is here to be after the inline declaration of JSCell::isObject
     620inline bool JSValue::isObject(const ClassInfo *c) const
     621{
     622    return !SimpleNumber::is(this) && downcast()->isObject(c);
     623}
     624
    615625// It may seem crazy to inline a function this large but it makes a big difference
    616626// since this is function very hot in variable lookup
     
    633643// but it makes a big difference to property lookup that derived classes can inline their
    634644// base class call to this.
    635 inline bool JSObject::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
     645ALWAYS_INLINE bool JSObject::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
    636646{
    637647    if (JSValue **location = getDirectLocation(propertyName)) {
    638         if ((*location)->type() == GetterSetterType) {
    639             GetterSetterImp *gs = static_cast<GetterSetterImp *>(*location);
    640             JSObject *getterFunc = gs->getGetter();
    641             if (getterFunc)
    642                 slot.setGetterSlot(this, getterFunc);
    643             else
    644                 slot.setUndefined(this);
    645         } else {
     648        if (_prop.hasGetterSetterProperties() && location[0]->type() == GetterSetterType)
     649            fillGetterPropertySlot(slot, location);
     650        else
    646651            slot.setValueSlot(this, location);
    647         }
    648652        return true;
    649653    }
Note: See TracChangeset for help on using the changeset viewer.