Ignore:
Timestamp:
Aug 6, 2005, 11:17:49 PM (20 years ago)
Author:
mjs
Message:

JavaScriptCore:

Reviewed by Darin.

Change over to the new PropertySlot mechanism for property
lookup. This allows the elimination of hasOwnProperty
methods. Also did some of the performance tuning enabled by this
(but not yet all the possible improvements for function calls,
assignment, ++, and so forth). And also much code cleanup.

Net result is about a 2% speedup on the JS iBench.

Also redid Geoff's fix for the chrashing applet by avoiding a NULL
prototype in the bindings code and using the default of Null()
instead.

  • JavaScriptCore.xcodeproj/project.pbxproj:
  • bindings/objc/objc_runtime.h:
  • bindings/objc/objc_runtime.mm: (ObjcFallbackObjectImp::ObjcFallbackObjectImp): (ObjcFallbackObjectImp::getOwnPropertySlot):
  • bindings/runtime_array.cpp: (RuntimeArrayImp::lengthGetter): (RuntimeArrayImp::indexGetter): (RuntimeArrayImp::getOwnPropertySlot):
  • bindings/runtime_array.h:
  • bindings/runtime_method.cpp: (RuntimeMethodImp::lengthGetter): (RuntimeMethodImp::getOwnPropertySlot):
  • bindings/runtime_method.h:
  • bindings/runtime_object.cpp: (RuntimeObjectImp::RuntimeObjectImp): (RuntimeObjectImp::fallbackObjectGetter): (RuntimeObjectImp::fieldGetter): (RuntimeObjectImp::methodGetter): (RuntimeObjectImp::getOwnPropertySlot):
  • bindings/runtime_object.h:
  • bindings/runtime_root.h:
  • kjs/array_instance.h:
  • kjs/array_object.cpp: (ArrayInstanceImp::lengthGetter): (ArrayInstanceImp::getOwnPropertySlot): (ArrayPrototypeImp::getOwnPropertySlot):
  • kjs/array_object.h:
  • kjs/date_object.cpp: (DatePrototypeImp::getOwnPropertySlot):
  • kjs/date_object.h:
  • kjs/function.cpp: (KJS::FunctionImp::argumentsGetter): (KJS::FunctionImp::lengthGetter): (KJS::FunctionImp::getOwnPropertySlot): (KJS::FunctionImp::put): (KJS::FunctionImp::deleteProperty): (KJS::ArgumentsImp::mappedIndexGetter): (KJS::ArgumentsImp::getOwnPropertySlot): (KJS::ActivationImp::argumentsGetter): (KJS::ActivationImp::getArgumentsGetter): (KJS::ActivationImp::getOwnPropertySlot): (KJS::ActivationImp::deleteProperty):
  • kjs/function.h:
  • kjs/internal.cpp: (InterpreterImp::InterpreterImp): (InterpreterImp::initGlobalObject): (InterpreterImp::~InterpreterImp): (InterpreterImp::evaluate):
  • kjs/internal.h: (KJS::InterpreterImp::globalExec):
  • kjs/interpreter.cpp: (Interpreter::Interpreter): (Interpreter::createLanguageInstanceForValue):
  • kjs/interpreter.h: (KJS::Interpreter::argumentsIdentifier): (KJS::Interpreter::specialPrototypeIdentifier):
  • kjs/lookup.h: (KJS::staticFunctionGetter): (KJS::staticValueGetter): (KJS::getStaticPropertySlot): (KJS::getStaticFunctionSlot): (KJS::getStaticValueSlot):
  • kjs/math_object.cpp: (MathObjectImp::getOwnPropertySlot):
  • kjs/math_object.h:
  • kjs/nodes.cpp: (ResolveNode::evaluate): (ResolveNode::evaluateReference): (AccessorNode1::evaluate): (AccessorNode2::evaluate):
  • kjs/number_object.cpp: (NumberObjectImp::getOwnPropertySlot):
  • kjs/number_object.h:
  • kjs/object.cpp: (KJS::ObjectImp::get): (KJS::ObjectImp::getProperty): (KJS::ObjectImp::getPropertySlot): (KJS::ObjectImp::getOwnPropertySlot): (KJS::ObjectImp::put): (KJS::ObjectImp::hasProperty): (KJS::ObjectImp::hasOwnProperty):
  • kjs/object.h: (KJS::ObjectImp::getDirectLocation): (KJS::ObjectImp::getPropertySlot): (KJS::ObjectImp::getOwnPropertySlot):
  • kjs/object_wrapper.h: Added. (KJS::): (KJS::Object::Object): (KJS::Object::operator ObjectImp *):
  • kjs/property_map.cpp: (KJS::PropertyMap::getLocation):
  • kjs/property_map.h:
  • kjs/property_slot.cpp: Added. (KJS::PropertySlot::undefinedGetter):
  • kjs/property_slot.h: Added. (KJS::PropertySlot::isSet): (KJS::PropertySlot::getValue): (KJS::PropertySlot::setValueSlot): (KJS::PropertySlot::setStaticEntry): (KJS::PropertySlot::setCustom): (KJS::PropertySlot::setCustomIndex): (KJS::PropertySlot::setUndefined): (KJS::PropertySlot::slotBase): (KJS::PropertySlot::staticEntry): (KJS::PropertySlot::index): (KJS::PropertySlot::):
  • kjs/protect.h:
  • kjs/protected_object.h: Added. (KJS::ProtectedObject::ProtectedObject): (KJS::ProtectedObject::~ProtectedObject): (KJS::ProtectedObject::operator=): (KJS::ProtectedReference::ProtectedReference): (KJS::ProtectedReference::~ProtectedReference): (KJS::ProtectedReference::operator=):
  • kjs/reference.h:
  • kjs/reference_list.cpp:
  • kjs/regexp_object.cpp: (RegExpObjectImp::backrefGetter): (RegExpObjectImp::getOwnPropertySlot):
  • kjs/regexp_object.h:
  • kjs/string_object.cpp: (StringInstanceImp::lengthGetter): (StringInstanceImp::indexGetter): (StringInstanceImp::getOwnPropertySlot): (StringPrototypeImp::getOwnPropertySlot):
  • kjs/string_object.h:

