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/PropertyNameArray.cpp

    r182205 r182406  
    3434    ASSERT(!identifier || (identifier == StringImpl::empty() || identifier->isAtomic() || identifier->isSymbol()));
    3535    if (!ASSERT_DISABLED) {
    36         uint32_t index = PropertyName(Identifier::fromUid(m_vm, identifier)).asIndex();
    37         ASSERT_UNUSED(index, index == PropertyName::NotAnIndex || index >= m_previouslyEnumeratedLength);
     36        Optional<uint32_t> index = parseIndex(Identifier::fromUid(m_vm, identifier));
     37        ASSERT_UNUSED(index, !index || index.value() >= m_previouslyEnumeratedLength);
    3838    }
    3939
Note: See TracChangeset for help on using the changeset viewer.