Ignore:
Timestamp:
Apr 6, 2015, 5:40:33 AM (10 years ago)
Author:
Yusuke Suzuki
Message:

Return Optional<uint32_t> from PropertyName::asIndex
https://bugs.webkit.org/show_bug.cgi?id=143422

Reviewed by Darin Adler.

Source/JavaScriptCore:

PropertyName::asIndex returns uint32_t and use UINT_MAX as NotAnIndex.
But it's not obvious to callers.

This patch changes

  1. PropertyName::asIndex() to return Optional<uint32_t> and
  2. function name asIndex() to parseIndex().

It forces callers to check the value is index or not explicitly.

  • bytecode/GetByIdStatus.cpp:

(JSC::GetByIdStatus::computeFor):

  • bytecode/PutByIdStatus.cpp:

(JSC::PutByIdStatus::computeFor):

  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::emitDirectPutById):

  • jit/Repatch.cpp:

(JSC::emitPutTransitionStubAndGetOldStructure):

  • jsc.cpp:
  • runtime/ArrayPrototype.cpp:

(JSC::arrayProtoFuncSort):

  • runtime/GenericArgumentsInlines.h:

(JSC::GenericArguments<Type>::getOwnPropertySlot):
(JSC::GenericArguments<Type>::put):
(JSC::GenericArguments<Type>::deleteProperty):
(JSC::GenericArguments<Type>::defineOwnProperty):

  • runtime/Identifier.h:

(JSC::parseIndex):
(JSC::Identifier::isSymbol):

  • runtime/JSArray.cpp:

(JSC::JSArray::defineOwnProperty):

  • runtime/JSCJSValue.cpp:

(JSC::JSValue::putToPrimitive):

  • runtime/JSGenericTypedArrayViewInlines.h:

(JSC::JSGenericTypedArrayView<Adaptor>::getOwnPropertySlot):
(JSC::JSGenericTypedArrayView<Adaptor>::put):
(JSC::JSGenericTypedArrayView<Adaptor>::defineOwnProperty):
(JSC::JSGenericTypedArrayView<Adaptor>::deleteProperty):

  • runtime/JSObject.cpp:

(JSC::JSObject::put):
(JSC::JSObject::putDirectAccessor):
(JSC::JSObject::putDirectCustomAccessor):
(JSC::JSObject::deleteProperty):
(JSC::JSObject::putDirectMayBeIndex):
(JSC::JSObject::defineOwnProperty):

  • runtime/JSObject.h:

(JSC::JSObject::getOwnPropertySlot):
(JSC::JSObject::getPropertySlot):
(JSC::JSObject::putDirectInternal):

  • runtime/JSString.cpp:

(JSC::JSString::getStringPropertyDescriptor):

  • runtime/JSString.h:

(JSC::JSString::getStringPropertySlot):

  • runtime/LiteralParser.cpp:

(JSC::LiteralParser<CharType>::parse):

  • runtime/PropertyName.h:

(JSC::parseIndex):
(JSC::toUInt32FromCharacters): Deleted.
(JSC::toUInt32FromStringImpl): Deleted.
(JSC::PropertyName::asIndex): Deleted.

  • runtime/PropertyNameArray.cpp:

(JSC::PropertyNameArray::add):

  • runtime/StringObject.cpp:

(JSC::StringObject::deleteProperty):

  • runtime/Structure.cpp:

(JSC::Structure::prototypeChainMayInterceptStoreTo):

Source/WebCore:

  • bindings/js/JSDOMWindowCustom.cpp:

(WebCore::JSDOMWindow::getOwnPropertySlot):
(WebCore::JSDOMWindow::getOwnPropertySlotByIndex):

  • bindings/js/JSHTMLAllCollectionCustom.cpp:

(WebCore::callHTMLAllCollection):
(WebCore::JSHTMLAllCollection::item):

  • bindings/scripts/CodeGeneratorJS.pm:

(GenerateGetOwnPropertySlotBody):
(GenerateImplementation):

  • bindings/scripts/test/JS/JSFloat64Array.cpp:

(WebCore::JSFloat64Array::getOwnPropertySlot):
(WebCore::JSFloat64Array::getOwnPropertyDescriptor):
(WebCore::JSFloat64Array::put):

  • bindings/scripts/test/JS/JSTestEventTarget.cpp:

(WebCore::JSTestEventTarget::getOwnPropertySlot):

  • bridge/runtime_array.cpp:

(JSC::RuntimeArray::getOwnPropertySlot):
(JSC::RuntimeArray::put):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/JSObject.h

    r182205 r182406  
    12471247    if (object->inlineGetOwnPropertySlot(vm, structure, propertyName, slot))
    12481248        return true;
    1249     unsigned index = propertyName.asIndex();
    1250     if (index != PropertyName::NotAnIndex)
    1251         return getOwnPropertySlotByIndex(object, exec, index, slot);
     1249    if (Optional<uint32_t> index = parseIndex(propertyName))
     1250        return getOwnPropertySlotByIndex(object, exec, index.value(), slot);
    12521251    return false;
    12531252}
     
    12771276    }
    12781277
    1279     unsigned index = propertyName.asIndex();
    1280     if (index != PropertyName::NotAnIndex)
    1281         return getPropertySlot(exec, index, slot);
     1278    if (Optional<uint32_t> index = parseIndex(propertyName))
     1279        return getPropertySlot(exec, index.value(), slot);
    12821280    return false;
    12831281}
     
    13231321    ASSERT(value.isGetterSetter() == !!(attributes & Accessor));
    13241322    ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this));
    1325     ASSERT(propertyName.asIndex() == PropertyName::NotAnIndex);
     1323    ASSERT(!parseIndex(propertyName));
    13261324
    13271325    Structure* structure = this->structure(vm);
Note: See TracChangeset for help on using the changeset viewer.