Title: [124872] trunk/Source/WebCore
Revision
124872
Author
[email protected]
Date
2012-08-07 02:27:36 -0700 (Tue, 07 Aug 2012)

Log Message

[V8] Remove custom toV8() calls for TypedArray.
https://bugs.webkit.org/show_bug.cgi?id=93248

Patch by Vineet Chaudhary <[email protected]> on 2012-08-07
Reviewed by Kentaro Hara.

With the support of [TypedArray] we can remove the custom calls toV8().
TypedArray spec : http://www.khronos.org/registry/typedarray/specs/latest/#7

Tests: TestTypedArray.idl
Tests under below folders should pass as this does not cause any behavioral changes.
       fast/canvas/webgl
       compositing/webgl

* bindings/js/JSInt8ArrayCustom.cpp:
* bindings/js/JSUint8ArrayCustom.cpp:
* bindings/js/JSUint8ClampedArrayCustom.cpp:
* bindings/scripts/CodeGeneratorV8.pm:
(GenerateImplementation): Modified Generator code to generate bindings for toV8().
(IsWrapperType):
(GetTypeNameOfExternalTypedArray): Method to get view type of TypedArray.
* bindings/scripts/test/V8/V8Float64Array.cpp: Tests results.
(WebCore::toV8):
* bindings/v8/custom/V8Float32ArrayCustom.cpp: Removed custom call toV8().
* bindings/v8/custom/V8Float64ArrayCustom.cpp: Ditto.
* bindings/v8/custom/V8Int16ArrayCustom.cpp: Ditto.
* bindings/v8/custom/V8Int32ArrayCustom.cpp: Ditto.
* bindings/v8/custom/V8Int8ArrayCustom.cpp: Ditto.
* bindings/v8/custom/V8Uint16ArrayCustom.cpp: Ditto.
* bindings/v8/custom/V8Uint32ArrayCustom.cpp: Ditto.
* bindings/v8/custom/V8Uint8ArrayCustom.cpp: Ditto.
* bindings/v8/custom/V8Uint8ClampedArrayCustom.cpp: Ditto.
* html/canvas/Int8Array.idl: Using TypedArray.
* html/canvas/Uint8Array.idl: Ditto.
* html/canvas/Uint8ClampedArray.idl: Ditto.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (124871 => 124872)


--- trunk/Source/WebCore/ChangeLog	2012-08-07 09:24:21 UTC (rev 124871)
+++ trunk/Source/WebCore/ChangeLog	2012-08-07 09:27:36 UTC (rev 124872)
@@ -1,3 +1,40 @@
+2012-08-07  Vineet Chaudhary  <[email protected]>
+
+        [V8] Remove custom toV8() calls for TypedArray.
+        https://bugs.webkit.org/show_bug.cgi?id=93248
+
+        Reviewed by Kentaro Hara.
+
+        With the support of [TypedArray] we can remove the custom calls toV8().
+        TypedArray spec : http://www.khronos.org/registry/typedarray/specs/latest/#7
+
+        Tests: TestTypedArray.idl
+        Tests under below folders should pass as this does not cause any behavioral changes.
+               fast/canvas/webgl
+               compositing/webgl
+
+        * bindings/js/JSInt8ArrayCustom.cpp:
+        * bindings/js/JSUint8ArrayCustom.cpp:
+        * bindings/js/JSUint8ClampedArrayCustom.cpp:
+        * bindings/scripts/CodeGeneratorV8.pm:
+        (GenerateImplementation): Modified Generator code to generate bindings for toV8().
+        (IsWrapperType):
+        (GetTypeNameOfExternalTypedArray): Method to get view type of TypedArray.
+        * bindings/scripts/test/V8/V8Float64Array.cpp: Tests results.
+        (WebCore::toV8):
+        * bindings/v8/custom/V8Float32ArrayCustom.cpp: Removed custom call toV8().
+        * bindings/v8/custom/V8Float64ArrayCustom.cpp: Ditto.
+        * bindings/v8/custom/V8Int16ArrayCustom.cpp: Ditto.
+        * bindings/v8/custom/V8Int32ArrayCustom.cpp: Ditto.
+        * bindings/v8/custom/V8Int8ArrayCustom.cpp: Ditto.
+        * bindings/v8/custom/V8Uint16ArrayCustom.cpp: Ditto.
+        * bindings/v8/custom/V8Uint32ArrayCustom.cpp: Ditto.
+        * bindings/v8/custom/V8Uint8ArrayCustom.cpp: Ditto.
+        * bindings/v8/custom/V8Uint8ClampedArrayCustom.cpp: Ditto.
+        * html/canvas/Int8Array.idl: Using TypedArray.
+        * html/canvas/Uint8Array.idl: Ditto.
+        * html/canvas/Uint8ClampedArray.idl: Ditto.
+
 2012-08-07  Pavel Feldman  <[email protected]>
 
         Web Inspector: [regression r121673] restore link between the command and the result.

