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


Ignore:
Timestamp:
Aug 12, 2002, 1:14:02 PM (23 years ago)
Author:
darin
Message:

top level:

  • Tests/WebFoundation-Misc/ifnsurlextensions-test.m: (TestURLCommon): Add tests for the new WebNSURLExtras methods.
  • Tests/libiftest/IFCheckLeaks.c: (IFCheckLeaksAtExit): Remove workaround for CFPreferences race condition; it's now in WebFoundation.

JavaScriptCore:

Speed improvements. 19% faster on cvs-js-performance, 1% on cvs-static-urls.

Use global string objects for length and other common property names rather
than constantly making and destroying them. Use integer versions of get() and
other related calls rather than always making a string.

Also get rid of many unneeded constructors, destructors, copy constructors, and
assignment operators. And make some functions non-virtual.

  • kjs/internal.h:
  • kjs/internal.cpp: (NumberImp::toUInt32): Implement. (ReferenceImp::ReferenceImp): Special case for numeric property names. (ReferenceImp::getPropertyName): Moved guts here from ValueImp. Handle numeric case. (ReferenceImp::getValue): Moved guts here from ValueImp. Handle numeric case. (ReferenceImp::putValue): Moved guts here from ValueImp. Handle numeric case. (ReferenceImp::deleteValue): Added. Handle numeric case.
  • kjs/array_object.h:
  • kjs/array_object.cpp: All-new array implementation that stores the elements in a C++ array rather than in a property map. (ArrayInstanceImp::ArrayInstanceImp): Allocate the C++ array. (ArrayInstanceImp::~ArrayInstanceImp): Delete the C++ array. (ArrayInstanceImp::get): Implement both the old version and the new overload that takes an unsigned index for speed. (ArrayInstanceImp::put): Implement both the old version and the new overload that takes an unsigned index for speed. (ArrayInstanceImp::hasProperty): Implement both the old version and the new overload that takes an unsigned index for speed. (ArrayInstanceImp::deleteProperty): Implement both the old version and the new overload that takes an unsigned index for speed. (ArrayInstanceImp::setLength): Added. Used by the above to resize the array. (ArrayInstanceImp::mark): Mark the elements of the array too. (ArrayPrototypeImp::ArrayPrototypeImp): Pass the length to the array instance constructor.
  • kjs/bool_object.cpp:
  • kjs/date_object.cpp:
  • kjs/error_object.cpp:
  • kjs/function.cpp:
  • kjs/function_object.cpp:
  • kjs/math_object.cpp:
  • kjs/nodes.cpp:
  • kjs/nodes.h:
  • kjs/number_object.cpp:
  • kjs/object_object.cpp:
  • kjs/regexp_object.cpp:
  • kjs/string_object.cpp:
  • kjs/nodes2string.cpp: (SourceStream::operator<<): Add a special case for char now that you can't create a UString from a char implicitly.
  • kjs/object.h:
  • kjs/object.cpp: (ObjectImp::get): Call through to the string version if the numeric version is not implemented. (ObjectImp::put): Call through to the string version if the numeric version is not implemented. (ObjectImp::hasProperty): Call through to the string version if the numeric version is not implemented. (ObjectImp::deleteProperty): Call through to the string version if the numeric version is not implemented.
  • kjs/types.h:
  • kjs/types.cpp: (Reference::Reference): Added constructors for the numeric property name case.
  • kjs/ustring.h: Made the constructor that turns a character into a string be explicit so we don't get numbers that turn themselves into strings.
  • kjs/ustring.cpp: (UString::UString): Detect the empty string case, and use a shared empty string. (UString::find): Add an overload for single character finds. (UString::rfind): Add an overload for single character finds. (KJS::operator==): Fix bug where it would call strlen(0) if the first string was not null. Also handle non-ASCII characters consistently with the rest of the code by casting to unsigned char just in case.
  • kjs/value.h: Make ValueImp and all subclasses non-copyable and non-assignable.
  • kjs/value.cpp: (ValueImp::toUInt32): New interface, mainly useful so we can detect array indices and not turn them into strings and back. (ValueImp::toInteger): Use the new toUInt32. Probably can use more improvement. (ValueImp::toInt32): Use the new toUInt32. Probably can use more improvement. (ValueImp::toUInt16): Use the new toUInt32. Probably can use more improvement. (ValueImp::getBase): Remove handling of the Reference case. That's in ReferenceImp now. (ValueImp::getPropertyName): Remove handling of the Reference case. That's in ReferenceImp now. (ValueImp::getValue): Remove handling of the Reference case. That's in ReferenceImp now. (ValueImp::putValue): Remove handling of the Reference case. That's in ReferenceImp now. (ValueImp::deleteValue): Added. Used so we can do delete the same way we do put.

