Changeset 37799 in webkit for trunk/JavaScriptCore/kjs/JSObject.h


Ignore:
Timestamp:
Oct 22, 2008, 5:11:11 PM (17 years ago)
Author:
Darin Adler
Message:

JavaScriptCore:

2008-10-22 Darin Adler <Darin Adler>

Reviewed by Sam Weinig.

A bit over 3% faster on V8 tests.

  • JavascriptCore.exp: Export leak-related functions..
  • API/JSCallbackConstructor.h: (JSC::JSCallbackConstructor::createStructureID): Set HasStandardGetOwnPropertySlot since this class doesn't override getPropertySlot.
  • API/JSCallbackFunction.h: (JSC::JSCallbackFunction::createStructureID): Ditto.
  • VM/ExceptionHelpers.cpp: (JSC::InterruptedExecutionError::InterruptedExecutionError): Use a structure that's created just for this class instead of trying to share a single "null prototype" structure.
  • VM/Machine.cpp: (JSC::Machine::cti_op_create_arguments_no_params): Rename Arguments::ArgumentsNoParameters to Arguments::NoParameters.


  • kjs/Arguments.h: Rename the enum from Arguments::ArgumentsParameters to Arguments::NoParametersType and the value from Arguments::ArgumentsNoParameters to Arguments::NoParameters. (JSC::Arguments::createStructureID): Added. Returns a structure without HasStandardGetOwnPropertySlot since this class overrides getOwnPropertySlot. (JSC::Arguments::Arguments): Added an assertion that there are no parameters.
  • kjs/DatePrototype.h: (JSC::DatePrototype::createStructureID): Added. Returns a structure without HasStandardGetOwnPropertySlot since this class overrides getOwnPropertySlot.
  • kjs/FunctionPrototype.h: (JSC::FunctionPrototype::createStructureID): Set HasStandardGetOwnPropertySlot since this class doesn't override getPropertySlot.
  • kjs/InternalFunction.h: (JSC::InternalFunction::createStructureID): Ditto.
  • kjs/JSArray.h: (JSC::JSArray::createStructureID): Added. Returns a structure without HasStandardGetOwnPropertySlot since this class overrides getOwnPropertySlot.
  • kjs/JSCell.h: Added declaration of fastGetOwnPropertySlot; a non-virtual version that uses the structure bit to decide whether to call the virtual version.
  • kjs/JSFunction.h: (JSC::JSFunction::createStructureID): Added. Returns a structure without HasStandardGetOwnPropertySlot since this class overrides getOwnPropertySlot.
  • kjs/JSGlobalData.cpp: (JSC::JSGlobalData::JSGlobalData): Initialize new structures; removed nullProtoStructureID.
  • kjs/JSGlobalData.h: Added new structures. Removed nullProtoStructureID.
  • kjs/JSGlobalObject.h: (JSC::JSGlobalObject::createStructureID): Added. Returns a structure without HasStandardGetOwnPropertySlot since this class overrides getOwnPropertySlot.
  • kjs/JSNotAnObject.h: (JSC::JSNotAnObjectErrorStub::JSNotAnObjectErrorStub): Use a structure that's created just for this class instead of trying to share a single "null prototype" structure. (JSC::JSNotAnObjectErrorStub::isNotAnObjectErrorStub): Marked this function virtual for clarity and made it private since no one should call it if they already have a pointer to this specific type. (JSC::JSNotAnObject::JSNotAnObject): Use a structure that's created just for this class instead of trying to share a single "null prototype" structure. (JSC::JSNotAnObject::createStructureID): Added. Returns a structure without HasStandardGetOwnPropertySlot since this class overrides getOwnPropertySlot.
  • kjs/JSObject.h: (JSC::JSObject::createStructureID): Added HasStandardGetOwnPropertySlot. (JSC::JSObject::inlineGetOwnPropertySlot): Added. Used so we can share code between getOwnPropertySlot and fastGetOwnPropertySlot. (JSC::JSObject::getOwnPropertySlot): Moved so that functions are above the functions that call them. Moved the guts of this function into inlineGetOwnPropertySlot. (JSC::JSCell::fastGetOwnPropertySlot): Added. Checks the HasStandardGetOwnPropertySlot bit and if it's set, calls inlineGetOwnPropertySlot, otherwise calls getOwnPropertySlot. (JSC::JSObject::getPropertySlot): Changed to call fastGetOwnPropertySlot. (JSC::JSValue::get): Changed to call fastGetOwnPropertySlot.
  • kjs/JSWrapperObject.h: Made constructor protected to emphasize that this class is only a base class and never instantiated.
  • kjs/MathObject.h: (JSC::MathObject::createStructureID): Added. Returns a structure without HasStandardGetOwnPropertySlot since this class overrides getOwnPropertySlot.
  • kjs/NumberConstructor.h: (JSC::NumberConstructor::createStructureID): Ditto.
  • kjs/RegExpConstructor.h: (JSC::RegExpConstructor::createStructureID): Ditto.
  • kjs/RegExpObject.h: (JSC::RegExpObject::createStructureID): Ditto.
  • kjs/StringObject.h: (JSC::StringObject::createStructureID): Ditto.
  • kjs/TypeInfo.h: Added HasStandardGetOwnPropertySlot flag and hasStandardGetOwnPropertySlot accessor function.

