Changeset 2753 in webkit for trunk/JavaScriptCore
- Timestamp:
- Nov 18, 2002, 11:57:11 PM (23 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r2751 r2753 1 2002-11-18 Darin Adler <[email protected]> 2 3 - reduced the creation of Value objects and hoisted the property map 4 into Object for another gain of about 6% 5 6 * JavaScriptCore.pbproj/project.pbxproj: Made property_map.h public. 7 * kjs/array_object.cpp: 8 (compareWithCompareFunctionForQSort): Don't wrap the ValueImp * in a Value 9 just to add it to a list. 10 (ArrayProtoFuncImp::call): Pass the globalObject directly so we don't have 11 to ref/deref. 12 * kjs/function.cpp: 13 (FunctionImp::call): Use a reference for the global object to avoid ref/deref. 14 (GlobalFuncImp::call): Ditto. 15 * kjs/internal.cpp: 16 (BooleanImp::toObject): Put the object directly into the list, don't create a Value. 17 (StringImp::toObject): Ditto. 18 (NumberImp::toObject): Ditto. 19 (InterpreterImp::evaluate): Use a reference for the global object. 20 * kjs/internal.h: Return a reference for the global object. 21 * kjs/interpreter.cpp: (Interpreter::globalObject): Ditto. 22 * kjs/interpreter.h: Ditto. 23 * kjs/object.cpp: Use _prop directly in the object, not a separate pointer. 24 * kjs/object.h: Ditto. 25 * kjs/types.cpp: Added List methods that work directly with ValueImp. 26 (List::append): Added a ValueImp version. 27 (List::prepend): Ditto. 28 (List::appendList): Work directly with the ValueImp's. 29 (List::prependList): Ditto. 30 (List::copy): Use appendList. 31 (List::empty): Use a shared global List. 32 * kjs/types.h: Update for above changes. 33 1 34 2002-11-18 Darin Adler <[email protected]> 2 35 -
trunk/JavaScriptCore/ChangeLog-2002-12-03
r2751 r2753 1 2002-11-18 Darin Adler <[email protected]> 2 3 - reduced the creation of Value objects and hoisted the property map 4 into Object for another gain of about 6% 5 6 * JavaScriptCore.pbproj/project.pbxproj: Made property_map.h public. 7 * kjs/array_object.cpp: 8 (compareWithCompareFunctionForQSort): Don't wrap the ValueImp * in a Value 9 just to add it to a list. 10 (ArrayProtoFuncImp::call): Pass the globalObject directly so we don't have 11 to ref/deref. 12 * kjs/function.cpp: 13 (FunctionImp::call): Use a reference for the global object to avoid ref/deref. 14 (GlobalFuncImp::call): Ditto. 15 * kjs/internal.cpp: 16 (BooleanImp::toObject): Put the object directly into the list, don't create a Value. 17 (StringImp::toObject): Ditto. 18 (NumberImp::toObject): Ditto. 19 (InterpreterImp::evaluate): Use a reference for the global object. 20 * kjs/internal.h: Return a reference for the global object. 21 * kjs/interpreter.cpp: (Interpreter::globalObject): Ditto. 22 * kjs/interpreter.h: Ditto. 23 * kjs/object.cpp: Use _prop directly in the object, not a separate pointer. 24 * kjs/object.h: Ditto. 25 * kjs/types.cpp: Added List methods that work directly with ValueImp. 26 (List::append): Added a ValueImp version. 27 (List::prepend): Ditto. 28 (List::appendList): Work directly with the ValueImp's. 29 (List::prependList): Ditto. 30 (List::copy): Use appendList. 31 (List::empty): Use a shared global List. 32 * kjs/types.h: Update for above changes. 33 1 34 2002-11-18 Darin Adler <[email protected]> 2 35 -
trunk/JavaScriptCore/ChangeLog-2003-10-25
r2751 r2753 1 2002-11-18 Darin Adler <[email protected]> 2 3 - reduced the creation of Value objects and hoisted the property map 4 into Object for another gain of about 6% 5 6 * JavaScriptCore.pbproj/project.pbxproj: Made property_map.h public. 7 * kjs/array_object.cpp: 8 (compareWithCompareFunctionForQSort): Don't wrap the ValueImp * in a Value 9 just to add it to a list. 10 (ArrayProtoFuncImp::call): Pass the globalObject directly so we don't have 11 to ref/deref. 12 * kjs/function.cpp: 13 (FunctionImp::call): Use a reference for the global object to avoid ref/deref. 14 (GlobalFuncImp::call): Ditto. 15 * kjs/internal.cpp: 16 (BooleanImp::toObject): Put the object directly into the list, don't create a Value. 17 (StringImp::toObject): Ditto. 18 (NumberImp::toObject): Ditto. 19 (InterpreterImp::evaluate): Use a reference for the global object. 20 * kjs/internal.h: Return a reference for the global object. 21 * kjs/interpreter.cpp: (Interpreter::globalObject): Ditto. 22 * kjs/interpreter.h: Ditto. 23 * kjs/object.cpp: Use _prop directly in the object, not a separate pointer. 24 * kjs/object.h: Ditto. 25 * kjs/types.cpp: Added List methods that work directly with ValueImp. 26 (List::append): Added a ValueImp version. 27 (List::prepend): Ditto. 28 (List::appendList): Work directly with the ValueImp's. 29 (List::prependList): Ditto. 30 (List::copy): Use appendList. 31 (List::empty): Use a shared global List. 32 * kjs/types.h: Update for above changes. 33 1 34 2002-11-18 Darin Adler <[email protected]> 2 35 -
trunk/JavaScriptCore/JavaScriptCore.pbproj/project.pbxproj
r2083 r2753 1332 1332 isa = PBXBuildFile; 1333 1333 settings = { 1334 ATTRIBUTES = ( 1335 Private, 1336 ); 1334 1337 }; 1335 1338 }; -
trunk/JavaScriptCore/kjs/array_object.cpp
r2738 r2753 230 230 231 231 args->arguments.clear(); 232 args->arguments.append( Value(*(ValueImp **)a));233 args->arguments.append( Value(*(ValueImp **)b));232 args->arguments.append(*(ValueImp **)a); 233 args->arguments.append(*(ValueImp **)b); 234 234 return args->compareFunction->call(args->exec, args->globalObject, args->arguments) 235 235 .toInt32(args->exec); … … 531 531 l.append(jObj); 532 532 l.append(minObj); 533 Object thisObj = exec->interpreter()->globalObject(); 534 cmp = sortFunction.call(exec,thisObj, l ).toInt32(exec); 533 cmp = sortFunction.call(exec, exec->interpreter()->globalObject(), l).toInt32(exec); 535 534 } else { 536 535 cmp = (jObj.toString(exec) < minObj.toString(exec)) ? -1 : 1; -
trunk/JavaScriptCore/kjs/function.cpp
r2736 r2753 80 80 Value FunctionImp::call(ExecState *exec, Object &thisObj, const List &args) 81 81 { 82 Object globalObj = exec->interpreter()->globalObject();82 Object &globalObj = exec->interpreter()->globalObject(); 83 83 84 84 Debugger *dbg = exec->interpreter()->imp()->debugger(); … … 369 369 370 370 // enter a new execution context 371 Object glob(exec->interpreter()->globalObject());372 371 Object thisVal(Object::dynamicCast(exec->context().thisValue())); 373 ContextImp *ctx = new ContextImp( glob,372 ContextImp *ctx = new ContextImp(exec->interpreter()->globalObject(), 374 373 exec, 375 374 thisVal, -
trunk/JavaScriptCore/kjs/internal.cpp
r2748 r2753 187 187 { 188 188 List args; 189 args.append( Boolean(const_cast<BooleanImp*>(this)));189 args.append(const_cast<BooleanImp*>(this)); 190 190 return Object::dynamicCast(exec->interpreter()->builtinBoolean().construct(exec,args)); 191 191 } … … 216 216 { 217 217 List args; 218 args.append( Value(const_cast<StringImp*>(this)));218 args.append(const_cast<StringImp*>(this)); 219 219 return Object::dynamicCast(exec->interpreter()->builtinString().construct(exec,args)); 220 220 } … … 245 245 { 246 246 List args; 247 args.append( Number(const_cast<NumberImp*>(this)));247 args.append(const_cast<NumberImp*>(this)); 248 248 return Object::dynamicCast(exec->interpreter()->builtinNumber().construct(exec,args)); 249 249 } … … 735 735 progNode->ref(); 736 736 737 Object globalObj = globalObject();737 Object &globalObj = globalObject(); 738 738 Object thisObj = globalObject(); 739 739 -
trunk/JavaScriptCore/kjs/internal.h
r2741 r2753 241 241 ~InterpreterImp(); 242 242 243 Object globalObject() const { return global; }243 Object &globalObject() const { return const_cast<Object &>(global); } 244 244 Interpreter* interpreter() const { return m_interpreter; } 245 245 -
trunk/JavaScriptCore/kjs/interpreter.cpp
r2738 r2753 109 109 } 110 110 111 Object Interpreter::globalObject() const111 Object &Interpreter::globalObject() const 112 112 { 113 113 return rep->globalObject(); -
trunk/JavaScriptCore/kjs/interpreter.h
r2738 r2753 146 146 * execution performed by this interpreter 147 147 */ 148 Object globalObject() const;148 Object &globalObject() const; 149 149 150 150 void initGlobalObject(); -
trunk/JavaScriptCore/kjs/object.cpp
r2741 r2753 38 38 #include "error_object.h" 39 39 #include "nodes.h" 40 #include "property_map.h"41 40 42 41 namespace KJS { … … 62 61 63 62 ObjectImp::ObjectImp(const Object &proto) 64 : _pro p(0), _proto(static_cast<ObjectImp*>(proto.imp())), _internalValue(0L), _scope(true)63 : _proto(static_cast<ObjectImp*>(proto.imp())), _internalValue(0L), _scope(true) 65 64 { 66 65 //fprintf(stderr,"ObjectImp::ObjectImp %p\n",(void*)this); 67 _prop = new PropertyMap();68 66 } 69 67 … … 72 70 { 73 71 //fprintf(stderr,"ObjectImp::ObjectImp %p\n",(void*)this); 74 _prop = 0;75 72 _proto = NullImp::staticNull; 76 73 _internalValue = 0L; 77 _prop = new PropertyMap();78 74 } 79 75 … … 81 77 { 82 78 //fprintf(stderr,"ObjectImp::~ObjectImp %p\n",(void*)this); 83 delete _prop;84 79 } 85 80 … … 92 87 _proto->mark(); 93 88 94 _prop ->mark();89 _prop.mark(); 95 90 96 91 if (_internalValue && !_internalValue->marked()) … … 171 166 ValueImp* ObjectImp::getDirect(const UString& propertyName) const 172 167 { 173 return _prop ->get(propertyName);168 return _prop.get(propertyName); 174 169 } 175 170 … … 199 194 } 200 195 201 _prop ->put(propertyName,value.imp(),attr);196 _prop.put(propertyName,value.imp(),attr); 202 197 } 203 198 … … 212 207 { 213 208 int attributes; 214 ValueImp *v = _prop ->get(propertyName, attributes);209 ValueImp *v = _prop.get(propertyName, attributes); 215 210 if (v) 216 211 return!(attributes & ReadOnly); … … 229 224 bool ObjectImp::hasProperty(ExecState *exec, const UString &propertyName) const 230 225 { 231 if (_prop ->get(propertyName))226 if (_prop.get(propertyName)) 232 227 return true; 233 228 … … 254 249 { 255 250 int attributes; 256 ValueImp *v = _prop ->get(propertyName, attributes);251 ValueImp *v = _prop.get(propertyName, attributes); 257 252 if (v) { 258 253 if ((attributes & DontDelete)) 259 254 return false; 260 _prop ->remove(propertyName);255 _prop.remove(propertyName); 261 256 return true; 262 257 } … … 276 271 void ObjectImp::deleteAllProperties( ExecState * ) 277 272 { 278 _prop ->clear();273 _prop.clear(); 279 274 } 280 275 … … 397 392 list = static_cast<ObjectImp*>(_proto)->propList(exec,recursive); 398 393 399 _prop ->addEnumerablesToReferenceList(list, Object(this));394 _prop.addEnumerablesToReferenceList(list, Object(this)); 400 395 401 396 // Add properties from the static hashtable of properties -
trunk/JavaScriptCore/kjs/object.h
r2749 r2753 41 41 #include "types.h" 42 42 #include "reference_list.h" 43 #include "property_map.h" 43 44 44 45 namespace KJS { 45 46 46 class PropertyMap;47 47 class HashTable; 48 48 class HashEntry; … … 583 583 private: 584 584 const HashEntry* findPropertyHashEntry( const UString& propertyName ) const; 585 PropertyMap *_prop;585 PropertyMap _prop; 586 586 ValueImp *_proto; 587 587 ValueImp *_internalValue; -
trunk/JavaScriptCore/kjs/types.cpp
r2748 r2753 47 47 ListNode(const Value &val, ListNode *p, ListNode *n) 48 48 : member(val.imp()), prev(p), next(n) {}; 49 ListNode(ValueImp *val, ListNode *p, ListNode *n) 50 : member(val), prev(p), next(n) {}; 49 51 ValueImp *member; 50 52 ListNode *prev, *next; … … 62 64 // ------------------------------ ListIterator --------------------------------- 63 65 64 ListIterator::ListIterator(ListNode *n) : node(n)65 {66 }67 68 ListIterator::ListIterator(const List &l)69 : node(l.hook->next)70 {71 }72 73 66 ValueImp* ListIterator::operator->() const 74 67 { … … 76 69 } 77 70 78 // operator Value* () const { return node->member; }79 71 Value ListIterator::operator*() const 80 72 { … … 82 74 } 83 75 84 // operator Value*() const { return node->member; }85 76 Value ListIterator::operator++() 86 77 { … … 107 98 --*this; 108 99 return Value(n->member); 109 }110 111 bool ListIterator::operator==(const ListIterator &it) const112 {113 return (node==it.node);114 }115 116 bool ListIterator::operator!=(const ListIterator &it) const117 {118 return (node!=it.node);119 100 } 120 101 … … 183 164 } 184 165 166 void List::append(ValueImp *val) 167 { 168 ListNode *n = new ListNode(val, hook->prev, hook); 169 if (!m_needsMarking) { 170 val->ref(); 171 } 172 hook->prev->next = n; 173 hook->prev = n; 174 } 175 185 176 void List::prepend(const Value& val) 186 177 { … … 193 184 } 194 185 186 void List::prepend(ValueImp *val) 187 { 188 ListNode *n = new ListNode(val, hook->prev, hook); 189 if (!m_needsMarking) { 190 val->ref(); 191 } 192 hook->next->prev = n; 193 hook->next = n; 194 } 195 195 196 void List::appendList(const List& lst) 196 197 { 197 List Iterator it = lst.begin();198 List Iterator e = lst.end();199 while (it != e) {200 append( *it);201 ++it;198 ListNode *otherHook = lst.hook; 199 ListNode *o = otherHook->next; 200 while (o != otherHook) { 201 append(o->member); 202 o = o->next; 202 203 } 203 204 } … … 205 206 void List::prependList(const List& lst) 206 207 { 207 List Iterator it = lst.end();208 List Iterator e = lst.begin();209 while (it != e) {210 --it;211 prepend(*it);208 ListNode *otherHook = lst.hook; 209 ListNode *o = otherHook->prev; 210 while (o != otherHook) { 211 prepend(o->member); 212 o = o->prev; 212 213 } 213 214 } … … 261 262 { 262 263 List newList; 263 264 ListIterator e = end(); 265 ListIterator it = begin(); 266 267 while(it != e) { 268 newList.append(*it); 269 ++it; 270 } 271 264 newList.appendList(*this); 272 265 return newList; 273 266 } … … 316 309 } 317 310 318 const List List::empty() 319 { 320 return List(); 311 const List &List::empty() 312 { 313 static List l; 314 return l; 321 315 } 322 316 -
trunk/JavaScriptCore/kjs/types.h
r2748 r2753 43 43 class ListIterator { 44 44 friend class List; 45 ListIterator() ;46 ListIterator(ListNode *n) ;45 ListIterator() : node(0) { } 46 ListIterator(ListNode *n) : node(n) { } 47 47 public: 48 48 /** … … 56 56 */ 57 57 ValueImp* operator->() const; 58 // operator Value* () const { return node->member; }59 58 Value operator*() const; 60 /**61 * Conversion to @ref KJS::Value*62 * @return A pointer to the element the iterator operates on.63 */64 // operator Value*() const { return node->member; }65 59 /** 66 60 * Postfix increment operator. … … 85 79 * False otherwise. 86 80 */ 87 bool operator==(const ListIterator &it) const ;81 bool operator==(const ListIterator &it) const { return node == it.node; } 88 82 /** 89 83 * Check for inequality with another iterator. 90 84 * @return True if the two iterators operate on different list elements. 91 85 */ 92 bool operator!=(const ListIterator &it) const ;86 bool operator!=(const ListIterator &it) const { return node != it.node; } 93 87 private: 94 88 ListNode *node; … … 120 114 */ 121 115 void append(const Value& val); 116 void append(ValueImp *val); 122 117 /** 123 118 * Insert an object at the beginning of the list. … … 126 121 */ 127 122 void prepend(const Value& val); 123 void prepend(ValueImp *val); 128 124 /** 129 125 * Appends the items of another list at the end of this one. … … 147 143 */ 148 144 void remove(const Value &val); 145 void remove(ValueImp *val); 149 146 /** 150 147 * Remove all elements from the list. … … 190 187 * function has a @ref KJS::List parameter. 191 188 */ 192 static const List empty();189 static const List &empty(); 193 190 #ifdef KJS_DEBUG_MEM 194 191 static void globalClear();
Note:
See TracChangeset
for help on using the changeset viewer.