WebFoundation:

  • CacheLoader.subproj/WebHTTPResourceLoader.m: (-[WebHTTPProtocolHandler createWFLoadRequest]): Fix handling of paths with queries and some other subtle path and port number handling issues by using _web_hostWithPort and _web_pathWithQuery.
  • Misc.subproj/WebNSURLExtras.h:
  • Misc.subproj/WebNSURLExtras.m: (-[NSURL _web_hostWithPort]): Added. (-[NSURL _web_pathWithQuery]): Added.
  • CacheLoader.subproj/WebResourceLoad.m: (initLoader): Get some random preference before creating threads. This makes it impossible to run into the CFPreferences race condition.

WebCore:

  • force-clean-timestamp: Need a full build because of KJS changes.
  • khtml/ecma/kjs_window.h: Need to store an Object, not an ObjectImp, because there's no way to copy an ObjectImp. KJS changes caught this mistake.
File:
1 edited

Legend:

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

    r1623 r1799  
    8080  class Object : public Value {
    8181  public:
    82     Object();
     82    Object() { }
    8383    explicit Object(ObjectImp *v);
    84     Object(const Object &v);
    85     virtual ~Object();
    86 
    87     Object& operator=(const Object &v);
    88 
    89     virtual const ClassInfo *classInfo() const;
     84   
     85    ObjectImp *imp() const;
     86
     87    const ClassInfo *classInfo() const;
    9088    bool inherits(const ClassInfo *cinfo) const;
    9189
     
    133131     */
    134132    Value get(ExecState *exec, const UString &propertyName) const;
     133    Value get(ExecState *exec, unsigned propertyName) const;
    135134
    136135    /**
     
    145144    void put(ExecState *exec, const UString &propertyName,
    146145             const Value &value, int attr = None);
     146    void put(ExecState *exec, unsigned propertyName,
     147             const Value &value, int attr = None);
    147148
    148149    /**
     
    169170     */
    170171    bool hasProperty(ExecState *exec, const UString &propertyName) const;
     172    bool hasProperty(ExecState *exec, unsigned propertyName) const;
    171173
    172174    /**
     
    182184     */
    183185    bool deleteProperty(ExecState *exec, const UString &propertyName);
     186    bool deleteProperty(ExecState *exec, unsigned propertyName);
    184187
    185188    /**
     
    350353  };
    351354
     355  inline Object Value::toObject(ExecState *exec) const { return rep->toObject(exec); }
     356 
    352357  class ObjectImp : public ValueImp {
    353358  public:
     
    467472    // [[Get]] - must be implemented by all Objects
    468473    virtual Value get(ExecState *exec, const UString &propertyName) const;
     474    virtual Value get(ExecState *exec, unsigned propertyName) const;
    469475
    470476    /**
     
    476482    virtual void put(ExecState *exec, const UString &propertyName,
    477483                     const Value &value, int attr = None);
     484    virtual void put(ExecState *exec, unsigned propertyName,
     485                     const Value &value, int attr = None);
    478486
    479487    /**
     
    493501    virtual bool hasProperty(ExecState *exec,
    494502                             const UString &propertyName) const;
     503    virtual bool hasProperty(ExecState *exec, unsigned propertyName) const;
    495504
    496505    /**
     
    502511    virtual bool deleteProperty(ExecState *exec,
    503512                                const UString &propertyName);
     513    virtual bool deleteProperty(ExecState *exec, unsigned propertyName);
    504514
    505515    /**
     
    560570    bool toBoolean(ExecState *exec) const;
    561571    double toNumber(ExecState *exec) const;
    562     int toInteger(ExecState *exec) const;
    563     int toInt32(ExecState *exec) const;
    564     unsigned int toUInt32(ExecState *exec) const;
    565     unsigned short toUInt16(ExecState *exec) const;
    566572    UString toString(ExecState *exec) const;
    567573    Object toObject(ExecState *exec) const;
     
    613619  };
    614620
     621  inline Object::Object(ObjectImp *v) : Value(v) { }
     622
     623  inline ObjectImp *Object::imp() const { return static_cast<ObjectImp*>(rep); }
     624
     625  inline const ClassInfo *Object::classInfo() const
     626    { return imp()->classInfo(); }
     627
     628  inline bool Object::inherits(const ClassInfo *cinfo) const
     629    { return imp()->inherits(cinfo); }
     630
     631  inline Value Object::prototype() const
     632    { return Value(imp()->prototype()); }
     633
     634  inline UString Object::className() const
     635    { return imp()->className(); }
     636
     637  inline Value Object::get(ExecState *exec, const UString &propertyName) const
     638    { return imp()->get(exec,propertyName); }
     639
     640  inline Value Object::get(ExecState *exec, unsigned propertyName) const
     641    { return imp()->get(exec,propertyName); }
     642
     643  inline void Object::put(ExecState *exec, const UString &propertyName, const Value &value, int attr)
     644    { imp()->put(exec,propertyName,value,attr); }
     645
     646  inline void Object::put(ExecState *exec, unsigned propertyName, const Value &value, int attr)
     647    { imp()->put(exec,propertyName,value,attr); }
     648
     649  inline bool Object::canPut(ExecState *exec, const UString &propertyName) const
     650    { return imp()->canPut(exec,propertyName); }
     651
     652  inline bool Object::hasProperty(ExecState *exec, const UString &propertyName) const
     653    { return imp()->hasProperty(exec, propertyName); }
     654
     655  inline bool Object::hasProperty(ExecState *exec, unsigned propertyName) const
     656    { return imp()->hasProperty(exec, propertyName); }
     657
     658  inline bool Object::deleteProperty(ExecState *exec, const UString &propertyName)
     659    { return imp()->deleteProperty(exec,propertyName); }
     660
     661  inline bool Object::deleteProperty(ExecState *exec, unsigned propertyName)
     662    { return imp()->deleteProperty(exec,propertyName); }
     663
     664  inline Value Object::defaultValue(ExecState *exec, Type hint) const
     665    { return imp()->defaultValue(exec,hint); }
     666
     667  inline bool Object::implementsConstruct() const
     668    { return imp()->implementsConstruct(); }
     669
     670  inline Object Object::construct(ExecState *exec, const List &args)
     671    { return imp()->construct(exec,args); }
     672
     673  inline bool Object::implementsCall() const
     674    { return imp()->implementsCall(); }
     675
     676  inline Value Object::call(ExecState *exec, Object &thisObj, const List &args)
     677    { return imp()->call(exec,thisObj,args); }
     678
     679  inline bool Object::implementsHasInstance() const
     680    { return imp()->implementsHasInstance(); }
     681
     682  inline Boolean Object::hasInstance(ExecState *exec, const Value &value)
     683    { return imp()->hasInstance(exec,value); }
     684
     685  inline const List Object::scope() const
     686    { return imp()->scope(); }
     687
     688  inline void Object::setScope(const List &s)
     689    { imp()->setScope(s); }
     690
     691  inline List Object::propList(ExecState *exec, bool recursive)
     692    { return imp()->propList(exec,recursive); }
     693
     694  inline Value Object::internalValue() const
     695    { return imp()->internalValue(); }
     696
     697  inline void Object::setInternalValue(const Value &v)
     698    { imp()->setInternalValue(v); }
     699
     700  extern const UString lengthPropertyName;
     701  extern const UString prototypePropertyName;
     702  extern const UString toStringPropertyName;
     703  extern const UString valueOfPropertyName;
     704
    615705}; // namespace
    616706
Note: See TracChangeset for help on using the changeset viewer.