TypedArray set method is slow when called with another typed array
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Aug 2012 19:20:33 +0000 (19:20 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Aug 2012 19:20:33 +0000 (19:20 +0000)
commitd36b13c0d2558f76f076c48395a688f449605499
treea865cf35ebf1d63bd0baf82f2b53bba19924386d
parente6003928ac21ec3aa5e170df2380cb6a7052ab03
TypedArray set method is slow when called with another typed array
https://bugs.webkit.org/show_bug.cgi?id=92556

Patch by Arnaud Renevier <a.renevier@sisa.samsung.com> on 2012-08-02
Reviewed by Kenneth Russell.

PerformanceTests:

* Bindings/typed-array-set-from-typed.html: Added.

Source/WebCore:

When setting multiples values to a typed array from an array like
element, try to determine if the argument is a typed array. If so,
cast the argument to a typed array, and read each element with .item()
method. That avoid reading the value as a JSValue, and speedups set
method by approximatively 10x.

Introduce setWebGLArrayWithTypedArrayArgument template function which
checks if argument is a typed array. If so, it copies the data to
target typed array and returns true. Otherwise, it returns false.

Introduce copyTypedArrayBuffer template function which copies data
from a typed array to another one. This function is also used from
constructArrayBufferViewWithTypedArrayArgument.

* bindings/js/JSArrayBufferViewHelper.h:
(WebCore):
(WebCore::copyTypedArrayBuffer):
(WebCore::setWebGLArrayWithTypedArrayArgument):
(WebCore::setWebGLArrayHelper):
(WebCore::constructArrayBufferViewWithTypedArrayArgument):
* bindings/js/JSFloat32ArrayCustom.cpp:
(WebCore::JSFloat32Array::set):
* bindings/js/JSFloat64ArrayCustom.cpp:
(WebCore::JSFloat64Array::set):
* bindings/js/JSInt16ArrayCustom.cpp:
(WebCore::JSInt16Array::set):
* bindings/js/JSInt32ArrayCustom.cpp:
(WebCore::JSInt32Array::set):
* bindings/js/JSInt8ArrayCustom.cpp:
(WebCore::JSInt8Array::set):
* bindings/js/JSUint16ArrayCustom.cpp:
(WebCore::JSUint16Array::set):
* bindings/js/JSUint32ArrayCustom.cpp:
(WebCore::JSUint32Array::set):
* bindings/js/JSUint8ArrayCustom.cpp:
(WebCore::JSUint8Array::set):
* bindings/js/JSUint8ClampedArrayCustom.cpp:
(WebCore::JSUint8ClampedArray::set):

Source/WTF:

Add an checkInboundData function to TypedArrayBase to check if a
position will be not be out of bound or overflow from the typed array.

* wtf/TypedArrayBase.h:
(WTF::TypedArrayBase::checkInboundData):
(TypedArrayBase):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@124483 268f45cc-cd09-0410-ab3c-d52691b4dbfc
15 files changed:
PerformanceTests/Bindings/typed-array-set-from-typed.html [new file with mode: 0644]
PerformanceTests/ChangeLog
Source/WTF/ChangeLog
Source/WTF/wtf/TypedArrayBase.h
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSArrayBufferViewHelper.h
Source/WebCore/bindings/js/JSFloat32ArrayCustom.cpp
Source/WebCore/bindings/js/JSFloat64ArrayCustom.cpp
Source/WebCore/bindings/js/JSInt16ArrayCustom.cpp
Source/WebCore/bindings/js/JSInt32ArrayCustom.cpp
Source/WebCore/bindings/js/JSInt8ArrayCustom.cpp
Source/WebCore/bindings/js/JSUint16ArrayCustom.cpp
Source/WebCore/bindings/js/JSUint32ArrayCustom.cpp
Source/WebCore/bindings/js/JSUint8ArrayCustom.cpp
Source/WebCore/bindings/js/JSUint8ClampedArrayCustom.cpp