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


Ignore:
Timestamp:
Jul 25, 2005, 3:17:20 PM (20 years ago)
Author:
mjs
Message:

JavaScriptCore:

Reviewed by Darin.

  • 10% speedup on JavaScript iBench
  • 5% speedup on 24fun BenchJS benchmark

Changed all get methods to getOwnProperty - they are no longer
responsible for prototype lookup, and determine if the property
was found as a side efect.

get() is now a nonvirtual ObjectImp method which calls the virtual
getOwnProperty and walks the prototype chain. A few selected
methods were inlined.

Changed ResolveNode::evaluate plus some other places to use
getProperty which does get() and hasProperty() in one lookup.

Also miscellaneous code cleanup.

  • bindings/objc/objc_runtime.h:
  • bindings/objc/objc_runtime.mm: (ObjcFallbackObjectImp::ObjcFallbackObjectImp): (ObjcFallbackObjectImp::getOwnProperty):
  • bindings/runtime_array.cpp: (RuntimeArrayImp::RuntimeArrayImp): (RuntimeArrayImp::getOwnProperty):
  • bindings/runtime_array.h:
  • bindings/runtime_method.cpp: (RuntimeMethodImp::getOwnProperty):
  • bindings/runtime_method.h:
  • bindings/runtime_object.cpp: (RuntimeObjectImp::getOwnProperty):
  • bindings/runtime_object.h:
  • kjs/array_instance.h:
  • kjs/array_object.cpp: (ArrayInstanceImp::getOwnProperty): (ArrayPrototypeImp::getOwnProperty): (ArrayProtoFuncImp::call):
  • kjs/array_object.h:
  • kjs/date_object.cpp: (DatePrototypeImp::getOwnProperty):
  • kjs/date_object.h:
  • kjs/function.cpp: (KJS::FunctionImp::getOwnProperty): (KJS::ArgumentsImp::getOwnProperty): (KJS::ActivationImp::getOwnProperty):
  • kjs/function.h:
  • kjs/lookup.h: (KJS::lookupGetOwnProperty): (KJS::lookupGetOwnFunction): (KJS::lookupGetOwnValue):
  • kjs/math_object.cpp: (MathObjectImp::getOwnProperty): (MathObjectImp::getValueProperty):
  • kjs/math_object.h:
  • kjs/nodes.cpp: (ResolveNode::evaluate):
  • kjs/number_object.cpp: (NumberObjectImp::getOwnProperty):
  • kjs/number_object.h:
  • kjs/object.cpp: (KJS::ObjectImp::get): (KJS::ObjectImp::getOwnProperty): (KJS::ObjectImp::getProperty):
  • kjs/object.h: (KJS::ObjectImp::getProperty): (KJS::ObjectImp::getOwnProperty):
  • kjs/object_object.cpp: (ObjectProtoFuncImp::call):
  • kjs/regexp_object.cpp: (RegExpObjectImp::getOwnProperty):
  • kjs/regexp_object.h:
  • kjs/string_object.cpp: (StringInstanceImp::getOwnProperty): (StringPrototypeImp::getOwnProperty):
  • kjs/string_object.h:

WebCore:

Reviewed by Darin.

  • 10% speedup on JavaScript iBench
  • 5% speedup on 24fun BenchJS benchmark

Changed all get methods to getOwnProperty - they are no longer responsible for
prototype lookup, and determine if the property was found as a side efect.