JavaScriptGlue:

2008-10-22 Darin Adler <Darin Adler>

Reviewed by Sam Weinig.

  • JSRun.cpp: (JSGlueGlobalObject::JSGlueGlobalObject): Moved constructor here. Set up flags in its new location in global object data, and set up a structure for UserObjectImp too. (JSRun::JSRun): Added code to give the JSGlueGlobalObject its own unique structure, rather than using the default one from JSGlobalObject.
  • JSRun.h: Made JSGlueGlobalObject take a structure ID. Also moved the data into a separate data object. And added userObjectStructure, a Structure to be used by UserObjectImp.
  • JSUtils.cpp: Removed unused sharedGlobalData global. (JSObjectKJSValue): Pass Structure in when creating UserObjectImp. (unprotectGlobalObject): Use JSGlueGLobalObject type specifically. (initializeGlobalObjectKey): Removed code to set up unused sharedGlobalData. (getThreadGlobalObject): Added. Shared by JSObjectKJSValue and getThreadGlobalExecState. Also now passes in a structure ID when creating the global object. (getThreadGlobalExecState): Changed to call getThreadGlobalObject.
  • UserObjectImp.cpp: (UserObjectImp::UserObjectImp): Changed to take a structure.
  • UserObjectImp.h: (UserObjectImp::createStructureID): Added. Returns a structure without HasStandardGetOwnPropertySlot since this class overrides getOwnPropertySlot.

WebCore:

2008-10-22 Darin Adler <Darin Adler>

Reviewed by Sam Weinig.

  • bindings/js/JSDOMWindowShell.h: (WebCore::JSDOMWindowShell::createStructureID): Added. Returns a structure without HasStandardGetOwnPropertySlot since this class overrides getOwnPropertySlot.
  • bindings/js/JSInspectorCallbackWrapper.cpp: (WebCore::JSInspectorCallbackWrapper::wrap): Change to use a unique structure for this class rather than sharing nullProtoStructureID, which no longer exists.
  • bindings/js/JSNamedNodesCollection.h: (WebCore::JSNamedNodesCollection::createStructureID): Added. Returns a structure without HasStandardGetOwnPropertySlot since this class overrides getOwnPropertySlot.
  • bindings/js/JSRGBColor.h: (WebCore::JSRGBColor::createStructureID): Ditto.
  • bindings/scripts/CodeGeneratorJS.pm: Added createStructureID functions for the wrappers, constructors, and prototypes in any case where they override getOwnPropertySlot, without HasStandardGetOwnPropertySlot.
  • bridge/objc/objc_runtime.h: (JSC::Bindings::ObjcFallbackObjectImp::createStructureID): Added. Returns a structure without HasStandardGetOwnPropertySlot since this class overrides getOwnPropertySlot.
  • bridge/qt/qt_runtime.h: (JSC::Bindings::QtRuntimeMethod::createStructureID): Ditto.
  • bridge/runtime_array.h: (JSC::RuntimeArray::createStructureID): Ditto.
  • bridge/runtime_method.h: (JSC::RuntimeMethod::createStructureID): Ditto.
  • bridge/runtime_object.h: (JSC::RuntimeObjectImp::createStructureID): Ditto.
File:
1 edited

