Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[JSC] TypedArray iteration does not need to get "length"
https://bugs.webkit.org/show_bug.cgi?id=243581 Reviewed by Alexey Shvayka. ArrayIterator#next spec says that if the array is TypedArray, we do not need to look up "length", and we can directly get TypedArray's internal length. This means that "length" property of instance, Uint8Array.prototype, and TypedArray.prototype are unrelated to iterator protocol. This makes iterator protocol guarantee simplified. This patch applies this change: we no longer ensure "length" validity. We also adjust ArrayIterator#next's slow path implementation to the spec. [1]: https://tc39.es/ecma262/#sec-createarrayiterator * JSTests/stress/typed-array-from-custom-length.js: * Source/JavaScriptCore/builtins/ArrayIteratorPrototype.js: (linkTimeConstant.arrayIteratorNextHelper): * Source/JavaScriptCore/runtime/JSArrayBufferView.cpp: (JSC::JSArrayBufferView::isIteratorProtocolFastAndNonObservable): * Source/JavaScriptCore/runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::installTypedArrayIteratorProtocolWatchpoint): (JSC::JSGlobalObject::installTypedArrayPrototypeIteratorProtocolWatchpoint): * Source/JavaScriptCore/runtime/JSGlobalObject.h: (JSC::JSGlobalObject::typedArrayPrototypeLengthAbsenceWatchpoint): Deleted. * Source/JavaScriptCore/runtime/JSTypedArrayViewPrototype.cpp: (JSC::JSTypedArrayViewPrototype::finishCreation): Canonical link: https://commits.webkit.org/253153@main
- Loading branch information
1 parent
dc4fdf8
commit af1cc8c
Showing
7 changed files
with
40 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
function shouldBe(actual, expected) { | ||
if (actual !== expected) | ||
throw new Error('bad value: ' + actual); | ||
} | ||
|
||
function shouldThrow(func, errorMessage) { | ||
var errorThrown = false; | ||
var error = null; | ||
try { | ||
func(); | ||
} catch (e) { | ||
errorThrown = true; | ||
error = e; | ||
} | ||
if (!errorThrown) | ||
throw new Error('not thrown'); | ||
if (String(error) !== errorMessage) | ||
throw new Error(`bad error: ${String(error)}`); | ||
} | ||
|
||
var array = new Uint8Array(42); | ||
var count = 0; | ||
|
||
shouldThrow(() => { | ||
for (let v of array) { | ||
++count; | ||
$.detachArrayBuffer(array.buffer); | ||
} | ||
}, `TypeError: Underlying ArrayBuffer has been detached from the view`); | ||
|
||
shouldBe(count, 1); |
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
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
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