haikuwebkit/LayoutTests/js/typedarray-set-same-type-me...

12 lines
303 B
Plaintext
Raw Permalink Normal View History

Incorrect TypedArray#set behavior https://bugs.webkit.org/show_bug.cgi?id=83818 Source/JavaScriptCore: Reviewed by Oliver Hunt and Mark Hahnenberg. This was so much fun! typedArray.set() is like a memmove on steroids, and I'm not smart enough to figure out optimal versions for *all* of the cases. But I did come up with optimal implementations for most of the cases, and I wrote spec-literal code (i.e. copy via a transfer buffer) for the cases I'm not smart enough to write optimal code for. * runtime/JSArrayBufferView.h: (JSC::JSArrayBufferView::hasArrayBuffer): * runtime/JSArrayBufferViewInlines.h: (JSC::JSArrayBufferView::buffer): (JSC::JSArrayBufferView::existingBufferInButterfly): (JSC::JSArrayBufferView::neuter): (JSC::JSArrayBufferView::byteOffset): * runtime/JSGenericTypedArrayView.h: * runtime/JSGenericTypedArrayViewInlines.h: (JSC::::setWithSpecificType): (JSC::::set): (JSC::::existingBuffer): LayoutTests: Reviewed by Oliver Hunt and Mark Hahnenberg. Made it possible for shouldBe() to compare typed arrays to each other and to any array-like object. Added a bunch of tests for different kinds of overlapping typedArray.set()'s. For sanity, also added the reduced test case from the bug. Interestingly, though, that test case already passed on trunk - probably by luck (we had incidentally changed the default copy direction from one that happened to not work to one that happened to be fine, but only for this test). * fast/js/jsc-test-list: * fast/js/resources/js-test-pre.js: (isTypedArray): (isResultCorrect): (stringify): (shouldBe): * fast/js/script-tests/typed-array-copy.js: Added. * fast/js/script-tests/typedarray-set-destination-smaller-than-source.js: Added. * fast/js/script-tests/typedarray-set-overlapping-elements-of-same-size.js: Added. * fast/js/script-tests/typedarray-set-same-type-memmove.js: Added. (arraysEqual): * fast/js/script-tests/typedarray-set-source-smaller-than-destination.js: Added. * fast/js/typed-array-copy-expected.txt: Added. * fast/js/typed-array-copy.html: Added. * fast/js/typedarray-set-destination-smaller-than-source-expected.txt: Added. * fast/js/typedarray-set-destination-smaller-than-source.html: Added. * fast/js/typedarray-set-overlapping-elements-of-same-size-expected.txt: Added. * fast/js/typedarray-set-overlapping-elements-of-same-size.html: Added. * fast/js/typedarray-set-same-type-memmove-expected.txt: Added. * fast/js/typedarray-set-same-type-memmove.html: Added. * fast/js/typedarray-set-source-smaller-than-destination-expected.txt: Added. * fast/js/typedarray-set-source-smaller-than-destination.html: Added. Canonical link: https://commits.webkit.org/138174@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@154518 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2013-08-23 20:40:34 +00:00
Tests the code path of typedArray.set that bottoms out in memmove.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS foo(10) is [42,42,43,44,45,46,47,48,49,50,51]
PASS bar(10) is [42,43,44,45,46,47,48,49,50,51,51]
PASS successfullyParsed is true
TEST COMPLETE