Modified: trunk/Source/WebCore/bindings/js/JSInt8ArrayCustom.cpp (124871 => 124872)


--- trunk/Source/WebCore/bindings/js/JSInt8ArrayCustom.cpp	2012-08-07 09:24:21 UTC (rev 124871)
+++ trunk/Source/WebCore/bindings/js/JSInt8ArrayCustom.cpp	2012-08-07 09:27:36 UTC (rev 124872)
@@ -49,14 +49,4 @@
     return setWebGLArrayHelper<Int8Array, signed char>(exec, impl());
 }
 
-EncodedJSValue JSC_HOST_CALL JSInt8ArrayConstructor::constructJSInt8Array(ExecState* exec)
-{
-    JSInt8ArrayConstructor* jsConstructor = jsCast<JSInt8ArrayConstructor*>(exec->callee());
-    RefPtr<Int8Array> array = constructArrayBufferView<Int8Array, signed char>(exec);
-    if (!array.get())
-        // Exception has already been thrown.
-        return JSValue::encode(JSValue());
-    return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), array.get())));
-}
-
 } // namespace WebCore

Modified: trunk/Source/WebCore/bindings/js/JSUint8ArrayCustom.cpp (124871 => 124872)


--- trunk/Source/WebCore/bindings/js/JSUint8ArrayCustom.cpp	2012-08-07 09:24:21 UTC (rev 124871)
+++ trunk/Source/WebCore/bindings/js/JSUint8ArrayCustom.cpp	2012-08-07 09:27:36 UTC (rev 124872)
@@ -48,14 +48,4 @@
     return setWebGLArrayHelper<Uint8Array, unsigned char>(exec, impl());
 }
 
-EncodedJSValue JSC_HOST_CALL JSUint8ArrayConstructor::constructJSUint8Array(ExecState* exec)
-{
-    JSUint8ArrayConstructor* jsConstructor = jsCast<JSUint8ArrayConstructor*>(exec->callee());
-    RefPtr<Uint8Array> array = constructArrayBufferView<Uint8Array, unsigned char>(exec);
-    if (!array.get())
-        // Exception has already been thrown.
-        return JSValue::encode(JSValue());
-    return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), array.get())));
-}
-
 } // namespace WebCore

Modified: trunk/Source/WebCore/bindings/js/JSUint8ClampedArrayCustom.cpp (124871 => 124872)


--- trunk/Source/WebCore/bindings/js/JSUint8ClampedArrayCustom.cpp	2012-08-07 09:24:21 UTC (rev 124871)
+++ trunk/Source/WebCore/bindings/js/JSUint8ClampedArrayCustom.cpp	2012-08-07 09:27:36 UTC (rev 124872)
@@ -48,14 +48,4 @@
     return setWebGLArrayHelper<Uint8ClampedArray, unsigned char>(exec, impl());
 }
 
