Repository navigation
Commit 37aa2b5
committed
[JSC] Avoid using wrapper iterator in builtins
https://bugs.webkit.org/show_bug.cgi?id=328563
rdar://190769590
Reviewed by Sosuke Suzuki.
Since for-of calls @@iterator unconditionally, we end up having iterator
wrappers in builtins to align to the spec behavior. But this does not
help at all in terms of the performance since for-of protocol is
tailored for the normal use cases. This patch just uses
@iteratorGenericNext, @ifAbruptCloseIterator, and @iteratorGenericClose
instead.
ToT Patched
array-from-iterable-typed-array 38.3254+-0.3136 ^ 33.4306+-0.2911 ^ definitely 1.1464x faster
array-from-iterable-arguments-with-mapfn 16.8144+-0.0560 ^ 12.2938+-0.1566 ^ definitely 1.3677x faster
array-from-iterable-string 13.2912+-0.1097 ^ 10.2982+-0.1468 ^ definitely 1.2906x faster
array-from-iterable-generator 22.6355+-0.2494 ^ 20.5139+-0.2091 ^ definitely 1.1034x faster
array-from-iterable-generator-with-mapfn 21.7771+-0.4297 ^ 15.9977+-0.3165 ^ definitely 1.3613x faster
array-from-iterable-custom-iterator-with-mapfn
17.9004+-0.1186 ^ 13.7685+-0.0657 ^ definitely 1.3001x faster
array-from-iterable-map-with-mapfn 22.8844+-0.1926 ^ 17.0909+-0.0785 ^ definitely 1.3390x faster
array-from-iterable-typed-array-with-mapfn
35.9297+-0.1972 ^ 32.1489+-0.2680 ^ definitely 1.1176x faster
array-from-iterable-string-with-mapfn 11.7597+-0.1257 ^ 8.8638+-0.1340 ^ definitely 1.3267x faster
array-from-iterable-map 22.9383+-0.1265 ^ 17.9592+-0.1083 ^ definitely 1.2772x faster
array-from-iterable-set-with-mapfn 14.8254+-0.1530 ^ 9.4993+-0.0998 ^ definitely 1.5607x faster
array-from-iterable-custom-iterator 18.6419+-0.1618 ^ 14.7639+-0.0369 ^ definitely 1.2627x faster
array-from-iterable-array-with-mapfn 13.6173+-0.0928 ^ 8.4895+-0.1468 ^ definitely 1.6040x faster
Tests: JSTests/microbenchmarks/array-from-iterable-arguments-with-mapfn.js
JSTests/microbenchmarks/array-from-iterable-array-with-mapfn.js
JSTests/microbenchmarks/array-from-iterable-custom-iterator-with-mapfn.js
JSTests/microbenchmarks/array-from-iterable-custom-iterator.js
JSTests/microbenchmarks/array-from-iterable-generator-with-mapfn.js
JSTests/microbenchmarks/array-from-iterable-generator.js
JSTests/microbenchmarks/array-from-iterable-map-with-mapfn.js
JSTests/microbenchmarks/array-from-iterable-map.js
JSTests/microbenchmarks/array-from-iterable-set-with-mapfn.js
JSTests/microbenchmarks/array-from-iterable-string-with-mapfn.js
JSTests/microbenchmarks/array-from-iterable-string.js
JSTests/microbenchmarks/array-from-iterable-typed-array-with-mapfn.js
JSTests/microbenchmarks/array-from-iterable-typed-array.js
JSTests/stress/array-from-iterable-closes-iterator-and-reads-iterator-once.js
JSTests/stress/builtin-iteration-closes-iterator-and-reads-iterator-once.js
JSTests/stress/iterator-helpers-flatmap-close-iterator-on-throw.js
JSTests/stress/iterator-helpers-flatmap-close-iterator.js
JSTests/stress/iterator-helpers-some-every-find-close-iterator.js
* JSTests/microbenchmarks/array-from-iterable-arguments-with-mapfn.js: Added.
(makeArguments):
(test):
* JSTests/microbenchmarks/array-from-iterable-array-with-mapfn.js: Added.
(test):
* JSTests/microbenchmarks/array-from-iterable-custom-iterator-with-mapfn.js: Added.
(CustomIterator):
(CustomIterator.prototype.next):
(items.Symbol.iterator):
(test):
* JSTests/microbenchmarks/array-from-iterable-custom-iterator.js: Added.
(CustomIterator):
(CustomIterator.prototype.next):
(items.Symbol.iterator):
(test):
* JSTests/microbenchmarks/array-from-iterable-generator-with-mapfn.js: Added.
(items):
(test):
* JSTests/microbenchmarks/array-from-iterable-generator.js: Added.
(items):
(test):
* JSTests/microbenchmarks/array-from-iterable-map-with-mapfn.js: Added.
(test):
* JSTests/microbenchmarks/array-from-iterable-map.js: Added.
(test):
* JSTests/microbenchmarks/array-from-iterable-set-with-mapfn.js: Added.
(test):
* JSTests/microbenchmarks/array-from-iterable-string-with-mapfn.js: Added.
(test):
* JSTests/microbenchmarks/array-from-iterable-string.js: Added.
(test):
* JSTests/microbenchmarks/array-from-iterable-typed-array-with-mapfn.js: Added.
(test):
* JSTests/microbenchmarks/array-from-iterable-typed-array.js: Added.
(test):
* JSTests/stress/array-from-iterable-closes-iterator-and-reads-iterator-once.js: Added.
(shouldBe):
(makeIterable):
(iterableWithGetter.get Symbol):
(set var):
(set new):
(nonObjectIterator.Symbol.iterator):
(catch):
(nonObjectResult.Symbol.iterator):
* JSTests/stress/builtin-iteration-closes-iterator-and-reads-iterator-once.js: Added.
(shouldBe):
(shouldThrow):
(makeIterableWithGetter.return.get Symbol):
(makeIterableWithGetter):
(checkReadsIteratorOnce):
(checkCloses):
(i.x):
(nonObjectIterable.Symbol.iterator):
(nonObjectResult.Symbol.iterator):
(Array.fromAsync.get Symbol):
(x.x.2.then):
(Array.fromAsync.Symbol.iterator):
(then):
* JSTests/stress/iterator-helpers-flatmap-close-iterator-on-throw.js: Added.
(shouldBe):
(shouldThrow):
(makeIterator):
(checkCloses):
(i.3.flatMap):
(i.3.flatMap.x.next.return.get done):
* JSTests/stress/iterator-helpers-flatmap-close-iterator.js: Added.
(shouldBe):
(shouldThrow):
(makeIterator):
(checkCloses):
(i.3.flatMap):
(i.3.flatMap.x):
* JSTests/stress/iterator-helpers-some-every-find-close-iterator.js: Added.
(shouldBe):
(shouldThrow):
(makeIterator):
(checkCloses):
(i.3.some):
(i.3.every):
(i.3.find):
* Source/JavaScriptCore/builtins/ArrayConstructor.js:
(from):
(linkTimeConstant.visibility.PrivateRecursive.async defaultAsyncFromAsyncIterator):
(fromAsync):
(from.wrapper.iterator): Deleted.
(wrapper.asyncIterator): Deleted.
(linkTimeConstant.visibility.PrivateRecursive.async defaultAsyncFromAsyncIteratorWithNext): Deleted.
* Source/JavaScriptCore/builtins/JSIteratorPrototype.js:
(flatMap.generator):
(flatMap):
(some):
(every):
(find):
(flatMap.iteratedWrapper.iterator): Deleted.
(flatMap.iteratedWrapper.next): Deleted.
(flatMap.iteratedWrapper.return): Deleted.
(flatMap.): Deleted.
(some.wrapper.iterator): Deleted.
(every.wrapper.iterator): Deleted.
(find.wrapper.iterator): Deleted.
* Source/JavaScriptCore/builtins/MapConstructor.js:
(groupBy):
(wrapper.iterator): Deleted.
* Source/JavaScriptCore/builtins/ObjectConstructor.js:
(groupBy):
(wrapper.iterator): Deleted.
* Source/JavaScriptCore/builtins/TypedArrayConstructor.js:
(from):
(from.wrapper.iterator): Deleted.
Canonical link: https://commits.webkit.org/324531@main1 parent 8ee560d commit 37aa2b5
23 files changed
Lines changed: 587 additions & 99 deletions
File tree
- JSTests
- microbenchmarks
- stress
- Source/JavaScriptCore/builtins
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
0 commit comments