Ignore:
Timestamp:
Jun 12, 2008, 9:53:56 PM (17 years ago)
Author:
Darin Adler
Message:

2008-06-12 Darin Adler <Darin Adler>

Reviewed by Maciej.

Speeds up SunSpider by 1.1%.

Optimized code path for getting built-in properties from strings -- avoid
boxing with a string object in that case. We can make further changes to avoid
even more boxing, but this change alone is a win.

  • API/JSCallbackObjectFunctions.h: (KJS::JSCallbackObject::staticValueGetter): Use isObject instead of inherits in asssert, since the type of slotBase() is now JSValue, not JSObject. (KJS::JSCallbackObject::staticFunctionGetter): Ditto. (KJS::JSCallbackObject::callbackGetter): Ditto.
  • kjs/internal.cpp: (KJS::StringImp::getPrimitiveNumber): Updated for change of data member name. (KJS::StringImp::toBoolean): Ditto. (KJS::StringImp::toNumber): Ditto. (KJS::StringImp::toString): Ditto. (KJS::StringInstance::create): Added; avoids a bit of cut and paste code. (KJS::StringImp::toObject): Use StringInstance::create. (KJS::StringImp::toThisObject): Ditto. (KJS::StringImp::lengthGetter): Added. Replaces the getter that used to live in the StringInstance class. (KJS::StringImp::indexGetter): Ditto. (KJS::StringImp::indexNumericPropertyGetter): Ditto. (KJS::StringImp::getOwnPropertySlot): Added. Deals with built in properties of the string class without creating a StringInstance.
  • kjs/internal.h: (KJS::StringImp::getStringPropertySlot): Added. To be used by both the string and string object getOwnPropertySlot function.
  • kjs/lookup.h: (KJS::staticFunctionGetter): Updated since slotBase() is now a JSValue rather than a JSObject.
  • kjs/object.h: Removed PropertySlot::slotBase() function, which can now move back into property_slot.h where it belongs since it doesn't have to cast to JSObject*.
  • kjs/property_slot.cpp: (KJS::PropertySlot::functionGetter): Updated since slot.slotBase() is now a JSValue* instead of JSObject*. setGetterSlot still guarantees the base is a JSObject*.
  • kjs/property_slot.h: (KJS::PropertySlot::PropertySlot): Changed base to JSValue* intead of JSCell*. (KJS::PropertySlot::setStaticEntry): Ditto. (KJS::PropertySlot::setCustom): Ditto. (KJS::PropertySlot::setCustomIndex): Ditto. (KJS::PropertySlot::setCustomNumeric): Ditto. (KJS::PropertySlot::slotBase): Moved inline here since it no longer involves a downcast to JSObject*. (KJS::PropertySlot::setBase): Changed to JSValue*.
  • kjs/string_object.cpp: (KJS::StringInstance::getOwnPropertySlot): Changed to use getStringPropertySlot instead of coding the properties here. This allows sharing the code with StringImp.
  • kjs/string_object.h: Removed inlineGetOwnPropertySlot, lengthGetter, and indexGetter. Made one of the constructors protected.
  • kjs/value.h: Made getOwnPropertySlot private in the JSCell class -- this is better since it's not the real JSObject getOwnPropertySlot semantic and most callers shouldn't use it.
File:
1 edited

Legend:

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

    r34355 r34518  
    11// -*- c-basic-offset: 2 -*-
    22/*
    3  *  This file is part of the KDE libraries
    43 *  Copyright (C) 1999-2000 Harri Porten ([email protected])
     4 *  Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
    55 *
    66 *  This library is free software; you can redistribute it and/or
     
    3232  class StringInstance : public JSWrapperObject {
    3333  public:
    34     StringInstance(JSObject *proto);
    35     StringInstance(JSObject *proto, StringImp*);
    36     StringInstance(JSObject *proto, const UString&);
     34    StringInstance(JSObject* prototype);
     35    StringInstance(JSObject* prototype, const UString&);
     36
     37    static StringInstance* create(ExecState*, StringImp*);
    3738
    3839    virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
     
    4041
    4142    virtual void put(ExecState* exec, const Identifier& propertyName, JSValue*);
    42     virtual bool deleteProperty(ExecState* exec, const Identifier& propertyName);
     43    virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
    4344    virtual void getPropertyNames(ExecState*, PropertyNameArray&);
    4445
    45     virtual const ClassInfo *classInfo() const { return &info; }
     46    virtual const ClassInfo* classInfo() const { return &info; }
    4647    static const ClassInfo info;
    4748
    4849    StringImp* internalValue() const { return static_cast<StringImp*>(JSWrapperObject::internalValue());}
    4950
    50   private:
    51     bool inlineGetOwnPropertySlot(ExecState*, unsigned, PropertySlot&);
    52 
    53     static JSValue* lengthGetter(ExecState*, const Identifier&, const PropertySlot&);
    54     static JSValue* indexGetter(ExecState*, const Identifier&, const PropertySlot&);
     51  protected:
     52    StringInstance(JSObject* prototype, StringImp*);
    5553  };
    5654
     
    144142  public:
    145143    StringObjectFuncImp(ExecState*, FunctionPrototype*, const Identifier&);
    146     virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
     144    virtual JSValue* callAsFunction(ExecState*, JSObject* thisObj, const List& args);
    147145  };
    148146
     
    150148
    151149#endif
    152 
Note: See TracChangeset for help on using the changeset viewer.