Changeset 95157 in webkit


Ignore:
Timestamp:
Sep 14, 2011 8:28:43 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

[v8] Improve performance of typed array copy constructor taking Array
https://bugs.webkit.org/show_bug.cgi?id=68015

Patch by Ulan Degenbaev <ulan@chromium.org> on 2011-09-14
Reviewed by Kenneth Russell.

Invoke the 'set' method of the constructed array instead of
copying the elements of the source array one by one.

Copy constructor tests already exist.

  • ../../Source/WebCore/WebCore.gypi:
  • ../../Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.cpp: Added.
  • ../../Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h:
Location:
trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r95119 r95157  
     12011-09-14  Ulan Degenbaev  <ulan@chromium.org>
     2
     3        [v8] Improve performance of typed array copy constructor taking Array
     4        https://bugs.webkit.org/show_bug.cgi?id=68015
     5
     6        Reviewed by Kenneth Russell.
     7
     8        Invoke the 'set' method of the constructed array instead of
     9        copying the elements of the source array one by one.
     10
     11        Copy constructor tests already exist.
     12
     13        * ../../Source/WebCore/WebCore.gypi:
     14        * ../../Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.cpp: Added.
     15        * ../../Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h:
     16
    1172011-09-14  Csaba Osztrogonác  <ossy@webkit.org>
    218
  • trunk/Source/WebCore/WebCore.gypi

    r95029 r95157  
    21172117            'bindings/v8/WrapperTypeInfo.h',
    21182118            'bindings/v8/custom/V8ArrayBufferCustom.cpp',
     2119            'bindings/v8/custom/V8ArrayBufferViewCustom.cpp',
    21192120            'bindings/v8/custom/V8ArrayBufferViewCustom.h',
    21202121            'bindings/v8/custom/V8AudioBufferSourceNodeCustom.cpp',
  • trunk/Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h

    r94357 r95157  
    11/*
    2  * Copyright (C) 2009 Google Inc. All rights reserved.
     2 * Copyright (C) 2009, 2011 Google Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3333
    3434#include "ArrayBuffer.h"
     35#include "ExceptionCode.h"
    3536
    3637#include "V8ArrayBuffer.h"
     
    3940
    4041namespace WebCore {
     42
     43
     44// Copy the elements from the source array to the typed destination array by
     45// invoking the 'set' method of the destination array in JS.
     46void copyElements(v8::Handle<v8::Object> destArray, v8::Handle<v8::Object> srcArray);
    4147
    4248// Template function used by the ArrayBufferView*Constructor callbacks.
     
    148154        return throwError("ArrayBufferView size is not a small enough positive integer.", V8Proxy::RangeError);
    149155
    150     if (!srcArray.IsEmpty()) {
    151         // Need to copy the incoming array into the newly created ArrayBufferView.
    152         for (unsigned i = 0; i < len; i++) {
    153             v8::Local<v8::Value> val = srcArray->Get(i);
    154             array->set(i, val->NumberValue());
    155         }
    156     }
    157156
    158157    // Transform the holder into a wrapper object for the array.
    159158    V8DOMWrapper::setDOMWrapper(args.Holder(), type, array.get());
    160159    args.Holder()->SetIndexedPropertiesToExternalArrayData(array.get()->baseAddress(), arrayType, array.get()->length());
     160
     161    if (!srcArray.IsEmpty())
     162        copyElements(args.Holder(), srcArray);
     163
    161164    return toV8(array.release(), args.Holder(), MarkIndependent);
    162165}
Note: See TracChangeset for help on using the changeset viewer.