-EncodedJSValue JSC_HOST_CALL JSUint8ClampedArrayConstructor::constructJSUint8ClampedArray(ExecState* exec)
-{
-    JSUint8ClampedArrayConstructor* jsConstructor = jsCast<JSUint8ClampedArrayConstructor*>(exec->callee());
-    RefPtr<Uint8ClampedArray> array = constructArrayBufferView<Uint8ClampedArray, unsigned char>(exec);
-    if (!array.get())
-        // Exception has already been thrown.
-        return JSValue::encode(JSValue());
-    return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), array.get())));
-}
-
 } // namespace WebCore

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (124871 => 124872)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2012-08-07 09:24:21 UTC (rev 124871)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2012-08-07 09:27:36 UTC (rev 124872)
@@ -2594,6 +2594,22 @@
         GenerateVisitDOMWrapper($dataNode, $implClassName);
     }
 
+    if ($dataNode->extendedAttributes->{"TypedArray"}) {
+        my $viewType = GetTypeNameOfExternalTypedArray($dataNode);
+        push(@implContent, <<END);
+v8::Handle<v8::Value> toV8($implClassName* impl, v8::Isolate* isolate)
+{
+    if (!impl)
+        return v8NullWithCheck(isolate);
+    v8::Handle<v8::Object> wrapper = V8${implClassName}::wrap(impl, isolate);
+    if (!wrapper.IsEmpty())
+        wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), $viewType, impl->length());
+    return wrapper;
+}
+
+END
+    }
+
     my $indexer;
     my $namedPropertyGetter;
     my @enabledPerContextFunctions;
@@ -3906,6 +3922,24 @@
     return !($non_wrapper_types{$type});
 }
 
+sub GetTypeNameOfExternalTypedArray
+{
+    my $dataNode = shift;
+    my $interfaceName = $dataNode->name;
+    my $viewType = $dataNode->extendedAttributes->{"TypedArray"};
+    return "v8::kExternalByteArray" if $viewType eq "signed char" and $interfaceName eq "Int8Array";
+    return "v8::kExternalPixelArray" if $viewType eq "unsigned char" and $interfaceName eq "Uint8ClampedArray";
+    return "v8::kExternalUnsignedByteArray" if $viewType eq "unsigned char" and $interfaceName eq "Uint8Array";
+    return "v8::kExternalShortArray" if $viewType eq "short" and $interfaceName eq "Int16Array";
+    return "v8::kExternalUnsignedShortArray" if $viewType eq "unsigned short" and $interfaceName eq "Uint16Array";
+    return "v8::kExternalIntArray" if $viewType eq "int" and $interfaceName eq "Int32Array";
+    return "v8::kExternalUnsignedIntArray" if $viewType eq "unsigned int" and $interfaceName eq "Uint32Array";
+    return "v8::kExternalFloatArray" if $viewType eq "float" and $interfaceName eq "Float32Array";
+    return "v8::kExternalDoubleArray" if $viewType eq "double" and $interfaceName eq "Float64Array";
+
+    die "TypedArray of unknown type is found";
+}
+
 sub IsArrayType
 {
     my $type = $codeGenerator->StripModule(shift);

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8Float64Array.cpp (124871 => 124872)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8Float64Array.cpp	2012-08-07 09:24:21 UTC (rev 124871)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8Float64Array.cpp	2012-08-07 09:27:36 UTC (rev 124872)
@@ -61,6 +61,16 @@
 
 } // namespace Float64ArrayV8Internal
 