Legend:

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

    r37747 r37799  
    5656        friend class BatchedTransitionOptimizer;
    5757        friend class CTI;
     58        friend class JSCell;
    5859
    5960    public:
     
    184185        static const size_t nonInlineBaseStorageCapacity = 16;
    185186
    186         static PassRefPtr<StructureID> createStructureID(JSValuePtr proto) { return StructureID::create(proto, TypeInfo(ObjectType)); }
     187        static PassRefPtr<StructureID> createStructureID(JSValuePtr prototype)
     188        {
     189            return StructureID::create(prototype, TypeInfo(ObjectType, HasStandardGetOwnPropertySlot));
     190        }
    187191
    188192    protected:
     
    190194
    191195    private:
     196        bool inlineGetOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
     197
    192198        const HashEntry* findPropertyHashEntry(ExecState*, const Identifier& propertyName) const;
    193199        StructureID* createInheritorID();
     
    267273}
    268274
    269 inline JSValuePtr JSObject::get(ExecState* exec, const Identifier& propertyName) const
    270 {
    271     PropertySlot slot(this);
    272     if (const_cast<JSObject*>(this)->getPropertySlot(exec, propertyName, slot))
    273         return slot.getValue(exec, propertyName);
    274    
    275     return jsUndefined();
    276 }
    277 
    278 inline JSValuePtr JSObject::get(ExecState* exec, unsigned propertyName) const
    279 {
    280     PropertySlot slot(this);
    281     if (const_cast<JSObject*>(this)->getPropertySlot(exec, propertyName, slot))
    282         return slot.getValue(exec, propertyName);
    283 
    284     return jsUndefined();
    285 }
    286 
    287 // It may seem crazy to inline a function this large but it makes a big difference
    288 // since this is function very hot in variable lookup
    289 inline bool JSObject::getPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
    290 {
    291     JSObject* object = this;
    292     while (true) {
    293         if (object->getOwnPropertySlot(exec, propertyName, slot))
    294             return true;
    295 
    296         JSValuePtr prototype = object->prototype();
    297         if (!prototype->isObject())
    298             return false;
    299 
    300         object = asObject(prototype);
    301     }
    302 }
    303 
    304 inline bool JSObject::getPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot)
    305 {
    306     JSObject* object = this;
    307 
    308     while (true) {
    309         if (object->getOwnPropertySlot(exec, propertyName, slot))
    310             return true;
    311 
    312         JSValuePtr prototype = object->prototype();
    313         if (!prototype->isObject())
    314             break;
    315 
    316         object = asObject(prototype);
     275ALWAYS_INLINE bool JSObject::inlineGetOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
     276{
     277    if (JSValuePtr* location = getDirectLocation(propertyName)) {
     278        if (m_structureID->hasGetterSetterProperties() && location[0]->isGetterSetter())
     279            fillGetterPropertySlot(slot, location);
     280        else
     281            slot.setValueSlot(this, location, offsetForLocation(location));
     282        return true;
     283    }
     284
     285    // non-standard Netscape extension
     286    if (propertyName == exec->propertyNames().underscoreProto) {
     287        slot.setValue(prototype());
     288        return true;
    317289    }
    318290
     
    320292}
    321293
    322 // It may seem crazy to inline a function this large, especially a virtual function,
    323 // but it makes a big difference to property lookup that derived classes can inline their
    324 // base class call to this.
    325294ALWAYS_INLINE bool JSObject::getOwnPropertySlotForWrite(ExecState* exec, const Identifier& propertyName, PropertySlot& slot, bool& slotIsWriteable)
    326295{
     
    352321ALWAYS_INLINE bool JSObject::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
    353322{
    354     if (JSValuePtr* location = getDirectLocation(propertyName)) {
    355         if (m_structureID->hasGetterSetterProperties() && location[0]->isGetterSetter())
    356             fillGetterPropertySlot(slot, location);
    357         else
    358             slot.setValueSlot(this, location, offsetForLocation(location));
    359         return true;
    360     }
    361 
    362     // non-standard Netscape extension
    363     if (propertyName == exec->propertyNames().underscoreProto) {
    364         slot.setValue(prototype());
    365         return true;
    366     }
    367 
    368     return false;
     323    return inlineGetOwnPropertySlot(exec, propertyName, slot);
     324}
     325
     326ALWAYS_INLINE bool JSCell::fastGetOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
     327{
     328    if (structureID()->typeInfo().hasStandardGetOwnPropertySlot())
     329        return asObject(this)->inlineGetOwnPropertySlot(exec, propertyName, slot);
     330    return getOwnPropertySlot(exec, propertyName, slot);
     331}
     332
     333// It may seem crazy to inline a function this large but it makes a big difference
     334// since this is function very hot in variable lookup
     335inline bool JSObject::getPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
     336{
     337    JSObject* object = this;
     338    while (true) {
     339        if (object->fastGetOwnPropertySlot(exec, propertyName, slot))
     340            return true;
     341        JSValuePtr prototype = object->prototype();
     342        if (!prototype->isObject())
     343            return false;
     344        object = asObject(prototype);
     345    }
     346}
     347
     348inline bool JSObject::getPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot)
     349{
     350    JSObject* object = this;
     351    while (true) {
     352        if (object->getOwnPropertySlot(exec, propertyName, slot))
     353            return true;
     354        JSValuePtr prototype = object->prototype();
     355        if (!prototype->isObject())
     356            return false;
     357        object = asObject(prototype);
     358    }
     359}
     360
     361inline JSValuePtr JSObject::get(ExecState* exec, const Identifier& propertyName) const
     362{
     363    PropertySlot slot(this);
     364    if (const_cast<JSObject*>(this)->getPropertySlot(exec, propertyName, slot))
     365        return slot.getValue(exec, propertyName);
     366   
     367    return jsUndefined();
     368}
     369
     370inline JSValuePtr JSObject::get(ExecState* exec, unsigned propertyName) const
     371{
     372    PropertySlot slot(this);
     373    if (const_cast<JSObject*>(this)->getPropertySlot(exec, propertyName, slot))
     374        return slot.getValue(exec, propertyName);
     375
     376    return jsUndefined();
    369377}
    370378
     
    462470    JSCell* cell = asCell();
    463471    while (true) {
    464         if (cell->getOwnPropertySlot(exec, propertyName, slot))
     472        if (cell->fastGetOwnPropertySlot(exec, propertyName, slot))
    465473            return slot.getValue(exec, propertyName);
    466474        ASSERT(cell->isObject());
Note: See TracChangeset for help on using the changeset viewer.