Changeset 2786 in webkit for trunk/JavaScriptCore
- Timestamp:
- Nov 20, 2002, 1:49:31 PM (23 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r2783 r2786 1 2002-11-20 Darin Adler <[email protected]> 2 3 - oops, checked in big regression instead of 5% speedup 4 5 * kjs/function.cpp: (ActivationImp::ActivationImp): Make a marking 6 list, not a refing list. 7 8 - a cut at the sparse array implementation 9 10 * kjs/array_instance.h: Keep storageLength separate from length. 11 * kjs/array_object.cpp: 12 (ArrayInstanceImp::ArrayInstanceImp): Start with storageLength == length. 13 (ArrayInstanceImp::get): Check against storage length. 14 (ArrayInstanceImp::put): Ditto. 15 (ArrayInstanceImp::hasProperty): Ditto. 16 (ArrayInstanceImp::deleteProperty): Ditto. 17 (ArrayInstanceImp::setLength): Only enlarge storage length up to a cutoff. 18 (ArrayInstanceImp::mark): Use storageLength. 19 (ArrayInstanceImp::pushUndefinedObjectsToEnd): Added FIXME. 20 1 21 2002-11-20 Darin Adler <[email protected]> 2 22 -
trunk/JavaScriptCore/ChangeLog-2002-12-03
r2783 r2786 1 2002-11-20 Darin Adler <[email protected]> 2 3 - oops, checked in big regression instead of 5% speedup 4 5 * kjs/function.cpp: (ActivationImp::ActivationImp): Make a marking 6 list, not a refing list. 7 8 - a cut at the sparse array implementation 9 10 * kjs/array_instance.h: Keep storageLength separate from length. 11 * kjs/array_object.cpp: 12 (ArrayInstanceImp::ArrayInstanceImp): Start with storageLength == length. 13 (ArrayInstanceImp::get): Check against storage length. 14 (ArrayInstanceImp::put): Ditto. 15 (ArrayInstanceImp::hasProperty): Ditto. 16 (ArrayInstanceImp::deleteProperty): Ditto. 17 (ArrayInstanceImp::setLength): Only enlarge storage length up to a cutoff. 18 (ArrayInstanceImp::mark): Use storageLength. 19 (ArrayInstanceImp::pushUndefinedObjectsToEnd): Added FIXME. 20 1 21 2002-11-20 Darin Adler <[email protected]> 2 22 -
trunk/JavaScriptCore/ChangeLog-2003-10-25
r2783 r2786 1 2002-11-20 Darin Adler <[email protected]> 2 3 - oops, checked in big regression instead of 5% speedup 4 5 * kjs/function.cpp: (ActivationImp::ActivationImp): Make a marking 6 list, not a refing list. 7 8 - a cut at the sparse array implementation 9 10 * kjs/array_instance.h: Keep storageLength separate from length. 11 * kjs/array_object.cpp: 12 (ArrayInstanceImp::ArrayInstanceImp): Start with storageLength == length. 13 (ArrayInstanceImp::get): Check against storage length. 14 (ArrayInstanceImp::put): Ditto. 15 (ArrayInstanceImp::hasProperty): Ditto. 16 (ArrayInstanceImp::deleteProperty): Ditto. 17 (ArrayInstanceImp::setLength): Only enlarge storage length up to a cutoff. 18 (ArrayInstanceImp::mark): Use storageLength. 19 (ArrayInstanceImp::pushUndefinedObjectsToEnd): Added FIXME. 20 1 21 2002-11-20 Darin Adler <[email protected]> 2 22 -
trunk/JavaScriptCore/kjs/array_instance.h
r2783 r2786 58 58 59 59 unsigned length; 60 unsigned storageLength; 60 61 unsigned capacity; 61 62 ValueImp **storage; -
trunk/JavaScriptCore/kjs/array_object.cpp
r2783 r2786 38 38 // ------------------------------ ArrayInstanceImp ----------------------------- 39 39 40 const unsigned sparseArrayCutoff = 10000; 41 40 42 const ClassInfo ArrayInstanceImp::info = {"Array", 0, 0, 0}; 41 43 … … 43 45 : ObjectImp(proto) 44 46 , length(initialLength) 45 , capacity(length) 46 , storage(length ? (ValueImp **)calloc(length, sizeof(ValueImp *)) : 0) 47 , storageLength(initialLength) 48 , capacity(storageLength) 49 , storage(capacity ? (ValueImp **)calloc(capacity, sizeof(ValueImp *)) : 0) 47 50 { 48 51 } … … 51 54 : ObjectImp(proto) 52 55 , length(list.size()) 53 , capacity(length) 54 , storage(length ? (ValueImp **)malloc(sizeof(ValueImp *) * length) : 0) 56 , storageLength(length) 57 , capacity(storageLength) 58 , storage(capacity ? (ValueImp **)malloc(sizeof(ValueImp *) * capacity) : 0) 55 59 { 56 60 ListIterator it = list.begin(); … … 76 80 if (index >= length) 77 81 return Undefined(); 82 if (index < storageLength) { 83 ValueImp *v = storage[index]; 84 return v ? Value(v) : Undefined(); 85 } 86 } 87 88 return ObjectImp::get(exec, propertyName); 89 } 90 91 Value ArrayInstanceImp::get(ExecState *exec, unsigned index) const 92 { 93 if (index >= length) 94 return Undefined(); 95 if (index < storageLength) { 78 96 ValueImp *v = storage[index]; 79 97 return v ? Value(v) : Undefined(); 80 98 } 81 82 return ObjectImp::get(exec, propertyName); 83 } 84 85 Value ArrayInstanceImp::get(ExecState *exec, unsigned index) const 86 { 87 if (index >= length) 88 return Undefined(); 89 ValueImp *v = storage[index]; 90 return v ? Value(v) : Undefined(); 99 100 return ObjectImp::get(exec, Identifier::from(index)); 91 101 } 92 102 … … 104 114 if (length <= index) 105 115 setLength(index + 1); 116 if (index < storageLength) { 117 storage[index] = value.imp(); 118 return; 119 } 120 } 121 122 ObjectImp::put(exec, propertyName, value, attr); 123 } 124 125 void ArrayInstanceImp::put(ExecState *exec, unsigned index, const Value &value, int attr) 126 { 127 if (length <= index) 128 setLength(index + 1); 129 if (index < storageLength) { 106 130 storage[index] = value.imp(); 107 131 return; 108 132 } 109 133 110 ObjectImp::put(exec, propertyName, value, attr); 111 } 112 113 void ArrayInstanceImp::put(ExecState *exec, unsigned index, const Value &value, int attr) 114 { 115 if (length <= index) 116 setLength(index + 1); 117 storage[index] = value.imp(); 134 ObjectImp::put(exec, Identifier::from(index), value, attr); 118 135 } 119 136 … … 128 145 if (index >= length) 129 146 return false; 147 if (index < storageLength) { 148 ValueImp *v = storage[index]; 149 return v && v != UndefinedImp::staticUndefined; 150 } 151 } 152 153 return ObjectImp::hasProperty(exec, propertyName); 154 } 155 156 bool ArrayInstanceImp::hasProperty(ExecState *exec, unsigned index) const 157 { 158 if (index >= length) 159 return false; 160 if (index < storageLength) { 130 161 ValueImp *v = storage[index]; 131 162 return v && v != UndefinedImp::staticUndefined; 132 163 } 133 164 134 return ObjectImp::hasProperty(exec, propertyName); 135 } 136 137 bool ArrayInstanceImp::hasProperty(ExecState *exec, unsigned index) const 138 { 139 if (index >= length) 140 return false; 141 ValueImp *v = storage[index]; 142 return v && v != UndefinedImp::staticUndefined; 165 return ObjectImp::hasProperty(exec, Identifier::from(index)); 143 166 } 144 167 … … 153 176 if (index >= length) 154 177 return true; 178 if (index < storageLength) { 179 storage[index] = 0; 180 return true; 181 } 182 } 183 184 return ObjectImp::deleteProperty(exec, propertyName); 185 } 186 187 bool ArrayInstanceImp::deleteProperty(ExecState *exec, unsigned index) 188 { 189 if (index >= length) 190 return true; 191 if (index < storageLength) { 155 192 storage[index] = 0; 156 193 return true; 157 194 } 158 195 159 return ObjectImp::deleteProperty(exec, propertyName); 160 } 161 162 bool ArrayInstanceImp::deleteProperty(ExecState *exec, unsigned index) 163 { 164 if (index >= length) 165 return true; 166 storage[index] = 0; 167 return true; 196 return ObjectImp::deleteProperty(exec, Identifier::from(index)); 168 197 } 169 198 170 199 void ArrayInstanceImp::setLength(unsigned newLength) 171 200 { 172 if (newLength < length) { 173 memset(storage + newLength, 0, sizeof(ValueImp *) * (length - newLength)); 174 } 175 if (newLength > capacity) { 176 unsigned newCapacity = (newLength * 3 + 1) / 2; 177 storage = (ValueImp **)realloc(storage, newCapacity * sizeof (ValueImp *)); 178 memset(storage + capacity, 0, sizeof(ValueImp *) * (newCapacity - capacity)); 179 capacity = newCapacity; 180 } 201 if (newLength <= sparseArrayCutoff || newLength == length + 1) { 202 if (newLength < storageLength) { 203 memset(storage + newLength, 0, sizeof(ValueImp *) * (storageLength - newLength)); 204 } 205 if (newLength > capacity) { 206 unsigned newCapacity = (newLength * 3 + 1) / 2; 207 storage = (ValueImp **)realloc(storage, newCapacity * sizeof (ValueImp *)); 208 memset(storage + capacity, 0, sizeof(ValueImp *) * (newCapacity - capacity)); 209 capacity = newCapacity; 210 } 211 storageLength = newLength; 212 } 213 214 // FIXME: Need to remove items from the property map when making a sparse 215 // list shorter. 216 181 217 length = newLength; 182 218 } … … 185 221 { 186 222 ObjectImp::mark(); 187 unsigned l = length;223 unsigned l = storageLength; 188 224 for (unsigned i = 0; i < l; ++i) { 189 225 ValueImp *imp = storage[i]; … … 253 289 254 290 unsigned o = 0; 255 for (unsigned i = 0; i != length; ++i) { 291 292 for (unsigned i = 0; i != storageLength; ++i) { 256 293 ValueImp *v = storage[i]; 257 294 if (v && v != undefined) { … … 261 298 } 262 299 } 263 if (o != length) 264 memset(storage + o, 0, sizeof(ValueImp *) * (length - o)); 300 301 // FIXME: Get sparse items down here. 302 303 if (o != storageLength) 304 memset(storage + o, 0, sizeof(ValueImp *) * (storageLength - o)); 305 265 306 return o; 266 307 } -
trunk/JavaScriptCore/kjs/function.cpp
r2783 r2786 331 331 // ECMA 10.1.6 332 332 ActivationImp::ActivationImp(ExecState *exec, FunctionImp *f, const List &args) 333 : _function(f), _arguments( args)333 : _function(f), _arguments(true) 334 334 { 335 335 Value protect(this); 336 _arguments = args; 336 337 _argumentsObject = new ArgumentsImp(exec, f, args); 337 338 putDirect(argumentsPropertyName, _argumentsObject, Internal|DontDelete);
Note:
See TracChangeset
for help on using the changeset viewer.