+v8::Handle<v8::Value> toV8(Float64Array* impl, v8::Isolate* isolate)
+{
+    if (!impl)
+        return v8NullWithCheck(isolate);
+    v8::Handle<v8::Object> wrapper = V8Float64Array::wrap(impl, isolate);
+    if (!wrapper.IsEmpty())
+        wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalDoubleArray, impl->length());
+    return wrapper;
+}
+
 static v8::Persistent<v8::FunctionTemplate> ConfigureV8Float64ArrayTemplate(v8::Persistent<v8::FunctionTemplate> desc)
 {
     desc->ReadOnlyPrototype();

Modified: trunk/Source/WebCore/bindings/v8/custom/V8Float32ArrayCustom.cpp (124871 => 124872)


--- trunk/Source/WebCore/bindings/v8/custom/V8Float32ArrayCustom.cpp	2012-08-07 09:24:21 UTC (rev 124871)
+++ trunk/Source/WebCore/bindings/v8/custom/V8Float32ArrayCustom.cpp	2012-08-07 09:27:36 UTC (rev 124872)
@@ -54,14 +54,4 @@
     return setWebGLArrayHelper<Float32Array, V8Float32Array>(args);
 }
 
-v8::Handle<v8::Value> toV8(Float32Array* impl, v8::Isolate* isolate)
-{
-    if (!impl)
-        return v8NullWithCheck(isolate);
-    v8::Handle<v8::Object> wrapper = V8Float32Array::wrap(impl, isolate);
-    if (!wrapper.IsEmpty())
-        wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalFloatArray, impl->length());
-    return wrapper;
-}
-
 } // namespace WebCore

Modified: trunk/Source/WebCore/bindings/v8/custom/V8Float64ArrayCustom.cpp (124871 => 124872)


--- trunk/Source/WebCore/bindings/v8/custom/V8Float64ArrayCustom.cpp	2012-08-07 09:24:21 UTC (rev 124871)
+++ trunk/Source/WebCore/bindings/v8/custom/V8Float64ArrayCustom.cpp	2012-08-07 09:27:36 UTC (rev 124872)
@@ -49,14 +49,4 @@
     return setWebGLArrayHelper<Float64Array, V8Float64Array>(args);
 }
 
-v8::Handle<v8::Value> toV8(Float64Array* impl, v8::Isolate* isolate)
-{
-    if (!impl)
-        return v8NullWithCheck(isolate);
-    v8::Handle<v8::Object> wrapper = V8Float64Array::wrap(impl, isolate);
-    if (!wrapper.IsEmpty())
-        wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalDoubleArray, impl->length());
-    return wrapper;
-}
-
 } // namespace WebCore

Modified: trunk/Source/WebCore/bindings/v8/custom/V8Int16ArrayCustom.cpp (124871 => 124872)


--- trunk/Source/WebCore/bindings/v8/custom/V8Int16ArrayCustom.cpp	2012-08-07 09:24:21 UTC (rev 124871)
+++ trunk/Source/WebCore/bindings/v8/custom/V8Int16ArrayCustom.cpp	2012-08-07 09:27:36 UTC (rev 124872)
@@ -53,14 +53,4 @@
     return setWebGLArrayHelper<Int16Array, V8Int16Array>(args);
 }
 
-v8::Handle<v8::Value> toV8(Int16Array* impl, v8::Isolate* isolate)
-{
-    if (!impl)
-        return v8NullWithCheck(isolate);
-    v8::Handle<v8::Object> wrapper = V8Int16Array::wrap(impl, isolate);
-    if (!wrapper.IsEmpty())
-        wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalShortArray, impl->length());
-    return wrapper;
-}
-
 } // namespace WebCore

Modified: trunk/Source/WebCore/bindings/v8/custom/V8Int32ArrayCustom.cpp (124871 => 124872)


--- trunk/Source/WebCore/bindings/v8/custom/V8Int32ArrayCustom.cpp	2012-08-07 09:24:21 UTC (rev 124871)
+++ trunk/Source/WebCore/bindings/v8/custom/V8Int32ArrayCustom.cpp	2012-08-07 09:27:36 UTC (rev 124872)
@@ -53,14 +53,4 @@
     return setWebGLArrayHelper<Int32Array, V8Int32Array>(args);
 }
 
