Changeset 178928 in webkit for trunk/Source/JavaScriptCore
- Timestamp:
- Jan 22, 2015, 11:34:34 AM (10 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r178926 r178928 1 2015-01-22 Commit Queue <[email protected]> 2 3 Unreviewed, rolling out r178894. 4 https://bugs.webkit.org/show_bug.cgi?id=140775 5 6 Broke JSC and bindings tests (Requested by ap_ on #webkit). 7 8 Reverted changeset: 9 10 "put_by_val_direct need to check the property is index or not 11 for using putDirect / putDirectIndex" 12 https://bugs.webkit.org/show_bug.cgi?id=140426 13 http://trac.webkit.org/changeset/178894 14 1 15 2015-01-22 Mark Lam <[email protected]> 2 16 -
trunk/Source/JavaScriptCore/bytecode/GetByIdStatus.cpp
r178894 r178928 271 271 return GetByIdStatus(); 272 272 273 if (toUInt32FromStringImpl(uid) )273 if (toUInt32FromStringImpl(uid) != PropertyName::NotAnIndex) 274 274 return GetByIdStatus(TakesSlowPath); 275 275 -
trunk/Source/JavaScriptCore/bytecode/PutByIdStatus.cpp
r178894 r178928 311 311 PutByIdStatus PutByIdStatus::computeFor(JSGlobalObject* globalObject, const StructureSet& set, AtomicStringImpl* uid, bool isDirect) 312 312 { 313 if (toUInt32FromStringImpl(uid) )313 if (toUInt32FromStringImpl(uid) != PropertyName::NotAnIndex) 314 314 return PutByIdStatus(TakesSlowPath); 315 315 -
trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
r178926 r178928 1502 1502 instructions().append(0); 1503 1503 instructions().append(0); 1504 instructions().append(property != m_vm->propertyNames->underscoreProto && !PropertyName(property).asIndex()); 1504 instructions().append( 1505 property != m_vm->propertyNames->underscoreProto 1506 && PropertyName(property).asIndex() == PropertyName::NotAnIndex); 1505 1507 return value; 1506 1508 } -
trunk/Source/JavaScriptCore/dfg/DFGOperations.cpp
r178894 r178928 98 98 99 99 if (LIKELY(property.isUInt32())) { 100 uint32_t index = property.asUInt32(); 101 ASSERT_WITH_MESSAGE(index != PropertyName::NotAnIndex, "Since JSValue::isUInt32 returns true only when the boxed value is int32_t and positive, it doesn't return true for uint32_t max value that is PropertyName::NotAnIndex."); 102 putByVal<strict, direct>(exec, baseValue, index, value); 100 putByVal<strict, direct>(exec, baseValue, property.asUInt32(), value); 103 101 return; 104 102 } … … 107 105 double propertyAsDouble = property.asDouble(); 108 106 uint32_t propertyAsUInt32 = static_cast<uint32_t>(propertyAsDouble); 109 if (propertyAsDouble == propertyAsUInt32 && propertyAsUInt32 != PropertyName::NotAnIndex) {107 if (propertyAsDouble == propertyAsUInt32) { 110 108 putByVal<strict, direct>(exec, baseValue, propertyAsUInt32, value); 111 109 return; … … 125 123 // Don't put to an object if toString throws an exception. 126 124 Identifier ident = property.toString(exec)->toIdentifier(exec); 127 if (vm->exception()) 128 return; 129 130 PutPropertySlot slot(baseValue, strict); 131 if (direct) { 132 PropertyName propertyName(ident); 133 RELEASE_ASSERT(baseValue.isObject()); 134 if (Optional<uint32_t> index = propertyName.asIndex()) 135 asObject(baseValue)->putDirectIndex(exec, index.value(), value, 0, strict ? PutDirectIndexShouldThrow : PutDirectIndexShouldNotThrow); 136 else 137 asObject(baseValue)->putDirect(*vm, propertyName, value, slot); 138 } else 139 baseValue.put(exec, ident, value, slot); 125 if (!vm->exception()) { 126 PutPropertySlot slot(baseValue, strict); 127 if (direct) { 128 RELEASE_ASSERT(baseValue.isObject()); 129 asObject(baseValue)->putDirect(*vm, ident, value, slot); 130 } else 131 baseValue.put(exec, ident, value, slot); 132 } 140 133 } 141 134 -
trunk/Source/JavaScriptCore/jit/JITOperations.cpp
r178894 r178928 52 52 #include "LegacyProfiler.h" 53 53 #include "ObjectConstructor.h" 54 #include "PropertyName.h"55 54 #include "Repatch.h" 56 55 #include "RepatchBuffer.h" … … 482 481 static void directPutByVal(CallFrame* callFrame, JSObject* baseObject, JSValue subscript, JSValue value) 483 482 { 484 bool isStrictMode = callFrame->codeBlock()->isStrictMode();485 483 if (LIKELY(subscript.isUInt32())) { 486 uint32_t index = subscript.asUInt32(); 487 ASSERT_WITH_MESSAGE(index != PropertyName::NotAnIndex, "Since JSValue::isUInt32 returns true only when the boxed value is int32_t and positive, it doesn't return true for uint32_t max value that is PropertyName::NotAnIndex."); 488 baseObject->putDirectIndex(callFrame, index, value, 0, isStrictMode ? PutDirectIndexShouldThrow : PutDirectIndexShouldNotThrow); 489 return; 490 } 491 492 if (subscript.isDouble()) { 493 double subscriptAsDouble = subscript.asDouble(); 494 uint32_t subscriptAsUInt32 = static_cast<uint32_t>(subscriptAsDouble); 495 if (subscriptAsDouble == subscriptAsUInt32 && subscriptAsUInt32 != PropertyName::NotAnIndex) { 496 baseObject->putDirectIndex(callFrame, subscriptAsUInt32, value, 0, isStrictMode ? PutDirectIndexShouldThrow : PutDirectIndexShouldNotThrow); 497 return; 498 } 499 } 500 501 if (isName(subscript)) { 502 PutPropertySlot slot(baseObject, isStrictMode); 484 uint32_t i = subscript.asUInt32(); 485 baseObject->putDirectIndex(callFrame, i, value); 486 } else if (isName(subscript)) { 487 PutPropertySlot slot(baseObject, callFrame->codeBlock()->isStrictMode()); 503 488 baseObject->putDirect(callFrame->vm(), jsCast<NameInstance*>(subscript.asCell())->privateName(), value, slot); 504 return; 505 } 506 507 // Don't put to an object if toString throws an exception. 508 Identifier property = subscript.toString(callFrame)->toIdentifier(callFrame); 509 if (callFrame->vm().exception()) 510 return; 511 512 PropertyName propertyName(property); 513 if (Optional<uint32_t> index = propertyName.asIndex()) 514 baseObject->putDirectIndex(callFrame, index.value(), value, 0, isStrictMode ? PutDirectIndexShouldThrow : PutDirectIndexShouldNotThrow); 515 else { 516 PutPropertySlot slot(baseObject, isStrictMode); 517 baseObject->putDirect(callFrame->vm(), propertyName, value, slot); 489 } else { 490 Identifier property = subscript.toString(callFrame)->toIdentifier(callFrame); 491 if (!callFrame->vm().exception()) { // Don't put to an object if toString threw an exception. 492 PutPropertySlot slot(baseObject, callFrame->codeBlock()->isStrictMode()); 493 baseObject->putDirect(callFrame->vm(), property, value, slot); 494 } 518 495 } 519 496 } -
trunk/Source/JavaScriptCore/jit/Repatch.cpp
r178894 r178928 983 983 PropertyName pname(ident); 984 984 Structure* oldStructure = structure; 985 if (!oldStructure->isObject() || oldStructure->isDictionary() || pname.asIndex() )985 if (!oldStructure->isObject() || oldStructure->isDictionary() || pname.asIndex() != PropertyName::NotAnIndex) 986 986 return nullptr; 987 987 -
trunk/Source/JavaScriptCore/jsc.cpp
r178894 r178928 335 335 } 336 336 337 Optional<uint32_t> index = propertyName.asIndex(); 338 if (index && index.value() < thisObject->getLength()) { 339 slot.setValue(thisObject, DontDelete | DontEnum, jsNumber(thisObject->m_vector[index.value()])); 337 unsigned index = propertyName.asIndex(); 338 if (index < thisObject->getLength()) { 339 ASSERT(index != PropertyName::NotAnIndex); 340 slot.setValue(thisObject, DontDelete | DontEnum, jsNumber(thisObject->m_vector[index])); 340 341 return true; 341 342 } -
trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp
r178894 r178928 820 820 RELEASE_ASSERT(baseValue.isObject()); 821 821 JSObject* baseObject = asObject(baseValue); 822 bool isStrictMode = exec->codeBlock()->isStrictMode();823 822 if (LIKELY(subscript.isUInt32())) { 824 uint32_t index = subscript.asUInt32(); 825 ASSERT_WITH_MESSAGE(index != PropertyName::NotAnIndex, "Since JSValue::isUInt32 returns true only when the boxed value is int32_t and positive, it doesn't return true for uint32_t max value that is PropertyName::NotAnIndex."); 826 baseObject->putDirectIndex(exec, index, value, 0, isStrictMode ? PutDirectIndexShouldThrow : PutDirectIndexShouldNotThrow); 827 LLINT_END(); 828 } 829 830 831 if (subscript.isDouble()) { 832 double subscriptAsDouble = subscript.asDouble(); 833 uint32_t subscriptAsUInt32 = static_cast<uint32_t>(subscriptAsDouble); 834 if (subscriptAsDouble == subscriptAsUInt32 && subscriptAsUInt32 != PropertyName::NotAnIndex) { 835 baseObject->putDirectIndex(exec, subscriptAsUInt32, value, 0, isStrictMode ? PutDirectIndexShouldThrow : PutDirectIndexShouldNotThrow); 836 LLINT_END(); 823 uint32_t i = subscript.asUInt32(); 824 baseObject->putDirectIndex(exec, i, value); 825 } else if (isName(subscript)) { 826 PutPropertySlot slot(baseObject, exec->codeBlock()->isStrictMode()); 827 baseObject->putDirect(exec->vm(), jsCast<NameInstance*>(subscript.asCell())->privateName(), value, slot); 828 } else { 829 Identifier property = subscript.toString(exec)->toIdentifier(exec); 830 if (!exec->vm().exception()) { // Don't put to an object if toString threw an exception. 831 PutPropertySlot slot(baseObject, exec->codeBlock()->isStrictMode()); 832 baseObject->putDirect(exec->vm(), property, value, slot); 837 833 } 838 }839 840 if (isName(subscript)) {841 PutPropertySlot slot(baseObject, isStrictMode);842 baseObject->putDirect(exec->vm(), jsCast<NameInstance*>(subscript.asCell())->privateName(), value, slot);843 LLINT_END();844 }845 846 // Don't put to an object if toString throws an exception.847 Identifier property = subscript.toString(exec)->toIdentifier(exec);848 if (exec->vm().exception())849 LLINT_END();850 851 PropertyName propertyName(property);852 if (Optional<uint32_t> index = propertyName.asIndex())853 baseObject->putDirectIndex(exec, index.value(), value, 0, isStrictMode ? PutDirectIndexShouldThrow : PutDirectIndexShouldNotThrow);854 else {855 PutPropertySlot slot(baseObject, isStrictMode);856 baseObject->putDirect(exec->vm(), propertyName, value, slot);857 834 } 858 835 LLINT_END(); -
trunk/Source/JavaScriptCore/runtime/Arguments.cpp
r178894 r178928 162 162 { 163 163 Arguments* thisObject = jsCast<Arguments*>(object); 164 if (Optional<uint32_t> index = propertyName.asIndex()) {165 if (JSValue value = thisObject->tryGetArgument(index.value())) {166 slot.setValue(thisObject, None, value);167 return true;168 }164 unsigned i = propertyName.asIndex(); 165 if (JSValue value = thisObject->tryGetArgument(i)) { 166 RELEASE_ASSERT(i < PropertyName::NotAnIndex); 167 slot.setValue(thisObject, None, value); 168 return true; 169 169 } 170 170 … … 225 225 { 226 226 Arguments* thisObject = jsCast<Arguments*>(cell); 227 Optional<uint32_t> index= propertyName.asIndex();228 if ( index && thisObject->trySetArgument(exec->vm(), index.value(), value))227 unsigned i = propertyName.asIndex(); 228 if (thisObject->trySetArgument(exec->vm(), i, value)) 229 229 return; 230 230 … … 268 268 269 269 Arguments* thisObject = jsCast<Arguments*>(cell); 270 Optional<uint32_t> index = propertyName.asIndex(); 271 if (index && index.value() < thisObject->m_numArguments) { 270 unsigned i = propertyName.asIndex(); 271 if (i < thisObject->m_numArguments) { 272 RELEASE_ASSERT(i < PropertyName::NotAnIndex); 272 273 if (!Base::deleteProperty(cell, exec, propertyName)) 273 274 return false; 274 if (thisObject->tryDeleteArgument(exec->vm(), i ndex.value()))275 if (thisObject->tryDeleteArgument(exec->vm(), i)) 275 276 return true; 276 277 } … … 298 299 { 299 300 Arguments* thisObject = jsCast<Arguments*>(object); 300 Optional<uint32_t> optionalIndex = propertyName.asIndex(); 301 if (optionalIndex && optionalIndex.value() < thisObject->m_numArguments) { 301 unsigned i = propertyName.asIndex(); 302 if (i < thisObject->m_numArguments) { 303 RELEASE_ASSERT(i < PropertyName::NotAnIndex); 302 304 // If the property is not yet present on the object, and is not yet marked as deleted, then add it now. 303 uint32_t index = optionalIndex.value();304 305 PropertySlot slot(thisObject); 305 if (!thisObject->isDeletedArgument(i ndex) && !JSObject::getOwnPropertySlot(thisObject, exec, propertyName, slot)) {306 JSValue value = thisObject->tryGetArgument(i ndex);306 if (!thisObject->isDeletedArgument(i) && !JSObject::getOwnPropertySlot(thisObject, exec, propertyName, slot)) { 307 JSValue value = thisObject->tryGetArgument(i); 307 308 ASSERT(value); 308 309 object->putDirectMayBeIndex(exec, propertyName, value); … … 313 314 // From ES 5.1, 10.6 Arguments Object 314 315 // 5. If the value of isMapped is not undefined, then 315 if (thisObject->isArgument(i ndex)) {316 if (thisObject->isArgument(i)) { 316 317 // a. If IsAccessorDescriptor(Desc) is true, then 317 318 if (descriptor.isAccessorDescriptor()) { 318 319 // i. Call the [[Delete]] internal method of map passing P, and false as the arguments. 319 thisObject->tryDeleteArgument(exec->vm(), i ndex);320 thisObject->tryDeleteArgument(exec->vm(), i); 320 321 } else { // b. Else 321 322 // i. If Desc.[[Value]] is present, then 322 323 // 1. Call the [[Put]] internal method of map passing P, Desc.[[Value]], and Throw as the arguments. 323 324 if (descriptor.value()) 324 thisObject->trySetArgument(exec->vm(), i ndex, descriptor.value());325 thisObject->trySetArgument(exec->vm(), i, descriptor.value()); 325 326 // ii. If Desc.[[Writable]] is present and its value is false, then 326 327 // 1. Call the [[Delete]] internal method of map passing P and false as arguments. 327 328 if (descriptor.writablePresent() && !descriptor.writable()) 328 thisObject->tryDeleteArgument(exec->vm(), i ndex);329 thisObject->tryDeleteArgument(exec->vm(), i); 329 330 } 330 331 } -
trunk/Source/JavaScriptCore/runtime/ArrayPrototype.cpp
r178894 r178928 743 743 for (size_t i = 0; i < nameArray.size(); ++i) { 744 744 PropertyName name = nameArray[i]; 745 Optional<uint32_t> optionalIndex = name.asIndex();746 if ( !optionalIndex)745 uint32_t index = name.asIndex(); 746 if (index == PropertyName::NotAnIndex) 747 747 continue; 748 749 uint32_t index = optionalIndex.value(); 748 750 749 JSValue value = getOrHole(thisObj, exec, index); 751 750 if (exec->hadException()) -
trunk/Source/JavaScriptCore/runtime/JSArray.cpp
r178894 r178928 159 159 // 4. Else if P is an array index (15.4), then 160 160 // a. Let index be ToUint32(P). 161 if (Optional<uint32_t> optionalIndex = propertyName.asIndex()) { 161 unsigned index = propertyName.asIndex(); 162 if (index != PropertyName::NotAnIndex) { 162 163 // b. Reject if index >= oldLen and oldLenDesc.[[Writable]] is false. 163 uint32_t index = optionalIndex.value();164 164 if (index >= array->length() && !array->isLengthWritable()) 165 165 return reject(exec, throwException, "Attempting to define numeric property on array with non-writable length property."); -
trunk/Source/JavaScriptCore/runtime/JSCJSValue.cpp
r178894 r178928 120 120 VM& vm = exec->vm(); 121 121 122 if (Optional<uint32_t> index = propertyName.asIndex()) { 123 putToPrimitiveByIndex(exec, index.value(), value, slot.isStrictMode()); 122 unsigned index = propertyName.asIndex(); 123 if (index != PropertyName::NotAnIndex) { 124 putToPrimitiveByIndex(exec, index, value, slot.isStrictMode()); 124 125 return; 125 126 } -
trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewInlines.h
r178894 r178928 303 303 } 304 304 305 Optional<uint32_t>index = propertyName.asIndex();306 if (index && thisObject->canGetIndexQuickly(index.value())) {307 slot.setValue(thisObject, DontDelete | ReadOnly, thisObject->getIndexQuickly(index .value()));305 unsigned index = propertyName.asIndex(); 306 if (index != PropertyName::NotAnIndex && thisObject->canGetIndexQuickly(index)) { 307 slot.setValue(thisObject, DontDelete | ReadOnly, thisObject->getIndexQuickly(index)); 308 308 return true; 309 309 } … … 325 325 } 326 326 327 if (Optional<uint32_t> index = propertyName.asIndex()) { 328 putByIndex(thisObject, exec, index.value(), value, slot.isStrictMode()); 327 unsigned index = propertyName.asIndex(); 328 if (index != PropertyName::NotAnIndex) { 329 putByIndex(thisObject, exec, index, value, slot.isStrictMode()); 329 330 return; 330 331 } … … 343 344 // defineOwnProperty for indexed properties on typed arrays, even if they're out 344 345 // of bounds. 345 if (propertyName == exec->propertyNames().length || propertyName.asIndex()) 346 if (propertyName == exec->propertyNames().length 347 || propertyName.asIndex() != PropertyName::NotAnIndex) 346 348 return reject(exec, shouldThrow, "Attempting to write to a read-only typed array property."); 347 349 … … 355 357 JSGenericTypedArrayView* thisObject = jsCast<JSGenericTypedArrayView*>(cell); 356 358 357 if (propertyName == exec->propertyNames().length || propertyName.asIndex()) 359 if (propertyName == exec->propertyNames().length 360 || propertyName.asIndex() != PropertyName::NotAnIndex) 358 361 return false; 359 362 -
trunk/Source/JavaScriptCore/runtime/JSObject.cpp
r178894 r178928 340 340 // Try indexed put first. This is required for correctness, since loads on property names that appear like 341 341 // valid indices will never look in the named property storage. 342 if (Optional<uint32_t> index = propertyName.asIndex()) { 343 putByIndex(thisObject, exec, index.value(), value, slot.isStrictMode()); 342 unsigned i = propertyName.asIndex(); 343 if (i != PropertyName::NotAnIndex) { 344 putByIndex(thisObject, exec, i, value, slot.isStrictMode()); 344 345 return; 345 346 } … … 1198 1199 ASSERT(value.isGetterSetter() && (attributes & Accessor)); 1199 1200 1200 if (Optional<uint32_t> index = propertyName.asIndex()) { 1201 putDirectIndex(exec, index.value(), value, attributes, PutDirectIndexLikePutDirect); 1201 unsigned index = propertyName.asIndex(); 1202 if (index != PropertyName::NotAnIndex) { 1203 putDirectIndex(exec, index, value, attributes, PutDirectIndexLikePutDirect); 1202 1204 return; 1203 1205 } … … 1208 1210 void JSObject::putDirectCustomAccessor(VM& vm, PropertyName propertyName, JSValue value, unsigned attributes) 1209 1211 { 1210 ASSERT( !propertyName.asIndex());1212 ASSERT(propertyName.asIndex() == PropertyName::NotAnIndex); 1211 1213 1212 1214 PutPropertySlot slot(this); … … 1256 1258 JSObject* thisObject = jsCast<JSObject*>(cell); 1257 1259 1258 if (Optional<uint32_t> index = propertyName.asIndex()) 1259 return thisObject->methodTable(exec->vm())->deletePropertyByIndex(thisObject, exec, index.value()); 1260 unsigned i = propertyName.asIndex(); 1261 if (i != PropertyName::NotAnIndex) 1262 return thisObject->methodTable(exec->vm())->deletePropertyByIndex(thisObject, exec, i); 1260 1263 1261 1264 if (!thisObject->staticFunctionsReified()) … … 2500 2503 void JSObject::putDirectMayBeIndex(ExecState* exec, PropertyName propertyName, JSValue value) 2501 2504 { 2502 if (Optional<uint32_t> index = propertyName.asIndex()) 2503 putDirectIndex(exec, index.value(), value); 2505 unsigned asIndex = propertyName.asIndex(); 2506 if (asIndex == PropertyName::NotAnIndex) 2507 putDirect(exec->vm(), propertyName, value); 2504 2508 else 2505 putDirect (exec->vm(), propertyName, value);2509 putDirectIndex(exec, asIndex, value); 2506 2510 } 2507 2511 … … 2656 2660 { 2657 2661 // If it's an array index, then use the indexed property storage. 2658 if (Optional<uint32_t> index = propertyName.asIndex()) { 2662 unsigned index = propertyName.asIndex(); 2663 if (index != PropertyName::NotAnIndex) { 2659 2664 // c. Let succeeded be the result of calling the default [[DefineOwnProperty]] internal method (8.12.9) on A passing P, Desc, and false as arguments. 2660 2665 // d. Reject if succeeded is false. … … 2663 2668 // e.ii. Call the default [[DefineOwnProperty]] internal method (8.12.9) on A passing "length", oldLenDesc, and false as arguments. This call will always return true. 2664 2669 // f. Return true. 2665 return object->defineOwnIndexedProperty(exec, index .value(), descriptor, throwException);2670 return object->defineOwnIndexedProperty(exec, index, descriptor, throwException); 2666 2671 } 2667 2672 -
trunk/Source/JavaScriptCore/runtime/JSObject.h
r178894 r178928 1245 1245 if (object->inlineGetOwnPropertySlot(vm, structure, propertyName, slot)) 1246 1246 return true; 1247 if (Optional<uint32_t> index = propertyName.asIndex()) 1248 return getOwnPropertySlotByIndex(object, exec, index.value(), slot); 1247 unsigned index = propertyName.asIndex(); 1248 if (index != PropertyName::NotAnIndex) 1249 return getOwnPropertySlotByIndex(object, exec, index, slot); 1249 1250 return false; 1250 1251 } … … 1274 1275 } 1275 1276 1276 if (Optional<uint32_t> index = propertyName.asIndex()) 1277 return getPropertySlot(exec, index.value(), slot); 1277 unsigned index = propertyName.asIndex(); 1278 if (index != PropertyName::NotAnIndex) 1279 return getPropertySlot(exec, index, slot); 1278 1280 return false; 1279 1281 } … … 1319 1321 ASSERT(value.isGetterSetter() == !!(attributes & Accessor)); 1320 1322 ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this)); 1321 ASSERT( !propertyName.asIndex());1323 ASSERT(propertyName.asIndex() == PropertyName::NotAnIndex); 1322 1324 1323 1325 Structure* structure = this->structure(vm); -
trunk/Source/JavaScriptCore/runtime/JSString.cpp
r178894 r178928 426 426 } 427 427 428 Optional<uint32_t> index = propertyName.asIndex(); 429 if (index && index.value() < m_length) { 430 descriptor.setDescriptor(getIndex(exec, index.value()), DontDelete | ReadOnly); 428 unsigned i = propertyName.asIndex(); 429 if (i < m_length) { 430 ASSERT(i != PropertyName::NotAnIndex); // No need for an explicit check, the above test would always fail! 431 descriptor.setDescriptor(getIndex(exec, i), DontDelete | ReadOnly); 431 432 return true; 432 433 } -
trunk/Source/JavaScriptCore/runtime/JSString.h
r178894 r178928 627 627 } 628 628 629 Optional<uint32_t> index = propertyName.asIndex(); 630 if (index && index.value() < m_length) { 631 slot.setValue(this, DontDelete | ReadOnly, getIndex(exec, index.value())); 629 unsigned i = propertyName.asIndex(); 630 if (i < m_length) { 631 ASSERT(i != PropertyName::NotAnIndex); // No need for an explicit check, the above test would always fail! 632 slot.setValue(this, DontDelete | ReadOnly, getIndex(exec, i)); 632 633 return true; 633 634 } -
trunk/Source/JavaScriptCore/runtime/LiteralParser.cpp
r178894 r178928 650 650 JSObject* object = asObject(objectStack.last()); 651 651 PropertyName ident = identifierStack.last(); 652 if (Optional<uint32_t> index = ident.asIndex()) 653 object->putDirectIndex(m_exec, index.value(), lastValue); 652 unsigned i = ident.asIndex(); 653 if (i != PropertyName::NotAnIndex) 654 object->putDirectIndex(m_exec, i, lastValue); 654 655 else 655 656 object->putDirect(m_exec->vm(), ident, lastValue); -
trunk/Source/JavaScriptCore/runtime/PropertyName.h
r178894 r178928 29 29 #include "Identifier.h" 30 30 #include "PrivateName.h" 31 #include <wtf/Optional.h>32 31 33 32 namespace JSC { 34 33 35 34 template <typename CharType> 36 ALWAYS_INLINE Optional<uint32_t>toUInt32FromCharacters(const CharType* characters, unsigned length)35 ALWAYS_INLINE uint32_t toUInt32FromCharacters(const CharType* characters, unsigned length) 37 36 { 38 37 // An empty string is not a number. 39 38 if (!length) 40 return Nullopt;39 return UINT_MAX; 41 40 42 41 // Get the first character, turning it into a digit. 43 42 uint32_t value = characters[0] - '0'; 44 43 if (value > 9) 45 return Nullopt;44 return UINT_MAX; 46 45 47 46 // Check for leading zeros. If the first characher is 0, then the 48 47 // length of the string must be one - e.g. "042" is not equal to "42". 49 48 if (!value && length > 1) 50 return Nullopt;49 return UINT_MAX; 51 50 52 51 while (--length) { 53 52 // Multiply value by 10, checking for overflow out of 32 bits. 54 53 if (value > 0xFFFFFFFFU / 10) 55 return Nullopt;54 return UINT_MAX; 56 55 value *= 10; 57 56 … … 59 58 uint32_t newValue = *(++characters) - '0'; 60 59 if (newValue > 9) 61 return Nullopt;60 return UINT_MAX; 62 61 63 62 // Add in the old value, checking for overflow out of 32 bits. 64 63 newValue += value; 65 64 if (newValue < value) 66 return Nullopt;65 return UINT_MAX; 67 66 value = newValue; 68 67 } 69 70 if (value == UINT_MAX) 71 return Nullopt; 68 72 69 return value; 73 70 } 74 71 75 ALWAYS_INLINE Optional<uint32_t>toUInt32FromStringImpl(StringImpl* impl)72 ALWAYS_INLINE uint32_t toUInt32FromStringImpl(StringImpl* impl) 76 73 { 77 74 if (impl->is8Bit()) … … 113 110 static const uint32_t NotAnIndex = UINT_MAX; 114 111 115 Optional<uint32_t>asIndex()112 uint32_t asIndex() 116 113 { 117 return m_impl ? toUInt32FromStringImpl(m_impl) : N ullopt;114 return m_impl ? toUInt32FromStringImpl(m_impl) : NotAnIndex; 118 115 } 119 116 120 117 void dump(PrintStream& out) const 121 118 { -
trunk/Source/JavaScriptCore/runtime/PropertyNameArray.cpp
r178894 r178928 34 34 ASSERT(!identifier || identifier == StringImpl::empty() || identifier->isAtomic()); 35 35 if (!ASSERT_DISABLED) { 36 Optional<uint32_t>index = PropertyName(Identifier(m_vm, identifier)).asIndex();37 ASSERT_UNUSED(index, !index || index.value()>= m_previouslyEnumeratedLength);36 uint32_t index = PropertyName(Identifier(m_vm, identifier)).asIndex(); 37 ASSERT_UNUSED(index, index == PropertyName::NotAnIndex || index >= m_previouslyEnumeratedLength); 38 38 } 39 39 -
trunk/Source/JavaScriptCore/runtime/StringObject.cpp
r178894 r178928 129 129 if (propertyName == exec->propertyNames().length) 130 130 return false; 131 Optional<uint32_t> index = propertyName.asIndex(); 132 if (index && thisObject->internalValue()->canGetIndex(index.value())) { 131 unsigned i = propertyName.asIndex(); 132 if (thisObject->internalValue()->canGetIndex(i)) { 133 ASSERT(i != PropertyName::NotAnIndex); // No need for an explicit check, the above test would always fail! 133 134 return false; 134 135 } -
trunk/Source/JavaScriptCore/runtime/Structure.cpp
r178894 r178928 1011 1011 bool Structure::prototypeChainMayInterceptStoreTo(VM& vm, PropertyName propertyName) 1012 1012 { 1013 if (propertyName.asIndex()) 1013 unsigned i = propertyName.asIndex(); 1014 if (i != PropertyName::NotAnIndex) 1014 1015 return anyObjectInChainMayInterceptIndexedAccesses(); 1015 1016
Note:
See TracChangeset
for help on using the changeset viewer.