Skip to content
  • fpizlo@apple.com's avatar
    Incorrect TypedArray#set behavior · 067496d0
    fpizlo@apple.com authored
    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.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154518 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    067496d0