-v8::Handle<v8::Value> toV8(Int32Array* impl, v8::Isolate* isolate)
-{
-    if (!impl)
-        return v8NullWithCheck(isolate);
-    v8::Handle<v8::Object> wrapper = V8Int32Array::wrap(impl, isolate);
-    if (!wrapper.IsEmpty())
-        wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalIntArray, impl->length());
-    return wrapper;
-}
-
 } // namespace WebCore

Modified: trunk/Source/WebCore/bindings/v8/custom/V8Int8ArrayCustom.cpp (124871 => 124872)


--- trunk/Source/WebCore/bindings/v8/custom/V8Int8ArrayCustom.cpp	2012-08-07 09:24:21 UTC (rev 124871)
+++ trunk/Source/WebCore/bindings/v8/custom/V8Int8ArrayCustom.cpp	2012-08-07 09:27:36 UTC (rev 124872)
@@ -53,14 +53,4 @@
     return setWebGLArrayHelper<Int8Array, V8Int8Array>(args);
 }
 
-v8::Handle<v8::Value> toV8(Int8Array* impl, v8::Isolate* isolate)
-{
-    if (!impl)
-        return v8NullWithCheck(isolate);
-    v8::Handle<v8::Object> wrapper = V8Int8Array::wrap(impl, isolate);
-    if (!wrapper.IsEmpty())
-        wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalByteArray, impl->length());
-    return wrapper;
-}
-
 } // namespace WebCore

Modified: trunk/Source/WebCore/bindings/v8/custom/V8Uint16ArrayCustom.cpp (124871 => 124872)


--- trunk/Source/WebCore/bindings/v8/custom/V8Uint16ArrayCustom.cpp	2012-08-07 09:24:21 UTC (rev 124871)
+++ trunk/Source/WebCore/bindings/v8/custom/V8Uint16ArrayCustom.cpp	2012-08-07 09:27:36 UTC (rev 124872)
@@ -53,14 +53,4 @@
     return setWebGLArrayHelper<Uint16Array, V8Uint16Array>(args);
 }
 
-v8::Handle<v8::Value> toV8(Uint16Array* impl, v8::Isolate* isolate)
-{
-    if (!impl)
-        return v8NullWithCheck(isolate);
-    v8::Handle<v8::Object> wrapper = V8Uint16Array::wrap(impl, isolate);
-    if (!wrapper.IsEmpty())
-        wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalUnsignedShortArray, impl->length());
-    return wrapper;
-}
-
 } // namespace WebCore

Modified: trunk/Source/WebCore/bindings/v8/custom/V8Uint32ArrayCustom.cpp (124871 => 124872)


--- trunk/Source/WebCore/bindings/v8/custom/V8Uint32ArrayCustom.cpp	2012-08-07 09:24:21 UTC (rev 124871)
+++ trunk/Source/WebCore/bindings/v8/custom/V8Uint32ArrayCustom.cpp	2012-08-07 09:27:36 UTC (rev 124872)
@@ -53,14 +53,4 @@
     return setWebGLArrayHelper<Uint32Array, V8Uint32Array>(args);
 }
 
-v8::Handle<v8::Value> toV8(Uint32Array* impl, v8::Isolate* isolate)
-{
-    if (!impl)
-        return v8NullWithCheck(isolate);
-    v8::Handle<v8::Object> wrapper = V8Uint32Array::wrap(impl, isolate);
-    if (!wrapper.IsEmpty())
-        wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalUnsignedIntArray, impl->length());
-    return wrapper;
-}
-
 } // namespace WebCore

Modified: trunk/Source/WebCore/bindings/v8/custom/V8Uint8ArrayCustom.cpp (124871 => 124872)


--- trunk/Source/WebCore/bindings/v8/custom/V8Uint8ArrayCustom.cpp	2012-08-07 09:24:21 UTC (rev 124871)
+++ trunk/Source/WebCore/bindings/v8/custom/V8Uint8ArrayCustom.cpp	2012-08-07 09:27:36 UTC (rev 124872)
@@ -53,14 +53,4 @@
     return setWebGLArrayHelper<Uint8Array, V8Uint8Array>(args);
 }
 
