Branch: refs/heads/main Home: https://github.com/WebKit/WebKit Commit: 4cf7b61be1fa78f8578e5f4262145fd22656fcd8 https://github.com/WebKit/WebKit/commit/4cf7b61be1fa78f8578e5f4262145fd22656fcd8 Author: Chris Dumez <cdu...@apple.com> Date: 2023-03-22 (Wed, 22 Mar 2023)
Changed paths: M Source/WebCore/bindings/scripts/CodeGeneratorJS.pm M Source/WebCore/bindings/scripts/IDLAttributes.json M Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.cpp M Source/WebCore/bindings/scripts/test/JS/JSTestIndexedSetterNoIdentifier.cpp M Source/WebCore/bindings/scripts/test/JS/JSTestIndexedSetterThrowingException.cpp M Source/WebCore/bindings/scripts/test/JS/JSTestIndexedSetterWithIdentifier.cpp M Source/WebCore/bindings/scripts/test/JS/JSTestNamedAndIndexedSetterNoIdentifier.cpp M Source/WebCore/bindings/scripts/test/JS/JSTestNamedAndIndexedSetterThrowingException.cpp M Source/WebCore/bindings/scripts/test/JS/JSTestNamedAndIndexedSetterWithIdentifier.cpp M Source/WebCore/bindings/scripts/test/JS/JSTestNamedDeleterWithIndexedGetter.cpp M Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithIndexedGetter.cpp M Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithIndexedGetterAndSetter.cpp M Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp M Source/WebCore/css/typedom/CSSUnparsedValue.cpp M Source/WebCore/css/typedom/CSSUnparsedValue.h M Source/WebCore/css/typedom/CSSUnparsedValue.idl M Source/WebCore/css/typedom/numeric/CSSNumericArray.cpp M Source/WebCore/css/typedom/numeric/CSSNumericArray.h M Source/WebCore/css/typedom/transform/CSSTransformValue.cpp M Source/WebCore/css/typedom/transform/CSSTransformValue.h M Source/WebCore/svg/SVGLengthList.idl M Source/WebCore/svg/SVGNumberList.idl M Source/WebCore/svg/SVGPathSegList.idl M Source/WebCore/svg/SVGPointList.idl M Source/WebCore/svg/SVGStringList.idl M Source/WebCore/svg/SVGTransformList.idl Log Message: ----------- Speed up JSNodeList indexing https://bugs.webkit.org/show_bug.cgi?id=254190 Reviewed by Ryosuke Niwa. Speed up JSNodeList indexing by generating more efficient JS bindings code. The generated bindings code looked like: ``` if (index < list->length()) return toJS(list->item(index)); ``` This was a bit inefficient in the common case since `item()` would repeat the bounds check and return null when out of bounds. It was even more unfortunate for NodeList since both `length()` and `item()` are virtual. As a result, I updated the bindings generator to generate: ``` if (auto item = list->item(index); LIKELY(!!item)) return toJS(WTFMove(item)); ``` This avoids the duplicates out-of-bounds checks and results in a single virtual function call for JSNodeList instead of 2. Only a few SVG list types still use the old logic since they may throw in some cases, as per the specification. This is very unusual but supported via a new [RaisesException] in the IDL. Some other types had logic that would throw an exception when out of bounds but this logic could never be triggered because the JS bindings were already doing a bounds check before calling `item()`. I updated those types to return null instead. * Source/WebCore/bindings/scripts/CodeGeneratorJS.pm: (GenerateIndexedGetter): (GenerateGetOwnPropertySlot): (GenerateGetOwnPropertySlotByIndex): * Source/WebCore/bindings/scripts/IDLAttributes.json: * Source/WebCore/css/typedom/CSSUnparsedValue.cpp: (WebCore::CSSUnparsedValue::item): * Source/WebCore/css/typedom/CSSUnparsedValue.h: * Source/WebCore/css/typedom/CSSUnparsedValue.idl: * Source/WebCore/css/typedom/numeric/CSSNumericArray.cpp: (WebCore::CSSNumericArray::item): * Source/WebCore/css/typedom/numeric/CSSNumericArray.h: * Source/WebCore/css/typedom/transform/CSSTransformValue.cpp: (WebCore::CSSTransformValue::item): * Source/WebCore/css/typedom/transform/CSSTransformValue.h: * Source/WebCore/svg/SVGLengthList.idl: * Source/WebCore/svg/SVGNumberList.idl: * Source/WebCore/svg/SVGPathSegList.idl: * Source/WebCore/svg/SVGPointList.idl: * Source/WebCore/svg/SVGStringList.idl: * Source/WebCore/svg/SVGTransformList.idl: Canonical link: https://commits.webkit.org/261988@main _______________________________________________ webkit-changes mailing list webkit-changes@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-changes