Also miscellaneous code cleanup.

  • khtml/ecma/kjs_css.cpp: (KJS::DOMCSSStyleDeclaration::getOwnProperty): (KJS::DOMStyleSheet::getOwnProperty): (KJS::DOMStyleSheetList::getOwnProperty): (KJS::DOMMediaList::getOwnProperty): (KJS::DOMCSSStyleSheet::getOwnProperty): (KJS::DOMCSSRuleList::getOwnProperty): (KJS::DOMCSSRule::getOwnProperty): (KJS::DOMCSSRule::getValueProperty): (KJS::CSSRuleConstructor::getOwnProperty): (KJS::DOMCSSValue::getOwnProperty): (KJS::CSSValueConstructor::getOwnProperty): (KJS::DOMCSSPrimitiveValue::getOwnProperty): (KJS::CSSPrimitiveValueConstructor::getOwnProperty): (KJS::DOMCSSValueList::getOwnProperty): (KJS::DOMRGBColor::getOwnProperty): (KJS::DOMRect::getOwnProperty): (KJS::DOMCounter::getOwnProperty):
  • khtml/ecma/kjs_css.h:
  • khtml/ecma/kjs_dom.cpp: (KJS::DOMNode::getOwnProperty): (KJS::DOMNodeList::getOwnProperty): (KJS::DOMAttr::getOwnProperty): (KJS::DOMDocument::getOwnProperty): (KJS::DOMElement::getOwnProperty): (KJS::DOMDocumentType::getOwnProperty): (KJS::DOMNamedNodeMap::getOwnProperty): (KJS::DOMProcessingInstruction::getOwnProperty): (KJS::DOMNotation::getOwnProperty): (KJS::DOMEntity::getOwnProperty): (KJS::NodeConstructor::getOwnProperty): (KJS::DOMExceptionConstructor::getOwnProperty): (KJS::DOMNamedNodesCollection::getOwnProperty): (KJS::DOMCharacterData::getOwnProperty):
  • khtml/ecma/kjs_dom.h:
  • khtml/ecma/kjs_events.cpp: (KJS::EventConstructor::getOwnProperty): (KJS::DOMEvent::getOwnProperty): (KJS::EventExceptionConstructor::getOwnProperty): (KJS::DOMUIEvent::getOwnProperty): (KJS::DOMMouseEvent::getOwnProperty): (KJS::DOMKeyboardEvent::getOwnProperty): (KJS::MutationEventConstructor::getOwnProperty): (KJS::DOMMutationEvent::getOwnProperty): (KJS::DOMWheelEvent::getOwnProperty): (KJS::Clipboard::getOwnProperty):
  • khtml/ecma/kjs_events.h:
  • khtml/ecma/kjs_html.cpp: (KJS::HTMLDocument::getOwnProperty): (KJS::KJS::HTMLElement::getOwnProperty): (KJS::KJS::HTMLCollection::getOwnProperty): (KJS::KJS::HTMLSelectCollection::getOwnProperty): (KJS::Image::getOwnProperty): (KJS::Context2D::getOwnProperty): (KJS::Gradient::getOwnProperty): (KJS::ImagePattern::getOwnProperty):
  • khtml/ecma/kjs_html.h:
  • khtml/ecma/kjs_navigator.cpp: (KJS::Plugin::Plugin): (KJS::Navigator::getOwnProperty): (KJS::Plugins::getOwnProperty): (KJS::MimeTypes::getOwnProperty): (KJS::Plugin::getOwnProperty): (KJS::MimeType::getOwnProperty):
  • khtml/ecma/kjs_navigator.h:
  • khtml/ecma/kjs_range.cpp: (KJS::DOMRange::getOwnProperty): (KJS::RangeConstructor::getOwnProperty):
  • khtml/ecma/kjs_range.h:
  • khtml/ecma/kjs_traversal.cpp: (KJS::DOMNodeIterator::getOwnProperty): (KJS::NodeFilterConstructor::getOwnProperty): (KJS::DOMTreeWalker::getOwnProperty):
  • khtml/ecma/kjs_traversal.h:
  • khtml/ecma/kjs_views.cpp: (KJS::DOMAbstractView::getOwnProperty):
  • khtml/ecma/kjs_views.h:
  • khtml/ecma/kjs_window.cpp: (KJS::Screen::getOwnProperty): (KJS::Window::~Window): (KJS::Window::getOwnProperty): (KJS::Window::put): (KJS::FrameArray::getOwnProperty): (KJS::Location::Location): (KJS::Location::getOwnProperty): (KJS::Location::put): (KJS::Selection::Selection): (KJS::Selection::getOwnProperty): (KJS::BarInfo::getOwnProperty): (KJS::History::getOwnProperty):
  • khtml/ecma/kjs_window.h:
  • khtml/ecma/xmlhttprequest.cpp: (KJS::XMLHttpRequest::getOwnProperty):
  • khtml/ecma/xmlhttprequest.h:
File:
1 edited

Legend:

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

    r9795 r9889  
    504504     */
    505505    // [[Get]] - must be implemented by all Objects
    506     virtual Value get(ExecState *exec, const Identifier &propertyName) const;
    507     virtual Value get(ExecState *exec, unsigned propertyName) const;
     506    Value get(ExecState *exec, const Identifier &propertyName) const;
     507    Value get(ExecState *exec, unsigned propertyName) const;
     508
     509    bool getProperty(ExecState *exec, const Identifier& propertyName, Value& result) const;
     510    bool getProperty(ExecState *exec, unsigned propertyName, Value& result) const;
     511
     512    virtual bool getOwnProperty(ExecState *exec, const Identifier& propertyName, Value& result) const;
     513    virtual bool getOwnProperty(ExecState *exec, unsigned propertyName, Value& result) const;
    508514
    509515    /**
     
    633639  };
    634640
     641
     642  // it may seem crazy to inline a function this large but it makes a big difference
     643  // since this is function very hot in variable lookup
     644  inline bool ObjectImp::getProperty(ExecState *exec, const Identifier& propertyName, Value& result) const
     645  {
     646    const ObjectImp *imp = this;
     647
     648    while (true) {
     649      if (imp->getOwnProperty(exec, propertyName, result))
     650        return true;
     651     
     652      const ValueImp *proto = imp->_proto;
     653      if (proto->dispatchType() != ObjectType)
     654        break;
     655     
     656      imp = static_cast<const ObjectImp *>(proto);
     657    }
     658   
     659    return false;
     660  }
     661
     662  // it may seem crazy to inline a function this large, especially a virtual function,
     663  // but it makes a big difference to property lookup if subclasses can inline their
     664  // superclass call to this
     665  inline bool ObjectImp::getOwnProperty(ExecState *exec, const Identifier &propertyName, Value &result) const
     666  {
     667      ValueImp *imp = getDirect(propertyName);
     668      if (imp) {
     669        result = Value(imp);
     670        return true;
     671      }
     672
     673      // non-standard netscape extension
     674      if (propertyName == specialPrototypePropertyName) {
     675        result = Value(_proto);
     676        return true;
     677      }
     678
     679      return false;
     680  }
     681
    635682  /**
    636683   * Types of Native Errors available. For custom errors, GeneralError
Note: See TracChangeset for help on using the changeset viewer.