• commit-queue@webkit.org's avatar
    constructing TypedArray from another TypedArray is slow · d8d6c696
    commit-queue@webkit.org authored
    Patch by Arnaud Renevier <a.renevier@sisa.samsung.com> on 2012-07-26
    Reviewed by Kenneth Russell.
    * Bindings/typed-array-construct-from-same-type.html: Added.
    * Bindings/typed-array-construct-from-typed.html: Added.
    When constructing 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 construction by
    approximatively 3x (even 30x if TypedArrays are both the same type).
    In order to achieve that, we use virtual getType method. We can use
    this information to cast the TypedArray to the actual type, and then
    read the values from the source.
    Introduce constructArrayBufferViewWithTypedArrayArgument template
    function which returns a new typed array if first argument is a typed
    array, or 0 otherwise.
    This patch also replaces previous is<Type>Array() calls with new
    getType method.
    * bindings/js/JSArrayBufferViewHelper.h:
    * bindings/v8/SerializedScriptValue.cpp:
    * html/canvas/DataView.h:
    * html/canvas/WebGLRenderingContext.cpp:
    * page/Crypto.cpp:
    Introduce virtual method getType on ArrayBufferView. It returns the actual
    type of the view. This method replaces previous is<Type>Array() methods.
    * wtf/ArrayBufferView.h:
    * wtf/Float32Array.h:
    * wtf/Float64Array.h:
    * wtf/Int16Array.h:
    * wtf/Int32Array.h:
    * wtf/Int8Array.h:
    * wtf/IntegralTypedArrayBase.h:
    * wtf/TypedArrayBase.h:
    * wtf/Uint16Array.h:
    * wtf/Uint32Array.h:
    * wtf/Uint8Array.h:
    * wtf/Uint8ClampedArray.h:
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@123819 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Crypto.cpp 2.52 KB