-v8::Handle<v8::Value> toV8(Uint8Array* impl, v8::Isolate* isolate)
-{
-    if (!impl)
-        return v8NullWithCheck(isolate);
-    v8::Handle<v8::Object> wrapper = V8Uint8Array::wrap(impl, isolate);
-    if (!wrapper.IsEmpty())
-        wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalUnsignedByteArray, impl->length());
-    return wrapper;
-}
-
 } // namespace WebCore

Modified: trunk/Source/WebCore/bindings/v8/custom/V8Uint8ClampedArrayCustom.cpp (124871 => 124872)


--- trunk/Source/WebCore/bindings/v8/custom/V8Uint8ClampedArrayCustom.cpp	2012-08-07 09:24:21 UTC (rev 124871)
+++ trunk/Source/WebCore/bindings/v8/custom/V8Uint8ClampedArrayCustom.cpp	2012-08-07 09:27:36 UTC (rev 124872)
@@ -50,14 +50,4 @@
     return setWebGLArrayHelper<Uint8ClampedArray, V8Uint8ClampedArray>(args);
 }
 
-v8::Handle<v8::Value> toV8(Uint8ClampedArray* impl, v8::Isolate* isolate)
-{
-    if (!impl)
-        return v8NullWithCheck(isolate);
-    v8::Handle<v8::Object> wrapper = V8Uint8ClampedArray::wrap(impl, isolate);
-    if (!wrapper.IsEmpty())
-        wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalPixelArray, impl->length());
-    return wrapper;
-}
-
 } // namespace WebCore

Modified: trunk/Source/WebCore/html/canvas/Int8Array.idl (124871 => 124872)


--- trunk/Source/WebCore/html/canvas/Int8Array.idl	2012-08-07 09:24:21 UTC (rev 124871)
+++ trunk/Source/WebCore/html/canvas/Int8Array.idl	2012-08-07 09:27:36 UTC (rev 124872)
@@ -33,7 +33,8 @@
         JSGenerateToNativeObject,
         JSNoStaticTables,
         CustomToJSObject,
-        DoNotCheckConstants
+        DoNotCheckConstants,
+        TypedArray=signed char
     ] Int8Array : ArrayBufferView {
         const unsigned long BYTES_PER_ELEMENT = 1;
 

Modified: trunk/Source/WebCore/html/canvas/Uint8Array.idl (124871 => 124872)


--- trunk/Source/WebCore/html/canvas/Uint8Array.idl	2012-08-07 09:24:21 UTC (rev 124871)
+++ trunk/Source/WebCore/html/canvas/Uint8Array.idl	2012-08-07 09:27:36 UTC (rev 124872)
@@ -33,7 +33,8 @@
         JSGenerateToNativeObject,
         JSNoStaticTables,
         CustomToJSObject,
-        DoNotCheckConstants
+        DoNotCheckConstants,
+        TypedArray=unsigned char
     ] Uint8Array : ArrayBufferView {
         const unsigned long BYTES_PER_ELEMENT = 1;
 

Modified: trunk/Source/WebCore/html/canvas/Uint8ClampedArray.idl (124871 => 124872)


--- trunk/Source/WebCore/html/canvas/Uint8ClampedArray.idl	2012-08-07 09:24:21 UTC (rev 124871)
+++ trunk/Source/WebCore/html/canvas/Uint8ClampedArray.idl	2012-08-07 09:27:36 UTC (rev 124872)
@@ -33,7 +33,8 @@
         JSGenerateToNativeObject,
         JSNoStaticTables,
         CustomToJSObject,
-        DoNotCheckConstants
+        DoNotCheckConstants,
+        TypedArray=unsigned char
     ] Uint8ClampedArray : Uint8Array {
         const unsigned long BYTES_PER_ELEMENT = 1;
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to