Changeset 178928 in webkit for trunk/Source/JavaScriptCore


Ignore:
Timestamp:
Jan 22, 2015, 11:34:34 AM (10 years ago)
Author:
[email protected]
Message:

Unreviewed, rolling out r178894.
https://bugs.webkit.org/show_bug.cgi?id=140775

Broke JSC and bindings tests (Requested by ap_ on #webkit).

Reverted changeset:

"put_by_val_direct need to check the property is index or not
for using putDirect / putDirectIndex"
https://bugs.webkit.org/show_bug.cgi?id=140426
http://trac.webkit.org/changeset/178894

Location:
trunk/Source/JavaScriptCore
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r178926 r178928  
     12015-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
    1152015-01-22  Mark Lam  <[email protected]>
    216
  • trunk/Source/JavaScriptCore/bytecode/GetByIdStatus.cpp

    r178894 r178928  
    271271        return GetByIdStatus();
    272272
    273     if (toUInt32FromStringImpl(uid))
     273    if (toUInt32FromStringImpl(uid) != PropertyName::NotAnIndex)
    274274        return GetByIdStatus(TakesSlowPath);
    275275   
  • trunk/Source/JavaScriptCore/bytecode/PutByIdStatus.cpp

    r178894 r178928  
    311311PutByIdStatus PutByIdStatus::computeFor(JSGlobalObject* globalObject, const StructureSet& set, AtomicStringImpl* uid, bool isDirect)
    312312{
    313     if (toUInt32FromStringImpl(uid))
     313    if (toUInt32FromStringImpl(uid) != PropertyName::NotAnIndex)
    314314        return PutByIdStatus(TakesSlowPath);
    315315
  • trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp

    r178926 r178928  
    15021502    instructions().append(0);
    15031503    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);
    15051507    return value;
    15061508}
  • trunk/Source/JavaScriptCore/dfg/DFGOperations.cpp

    r178894 r178928  
    9898
    9999    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);
    103101        return;
    104102    }
     
    107105        double propertyAsDouble = property.asDouble();
    108106        uint32_t propertyAsUInt32 = static_cast<uint32_t>(propertyAsDouble);
    109         if (propertyAsDouble == propertyAsUInt32 && propertyAsUInt32 != PropertyName::NotAnIndex) {
     107        if (propertyAsDouble == propertyAsUInt32) {
    110108            putByVal<strict, direct>(exec, baseValue, propertyAsUInt32, value);
    111109            return;
     
    125123    // Don't put to an object if toString throws an exception.
    126124    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    }
    140133}
    141134
  • trunk/Source/JavaScriptCore/jit/JITOperations.cpp

    r178894 r178928  
    5252#include "LegacyProfiler.h"
    5353#include "ObjectConstructor.h"
    54 #include "PropertyName.h"
    5554#include "Repatch.h"
    5655#include "RepatchBuffer.h"
     
    482481static void directPutByVal(CallFrame* callFrame, JSObject* baseObject, JSValue subscript, JSValue value)
    483482{
    484     bool isStrictMode = callFrame->codeBlock()->isStrictMode();
    485483    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());
    503488        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        }
    518495    }
    519496}
  • trunk/Source/JavaScriptCore/jit/Repatch.cpp

    r178894 r178928  
    983983    PropertyName pname(ident);
    984984    Structure* oldStructure = structure;
    985     if (!oldStructure->isObject() || oldStructure->isDictionary() || pname.asIndex())
     985    if (!oldStructure->isObject() || oldStructure->isDictionary() || pname.asIndex() != PropertyName::NotAnIndex)
    986986        return nullptr;
    987987
  • trunk/Source/JavaScriptCore/jsc.cpp

    r178894 r178928  
    335335        }
    336336
    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]));
    340341            return true;
    341342        }
  • trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp

    r178894 r178928  
    820820    RELEASE_ASSERT(baseValue.isObject());
    821821    JSObject* baseObject = asObject(baseValue);
    822     bool isStrictMode = exec->codeBlock()->isStrictMode();
    823822    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);
    837833        }
    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);
    857834    }
    858835    LLINT_END();
  • trunk/Source/JavaScriptCore/runtime/Arguments.cpp

    r178894 r178928  
    162162{
    163163    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;
    169169    }
    170170
     
    225225{
    226226    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))
    229229        return;
    230230
     
    268268
    269269    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);
    272273        if (!Base::deleteProperty(cell, exec, propertyName))
    273274            return false;
    274         if (thisObject->tryDeleteArgument(exec->vm(), index.value()))
     275        if (thisObject->tryDeleteArgument(exec->vm(), i))
    275276            return true;
    276277    }
     
    298299{
    299300    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);
    302304        // 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();
    304305        PropertySlot slot(thisObject);
    305         if (!thisObject->isDeletedArgument(index) && !JSObject::getOwnPropertySlot(thisObject, exec, propertyName, slot)) {
    306             JSValue value = thisObject->tryGetArgument(index);
     306        if (!thisObject->isDeletedArgument(i) && !JSObject::getOwnPropertySlot(thisObject, exec, propertyName, slot)) {
     307            JSValue value = thisObject->tryGetArgument(i);
    307308            ASSERT(value);
    308309            object->putDirectMayBeIndex(exec, propertyName, value);
     
    313314        // From ES 5.1, 10.6 Arguments Object
    314315        // 5. If the value of isMapped is not undefined, then
    315         if (thisObject->isArgument(index)) {
     316        if (thisObject->isArgument(i)) {
    316317            // a. If IsAccessorDescriptor(Desc) is true, then
    317318            if (descriptor.isAccessorDescriptor()) {
    318319                // i. Call the [[Delete]] internal method of map passing P, and false as the arguments.
    319                 thisObject->tryDeleteArgument(exec->vm(), index);
     320                thisObject->tryDeleteArgument(exec->vm(), i);
    320321            } else { // b. Else
    321322                // i. If Desc.[[Value]] is present, then
    322323                // 1. Call the [[Put]] internal method of map passing P, Desc.[[Value]], and Throw as the arguments.
    323324                if (descriptor.value())
    324                     thisObject->trySetArgument(exec->vm(), index, descriptor.value());
     325                    thisObject->trySetArgument(exec->vm(), i, descriptor.value());
    325326                // ii. If Desc.[[Writable]] is present and its value is false, then
    326327                // 1. Call the [[Delete]] internal method of map passing P and false as arguments.
    327328                if (descriptor.writablePresent() && !descriptor.writable())
    328                     thisObject->tryDeleteArgument(exec->vm(), index);
     329                    thisObject->tryDeleteArgument(exec->vm(), i);
    329330            }
    330331        }
  • trunk/Source/JavaScriptCore/runtime/ArrayPrototype.cpp

    r178894 r178928  
    743743    for (size_t i = 0; i < nameArray.size(); ++i) {
    744744        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)
    747747            continue;
    748 
    749         uint32_t index = optionalIndex.value();
     748       
    750749        JSValue value = getOrHole(thisObj, exec, index);
    751750        if (exec->hadException())
  • trunk/Source/JavaScriptCore/runtime/JSArray.cpp

    r178894 r178928  
    159159    // 4. Else if P is an array index (15.4), then
    160160    // a. Let index be ToUint32(P).
    161     if (Optional<uint32_t> optionalIndex = propertyName.asIndex()) {
     161    unsigned index = propertyName.asIndex();
     162    if (index != PropertyName::NotAnIndex) {
    162163        // b. Reject if index >= oldLen and oldLenDesc.[[Writable]] is false.
    163         uint32_t index = optionalIndex.value();
    164164        if (index >= array->length() && !array->isLengthWritable())
    165165            return reject(exec, throwException, "Attempting to define numeric property on array with non-writable length property.");
  • trunk/Source/JavaScriptCore/runtime/JSCJSValue.cpp

    r178894 r178928  
    120120    VM& vm = exec->vm();
    121121
    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());
    124125        return;
    125126    }
  • trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewInlines.h

    r178894 r178928  
    303303    }
    304304   
    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));
    308308        return true;
    309309    }
     
    325325    }
    326326   
    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());
    329330        return;
    330331    }
     
    343344    // defineOwnProperty for indexed properties on typed arrays, even if they're out
    344345    // of bounds.
    345     if (propertyName == exec->propertyNames().length || propertyName.asIndex())
     346    if (propertyName == exec->propertyNames().length
     347        || propertyName.asIndex() != PropertyName::NotAnIndex)
    346348        return reject(exec, shouldThrow, "Attempting to write to a read-only typed array property.");
    347349   
     
    355357    JSGenericTypedArrayView* thisObject = jsCast<JSGenericTypedArrayView*>(cell);
    356358   
    357     if (propertyName == exec->propertyNames().length || propertyName.asIndex())
     359    if (propertyName == exec->propertyNames().length
     360        || propertyName.asIndex() != PropertyName::NotAnIndex)
    358361        return false;
    359362   
  • trunk/Source/JavaScriptCore/runtime/JSObject.cpp

    r178894 r178928  
    340340    // Try indexed put first. This is required for correctness, since loads on property names that appear like
    341341    // 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());
    344345        return;
    345346    }
     
    11981199    ASSERT(value.isGetterSetter() && (attributes & Accessor));
    11991200
    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);
    12021204        return;
    12031205    }
     
    12081210void JSObject::putDirectCustomAccessor(VM& vm, PropertyName propertyName, JSValue value, unsigned attributes)
    12091211{
    1210     ASSERT(!propertyName.asIndex());
     1212    ASSERT(propertyName.asIndex() == PropertyName::NotAnIndex);
    12111213
    12121214    PutPropertySlot slot(this);
     
    12561258    JSObject* thisObject = jsCast<JSObject*>(cell);
    12571259   
    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);
    12601263
    12611264    if (!thisObject->staticFunctionsReified())
     
    25002503void JSObject::putDirectMayBeIndex(ExecState* exec, PropertyName propertyName, JSValue value)
    25012504{
    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);
    25042508    else
    2505         putDirect(exec->vm(), propertyName, value);
     2509        putDirectIndex(exec, asIndex, value);
    25062510}
    25072511
     
    26562660{
    26572661    // 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) {
    26592664        // 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.
    26602665        // d. Reject if succeeded is false.
     
    26632668        // 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.
    26642669        // f. Return true.
    2665         return object->defineOwnIndexedProperty(exec, index.value(), descriptor, throwException);
     2670        return object->defineOwnIndexedProperty(exec, index, descriptor, throwException);
    26662671    }
    26672672   
  • trunk/Source/JavaScriptCore/runtime/JSObject.h

    r178894 r178928  
    12451245    if (object->inlineGetOwnPropertySlot(vm, structure, propertyName, slot))
    12461246        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);
    12491250    return false;
    12501251}
     
    12741275    }
    12751276
    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);
    12781280    return false;
    12791281}
     
    13191321    ASSERT(value.isGetterSetter() == !!(attributes & Accessor));
    13201322    ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this));
    1321     ASSERT(!propertyName.asIndex());
     1323    ASSERT(propertyName.asIndex() == PropertyName::NotAnIndex);
    13221324
    13231325    Structure* structure = this->structure(vm);
  • trunk/Source/JavaScriptCore/runtime/JSString.cpp

    r178894 r178928  
    426426    }
    427427   
    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);
    431432        return true;
    432433    }
  • trunk/Source/JavaScriptCore/runtime/JSString.h

    r178894 r178928  
    627627    }
    628628
    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));
    632633        return true;
    633634    }
  • trunk/Source/JavaScriptCore/runtime/LiteralParser.cpp

    r178894 r178928  
    650650                JSObject* object = asObject(objectStack.last());
    651651                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);
    654655                else
    655656                    object->putDirect(m_exec->vm(), ident, lastValue);
  • trunk/Source/JavaScriptCore/runtime/PropertyName.h

    r178894 r178928  
    2929#include "Identifier.h"
    3030#include "PrivateName.h"
    31 #include <wtf/Optional.h>
    3231
    3332namespace JSC {
    3433
    3534template <typename CharType>
    36 ALWAYS_INLINE Optional<uint32_t> toUInt32FromCharacters(const CharType* characters, unsigned length)
     35ALWAYS_INLINE uint32_t toUInt32FromCharacters(const CharType* characters, unsigned length)
    3736{
    3837    // An empty string is not a number.
    3938    if (!length)
    40         return Nullopt;
     39        return UINT_MAX;
    4140
    4241    // Get the first character, turning it into a digit.
    4342    uint32_t value = characters[0] - '0';
    4443    if (value > 9)
    45         return Nullopt;
     44        return UINT_MAX;
    4645   
    4746    // Check for leading zeros. If the first characher is 0, then the
    4847    // length of the string must be one - e.g. "042" is not equal to "42".
    4948    if (!value && length > 1)
    50         return Nullopt;
     49        return UINT_MAX;
    5150   
    5251    while (--length) {
    5352        // Multiply value by 10, checking for overflow out of 32 bits.
    5453        if (value > 0xFFFFFFFFU / 10)
    55             return Nullopt;
     54            return UINT_MAX;
    5655        value *= 10;
    5756       
     
    5958        uint32_t newValue = *(++characters) - '0';
    6059        if (newValue > 9)
    61             return Nullopt;
     60            return UINT_MAX;
    6261       
    6362        // Add in the old value, checking for overflow out of 32 bits.
    6463        newValue += value;
    6564        if (newValue < value)
    66             return Nullopt;
     65            return UINT_MAX;
    6766        value = newValue;
    6867    }
    69 
    70     if (value == UINT_MAX)
    71         return Nullopt;
     68   
    7269    return value;
    7370}
    7471
    75 ALWAYS_INLINE Optional<uint32_t> toUInt32FromStringImpl(StringImpl* impl)
     72ALWAYS_INLINE uint32_t toUInt32FromStringImpl(StringImpl* impl)
    7673{
    7774    if (impl->is8Bit())
     
    113110    static const uint32_t NotAnIndex = UINT_MAX;
    114111
    115     Optional<uint32_t> asIndex()
     112    uint32_t asIndex()
    116113    {
    117         return m_impl ? toUInt32FromStringImpl(m_impl) : Nullopt;
     114        return m_impl ? toUInt32FromStringImpl(m_impl) : NotAnIndex;
    118115    }
    119 
     116   
    120117    void dump(PrintStream& out) const
    121118    {
  • trunk/Source/JavaScriptCore/runtime/PropertyNameArray.cpp

    r178894 r178928  
    3434    ASSERT(!identifier || identifier == StringImpl::empty() || identifier->isAtomic());
    3535    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);
    3838    }
    3939
  • trunk/Source/JavaScriptCore/runtime/StringObject.cpp

    r178894 r178928  
    129129    if (propertyName == exec->propertyNames().length)
    130130        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!
    133134        return false;
    134135    }
  • trunk/Source/JavaScriptCore/runtime/Structure.cpp

    r178894 r178928  
    10111011bool Structure::prototypeChainMayInterceptStoreTo(VM& vm, PropertyName propertyName)
    10121012{
    1013     if (propertyName.asIndex())
     1013    unsigned i = propertyName.asIndex();
     1014    if (i != PropertyName::NotAnIndex)
    10141015        return anyObjectInChainMayInterceptIndexedAccesses();
    10151016   
Note: See TracChangeset for help on using the changeset viewer.