Changeset 2783 in webkit for trunk/JavaScriptCore
- Timestamp:
- Nov 20, 2002, 1:12:14 PM (23 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 1 added
- 31 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r2781 r2783 1 2002-11-20 Darin Adler <[email protected]> 2 3 - decrease ref/deref -- 5% speedup in iBench 4 5 * JavaScriptCore.pbproj/project.pbxproj: Added array_instance.h 6 * kjs/array_instance.h: Added so it can be shared by function.h. 7 8 * kjs/array_object.cpp: 9 * kjs/array_object.h: 10 * kjs/bool_object.cpp: 11 * kjs/bool_object.h: 12 * kjs/collector.cpp: 13 * kjs/date_object.cpp: 14 * kjs/date_object.h: 15 * kjs/error_object.cpp: 16 * kjs/function.cpp: 17 * kjs/function.h: 18 * kjs/function_object.cpp: 19 * kjs/internal.cpp: 20 * kjs/internal.h: 21 * kjs/math_object.cpp: 22 * kjs/nodes.cpp: 23 * kjs/number_object.cpp: 24 * kjs/object.cpp: 25 * kjs/object.h: 26 * kjs/object_object.cpp: 27 * kjs/property_map.cpp: 28 * kjs/reference.cpp: 29 * kjs/reference.h: 30 * kjs/regexp_object.cpp: 31 * kjs/string_object.cpp: 32 * kjs/string_object.h: 33 * kjs/value.cpp: 34 * kjs/value.h: 35 Switched lots of interfaces so they don't require ref/deref. 36 1 37 2002-11-20 Maciej Stachowiak <[email protected]> 2 38 -
trunk/JavaScriptCore/ChangeLog-2002-12-03
r2781 r2783 1 2002-11-20 Darin Adler <[email protected]> 2 3 - decrease ref/deref -- 5% speedup in iBench 4 5 * JavaScriptCore.pbproj/project.pbxproj: Added array_instance.h 6 * kjs/array_instance.h: Added so it can be shared by function.h. 7 8 * kjs/array_object.cpp: 9 * kjs/array_object.h: 10 * kjs/bool_object.cpp: 11 * kjs/bool_object.h: 12 * kjs/collector.cpp: 13 * kjs/date_object.cpp: 14 * kjs/date_object.h: 15 * kjs/error_object.cpp: 16 * kjs/function.cpp: 17 * kjs/function.h: 18 * kjs/function_object.cpp: 19 * kjs/internal.cpp: 20 * kjs/internal.h: 21 * kjs/math_object.cpp: 22 * kjs/nodes.cpp: 23 * kjs/number_object.cpp: 24 * kjs/object.cpp: 25 * kjs/object.h: 26 * kjs/object_object.cpp: 27 * kjs/property_map.cpp: 28 * kjs/reference.cpp: 29 * kjs/reference.h: 30 * kjs/regexp_object.cpp: 31 * kjs/string_object.cpp: 32 * kjs/string_object.h: 33 * kjs/value.cpp: 34 * kjs/value.h: 35 Switched lots of interfaces so they don't require ref/deref. 36 1 37 2002-11-20 Maciej Stachowiak <[email protected]> 2 38 -
trunk/JavaScriptCore/ChangeLog-2003-10-25
r2781 r2783 1 2002-11-20 Darin Adler <[email protected]> 2 3 - decrease ref/deref -- 5% speedup in iBench 4 5 * JavaScriptCore.pbproj/project.pbxproj: Added array_instance.h 6 * kjs/array_instance.h: Added so it can be shared by function.h. 7 8 * kjs/array_object.cpp: 9 * kjs/array_object.h: 10 * kjs/bool_object.cpp: 11 * kjs/bool_object.h: 12 * kjs/collector.cpp: 13 * kjs/date_object.cpp: 14 * kjs/date_object.h: 15 * kjs/error_object.cpp: 16 * kjs/function.cpp: 17 * kjs/function.h: 18 * kjs/function_object.cpp: 19 * kjs/internal.cpp: 20 * kjs/internal.h: 21 * kjs/math_object.cpp: 22 * kjs/nodes.cpp: 23 * kjs/number_object.cpp: 24 * kjs/object.cpp: 25 * kjs/object.h: 26 * kjs/object_object.cpp: 27 * kjs/property_map.cpp: 28 * kjs/reference.cpp: 29 * kjs/reference.h: 30 * kjs/regexp_object.cpp: 31 * kjs/string_object.cpp: 32 * kjs/string_object.h: 33 * kjs/value.cpp: 34 * kjs/value.h: 35 Switched lots of interfaces so they don't require ref/deref. 36 1 37 2002-11-20 Maciej Stachowiak <[email protected]> 2 38 -
trunk/JavaScriptCore/JavaScriptCore.pbproj/project.pbxproj
r2760 r2783 224 224 F5BB2BC7030F772101FCFE1D, 225 225 933A349C038AE7C6008635CE, 226 938772E6038BFE19008635CE, 226 227 ); 227 228 isa = PBXHeadersBuildPhase; … … 319 320 08FB77AEFE84172EC02AAC07 = { 320 321 children = ( 322 938772E5038BFE19008635CE, 321 323 F692A84D0255597D01FF60F7, 322 324 F692A84E0255597D01FF60F7, … … 472 474 }; 473 475 }; 476 938772E5038BFE19008635CE = { 477 fileEncoding = 4; 478 isa = PBXFileReference; 479 path = array_instance.h; 480 refType = 4; 481 }; 482 938772E6038BFE19008635CE = { 483 fileRef = 938772E5038BFE19008635CE; 484 isa = PBXBuildFile; 485 settings = { 486 }; 487 }; 474 488 //930 475 489 //931 -
trunk/JavaScriptCore/kjs/array_object.cpp
r2777 r2783 40 40 const ClassInfo ArrayInstanceImp::info = {"Array", 0, 0, 0}; 41 41 42 ArrayInstanceImp::ArrayInstanceImp( const Object &proto, unsigned initialLength)42 ArrayInstanceImp::ArrayInstanceImp(ObjectImp *proto, unsigned initialLength) 43 43 : ObjectImp(proto) 44 44 , length(initialLength) … … 48 48 } 49 49 50 ArrayInstanceImp::ArrayInstanceImp( const Object &proto, const List &list)50 ArrayInstanceImp::ArrayInstanceImp(ObjectImp *proto, const List &list) 51 51 : ObjectImp(proto) 52 52 , length(list.size()) … … 290 290 ArrayPrototypeImp::ArrayPrototypeImp(ExecState *exec, 291 291 ObjectPrototypeImp *objProto) 292 : ArrayInstanceImp( Object(objProto), 0)292 : ArrayInstanceImp(objProto, 0) 293 293 { 294 294 Value protect(this); … … 665 665 // a single numeric argument denotes the array size (!) 666 666 if (args.size() == 1 && args[0].type() == NumberType) 667 return Object(new ArrayInstanceImp(exec->interpreter()->builtinArrayPrototype() , args[0].toUInt32(exec)));667 return Object(new ArrayInstanceImp(exec->interpreter()->builtinArrayPrototype().imp(), args[0].toUInt32(exec))); 668 668 669 669 // otherwise the array is constructed with the arguments in it 670 return Object(new ArrayInstanceImp(exec->interpreter()->builtinArrayPrototype() , args));670 return Object(new ArrayInstanceImp(exec->interpreter()->builtinArrayPrototype().imp(), args)); 671 671 } 672 672 … … 682 682 return construct(exec,args); 683 683 } 684 -
trunk/JavaScriptCore/kjs/array_object.h
r2760 r2783 27 27 28 28 namespace KJS { 29 30 class ArrayInstanceImp : public ObjectImp {31 public:32 ArrayInstanceImp(const Object &proto, unsigned initialLength);33 ArrayInstanceImp(const Object &proto, const List &initialValues);34 ~ArrayInstanceImp();35 36 virtual Value get(ExecState *exec, const Identifier &propertyName) const;37 virtual Value get(ExecState *exec, unsigned propertyName) const;38 virtual void put(ExecState *exec, const Identifier &propertyName, const Value &value, int attr = None);39 virtual void put(ExecState *exec, unsigned propertyName, const Value &value, int attr = None);40 virtual bool hasProperty(ExecState *exec, const Identifier &propertyName) const;41 virtual bool hasProperty(ExecState *exec, unsigned propertyName) const;42 virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);43 virtual bool deleteProperty(ExecState *exec, unsigned propertyName);44 45 virtual void mark();46 47 virtual const ClassInfo *classInfo() const { return &info; }48 static const ClassInfo info;49 50 unsigned getLength() const { return length; }51 52 void sort(ExecState *exec);53 void sort(ExecState *exec, Object &compareFunction);54 55 private:56 void setLength(unsigned newLength);57 58 unsigned pushUndefinedObjectsToEnd();59 60 unsigned length;61 unsigned capacity;62 ValueImp **storage;63 };64 29 65 30 class ArrayPrototypeImp : public ArrayInstanceImp { -
trunk/JavaScriptCore/kjs/bool_object.cpp
r1824 r2783 36 36 const ClassInfo BooleanInstanceImp::info = {"Boolean", 0, 0, 0}; 37 37 38 BooleanInstanceImp::BooleanInstanceImp( const Object &proto)38 BooleanInstanceImp::BooleanInstanceImp(ObjectImp *proto) 39 39 : ObjectImp(proto) 40 40 { … … 48 48 ObjectPrototypeImp *objectProto, 49 49 FunctionPrototypeImp *funcProto) 50 : BooleanInstanceImp( Object(objectProto))50 : BooleanInstanceImp(objectProto) 51 51 { 52 52 Value protect(this); 53 53 // The constructor will be added later by InterpreterImp::InterpreterImp() 54 54 55 put (exec,toStringPropertyName, Object(new BooleanProtoFuncImp(exec,funcProto,BooleanProtoFuncImp::ToString,0)), DontEnum);56 put (exec,valueOfPropertyName, Object(new BooleanProtoFuncImp(exec,funcProto,BooleanProtoFuncImp::ValueOf,0)), DontEnum);55 putDirect(toStringPropertyName, new BooleanProtoFuncImp(exec,funcProto,BooleanProtoFuncImp::ToString,0), DontEnum); 56 putDirect(valueOfPropertyName, new BooleanProtoFuncImp(exec,funcProto,BooleanProtoFuncImp::ValueOf,0), DontEnum); 57 57 setInternalValue(Boolean(false)); 58 58 } … … 66 66 { 67 67 Value protect(this); 68 put (exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);68 putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum); 69 69 } 70 70 … … 105 105 { 106 106 Value protect(this); 107 put (exec,prototypePropertyName, Object(booleanProto),DontEnum|DontDelete|ReadOnly);107 putDirect(prototypePropertyName, booleanProto, DontEnum|DontDelete|ReadOnly); 108 108 109 109 // no. of arguments for constructor 110 put (exec,lengthPropertyName, Number(1), ReadOnly|DontDelete|DontEnum);110 putDirect(lengthPropertyName, NumberImp::one(), ReadOnly|DontDelete|DontEnum); 111 111 } 112 112 … … 120 120 Object BooleanObjectImp::construct(ExecState *exec, const List &args) 121 121 { 122 Object proto = exec->interpreter()->builtinBooleanPrototype(); 123 Object obj(new BooleanInstanceImp(proto)); 122 Object obj(new BooleanInstanceImp(exec->interpreter()->builtinBooleanPrototype().imp())); 124 123 125 124 Boolean b; -
trunk/JavaScriptCore/kjs/bool_object.h
r1024 r2783 30 30 class BooleanInstanceImp : public ObjectImp { 31 31 public: 32 BooleanInstanceImp( const Object &proto);32 BooleanInstanceImp(ObjectImp *proto); 33 33 34 34 virtual const ClassInfo *classInfo() const { return &info; } -
trunk/JavaScriptCore/kjs/collector.cpp
r2781 r2783 100 100 heap.oversizeCells[heap.usedOversizeCells] = (CollectorCell *)newCell; 101 101 heap.usedOversizeCells++; 102 heap.numLiveObjects++; 102 103 103 104 return (void *)newCell; … … 141 142 targetBlock->bitmap[wordInBitmap] |= (1 << bitInWord); 142 143 targetBlock->usedCells++; 144 heap.numLiveObjects++; 143 145 return (void *)(targetBlock->cells + cellPos); 144 146 } … … 293 295 294 296 #if APPLE_CHANGES 297 295 298 int Collector::numInterpreters() 296 299 { … … 343 346 344 347 if ((word & (1 << bitInWord)) && 345 imp->refcount == 0) {348 imp->refcount != 0) { 346 349 ++count; 347 350 } … … 352 355 for (int cell = 0; cell < heap.usedOversizeCells; cell++) { 353 356 ValueImp *imp = (ValueImp *)heap.oversizeCells[cell]; 354 if (imp->refcount == 0) {357 if (imp->refcount != 0) { 355 358 ++count; 356 359 } … … 360 363 } 361 364 365 // FIXME: Rename. Root object classes are more useful than live object classes. 362 366 CFSetRef Collector::liveObjectClasses() 363 367 { … … 370 374 ValueImp *imp = (ValueImp *)(heap.blocks[block]->cells + BITS_PER_WORD * wordInBitmap + bitInWord); 371 375 372 if (word & (1 << bitInWord)) { 376 if (word & (1 << bitInWord) 377 && ((imp->_flags & ValueImp::VI_GCALLOWED) == 0 || imp->refcount != 0)) { 373 378 const char *mangled_name = typeid(*imp).name(); 374 379 int status; … … 386 391 for (int cell = 0; cell < heap.usedOversizeCells; cell++) { 387 392 ValueImp *imp = (ValueImp *)heap.oversizeCells[cell]; 388 389 const char *mangled_name = typeid(*imp).name(); 390 int status; 391 char *demangled_name = __cxxabiv1::__cxa_demangle (mangled_name, NULL, NULL, &status); 392 393 CFStringRef className = CFStringCreateWithCString(NULL, demangled_name, kCFStringEncodingASCII); 394 free(demangled_name); 395 CFSetAddValue(classes, className); 396 CFRelease(className); 393 394 if ((imp->_flags & ValueImp::VI_GCALLOWED) == 0 || imp->refcount != 0) { 395 const char *mangled_name = typeid(*imp).name(); 396 int status; 397 char *demangled_name = __cxxabiv1::__cxa_demangle (mangled_name, NULL, NULL, &status); 398 399 CFStringRef className = CFStringCreateWithCString(NULL, demangled_name, kCFStringEncodingASCII); 400 free(demangled_name); 401 CFSetAddValue(classes, className); 402 CFRelease(className); 403 } 397 404 } 398 405 … … 400 407 } 401 408 402 #endif 409 #endif // APPLE_CHANGES -
trunk/JavaScriptCore/kjs/date_object.cpp
r2760 r2783 210 210 const ClassInfo DateInstanceImp::info = {"Date", 0, 0, 0}; 211 211 212 DateInstanceImp::DateInstanceImp( const Object &proto)212 DateInstanceImp::DateInstanceImp(ObjectImp *proto) 213 213 : ObjectImp(proto) 214 214 { … … 272 272 DatePrototypeImp::DatePrototypeImp(ExecState *, 273 273 ObjectPrototypeImp *objectProto) 274 : DateInstanceImp( Object(objectProto))274 : DateInstanceImp(objectProto) 275 275 { 276 276 Value protect(this); 277 setInternalValue(Number (NaN));277 setInternalValue(NumberImp::create(NaN)); 278 278 // The constructor will be added later, after DateObjectImp has been built 279 279 } … … 293 293 { 294 294 Value protect(this); 295 put (exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);295 putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum); 296 296 } 297 297 … … 524 524 { 525 525 Value protect(this); 526 526 527 // ECMA 15.9.4.1 Date.prototype 527 put(exec,prototypePropertyName, Object(dateProto), DontEnum|DontDelete|ReadOnly); 528 529 put(exec,"parse", Object(new DateObjectFuncImp(exec,funcProto,DateObjectFuncImp::Parse, 1)), DontEnum); 530 put(exec,"UTC", Object(new DateObjectFuncImp(exec,funcProto,DateObjectFuncImp::UTC, 7)), DontEnum); 528 putDirect(prototypePropertyName, dateProto, DontEnum|DontDelete|ReadOnly); 529 530 static const Identifier parsePropertyName("parse"); 531 putDirect(parsePropertyName, new DateObjectFuncImp(exec,funcProto,DateObjectFuncImp::Parse, 1), DontEnum); 532 static const Identifier UTCPropertyName("UTC"); 533 putDirect("UTC", new DateObjectFuncImp(exec,funcProto,DateObjectFuncImp::UTC, 7), DontEnum); 531 534 532 535 // no. of arguments for constructor 533 put (exec,lengthPropertyName, Number(7), ReadOnly|DontDelete|DontEnum);536 putDirect(lengthPropertyName, 7, ReadOnly|DontDelete|DontEnum); 534 537 } 535 538 … … 602 605 603 606 Object proto = exec->interpreter()->builtinDatePrototype(); 604 Object ret(new DateInstanceImp(proto ));607 Object ret(new DateInstanceImp(proto.imp())); 605 608 ret.setInternalValue(timeClip(value)); 606 609 return ret; … … 637 640 { 638 641 Value protect(this); 639 put (exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);642 putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum); 640 643 } 641 644 -
trunk/JavaScriptCore/kjs/date_object.h
r2760 r2783 32 32 class DateInstanceImp : public ObjectImp { 33 33 public: 34 DateInstanceImp( const Object &proto);34 DateInstanceImp(ObjectImp *proto); 35 35 36 36 virtual const ClassInfo *classInfo() const { return &info; } -
trunk/JavaScriptCore/kjs/error_object.cpp
r2772 r2783 36 36 ObjectPrototypeImp *objectProto, 37 37 FunctionPrototypeImp *funcProto) 38 : ObjectImp( Object(objectProto))38 : ObjectImp(objectProto) 39 39 { 40 40 Value protect(this); … … 44 44 put(exec, namePropertyName, String("Error"), DontEnum); 45 45 put(exec, messagePropertyName, String("Unknown error"), DontEnum); 46 put (exec, toStringPropertyName, Object(new ErrorProtoFuncImp(exec,funcProto)), DontEnum);46 putDirect(toStringPropertyName, new ErrorProtoFuncImp(exec,funcProto), DontEnum); 47 47 } 48 48 … … 53 53 { 54 54 Value protect(this); 55 put (exec,lengthPropertyName,Number(0),DontDelete|ReadOnly|DontEnum);55 putDirect(lengthPropertyName, NumberImp::zero(), DontDelete|ReadOnly|DontEnum); 56 56 } 57 57 … … 87 87 Value protect(this); 88 88 // ECMA 15.11.3.1 Error.prototype 89 put (exec, prototypePropertyName, Object(errorProto), DontEnum|DontDelete|ReadOnly);90 //put (exec,namePropertyName, String(n));89 putDirect(prototypePropertyName, errorProto, DontEnum|DontDelete|ReadOnly); 90 //putDirect(namePropertyName, String(n)); 91 91 } 92 92 … … 100 100 { 101 101 Object proto = Object::dynamicCast(exec->interpreter()->builtinErrorPrototype()); 102 Object obj(new ObjectImp(proto)); 102 ObjectImp *imp = new ObjectImp(proto); 103 Object obj(imp); 103 104 104 105 if (!args.isEmpty() && args[0].type() != UndefinedType) { 105 obj.put(exec, messagePropertyName, String(args[0].toString(exec)));106 imp->putDirect(messagePropertyName, new StringImp(args[0].toString(exec))); 106 107 } 107 108 … … 125 126 NativeErrorPrototypeImp::NativeErrorPrototypeImp(ExecState *exec, ErrorPrototypeImp *errorProto, 126 127 ErrorType et, UString name, UString message) 127 : ObjectImp( Object(errorProto))128 : ObjectImp(errorProto) 128 129 { 129 130 Value protect(this); 130 131 errType = et; 131 put (exec, namePropertyName, String(name));132 put (exec, messagePropertyName, String(message));132 putDirect(namePropertyName, new StringImp(name), 0); 133 putDirect(messagePropertyName, new StringImp(message), 0); 133 134 } 134 135 … … 144 145 proto = static_cast<ObjectImp*>(prot.imp()); 145 146 146 put (exec,lengthPropertyName,Number(1),DontDelete|ReadOnly|DontEnum); // ECMA 15.11.7.5147 put (exec,prototypePropertyName,prot);147 putDirect(lengthPropertyName, NumberImp::one(), DontDelete|ReadOnly|DontEnum); // ECMA 15.11.7.5 148 putDirect(prototypePropertyName, proto, 0); 148 149 } 149 150 … … 155 156 Object NativeErrorImp::construct(ExecState *exec, const List &args) 156 157 { 157 Object obj(new ObjectImp(Object(proto))); 158 ObjectImp *imp = new ObjectImp(proto); 159 Object obj(imp); 158 160 if (args[0].type() != UndefinedType) 159 obj.put(exec, messagePropertyName, String(args[0].toString(exec)));161 imp->putDirect(messagePropertyName, new StringImp(args[0].toString(exec))); 160 162 return obj; 161 163 } … … 177 179 proto->mark(); 178 180 } 179 -
trunk/JavaScriptCore/kjs/function.cpp
r2779 r2783 319 319 // ECMA 10.1.8 320 320 ArgumentsImp::ArgumentsImp(ExecState *exec, FunctionImp *func, const List &args) 321 : ObjectImp(exec->interpreter()->builtinObjectPrototype())321 : ArrayInstanceImp(exec->interpreter()->builtinObjectPrototype().imp(), args) 322 322 { 323 323 Value protect(this); 324 put(exec,calleePropertyName, Object(func), DontEnum); 325 put(exec,lengthPropertyName, Number(args.size()), DontEnum); 326 if (!args.isEmpty()) { 327 ListIterator arg = args.begin(); 328 for (int i = 0; arg != args.end(); arg++, i++) { 329 put(exec,i, *arg, DontEnum); 330 } 331 } 324 putDirect(calleePropertyName, func, DontEnum); 332 325 } 333 326 … … 338 331 // ECMA 10.1.6 339 332 ActivationImp::ActivationImp(ExecState *exec, FunctionImp *f, const List &args) 340 : _function(f) 333 : _function(f), _arguments(args) 341 334 { 342 335 Value protect(this); 343 arguments = new ArgumentsImp(exec,f, args); 344 arguments->setGcAllowed(); 345 put(exec, argumentsPropertyName, Object(arguments), Internal|DontDelete); 336 _argumentsObject = new ArgumentsImp(exec, f, args); 337 putDirect(argumentsPropertyName, _argumentsObject, Internal|DontDelete); 346 338 } 347 339 … … 353 345 { 354 346 Value protect(this); 355 put (exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);347 putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum); 356 348 } 357 349 -
trunk/JavaScriptCore/kjs/function.h
r2779 r2783 25 25 26 26 #include "internal.h" 27 #include "array_instance.h" 27 28 28 29 namespace KJS { … … 91 92 92 93 93 class ArgumentsImp : public ObjectImp {94 class ArgumentsImp : public ArrayInstanceImp { 94 95 public: 95 96 ArgumentsImp(ExecState *exec, FunctionImp *func, const List &args); … … 103 104 ActivationImp(ExecState *exec, FunctionImp *f, const List &args); 104 105 105 Object argumentsObject() { return Object(arguments); }106 107 106 virtual const ClassInfo *classInfo() const { return &info; } 108 107 static const ClassInfo info; … … 112 111 private: 113 112 FunctionImp *_function; 114 ObjectImp* arguments; 113 List _arguments; 114 ObjectImp *_argumentsObject; 115 115 }; 116 116 -
trunk/JavaScriptCore/kjs/function_object.cpp
r2778 r2783 41 41 { 42 42 Value protect(this); 43 put(exec, toStringPropertyName, Object(new FunctionProtoFuncImp(exec, this, FunctionProtoFuncImp::ToString, 0)), DontEnum); 44 put(exec, "apply", Object(new FunctionProtoFuncImp(exec, this, FunctionProtoFuncImp::Apply, 2)), DontEnum); 45 put(exec, "call", Object(new FunctionProtoFuncImp(exec, this, FunctionProtoFuncImp::Call, 1)), DontEnum); 43 putDirect(toStringPropertyName, new FunctionProtoFuncImp(exec, this, FunctionProtoFuncImp::ToString, 0), DontEnum); 44 static const Identifier applyPropertyName("apply"); 45 putDirect(applyPropertyName, new FunctionProtoFuncImp(exec, this, FunctionProtoFuncImp::Apply, 2), DontEnum); 46 static const Identifier callPropertyName("call"); 47 putDirect(callPropertyName, new FunctionProtoFuncImp(exec, this, FunctionProtoFuncImp::Call, 1), DontEnum); 46 48 } 47 49 … … 68 70 { 69 71 Value protect(this); 70 put (exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);72 putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum); 71 73 } 72 74 … … 175 177 { 176 178 Value protect(this); 177 put (exec,prototypePropertyName, Object(funcProto), DontEnum|DontDelete|ReadOnly);179 putDirect(prototypePropertyName, funcProto, DontEnum|DontDelete|ReadOnly); 178 180 179 181 // no. of arguments for constructor 180 put (exec,lengthPropertyName, Number(1), ReadOnly|DontDelete|DontEnum);182 putDirect(lengthPropertyName, NumberImp::one(), ReadOnly|DontDelete|DontEnum); 181 183 } 182 184 … … 276 278 } 277 279 278 fimp->put(exec,lengthPropertyName, Number(params),ReadOnly|DontDelete|DontEnum);279 280 List consArgs; 280 281 281 282 Object objCons = exec->interpreter()->builtinObject(); 282 283 Object prototype = objCons.construct(exec,List::empty()); 283 prototype.put(exec, constructorPropertyName, 284 Object(fimp), DontEnum|DontDelete|ReadOnly); 285 fimp->put(exec,prototypePropertyName,prototype,DontEnum|DontDelete|ReadOnly); 284 prototype.put(exec, constructorPropertyName, Value(fimp), DontEnum|DontDelete|ReadOnly); 285 fimp->put(exec, prototypePropertyName, prototype, DontEnum|DontDelete|ReadOnly); 286 286 return ret; 287 287 } -
trunk/JavaScriptCore/kjs/internal.cpp
r2760 r2783 222 222 // ------------------------------ NumberImp ------------------------------------ 223 223 224 NumberImp *NumberImp::staticNaN; 225 226 ValueImp *NumberImp::create(int i) 227 { 228 if (SimpleNumber::fits(i)) 229 return SimpleNumber::make(i); 230 NumberImp *imp = new NumberImp(static_cast<double>(i)); 231 imp->setGcAllowedFast(); 232 return imp; 233 } 234 235 ValueImp *NumberImp::create(double d) 236 { 237 if (SimpleNumber::fits(d)) 238 return SimpleNumber::make((int)d); 239 if (isNaN(d)) 240 return staticNaN; 241 NumberImp *imp = new NumberImp(d); 242 imp->setGcAllowedFast(); 243 return imp; 244 } 245 224 246 Value NumberImp::toPrimitive(ExecState *, Type) const 225 247 { … … 453 475 BooleanImp::staticFalse = new BooleanImp(false); 454 476 BooleanImp::staticFalse->ref(); 477 NumberImp::staticNaN = new NumberImp(NaN); 478 NumberImp::staticNaN->ref(); 455 479 } 456 480 … … 470 494 BooleanImp::staticFalse->setGcAllowed(); 471 495 BooleanImp::staticFalse = 0L; 496 NumberImp::staticNaN->deref(); 497 NumberImp::staticNaN->setGcAllowed(); 498 NumberImp::staticNaN = 0; 472 499 } 473 500 … … 787 814 788 815 InternalFunctionImp::InternalFunctionImp(FunctionPrototypeImp *funcProto) 789 : ObjectImp( Object(funcProto))816 : ObjectImp(funcProto) 790 817 { 791 818 } -
trunk/JavaScriptCore/kjs/internal.h
r2778 r2783 119 119 120 120 class NumberImp : public ValueImp { 121 public: 122 NumberImp(double v) : val(v) { } 121 friend class Number; 122 friend class InterpreterImp; 123 public: 124 static ValueImp *create(int); 125 static ValueImp *create(double); 126 static ValueImp *zero() { return SimpleNumber::make(0); } 127 static ValueImp *one() { return SimpleNumber::make(1); } 128 static ValueImp *two() { return SimpleNumber::make(2); } 129 123 130 double value() const { return val; } 124 131 … … 131 138 Object toObject(ExecState *exec) const; 132 139 133 private: 140 static NumberImp *staticNaN; 141 142 private: 143 NumberImp(double v) : val(v) { } 144 134 145 virtual bool toUInt32(unsigned&) const; 135 146 -
trunk/JavaScriptCore/kjs/math_object.cpp
r2760 r2783 77 77 MathObjectImp::MathObjectImp(ExecState * /*exec*/, 78 78 ObjectPrototypeImp *objProto) 79 : ObjectImp( Object(objProto))79 : ObjectImp(objProto) 80 80 { 81 81 } … … 131 131 { 132 132 Value protect(this); 133 put (exec,lengthPropertyName,Number(l),DontDelete|ReadOnly|DontEnum);133 putDirect(lengthPropertyName, l, DontDelete|ReadOnly|DontEnum); 134 134 } 135 135 -
trunk/JavaScriptCore/kjs/nodes.cpp
r2778 r2783 229 229 //cout << "Resolve: FOUND '" << ident.ascii() << "'" 230 230 // << " in " << (void*)o << " " << o->classInfo()->className << endl; 231 return Reference( Object(o), ident);231 return Reference(o, ident); 232 232 } 233 233 scope++; -
trunk/JavaScriptCore/kjs/number_object.cpp
r2772 r2783 51 51 { 52 52 Value protect(this); 53 setInternalValue(Number (0));53 setInternalValue(NumberImp::zero()); 54 54 55 55 // The constructor will be added later, after NumberObjectImp has been constructed 56 56 57 put (exec,toStringPropertyName, Object(new NumberProtoFuncImp(exec,funcProto,NumberProtoFuncImp::ToString, 1)), DontEnum);58 put (exec,toLocaleStringPropertyName, Object(new NumberProtoFuncImp(exec,funcProto,NumberProtoFuncImp::ToLocaleString, 0)), DontEnum);59 put (exec,valueOfPropertyName, Object(new NumberProtoFuncImp(exec,funcProto,NumberProtoFuncImp::ValueOf, 0)), DontEnum);57 putDirect(toStringPropertyName, new NumberProtoFuncImp(exec,funcProto,NumberProtoFuncImp::ToString, 1), DontEnum); 58 putDirect(toLocaleStringPropertyName, new NumberProtoFuncImp(exec,funcProto,NumberProtoFuncImp::ToLocaleString, 0), DontEnum); 59 putDirect(valueOfPropertyName, new NumberProtoFuncImp(exec,funcProto,NumberProtoFuncImp::ValueOf, 0), DontEnum); 60 60 } 61 61 … … 68 68 { 69 69 Value protect(this); 70 put (exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);70 putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum); 71 71 } 72 72 … … 125 125 Value protect(this); 126 126 // Number.Prototype 127 put (exec,prototypePropertyName, Value(numberProto),DontEnum|DontDelete|ReadOnly);127 putDirect(prototypePropertyName, numberProto,DontEnum|DontDelete|ReadOnly); 128 128 129 129 // no. of arguments for constructor 130 put (exec,lengthPropertyName, Number(1), ReadOnly|DontDelete|DontEnum);130 putDirect(lengthPropertyName, NumberImp::one(), ReadOnly|DontDelete|DontEnum); 131 131 } 132 132 -
trunk/JavaScriptCore/kjs/object.cpp
r2772 r2783 59 59 } 60 60 61 ObjectImp::ObjectImp(ObjectImp *proto) 62 : _proto(proto), _internalValue(0L), _scope(true) 63 { 64 //fprintf(stderr,"ObjectImp::ObjectImp %p\n",(void*)this); 65 } 66 61 67 ObjectImp::ObjectImp() : 62 68 _scope(true) … … 153 159 } 154 160 155 // This get method only looks at the property map.156 // A bit like hasProperty(recursive=false), this doesn't go to the prototype.157 // This is used e.g. by lookupOrCreateFunction (to cache a function, we don't want158 // to look up in the prototype, it might already exist there)159 ValueImp* ObjectImp::getDirect(const Identifier& propertyName) const160 {161 return _prop.get(propertyName);162 }163 164 161 // ECMA 8.6.2.2 165 162 void ObjectImp::put(ExecState *exec, const Identifier &propertyName, … … 168 165 assert(!value.isNull()); 169 166 assert(value.type() != ListType); 167 168 // non-standard netscape extension 169 if (propertyName == specialPrototypePropertyName) { 170 setPrototype(value); 171 return; 172 } 170 173 171 174 /* TODO: check for write permissions directly w/o this call */ … … 178 181 fprintf( stderr, "WARNING: canPut %s said NO\n", propertyName.ascii() ); 179 182 #endif 180 return;181 }182 183 // non-standard netscape extension184 if (propertyName == specialPrototypePropertyName) {185 setPrototype(value);186 183 return; 187 184 } … … 395 392 for (int i = 0; i < size; ++i, ++e) { 396 393 if ( e->s && !(e->attr & DontEnum) ) 397 list.append(Reference( Object(this), e->s)); /// ######### check for duplicates with the propertymap394 list.append(Reference(this, e->s)); /// ######### check for duplicates with the propertymap 398 395 } 399 396 } … … 412 409 { 413 410 _internalValue = v.imp(); 411 } 412 413 void ObjectImp::setInternalValue(ValueImp *v) 414 { 415 v->setGcAllowed(); 416 _internalValue = v; 414 417 } 415 418 … … 445 448 } 446 449 450 void ObjectImp::putDirect(const Identifier &propertyName, ValueImp *value, int attr) 451 { 452 value->setGcAllowed(); 453 _prop.put(propertyName, value, attr); 454 } 455 456 void ObjectImp::putDirect(const Identifier &propertyName, int value, int attr) 457 { 458 _prop.put(propertyName, NumberImp::create(value), attr); 459 } 447 460 448 461 // ------------------------------ Error ---------------------------------------- -
trunk/JavaScriptCore/kjs/object.h
r2772 r2783 370 370 */ 371 371 ObjectImp(const Object &proto); 372 ObjectImp(ObjectImp *proto); 372 373 373 374 /** … … 525 526 * It's simply a quick way to remove everything before destroying. 526 527 */ 527 void deleteAllProperties( ExecState *);528 void deleteAllProperties(ExecState *); 528 529 529 530 /** … … 572 573 Value internalValue() const; 573 574 void setInternalValue(const Value &v); 575 void setInternalValue(ValueImp *v); 574 576 575 577 Value toPrimitive(ExecState *exec, … … 580 582 Object toObject(ExecState *exec) const; 581 583 582 ValueImp* getDirect(const Identifier& propertyName) const; 584 // This get method only looks at the property map. 585 // A bit like hasProperty(recursive=false), this doesn't go to the prototype. 586 // This is used e.g. by lookupOrCreateFunction (to cache a function, we don't want 587 // to look up in the prototype, it might already exist there) 588 ValueImp *getDirect(const Identifier& propertyName) const 589 { return _prop.get(propertyName); } 590 void putDirect(const Identifier &propertyName, ValueImp *value, int attr = 0); 591 void putDirect(const Identifier &propertyName, int value, int attr = 0); 592 583 593 private: 584 594 const HashEntry* findPropertyHashEntry( const Identifier& propertyName ) const; -
trunk/JavaScriptCore/kjs/object_object.cpp
r1799 r2783 39 39 { 40 40 Value protect(this); 41 put (exec,toStringPropertyName, Object(new ObjectProtoFuncImp(exec,funcProto,ObjectProtoFuncImp::ToString, 0)), DontEnum);42 put (exec,valueOfPropertyName, Object(new ObjectProtoFuncImp(exec,funcProto,ObjectProtoFuncImp::ValueOf, 0)), DontEnum);41 putDirect(toStringPropertyName, new ObjectProtoFuncImp(exec,funcProto,ObjectProtoFuncImp::ToString, 0), DontEnum); 42 putDirect(valueOfPropertyName, new ObjectProtoFuncImp(exec,funcProto,ObjectProtoFuncImp::ValueOf, 0), DontEnum); 43 43 } 44 44 … … 52 52 { 53 53 Value protect(this); 54 put (exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);54 putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum); 55 55 } 56 56 … … 80 80 Value protect(this); 81 81 // ECMA 15.2.3.1 82 put (exec,prototypePropertyName, Object(objProto), DontEnum|DontDelete|ReadOnly);82 putDirect(prototypePropertyName, objProto, DontEnum|DontDelete|ReadOnly); 83 83 84 84 // no. of arguments for constructor 85 put (exec,lengthPropertyName, Number(1), ReadOnly|DontDelete|DontEnum);85 putDirect(lengthPropertyName, NumberImp::one(), ReadOnly|DontDelete|DontEnum); 86 86 } 87 87 -
trunk/JavaScriptCore/kjs/property_map.cpp
r2777 r2783 127 127 { 128 128 UString::Rep *rep = name._ustring.rep; 129 129 130 130 #if USE_SINGLE_ENTRY 131 131 if (!_table) { -
trunk/JavaScriptCore/kjs/reference.cpp
r2766 r2783 37 37 38 38 Reference::Reference(const Object& b, unsigned p) 39 : base(b), 40 propertyNameAsNumber(p), 41 baseIsValue(false), 42 propertyNameIsNumber(true) 43 { 44 } 45 46 Reference::Reference(ObjectImp *b, const Identifier& p) 47 : base(b), 48 baseIsValue(false), 49 propertyNameIsNumber(false), 50 prop(p) 51 { 52 } 53 54 Reference::Reference(ObjectImp *b, unsigned p) 39 55 : base(b), 40 56 propertyNameAsNumber(p), -
trunk/JavaScriptCore/kjs/reference.h
r2760 r2783 35 35 Reference(const Object& b, const Identifier& p); 36 36 Reference(const Object& b, unsigned p); 37 Reference(ObjectImp *b, const Identifier& p); 38 Reference(ObjectImp *b, unsigned p); 37 39 Reference(const Null& b, const Identifier& p); 38 40 Reference(const Null& b, unsigned p); -
trunk/JavaScriptCore/kjs/regexp_object.cpp
r2766 r2783 41 41 ObjectPrototypeImp *objProto, 42 42 FunctionPrototypeImp *funcProto) 43 : ObjectImp( Object(objProto))43 : ObjectImp(objProto) 44 44 { 45 45 Value protect(this); … … 48 48 // The constructor will be added later in RegExpObject's constructor (?) 49 49 50 put(exec, "exec", Object(new RegExpProtoFuncImp(exec,funcProto,RegExpProtoFuncImp::Exec, 0)), DontEnum); 51 put(exec, "test", Object(new RegExpProtoFuncImp(exec,funcProto,RegExpProtoFuncImp::Test, 0)), DontEnum); 52 put(exec, toStringPropertyName, Object(new RegExpProtoFuncImp(exec,funcProto,RegExpProtoFuncImp::ToString, 0)), DontEnum); 50 static const Identifier execPropertyName("exec"); 51 putDirect(execPropertyName, new RegExpProtoFuncImp(exec,funcProto,RegExpProtoFuncImp::Exec, 0), DontEnum); 52 static const Identifier testPropertyName("test"); 53 putDirect(testPropertyName, new RegExpProtoFuncImp(exec,funcProto,RegExpProtoFuncImp::Test, 0), DontEnum); 54 putDirect(toStringPropertyName, new RegExpProtoFuncImp(exec,funcProto,RegExpProtoFuncImp::ToString, 0), DontEnum); 53 55 } 54 56 … … 60 62 { 61 63 Value protect(this); 62 put (exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);64 putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum); 63 65 } 64 66 … … 138 140 139 141 RegExpImp::RegExpImp(RegExpPrototypeImp *regexpProto) 140 : ObjectImp( Object(regexpProto)), reg(0L)142 : ObjectImp(regexpProto), reg(0L) 141 143 { 142 144 } … … 157 159 Value protect(this); 158 160 // ECMA 15.10.5.1 RegExp.prototype 159 put (exec,prototypePropertyName, Object(regProto), DontEnum|DontDelete|ReadOnly);161 putDirect(prototypePropertyName, regProto, DontEnum|DontDelete|ReadOnly); 160 162 161 163 // no. of arguments for constructor 162 put (exec,lengthPropertyName, Number(2), ReadOnly|DontDelete|DontEnum);164 putDirect(lengthPropertyName, NumberImp::two(), ReadOnly|DontDelete|DontEnum); 163 165 } 164 166 … … 222 224 Object RegExpObjectImp::construct(ExecState *exec, const List &args) 223 225 { 224 String p = args.isEmpty() ? UString("") : args[0].toString(exec);226 UString p = args.isEmpty() ? UString("") : args[0].toString(exec); 225 227 UString flags = args[1].toString(exec); 226 228 … … 234 236 // TODO: throw a syntax error on invalid flags 235 237 236 dat->put (exec, "global", Boolean(global));237 dat->put (exec, "ignoreCase", Boolean(ignoreCase));238 dat->put (exec, "multiline", Boolean(multiline));239 240 dat->put (exec, "source", p);241 dat->put (exec, "lastIndex", Number(0), DontDelete | DontEnum);238 dat->putDirect("global", global ? BooleanImp::staticTrue : BooleanImp::staticFalse); 239 dat->putDirect("ignoreCase", ignoreCase ? BooleanImp::staticTrue : BooleanImp::staticFalse); 240 dat->putDirect("multiline", multiline ? BooleanImp::staticTrue : BooleanImp::staticFalse); 241 242 dat->putDirect("source", new StringImp(p)); 243 dat->putDirect("lastIndex", NumberImp::zero(), DontDelete | DontEnum); 242 244 243 245 int reflags = RegExp::None; … … 248 250 if (multiline) 249 251 reflags |= RegExp::Multiline; 250 dat->setRegExp(new RegExp(p .value(), reflags));252 dat->setRegExp(new RegExp(p, reflags)); 251 253 252 254 return obj; -
trunk/JavaScriptCore/kjs/string_object.cpp
r2772 r2783 38 38 const ClassInfo StringInstanceImp::info = {"String", 0, 0, 0}; 39 39 40 StringInstanceImp::StringInstanceImp( const Object &proto)40 StringInstanceImp::StringInstanceImp(ObjectImp *proto) 41 41 : ObjectImp(proto) 42 42 { … … 44 44 } 45 45 46 StringInstanceImp::StringInstanceImp( const Object &proto, const UString &string)46 StringInstanceImp::StringInstanceImp(ObjectImp *proto, const UString &string) 47 47 : ObjectImp(proto) 48 48 { … … 120 120 StringPrototypeImp::StringPrototypeImp(ExecState *exec, 121 121 ObjectPrototypeImp *objProto) 122 : StringInstanceImp( Object(objProto))122 : StringInstanceImp(objProto) 123 123 { 124 124 Value protect(this); 125 125 // The constructor will be added later, after StringObjectImp has been built 126 put (exec,lengthPropertyName,Number(0),DontDelete|ReadOnly|DontEnum);126 putDirect(lengthPropertyName, NumberImp::zero(), DontDelete|ReadOnly|DontEnum); 127 127 128 128 } … … 141 141 { 142 142 Value protect(this); 143 put (exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);143 putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum); 144 144 } 145 145 … … 532 532 Value protect(this); 533 533 // ECMA 15.5.3.1 String.prototype 534 put (exec,prototypePropertyName, Object(stringProto), DontEnum|DontDelete|ReadOnly);534 putDirect(prototypePropertyName, stringProto, DontEnum|DontDelete|ReadOnly); 535 535 536 536 static Identifier fromCharCode("fromCharCode"); 537 put (exec,fromCharCode, Object(new StringObjectFuncImp(exec,funcProto)), DontEnum);537 putDirect(fromCharCode, new StringObjectFuncImp(exec,funcProto), DontEnum); 538 538 539 539 // no. of arguments for constructor 540 put (exec,lengthPropertyName, Number(1), ReadOnly|DontDelete|DontEnum);540 putDirect(lengthPropertyName, NumberImp::one(), ReadOnly|DontDelete|DontEnum); 541 541 } 542 542 … … 550 550 Object StringObjectImp::construct(ExecState *exec, const List &args) 551 551 { 552 Object proto = exec->interpreter()->builtinStringPrototype();552 ObjectImp *proto = exec->interpreter()->builtinStringPrototype().imp(); 553 553 if (args.size() == 0) 554 554 return Object(new StringInstanceImp(proto)); … … 579 579 { 580 580 Value protect(this); 581 put (exec,lengthPropertyName,Number(1),DontDelete|ReadOnly|DontEnum);581 putDirect(lengthPropertyName, NumberImp::one(), DontDelete|ReadOnly|DontEnum); 582 582 } 583 583 -
trunk/JavaScriptCore/kjs/string_object.h
r2760 r2783 30 30 class StringInstanceImp : public ObjectImp { 31 31 public: 32 StringInstanceImp( const Object &proto);33 StringInstanceImp( const Object &proto, const UString &string);32 StringInstanceImp(ObjectImp *proto); 33 StringInstanceImp(ObjectImp *proto, const UString &string); 34 34 35 35 virtual Value get(ExecState *exec, const Identifier &propertyName) const; -
trunk/JavaScriptCore/kjs/value.cpp
r1850 r2783 203 203 { 204 204 rep = v; 205 if ( rep)205 if (v) 206 206 { 207 rep->ref();207 v->ref(); 208 208 //fprintf(stderr, "Value::Value(%p) imp=%p ref=%d\n", this, rep, rep->refcount); 209 209 v->setGcAllowed(); … … 296 296 // ------------------------------ String --------------------------------------- 297 297 298 String::String(const UString &s) : Value(new StringImp( UString(s)))298 String::String(const UString &s) : Value(new StringImp(s)) 299 299 { 300 300 } … … 323 323 324 324 Number::Number(double d) 325 : Value(SimpleNumber::fits(d) ? SimpleNumber::make((long)d) : new NumberImp(d)) { }325 : Value(SimpleNumber::fits(d) ? SimpleNumber::make((long)d) : (KJS::isNaN(d) ? NumberImp::staticNaN : new NumberImp(d))) { } 326 326 327 327 Number::Number(long int l) … … 349 349 int Number::intValue() const 350 350 { 351 return int(value()); 351 if (SimpleNumber::is(rep)) 352 return SimpleNumber::value(rep); 353 return (int)((NumberImp*)rep)->value(); 352 354 } 353 355 354 356 bool Number::isNaN() const 355 357 { 356 return KJS::isNaN(value());358 return rep == NumberImp::staticNaN; 357 359 } 358 360 359 361 bool Number::isInf() const 360 362 { 361 return KJS::isInf(value()); 362 } 363 if (SimpleNumber::is(rep)) 364 return false; 365 return KJS::isInf(((NumberImp*)rep)->value()); 366 } -
trunk/JavaScriptCore/kjs/value.h
r1861 r2783 109 109 */ 110 110 void setGcAllowed(); 111 112 // Will crash if called on a simple number. 113 void setGcAllowedFast() { _flags |= VI_GCALLOWED; } 111 114 112 115 int toInteger(ExecState *exec) const;
Note:
See TracChangeset
for help on using the changeset viewer.