WebCore:

Reviewed by Darin.

Change over to the new PropertySlot mechanism for property
lookup. This allows the elimination of hasOwnProperty methods. I
also did a bunch of code cleanup and regularization of the various
property lookup methods.

Test cases added: Added a test case for a bug I found along the way.

  • layout-tests/fast/js/string-index-overflow.html:
  • layout-tests/fast/js/string-index-overflow-expected.txt:
  • khtml/ecma/kjs_binding.cpp: (KJS::ScriptInterpreter::createLanguageInstanceForValue):
  • khtml/ecma/kjs_binding.h:
  • khtml/ecma/kjs_css.cpp: (KJS::DOMCSSStyleDeclaration::indexGetter): (KJS::DOMCSSStyleDeclaration::cssPropertyGetter): (KJS::DOMCSSStyleDeclaration::getOwnPropertySlot): (KJS::DOMCSSStyleDeclaration::getValueProperty): (KJS::DOMStyleSheet::getOwnPropertySlot): (KJS::DOMStyleSheetList::getValueProperty): (KJS::DOMStyleSheetList::indexGetter): (KJS::DOMStyleSheetList::nameGetter): (KJS::DOMStyleSheetList::getOwnPropertySlot): (KJS::DOMMediaList::getValueProperty): (KJS::DOMMediaList::indexGetter): (KJS::DOMMediaList::getOwnPropertySlot): (KJS::DOMCSSStyleSheet::getValueProperty): (KJS::DOMCSSStyleSheet::getOwnPropertySlot): (KJS::DOMCSSRuleList::getValueProperty): (KJS::DOMCSSRuleList::indexGetter): (KJS::DOMCSSRuleList::getOwnPropertySlot): (KJS::DOMCSSRule::getOwnPropertySlot): (KJS::CSSRuleConstructor::getOwnPropertySlot): (KJS::DOMCSSValue::getValueProperty): (KJS::DOMCSSValue::getOwnPropertySlot): (KJS::CSSValueConstructor::getOwnPropertySlot): (KJS::DOMCSSPrimitiveValue::getValueProperty): (KJS::DOMCSSPrimitiveValue::getOwnPropertySlot): (KJS::CSSPrimitiveValueConstructor::getOwnPropertySlot): (KJS::DOMCSSValueList::getValueProperty): (KJS::DOMCSSValueList::indexGetter): (KJS::DOMCSSValueList::getOwnPropertySlot): (KJS::DOMRGBColor::getOwnPropertySlot): (KJS::DOMRect::getOwnPropertySlot): (KJS::DOMCounter::getOwnPropertySlot):
  • khtml/ecma/kjs_css.h: (KJS::DOMCSSStyleDeclaration::): (KJS::DOMCSSStyleSheet::): (KJS::DOMCSSRule::): (KJS::DOMCSSValueList::):
  • khtml/ecma/kjs_dom.cpp: (KJS::DOMNode::getOwnPropertySlot): (KJS::): (KJS::DOMNodeList::getValueProperty): (KJS::DOMNodeList::indexGetter): (KJS::DOMNodeList::nameGetter): (KJS::DOMNodeList::getOwnPropertySlot): (KJS::DOMNodeList::call): (KJS::DOMAttr::getOwnPropertySlot): (KJS::DOMDocument::getOwnPropertySlot): (KJS::DOMElement::getValueProperty): (KJS::DOMElement::attributeGetter): (KJS::DOMElement::getOwnPropertySlot): (KJS::DOMDocumentType::getOwnPropertySlot): (KJS::DOMNamedNodeMap::lengthGetter): (KJS::DOMNamedNodeMap::indexGetter): (KJS::DOMNamedNodeMap::getOwnPropertySlot): (KJS::DOMProcessingInstruction::getOwnPropertySlot): (KJS::DOMNotation::getOwnPropertySlot): (KJS::DOMEntity::getOwnPropertySlot): (KJS::NodeConstructor::getOwnPropertySlot): (KJS::DOMExceptionConstructor::getOwnPropertySlot): (KJS::DOMNamedNodesCollection::lengthGetter): (KJS::DOMNamedNodesCollection::indexGetter): (KJS::DOMNamedNodesCollection::getOwnPropertySlot): (KJS::DOMCharacterData::getOwnPropertySlot):
  • khtml/ecma/kjs_dom.h:
  • khtml/ecma/kjs_events.cpp: (KJS::EventConstructor::getOwnPropertySlot): (KJS::DOMEvent::getOwnPropertySlot): (KJS::EventExceptionConstructor::getOwnPropertySlot): (KJS::DOMUIEvent::getOwnPropertySlot): (KJS::DOMMouseEvent::getOwnPropertySlot): (KJS::DOMKeyboardEvent::getOwnPropertySlot): (KJS::MutationEventConstructor::getOwnPropertySlot): (KJS::DOMMutationEvent::getOwnPropertySlot): (KJS::DOMWheelEvent::getOwnPropertySlot): (KJS::Clipboard::getOwnPropertySlot):
  • khtml/ecma/kjs_events.h:
  • khtml/ecma/kjs_html.cpp: (KJS::HTMLDocument::namedItemGetter): (KJS::HTMLDocument::getValueProperty): (KJS::HTMLDocument::getOwnPropertySlot): (KJS::HTMLElement::formIndexGetter): (KJS::HTMLElement::formNameGetter): (KJS::HTMLElement::selectIndexGetter): (KJS::HTMLElement::framesetNameGetter): (KJS::HTMLElement::frameWindowPropertyGetter): (KJS::HTMLElement::runtimeObjectGetter): (KJS::HTMLElement::runtimeObjectPropertyGetter): (KJS::HTMLElement::getOwnPropertySlot): (KJS::HTMLCollection::lengthGetter): (KJS::HTMLCollection::indexGetter): (KJS::HTMLCollection::nameGetter): (KJS::HTMLCollection::getOwnPropertySlot): (KJS::HTMLSelectCollection::selectedIndexGetter): (KJS::HTMLSelectCollection::getOwnPropertySlot): (KJS::Image::getOwnPropertySlot): (KJS::Context2D::getOwnPropertySlot): (KJS::Gradient::getOwnPropertySlot): (KJS::ImagePattern::getOwnPropertySlot):
  • khtml/ecma/kjs_html.h: (KJS::HTMLCollection::toBoolean):
  • khtml/ecma/kjs_navigator.cpp: (KJS::Plugins::): (KJS::MimeTypes::): (KJS::Plugin::): (KJS::MimeType::): (KJS::): (KJS::Navigator::getOwnPropertySlot): (KJS::Plugins::getValueProperty): (KJS::Plugins::indexGetter): (KJS::Plugins::nameGetter): (KJS::Plugins::getOwnPropertySlot): (KJS::MimeTypes::getValueProperty): (KJS::MimeTypes::indexGetter): (KJS::MimeTypes::nameGetter): (KJS::MimeTypes::getOwnPropertySlot): (KJS::Plugin::getValueProperty): (KJS::Plugin::indexGetter): (KJS::Plugin::nameGetter): (KJS::Plugin::getOwnPropertySlot): (KJS::MimeType::getValueProperty): (KJS::MimeType::getOwnPropertySlot):
  • khtml/ecma/kjs_navigator.h:
  • khtml/ecma/kjs_range.cpp: (KJS::DOMRange::getOwnPropertySlot): (KJS::RangeConstructor::getOwnPropertySlot):
  • khtml/ecma/kjs_range.h:
  • khtml/ecma/kjs_traversal.cpp: (KJS::DOMNodeIterator::getOwnPropertySlot): (KJS::NodeFilterConstructor::getOwnPropertySlot): (KJS::DOMTreeWalker::getOwnPropertySlot):
  • khtml/ecma/kjs_traversal.h:
  • khtml/ecma/kjs_views.cpp: (KJS::DOMAbstractView::~DOMAbstractView): (KJS::DOMAbstractView::getValueProperty): (KJS::DOMAbstractView::getOwnPropertySlot):
  • khtml/ecma/kjs_views.h:
  • khtml/ecma/kjs_window.cpp: (KJS::FrameArray::): (KJS::FrameArray::classInfo): (KJS::Screen::getOwnPropertySlot): (KJS::Window::getValueProperty): (KJS::Window::childFrameGetter): (KJS::Window::namedFrameGetter): (KJS::Window::indexGetter): (KJS::Window::namedItemGetter): (KJS::Window::getOwnPropertySlot): (KJS::): (KJS::FrameArray::getValueProperty): (KJS::FrameArray::indexGetter): (KJS::FrameArray::nameGetter): (KJS::FrameArray::getOwnPropertySlot): (KJS::Location::getValueProperty): (KJS::Location::getOwnPropertySlot): (KJS::Selection::getValueProperty): (KJS::Selection::getOwnPropertySlot): (KJS::BarInfo::getValueProperty): (KJS::BarInfo::getOwnPropertySlot): (KJS::History::getOwnPropertySlot):
  • khtml/ecma/kjs_window.h:
  • khtml/ecma/xmlhttprequest.cpp: (KJS::XMLHttpRequest::getOwnPropertySlot):
  • khtml/ecma/xmlhttprequest.h:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/string_object.cpp

    r9889 r10076  
    5151}
    5252
    53 bool StringInstanceImp::getOwnProperty(ExecState *exec, const Identifier& propertyName, Value& result) const
     53Value StringInstanceImp::lengthGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot &slot)
     54{
     55    return Value(static_cast<StringInstanceImp *>(slot.slotBase())->internalValue().toString(exec).size());
     56}
     57
     58Value StringInstanceImp::indexGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot &slot)
     59{
     60    const UChar c = static_cast<StringInstanceImp *>(slot.slotBase())->internalValue().toString(exec)[slot.index()];
     61    return Value(UString(&c, 1));
     62}
     63
     64bool StringInstanceImp::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot &slot)
    5465{
    5566  if (propertyName == lengthPropertyName) {
    56     result = Value(internalValue().toString(exec).size());
     67    slot.setCustom(this, lengthGetter);
    5768    return true;
    5869  }
     
    6475    const unsigned length = s.size();
    6576    if (index >= length)
    66       return Undefined();
    67     const UChar c = s[index];
    68     result = Value(UString(&c, 1));
     77      return false;
     78    slot.setCustomIndex(this, index, indexGetter);
    6979    return true;
    7080  }
    7181
    72   return ObjectImp::getOwnProperty(exec, propertyName, result);
     82  return ObjectImp::getOwnPropertySlot(exec, propertyName, slot);
    7383}
    7484
     
    7888    return;
    7989  ObjectImp::put(exec, propertyName, value, attr);
    80 }
    81 
    82 bool StringInstanceImp::hasOwnProperty(ExecState *exec, const Identifier &propertyName) const
    83 {
    84   if (propertyName == lengthPropertyName)
    85     return true;
    86 
    87   bool ok;
    88   const unsigned index = propertyName.toArrayIndex(&ok);
    89   if (ok) {
    90     const unsigned length = internalValue().toString(exec).size();
    91     if (index < length)
    92       return true;
    93   }
    94 
    95   return ObjectImp::hasOwnProperty(exec, propertyName);
    9690}
    9791
     
    155149}
    156150
    157 bool StringPrototypeImp::getOwnProperty(ExecState *exec, const Identifier& propertyName, Value& result) const
    158 {
    159   return lookupGetOwnFunction<StringProtoFuncImp, StringInstanceImp>(exec, propertyName, &stringTable, this, result);
     151bool StringPrototypeImp::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot &slot)
     152{
     153  return getStaticFunctionSlot<StringProtoFuncImp, StringInstanceImp>(exec, &stringTable, this, propertyName, slot);
    160154}
    161155
Note: See TracChangeset for help on using the changeset viewer.