Branch: refs/heads/main Home: https://github.com/WebKit/WebKit Commit: 7b9df2f4b1a9e2f12cf4feceb0870e44ab8efed6 https://github.com/WebKit/WebKit/commit/7b9df2f4b1a9e2f12cf4feceb0870e44ab8efed6 Author: Sosuke Suzuki <aosuk...@gmail.com> Date: 2025-08-01 (Fri, 01 Aug 2025)
Changed paths: A JSTests/microbenchmarks/array-prototype-flat-depth-1-double.js A JSTests/microbenchmarks/array-prototype-flat-depth-1-int32.js A JSTests/microbenchmarks/array-prototype-flat-depth-1-mixed.js A JSTests/microbenchmarks/array-prototype-flat-depth-1-string.js A JSTests/microbenchmarks/array-prototype-flat-depth-2.js A JSTests/microbenchmarks/array-prototype-flat-depth-3.js A JSTests/microbenchmarks/array-prototype-flat-depth-infinity.js A JSTests/microbenchmarks/array-prototype-flat-huge-arrays.js A JSTests/microbenchmarks/array-prototype-flat-large-nested.js A JSTests/microbenchmarks/array-prototype-flat-small-arrays.js A JSTests/microbenchmarks/array-prototype-flat-sparse-array.js A JSTests/stress/array-prototype-flat-hole.js A JSTests/stress/array-prototype-flat-nested-proxy-array.js M Source/JavaScriptCore/builtins/ArrayPrototype.js M Source/JavaScriptCore/runtime/ArrayPrototype.cpp M Source/JavaScriptCore/runtime/CommonIdentifiers.h M Source/JavaScriptCore/runtime/JSArray.cpp M Source/JavaScriptCore/runtime/JSArray.h Log Message: ----------- [JSC] Implement `Array.prototype.flat` in C++ https://bugs.webkit.org/show_bug.cgi?id=294503 Reviewed by Yusuke Suzuki. This patch implements `Array.prototype.flat` in C++. The new fast path for `Array#flat` first calculates the length of the resulting array using O(n) `calculateFlattenedLength`, then directly sets values into the butterfly buffer of the resulting array using O(n) `fastFlatIntoBuffer`. TipOfTree Patched array-prototype-flat-depth-1-string 395.8826+-4.5561 ^ 147.9479+-3.7062 ^ definitely 2.6758x faster array-prototype-flat-large-nested 111.9910+-4.9277 ^ 30.5805+-0.2314 ^ definitely 3.6622x faster array-prototype-flat-sparse-array 198.6802+-2.0652 ^ 133.4569+-3.7686 ^ definitely 1.4887x faster array-prototype-flat-small-arrays 9.0792+-0.4023 ^ 4.8345+-0.1067 ^ definitely 1.8780x faster array-prototype-flat-depth-1-double 600.7011+-40.1338 ^ 105.1259+-1.4612 ^ definitely 5.7141x faster array-prototype-flat-depth-1-int32 447.6045+-6.5491 ^ 106.2142+-7.6386 ^ definitely 4.2142x faster array-prototype-flat-depth-infinity 524.9275+-4.1636 ^ 141.2842+-5.6371 ^ definitely 3.7154x faster array-prototype-flat-depth-2 522.6723+-2.1402 ^ 118.4029+-5.5013 ^ definitely 4.4144x faster array-prototype-flat-huge-arrays 43.4337+-3.9484 ^ 10.1096+-0.1294 ^ definitely 4.2963x faster array-prototype-flat-depth-1-mixed 450.7441+-18.1260 ^ 136.2629+-0.7525 ^ definitely 3.3079x faster array-prototype-flat-depth-3 526.4249+-2.3837 ^ 124.7195+-4.6807 ^ definitely 4.2209x faster * JSTests/microbenchmarks/array-prototype-flat-depth-1-double.js: Added. (shouldBe): * JSTests/microbenchmarks/array-prototype-flat-depth-1-int32.js: Added. (shouldBe): * JSTests/microbenchmarks/array-prototype-flat-depth-1-mixed.js: Added. (shouldBe): * JSTests/microbenchmarks/array-prototype-flat-depth-1-string.js: Added. (shouldBe): * JSTests/microbenchmarks/array-prototype-flat-depth-2.js: Added. (shouldBe): * JSTests/microbenchmarks/array-prototype-flat-depth-3.js: Added. (shouldBe): * JSTests/microbenchmarks/array-prototype-flat-depth-infinity.js: Added. (shouldBe): * JSTests/microbenchmarks/array-prototype-flat-huge-arrays.js: Added. (shouldBe): * JSTests/microbenchmarks/array-prototype-flat-large-nested.js: Added. (shouldBe): (createLargeNestedArray): * JSTests/microbenchmarks/array-prototype-flat-small-arrays.js: Added. (shouldBe): * JSTests/microbenchmarks/array-prototype-flat-sparse-array.js: Added. (shouldBe): * JSTests/stress/array-prototype-flat-hole.js: Added. (shouldBe): * JSTests/stress/array-prototype-flat-nested-proxy-array.js: Added. (shouldBe): (const.handler.has): * Source/JavaScriptCore/builtins/ArrayPrototype.js: (flat): Deleted. * Source/JavaScriptCore/runtime/ArrayPrototype.cpp: (JSC::ArrayPrototype::finishCreation): (JSC::flatIntoArray): (JSC::JSC_DEFINE_HOST_FUNCTION): * Source/JavaScriptCore/runtime/CommonIdentifiers.h: * Source/JavaScriptCore/runtime/JSArray.cpp: (JSC::calculateFlattenedLength): (JSC::fastFlatIntoBuffer): (JSC::JSArray::fastFlat): * Source/JavaScriptCore/runtime/JSArray.h: Canonical link: https://commits.webkit.org/298127@main To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications _______________________________________________ webkit-changes mailing list webkit-changes@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-changes