Changeset 94783 in webkit


Ignore:
Timestamp:
Sep 8, 2011 12:55:20 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

[v8] Improve performance of typed array set() taking Array
https://bugs.webkit.org/show_bug.cgi?id=63644

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

Overwrite the native 'set' method of the type arrays with JS
implementation after initialization of the global context.

Add tests for invalid and boundary offsets. No performance tests.

  • LayoutTests/fast/canvas/webgl/array-unit-tests-expected.txt:
  • LayoutTests/fast/canvas/webgl/array-unit-tests.html:
  • Source/WebCore/WebCore.gyp/WebCore.gyp:
  • Source/WebCore/WebCore.gypi:
  • Source/WebCore/bindings/v8/V8BindingScripts.cpp: Added.
  • Source/WebCore/bindings/v8/V8BindingScripts.h: Added.
  • Source/WebCore/bindings/v8/V8DOMWindowShell.cpp:
  • Source/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp:
  • Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustomScript.js: Added.
Location:
trunk
Files:
3 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r94772 r94783  
     12011-09-08  Ulan Degenbaev  <ulan@chromium.org>
     2
     3        [v8] Improve performance of typed array set() taking Array
     4        https://bugs.webkit.org/show_bug.cgi?id=63644
     5
     6        Reviewed by Kenneth Russell.
     7
     8        Overwrite the native 'set' method of the type arrays with JS
     9        implementation after initialization of the global context.
     10
     11        Add tests for invalid and boundary offsets. No performance tests.
     12
     13        * LayoutTests/fast/canvas/webgl/array-unit-tests-expected.txt:
     14        * LayoutTests/fast/canvas/webgl/array-unit-tests.html:
     15        * Source/WebCore/WebCore.gyp/WebCore.gyp:
     16        * Source/WebCore/WebCore.gypi:
     17        * Source/WebCore/bindings/v8/V8BindingScripts.cpp: Added.
     18        * Source/WebCore/bindings/v8/V8BindingScripts.h: Added.
     19        * Source/WebCore/bindings/v8/V8DOMWindowShell.cpp:
     20        * Source/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp:
     21        * Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustomScript.js: Added.
     22
    1232011-09-08  Varun Jain  <varunjain@google.com>
    224
  • trunk/LayoutTests/fast/canvas/webgl/array-unit-tests-expected.txt

    r91803 r94783  
    4444PASS array.subarray(-2147483648).length is (32 / typeSize)
    4545PASS Setting Float32Array from array with out-of-range offset was caught
     46PASS Setting Float32Array from Float32Array with out-of-range offset was caught
     47PASS Setting Float32Array from array with negative offset was caught
     48PASS Setting Float32Array from Float32Array with negative offset was caught
     49PASS Setting Float32Array from array with -0 offset
     50PASS Setting Float32Array from Float32Array with -0 offset
     51PASS Setting Float32Array from array with boundary offset
     52PASS Setting Float32Array from Float32Array with boundary offset
     53PASS Setting Float32Array from array with non-integer offset
     54PASS Setting Float32Array from Float32Array with non-integer offset
    4655PASS Setting Float32Array from fake array with invalid length was caught
    47 PASS Setting Float32Array from Float32Array with out-of-range offset was caught
    4856PASS array.get is undefined.
    4957PASS array.set(0, 1) threw exception.
     
    9098PASS array.subarray(-2147483648).length is (32 / typeSize)
    9199PASS Setting Float64Array from array with out-of-range offset was caught
     100PASS Setting Float64Array from Float64Array with out-of-range offset was caught
     101PASS Setting Float64Array from array with negative offset was caught
     102PASS Setting Float64Array from Float64Array with negative offset was caught
     103PASS Setting Float64Array from array with -0 offset
     104PASS Setting Float64Array from Float64Array with -0 offset
     105PASS Setting Float64Array from array with boundary offset
     106PASS Setting Float64Array from Float64Array with boundary offset
     107PASS Setting Float64Array from array with non-integer offset
     108PASS Setting Float64Array from Float64Array with non-integer offset
    92109PASS Setting Float64Array from fake array with invalid length was caught
    93 PASS Setting Float64Array from Float64Array with out-of-range offset was caught
    94110PASS array.get is undefined.
    95111PASS array.set(0, 1) threw exception.
     
    132148PASS array.subarray(-2147483648).length is (32 / typeSize)
    133149PASS Setting Int8Array from array with out-of-range offset was caught
     150PASS Setting Int8Array from Int8Array with out-of-range offset was caught
     151PASS Setting Int8Array from array with negative offset was caught
     152PASS Setting Int8Array from Int8Array with negative offset was caught
     153PASS Setting Int8Array from array with -0 offset
     154PASS Setting Int8Array from Int8Array with -0 offset
     155PASS Setting Int8Array from array with boundary offset
     156PASS Setting Int8Array from Int8Array with boundary offset
     157PASS Setting Int8Array from array with non-integer offset
     158PASS Setting Int8Array from Int8Array with non-integer offset
    134159PASS Setting Int8Array from fake array with invalid length was caught
    135 PASS Setting Int8Array from Int8Array with out-of-range offset was caught
    136160PASS array.get is undefined.
    137161PASS array.set(0, 1) threw exception.
     
    179203PASS array.subarray(-2147483648).length is (32 / typeSize)
    180204PASS Setting Int16Array from array with out-of-range offset was caught
     205PASS Setting Int16Array from Int16Array with out-of-range offset was caught
     206PASS Setting Int16Array from array with negative offset was caught
     207PASS Setting Int16Array from Int16Array with negative offset was caught
     208PASS Setting Int16Array from array with -0 offset
     209PASS Setting Int16Array from Int16Array with -0 offset
     210PASS Setting Int16Array from array with boundary offset
     211PASS Setting Int16Array from Int16Array with boundary offset
     212PASS Setting Int16Array from array with non-integer offset
     213PASS Setting Int16Array from Int16Array with non-integer offset
    181214PASS Setting Int16Array from fake array with invalid length was caught
    182 PASS Setting Int16Array from Int16Array with out-of-range offset was caught
    183215PASS array.get is undefined.
    184216PASS array.set(0, 1) threw exception.
     
    226258PASS array.subarray(-2147483648).length is (32 / typeSize)
    227259PASS Setting Int32Array from array with out-of-range offset was caught
     260PASS Setting Int32Array from Int32Array with out-of-range offset was caught
     261PASS Setting Int32Array from array with negative offset was caught
     262PASS Setting Int32Array from Int32Array with negative offset was caught
     263PASS Setting Int32Array from array with -0 offset
     264PASS Setting Int32Array from Int32Array with -0 offset
     265PASS Setting Int32Array from array with boundary offset
     266PASS Setting Int32Array from Int32Array with boundary offset
     267PASS Setting Int32Array from array with non-integer offset
     268PASS Setting Int32Array from Int32Array with non-integer offset
    228269PASS Setting Int32Array from fake array with invalid length was caught
    229 PASS Setting Int32Array from Int32Array with out-of-range offset was caught
    230270PASS array.get is undefined.
    231271PASS array.set(0, 1) threw exception.
     
    268308PASS array.subarray(-2147483648).length is (32 / typeSize)
    269309PASS Setting Uint8Array from array with out-of-range offset was caught
     310PASS Setting Uint8Array from Uint8Array with out-of-range offset was caught
     311PASS Setting Uint8Array from array with negative offset was caught
     312PASS Setting Uint8Array from Uint8Array with negative offset was caught
     313PASS Setting Uint8Array from array with -0 offset
     314PASS Setting Uint8Array from Uint8Array with -0 offset
     315PASS Setting Uint8Array from array with boundary offset
     316PASS Setting Uint8Array from Uint8Array with boundary offset
     317PASS Setting Uint8Array from array with non-integer offset
     318PASS Setting Uint8Array from Uint8Array with non-integer offset
    270319PASS Setting Uint8Array from fake array with invalid length was caught
    271 PASS Setting Uint8Array from Uint8Array with out-of-range offset was caught
    272320PASS array.get is undefined.
    273321PASS array.set(0, 1) threw exception.
     
    315363PASS array.subarray(-2147483648).length is (32 / typeSize)
    316364PASS Setting Uint16Array from array with out-of-range offset was caught
     365PASS Setting Uint16Array from Uint16Array with out-of-range offset was caught
     366PASS Setting Uint16Array from array with negative offset was caught
     367PASS Setting Uint16Array from Uint16Array with negative offset was caught
     368PASS Setting Uint16Array from array with -0 offset
     369PASS Setting Uint16Array from Uint16Array with -0 offset
     370PASS Setting Uint16Array from array with boundary offset
     371PASS Setting Uint16Array from Uint16Array with boundary offset
     372PASS Setting Uint16Array from array with non-integer offset
     373PASS Setting Uint16Array from Uint16Array with non-integer offset
    317374PASS Setting Uint16Array from fake array with invalid length was caught
    318 PASS Setting Uint16Array from Uint16Array with out-of-range offset was caught
    319375PASS array.get is undefined.
    320376PASS array.set(0, 1) threw exception.
     
    362418PASS array.subarray(-2147483648).length is (32 / typeSize)
    363419PASS Setting Uint32Array from array with out-of-range offset was caught
     420PASS Setting Uint32Array from Uint32Array with out-of-range offset was caught
     421PASS Setting Uint32Array from array with negative offset was caught
     422PASS Setting Uint32Array from Uint32Array with negative offset was caught
     423PASS Setting Uint32Array from array with -0 offset
     424PASS Setting Uint32Array from Uint32Array with -0 offset
     425PASS Setting Uint32Array from array with boundary offset
     426PASS Setting Uint32Array from Uint32Array with boundary offset
     427PASS Setting Uint32Array from array with non-integer offset
     428PASS Setting Uint32Array from Uint32Array with non-integer offset
    364429PASS Setting Uint32Array from fake array with invalid length was caught
    365 PASS Setting Uint32Array from Uint32Array with out-of-range offset was caught
    366430PASS array.get is undefined.
    367431PASS array.set(0, 1) threw exception.
  • trunk/LayoutTests/fast/canvas/webgl/array-unit-tests.html

    r91803 r94783  
    617617}
    618618
     619function setWithInvalidOffset(type, name, length,
     620                              sourceType, sourceName, sourceLength,
     621                              offset, offsetDescription) {
     622    var webglArray = new type(length);
     623    var sourceArray = new sourceType(sourceLength);
     624    for (var i = 0; i < sourceLength; i++)
     625        sourceArray[i] = 42 + i;
     626    try {
     627        webglArray.set(sourceArray, offset);
     628        testFailed("Setting " + name + " from " + sourceName + " with " +
     629                   offsetDescription + " offset was not caught");
     630    } catch (e) {
     631        testPassed("Setting " + name + " from " + sourceName + " with " +
     632                   offsetDescription + " offset was caught");
     633    }
     634}
     635
     636function setWithValidOffset(type, name, length,
     637                            sourceType, sourceName, sourceLength,
     638                            offset, offsetDescription) {
     639    running("Setting " + name + " from " + sourceName + " with " +
     640            offsetDescription + " offset");
     641    var webglArray = new type(length);
     642    var sourceArray = new sourceType(sourceLength);
     643    for (var i = 0; i < sourceLength; i++)
     644        sourceArray[i] = 42 + i;
     645    try {
     646        webglArray.set(sourceArray, offset);
     647        offset = Math.floor(offset);
     648        for (var i = 0; i < sourceLength; i++) {
     649            assertEq("Element " + i + offset, sourceArray[i], webglArray[i + offset]);
     650        }
     651        pass();
     652    } catch (e) {
     653        fail(e);
     654    }
     655}
     656
     657
    619658function testSettingFromArrayWithOutOfRangeOffset(type, name) {
    620     var webglArray = new type(32);
    621     var array = [];
    622     for (var i = 0; i < 16; i++) {
    623         array.push(i);
    624     }
    625     try {
    626         webglArray.set(array, 0x7FFFFFF8);
    627         testFailed("Setting " + name + " from array with out-of-range offset was not caught");
    628     } catch (e) {
    629         testPassed("Setting " + name + " from array with out-of-range offset was caught");
    630     }
     659    setWithInvalidOffset(type, name, 32, Array, "array", 16,
     660                         0x7FFFFFF8, "out-of-range");
     661}
     662
     663function testSettingFromTypedArrayWithOutOfRangeOffset(type, name) {
     664    setWithInvalidOffset(type, name, 32, type, name, 16,
     665                         0x7FFFFFF8, "out-of-range");
     666}
     667
     668function testSettingFromArrayWithNegativeOffset(type, name) {
     669    setWithInvalidOffset(type, name, 32, Array, "array", 16,
     670                         -1, "negative");
     671}
     672
     673function testSettingFromTypedArrayWithNegativeOffset(type, name) {
     674    setWithInvalidOffset(type, name, 32, type, name, 16,
     675                         -1, "negative");
     676}
     677
     678function testSettingFromArrayWithMinusZeroOffset(type, name) {
     679    setWithValidOffset(type, name, 32, Array, "array", 16,
     680                       -0, "-0");
     681}
     682
     683function testSettingFromTypedArrayWithMinusZeroOffset(type, name) {
     684    setWithValidOffset(type, name, 32, type, name, 16,
     685                       -0, "-0");
     686}
     687
     688function testSettingFromArrayWithBoundaryOffset(type, name) {
     689    setWithValidOffset(type, name, 32, Array, "array", 16,
     690                       16, "boundary");
     691}
     692
     693function testSettingFromTypedArrayWithBoundaryOffset(type, name) {
     694    setWithValidOffset(type, name, 32, type, name, 16,
     695                       16, "boundary");
     696}
     697
     698function testSettingFromArrayWithNonIntegerOffset(type, name) {
     699    setWithValidOffset(type, name, 32, Array, "array", 16,
     700                       16.999, "non-integer");
     701}
     702
     703function testSettingFromTypedArrayWithNonIntegerOffset(type, name) {
     704    setWithValidOffset(type, name, 32, type, name, 16,
     705                       16.999, "non-integer");
    631706}
    632707
     
    643718}
    644719
    645 function testSettingFromTypedArrayWithOutOfRangeOffset(type, name) {
    646     var webglArray = new type(32);
    647     var srcArray = new type(16);
    648     for (var i = 0; i < 16; i++) {
    649         srcArray[i] = i;
    650     }
    651     try {
    652         webglArray.set(srcArray, 0x7FFFFFF8);
    653         testFailed("Setting " + name + " from " + name + " with out-of-range offset was not caught");
    654     } catch (e) {
    655         testPassed("Setting " + name + " from " + name + " with out-of-range offset was caught");
    656     }
    657 }
    658720
    659721function negativeTestGetAndSetMethods(type, name) {
     
    873935    testSubarrayWithDefaultValues(type, name, testCase.elementSizeInBytes);
    874936    testSettingFromArrayWithOutOfRangeOffset(type, name);
     937    testSettingFromTypedArrayWithOutOfRangeOffset(type, name);
     938    testSettingFromArrayWithNegativeOffset(type, name);
     939    testSettingFromTypedArrayWithNegativeOffset(type, name);
     940    testSettingFromArrayWithMinusZeroOffset(type, name);
     941    testSettingFromTypedArrayWithMinusZeroOffset(type, name);
     942    testSettingFromArrayWithBoundaryOffset(type, name);
     943    testSettingFromTypedArrayWithBoundaryOffset(type, name);
     944    testSettingFromArrayWithNonIntegerOffset(type, name);
     945    testSettingFromTypedArrayWithNonIntegerOffset(type, name);
    875946    testSettingFromFakeArrayWithOutOfRangeLength(type, name);
    876     testSettingFromTypedArrayWithOutOfRangeOffset(type, name);
    877947    negativeTestGetAndSetMethods(type, name);
    878948    testNaNConversion(type, name);
  • trunk/Source/WebCore/WebCore.gyp/WebCore.gyp

    r94694 r94783  
    481481        # Actions to build derived sources.
    482482        {
     483          'action_name': 'generateV8ArrayBufferViewCustomScript',
     484          'inputs': [
     485            '../bindings/v8/custom/V8ArrayBufferViewCustomScript.js',
     486          ],
     487          'outputs': [
     488            '<(SHARED_INTERMEDIATE_DIR)/webkit/V8ArrayBufferViewCustomScript.h',
     489          ],
     490          'action': [
     491            'perl',
     492            '../inspector/xxd.pl',
     493            'V8ArrayBufferViewCustomScript_js',
     494            '<@(_inputs)',
     495            '<@(_outputs)'
     496          ],
     497          'message': 'Generating V8ArrayBufferViewCustomScript.h from V8ArrayBufferViewCustomScript.js',
     498        },
     499        {
    483500          'action_name': 'generateXMLViewerCSS',
    484501          'inputs': [
  • trunk/Source/WebCore/WebCore.gypi

    r94703 r94783  
    20642064            'bindings/v8/V8Binding.cpp',
    20652065            'bindings/v8/V8Binding.h',
     2066            'bindings/v8/V8BindingScripts.cpp',
     2067            'bindings/v8/V8BindingScripts.h',
    20662068            'bindings/v8/V8Collection.cpp',
    20672069            'bindings/v8/V8Collection.h',
  • trunk/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp

    r94275 r94783  
    11/*
    2  * Copyright (C) 2008, 2009 Google Inc. All rights reserved.
    3  * 
     2 * Copyright (C) 2008, 2009, 2011 Google Inc. All rights reserved.
     3 *
    44 * Redistribution and use in source and binary forms, with or without
    55 * modification, are permitted provided that the following conditions are
    66 * met:
    7  * 
     7 *
    88 *     * Redistributions of source code must retain the above copyright
    99 * notice, this list of conditions and the following disclaimer.
     
    1515 * contributors may be used to endorse or promote products derived from
    1616 * this software without specific prior written permission.
    17  * 
     17 *
    1818 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    1919 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     
    4747#include "StorageNamespace.h"
    4848#include "V8Binding.h"
     49#include "V8BindingScripts.h"
    4950#include "V8BindingState.h"
    5051#include "V8Collection.h"
     
    340341    setSecurityToken();
    341342
     343    V8BindingScripts::runScripts(v8Context);
     344
    342345    m_frame->loader()->client()->didCreateScriptContextForFrame();
    343346
  • trunk/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp

    r92694 r94783  
    4242#include "SharedWorkerContext.h"
    4343#include "V8Binding.h"
     44#include "V8BindingScripts.h"
    4445#include "V8DOMMap.h"
    4546#include "V8DedicatedWorkerContext.h"
     
    175176    v8::Handle<v8::Object> globalObject = v8::Handle<v8::Object>::Cast(m_context->Global()->GetPrototype());
    176177    globalObject->SetPrototype(jsWorkerContext);
     178
     179    V8BindingScripts::runScripts(context);
     180
    177181    return true;
    178182}
Note: See TracChangeset for help on using the changeset viewer.