Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Upstream TypedArray.prototype.fill speedup from bun
https://bugs.webkit.org/show_bug.cgi?id=239891 Reviewed by Saam Barati. This patch imports bun's improvement in TypedArray#fill[1], bun is MIT licensed. We use memset and its variant to fill TypedArray if possible. Microbenchmarks show 5x improvement. ToT Patched typed-array-fill 1092.0348+-6.2496 ^ 221.3430+-9.1261 ^ definitely 4.9337x faster [1]: Jarred-Sumner@b06577c * JSTests/microbenchmarks/typed-array-fill.js: Added. * JSTests/stress/typed-array-fill-complicated.js: Added. (shouldBe): (throw.new.Error): * Source/JavaScriptCore/runtime/JSGenericTypedArrayViewPrototypeFunctions.h: (JSC::speciesConstruct): (JSC::genericTypedArrayViewProtoFuncCopyWithin): (JSC::genericTypedArrayViewProtoFuncIncludes): (JSC::genericTypedArrayViewProtoFuncIndexOf): (JSC::genericTypedArrayViewProtoFuncJoin): (JSC::genericTypedArrayViewProtoFuncFill): (JSC::genericTypedArrayViewProtoFuncLastIndexOf): (JSC::genericTypedArrayViewProtoFuncReverse): (JSC::genericTypedArrayViewPrivateFuncSort): (JSC::genericTypedArrayViewProtoFuncSlice): (JSC::genericTypedArrayViewPrivateFuncSubarrayCreate): Canonical link: https://commits.webkit.org/250455@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294047 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
with
154 additions
and 23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,11 @@ | ||
var a1 = new Uint8Array(1024 * 1024 * 1); | ||
var a2 = new Uint16Array(1024 * 1024 * 1); | ||
var a3 = new Uint32Array(1024 * 1024 * 1); | ||
var a4 = new Float64Array(1024 * 1024 * 1); | ||
|
||
for (var i = 0; i < 3e2; ++i) { | ||
a1.fill(99); | ||
a2.fill(99); | ||
a3.fill(99); | ||
a4.fill(99); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,22 @@ | ||
function shouldBe(actual, expected) { | ||
if (actual !== expected) | ||
throw new Error('bad value: ' + actual); | ||
} | ||
|
||
{ | ||
let a0 = new Uint8Array(100); | ||
shouldBe(a0[3], 0); | ||
shouldBe(a0[4], 0); | ||
a0.fill(42, 3, 4); | ||
shouldBe(a0[3], 42); | ||
shouldBe(a0[4], 0); | ||
} | ||
{ | ||
let a0 = new Uint8Array(4); | ||
shouldBe(a0[0], 0); | ||
a0.fill(42, 0, 0); | ||
shouldBe(a0[0], 0); | ||
a0.fill(42, 3, 0); | ||
for (let i = 0; i < 4; ++i) | ||
shouldBe(a0[i], 0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters