Changeset 2777 in webkit for trunk/JavaScriptCore/kjs
- Timestamp:
- Nov 20, 2002, 12:53:04 AM (23 years ago)
- Location:
- trunk/JavaScriptCore/kjs
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/array_object.cpp
r2760 r2777 215 215 , compareFunction(cf) 216 216 , globalObject(e->interpreter()->globalObject()) 217 { } 217 { 218 arguments.append(Undefined()); 219 arguments.append(Undefined()); 220 } 218 221 219 222 ExecState *exec; … … 229 232 CompareWithCompareFunctionArguments *args = compareWithCompareFunctionArguments; 230 233 231 args->arguments.clear(); 232 args->arguments.append(*(ValueImp **)a); 233 args->arguments.append(*(ValueImp **)b); 234 args->arguments.replaceFirst(*(ValueImp **)a); 235 args->arguments.replaceLast(*(ValueImp **)b); 234 236 return args->compareFunction->call(args->exec, args->globalObject, args->arguments) 235 237 .toInt32(args->exec); -
trunk/JavaScriptCore/kjs/property_map.cpp
r2776 r2777 26 26 #include "reference_list.h" 27 27 28 // At the time I added this, the optimization still gave a 1.5% performance boost. 29 #define USE_SINGLE_ENTRY 1 30 28 31 namespace KJS { 29 32 … … 36 39 PropertyMap::~PropertyMap() 37 40 { 41 #if USE_SINGLE_ENTRY 38 42 UString::Rep *key = _singleEntry.key; 39 43 if (key) 40 44 key->deref(); 45 #endif 41 46 for (int i = 0; i < _tableSize; i++) { 42 key = _table[i].key;47 UString::Rep *key = _table[i].key; 43 48 if (key) 44 49 key->deref(); … … 49 54 void PropertyMap::clear() 50 55 { 56 #if USE_SINGLE_ENTRY 51 57 UString::Rep *key = _singleEntry.key; 52 58 if (key) { … … 54 60 _singleEntry.key = 0; 55 61 } 62 #endif 56 63 for (int i = 0; i < _tableSize; i++) { 57 64 UString::Rep *key = _table[i].key; … … 71 78 ValueImp *PropertyMap::get(const Identifier &name, int &attributes) const 72 79 { 73 if (!_table) { 80 UString::Rep *rep = name._ustring.rep; 81 82 if (!_table) { 83 #if USE_SINGLE_ENTRY 74 84 UString::Rep *key = _singleEntry.key; 75 if ( name._ustring.rep == key) {85 if (rep == key) { 76 86 attributes = _singleEntry.attributes; 77 87 return _singleEntry.value; 78 88 } 89 #endif 79 90 return 0; 80 91 } 81 92 82 int i = hash( name._ustring.rep);93 int i = hash(rep); 83 94 while (UString::Rep *key = _table[i].key) { 84 if ( name._ustring.rep == key) {95 if (rep == key) { 85 96 attributes = _table[i].attributes; 86 97 return _table[i].value; … … 93 104 ValueImp *PropertyMap::get(const Identifier &name) const 94 105 { 95 if (!_table) { 106 UString::Rep *rep = name._ustring.rep; 107 108 if (!_table) { 109 #if USE_SINGLE_ENTRY 96 110 UString::Rep *key = _singleEntry.key; 97 if ( name._ustring.rep == key)111 if (rep == key) 98 112 return _singleEntry.value; 113 #endif 99 114 return 0; 100 115 } 101 116 102 int i = hash( name._ustring.rep);117 int i = hash(rep); 103 118 while (UString::Rep *key = _table[i].key) { 104 if ( name._ustring.rep == key)119 if (rep == key) 105 120 return _table[i].value; 106 121 i = (i + 1) & _tableSizeMask; … … 111 126 void PropertyMap::put(const Identifier &name, ValueImp *value, int attributes) 112 127 { 128 UString::Rep *rep = name._ustring.rep; 129 130 #if USE_SINGLE_ENTRY 113 131 if (!_table) { 114 132 UString::Rep *key = _singleEntry.key; 115 133 if (key) { 116 if ( name._ustring.rep == key) {134 if (rep == key) { 117 135 _singleEntry.value = value; 118 136 return; 119 137 } 120 138 } else { 121 name._ustring.rep->ref();122 _singleEntry.key = name._ustring.rep;139 rep->ref(); 140 _singleEntry.key = rep; 123 141 _singleEntry.value = value; 124 142 _singleEntry.attributes = attributes; … … 127 145 } 128 146 } 147 #endif 129 148 130 149 if (_keyCount * 2 >= _tableSize) 131 150 expand(); 132 151 133 int i = hash( name._ustring.rep);152 int i = hash(rep); 134 153 while (UString::Rep *key = _table[i].key) { 135 if ( name._ustring.rep == key) {154 if (rep == key) { 136 155 // Put a new value in an existing hash table entry. 137 156 _table[i].value = value; … … 143 162 144 163 // Create a new hash table entry. 145 name._ustring.rep->ref();146 _table[i].key = name._ustring.rep;164 rep->ref(); 165 _table[i].key = rep; 147 166 _table[i].value = value; 148 167 _table[i].attributes = attributes; … … 170 189 _table = (Entry *)calloc(_tableSize, sizeof(Entry)); 171 190 191 #if USE_SINGLE_ENTRY 172 192 UString::Rep *key = _singleEntry.key; 173 193 if (key) { … … 175 195 _singleEntry.key = 0; 176 196 } 197 #endif 177 198 178 199 for (int i = 0; i != oldTableSize; ++i) { 179 key = oldTable[i].key;200 UString::Rep *key = oldTable[i].key; 180 201 if (key) 181 202 insert(key, oldTable[i].value, oldTable[i].attributes); … … 187 208 void PropertyMap::remove(const Identifier &name) 188 209 { 210 UString::Rep *rep = name._ustring.rep; 211 189 212 UString::Rep *key; 190 213 191 214 if (!_table) { 215 #if USE_SINGLE_ENTRY 192 216 key = _singleEntry.key; 193 if ( name._ustring.rep == key) {217 if (rep == key) { 194 218 key->deref(); 195 219 _singleEntry.key = 0; 196 220 _keyCount = 0; 197 221 } 222 #endif 198 223 return; 199 224 } 200 225 201 226 // Find the thing to remove. 202 int i = hash( name._ustring.rep);227 int i = hash(rep); 203 228 while ((key = _table[i].key)) { 204 if ( name._ustring.rep == key)229 if (rep == key) 205 230 break; 206 231 i = (i + 1) & _tableSizeMask; … … 227 252 void PropertyMap::mark() const 228 253 { 254 #if USE_SINGLE_ENTRY 229 255 if (_singleEntry.key) { 230 256 ValueImp *v = _singleEntry.value; … … 232 258 v->mark(); 233 259 } 260 #endif 234 261 for (int i = 0; i != _tableSize; ++i) { 235 262 if (_table[i].key) { … … 243 270 void PropertyMap::addEnumerablesToReferenceList(ReferenceList &list, const Object &base) const 244 271 { 272 #if USE_SINGLE_ENTRY 245 273 UString::Rep *key = _singleEntry.key; 246 274 if (key && !(_singleEntry.attributes & DontEnum)) 247 275 list.append(Reference(base, Identifier(key))); 276 #endif 248 277 for (int i = 0; i != _tableSize; ++i) { 249 278 UString::Rep *key = _table[i].key; -
trunk/JavaScriptCore/kjs/types.cpp
r2757 r2777 350 350 other.hook = tmp; 351 351 } 352 353 void List::replaceFirst(ValueImp *v) 354 { 355 ListNode *n = hook->next; 356 if (!m_needsMarking) { 357 v->ref(); 358 n->member->deref(); 359 } 360 n->member = v; 361 } 362 363 void List::replaceLast(ValueImp *v) 364 { 365 ListNode *n = hook->prev; 366 if (!m_needsMarking) { 367 v->ref(); 368 n->member->deref(); 369 } 370 n->member = v; 371 } -
trunk/JavaScriptCore/kjs/types.h
r2757 r2777 184 184 */ 185 185 static const List &empty(); 186 186 187 void mark(); 188 189 void replaceFirst(ValueImp *); 190 void replaceLast(ValueImp *); 191 187 192 private: 188 193
Note:
See TracChangeset
for help on using the changeset viewer.