Changeset 1799 in webkit for trunk/JavaScriptCore/kjs/internal.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/internal.h

    r1024 r1799  
    5050  class UndefinedImp : public ValueImp {
    5151  public:
    52     UndefinedImp() {}
    53     virtual ~UndefinedImp() { }
    54 
    5552    Type type() const { return UndefinedType; }
    5653
     
    6461  };
    6562
     63  inline Undefined::Undefined(UndefinedImp *imp) : Value(imp) { }
     64
    6665  class NullImp : public ValueImp {
    6766  public:
    68     NullImp() {}
    69     virtual ~NullImp() { }
    70 
    7167    Type type() const { return NullType; }
    7268
     
    8076  };
    8177
     78  inline Null::Null(NullImp *imp) : Value(imp) { }
     79
    8280  class BooleanImp : public ValueImp {
    8381  public:
    84     virtual ~BooleanImp() { }
    8582    BooleanImp(bool v = false) : val(v) { }
    8683    bool value() const { return val; }
     
    9996    bool val;
    10097  };
     98 
     99  inline Boolean::Boolean(BooleanImp *imp) : Value(imp) { }
    101100
    102101  class StringImp : public ValueImp {
    103102  public:
    104     StringImp(const UString& v);
    105     virtual ~StringImp() { }
     103    StringImp(const UString& v) : val(v) { }
    106104    UString value() const { return val; }
    107105
     
    118116  };
    119117
     118  inline String::String(StringImp *imp) : Value(imp) { }
     119
    120120  class NumberImp : public ValueImp {
    121121  public:
    122     NumberImp(double v);
    123     virtual ~NumberImp() { }
     122    NumberImp(double v) : val(v) { }
    124123    double value() const { return val; }
    125124
     
    132131    Object toObject(ExecState *exec) const;
    133132
     133    virtual bool toUInt32(unsigned&) const;
     134
    134135  private:
    135136    double val;
    136137  };
     138
     139  inline Number::Number(NumberImp *imp) : Value(imp) { }
    137140
    138141  // ---------------------------------------------------------------------------
     
    142145  class ReferenceImp : public ValueImp {
    143146  public:
    144 
    145147    ReferenceImp(const Value& v, const UString& p);
    146     virtual ~ReferenceImp() { }
     148    ReferenceImp(const Value& v, unsigned p);
    147149    virtual void mark();
    148150
     
    153155    Object toObject(ExecState *exec) const;
    154156
    155     Value getBase() const { return Value(base); }
    156     UString getPropertyName() const { return prop; }
     157    Value getBase(ExecState *) const { return Value(base); }
     158    UString getPropertyName(ExecState *) const;
     159    Value getValue(ExecState *exec) const;
     160    void putValue(ExecState *exec, const Value& w);
     161    bool deleteValue(ExecState *exec);
    157162
    158163    Type type() const { return ReferenceType; }
     
    160165  private:
    161166    ValueImp *base;
    162     UString prop;
    163   };
     167    bool propertyNameIsNumber;
     168    unsigned propertyNameAsNumber;
     169    mutable UString prop;
     170  };
     171 
     172  inline Reference::Reference(ReferenceImp *imp) : Value(imp) { }
    164173
    165174  class CompletionImp : public ValueImp {
     
    186195    UString tar;
    187196  };
     197
     198  inline Completion::Completion(CompletionImp *imp) : Value(imp) { }
    188199
    189200  /**
     
    244255    static ListImp *emptyList;
    245256  };
     257 
     258  inline List::List(ListImp *imp) : Value(imp) { }
    246259
    247260  /**
Note: See TracChangeset for help on using the changeset viewer.