Commit ea7b828
[JSC] Iterator Helpers methods should not iterate an array
https://bugs.webkit.org/show_bug.cgi?id=279876
Reviewed by Alexey Shvayka.
We implemented a function called `forEachInIteratorProtocol` to implement
`Iterator.prototype.toArray`[1]. As the name suggests, this function iterates over objects that
conform to the iterator protocol, but it also iterates over fast arrays.
The methods of Iterator Helpers use the `GetIteratorDirect` abstract operation[2] to directly get
the object's `next` property. Unlike the `GetIterator` abstract operation[3], it does not get the
`@@iterator`.
This patch changes the `forEachInIteratorProtocol` function to stop iterating over arrays. It also
removes the fast path for fast arrays in `Iterator.prototype.toArray`[4].
[1]: https://commits.webkit.org/283381@main
[2]: https://tc39.es/proposal-iterator-helpers/#sec-getiteratordirect
[3]: https://tc39.es/ecma262/#sec-getiterator
[4]: https://commits.webkit.org/283381@main
* JSTests/microbenchmarks/iterator-prototype-toArray-for-array.js: Removed.
* JSTests/stress/iterator-prototype-forEach.js:
(sameArray):
(const.validIter): Deleted.
(const.invalidCallback.of.invalidCallbacks.shouldThrow): Deleted.
* JSTests/stress/iterator-prototype-toArray-empty.js: Removed.
* JSTests/stress/iterator-prototype-toArray.js:
(sameArray):
* Source/JavaScriptCore/runtime/IteratorOperations.h:
(JSC::forEachInIteratorProtocol):
* Source/JavaScriptCore/runtime/JSIteratorPrototype.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
Canonical link: https://commits.webkit.org/283933@main1 parent 83db213 commit ea7b828
File tree
6 files changed
+6
-128
lines changed- JSTests
- microbenchmarks
- stress
- Source/JavaScriptCore/runtime
6 files changed
+6
-128
lines changedLines changed: 0 additions & 6 deletions
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | | - | |
105 | | - | |
106 | | - | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
| |||
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
99 | | - | |
100 | | - | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | 176 | | |
184 | 177 | | |
185 | 178 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | 155 | | |
163 | 156 | | |
164 | 157 | | |
| |||
0 commit comments