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.cpp

    r1790 r1799  
    193193// ------------------------------ StringImp ------------------------------------
    194194
    195 StringImp::StringImp(const UString& v)
    196   : val(v)
    197 {
    198 }
    199 
    200195Value StringImp::toPrimitive(ExecState */*exec*/, Type) const
    201196{
     
    221216{
    222217  List args;
    223   args.append(String(const_cast<StringImp*>(this)));
     218  args.append(Value(const_cast<StringImp*>(this)));
    224219  return Object::dynamicCast(exec->interpreter()->builtinString().construct(exec,args));
    225220}
    226221
    227222// ------------------------------ NumberImp ------------------------------------
    228 
    229 NumberImp::NumberImp(double v)
    230   : val(v)
    231 {
    232 }
    233223
    234224Value NumberImp::toPrimitive(ExecState *, Type) const
     
    259249}
    260250
     251bool NumberImp::toUInt32(unsigned& uint32) const
     252{
     253  uint32 = (unsigned)val;
     254  return (double)uint32 == val;
     255}
     256
    261257// ------------------------------ ReferenceImp ---------------------------------
    262258
     259ReferenceImp::ReferenceImp(const Value& v, unsigned p)
     260  : base(v.imp()), propertyNameIsNumber(true), propertyNameAsNumber(p)
     261{
     262}
     263
    263264ReferenceImp::ReferenceImp(const Value& v, const UString& p)
    264   : base(v.imp()), prop(p)
     265  : base(v.imp()), propertyNameIsNumber(false), prop(p)
    265266{
    266267}
     
    306307  assert(false);
    307308  return Object();
     309}
     310
     311UString ReferenceImp::getPropertyName(ExecState *) const
     312{
     313  if (propertyNameIsNumber && prop.isNull())
     314    prop = UString::from(propertyNameAsNumber);
     315  return prop;
     316}
     317
     318Value ReferenceImp::getValue(ExecState *exec) const
     319{
     320  Value o = getBase(exec);
     321
     322  if (o.isNull() || o.type() == NullType) {
     323    UString m = I18N_NOOP("Can't find variable: ") + getPropertyName(exec);
     324    Object err = Error::create(exec, ReferenceError, m.ascii());
     325    exec->setException(err);
     326    return err;
     327  }
     328
     329  if (o.type() != ObjectType) {
     330    UString m = I18N_NOOP("Base is not an object");
     331    Object err = Error::create(exec, ReferenceError, m.ascii());
     332    exec->setException(err);
     333    return err;
     334  }
     335
     336  if (propertyNameIsNumber)
     337    return static_cast<ObjectImp*>(o.imp())->get(exec,propertyNameAsNumber);
     338  return static_cast<ObjectImp*>(o.imp())->get(exec,prop);
     339}
     340
     341void ReferenceImp::putValue(ExecState *exec, const Value& w)
     342{
     343#ifdef KJS_VERBOSE
     344  printInfo(exec,(UString("setting property ")+getPropertyName(exec)).cstring().c_str(),w);
     345#endif
     346  Value o = getBase(exec);
     347  if (o.type() == NullType)
     348    o = exec->interpreter()->globalObject();
     349
     350  if (propertyNameIsNumber)
     351    return static_cast<ObjectImp*>(o.imp())->put(exec,propertyNameAsNumber, w);
     352  return static_cast<ObjectImp*>(o.imp())->put(exec,prop, w);
     353}
     354
     355bool ReferenceImp::deleteValue(ExecState *exec)
     356{
     357  Value b = getBase(exec);
     358
     359  // The spec doesn't mention what to do if the base is null... just return true
     360  if (b.type() != ObjectType) {
     361    assert(b.type() == NullType);
     362    return true;
     363  }
     364
     365  if (propertyNameIsNumber)
     366    return static_cast<ObjectImp*>(b.imp())->deleteProperty(exec,propertyNameAsNumber);
     367  return static_cast<ObjectImp*>(b.imp())->deleteProperty(exec,prop);
    308368}
    309369
     
    11201180    return Boolean(false);
    11211181
    1122   Value prot = get(exec,"prototype");
     1182  Value prot = get(exec,prototypePropertyName);
    11231183  if (prot.type() != ObjectType && prot.type() != NullType) {
    11241184    Object err = Error::create(exec, TypeError, "Invalid prototype encountered "
Note: See TracChangeset for help on using the changeset viewer.