Title: [101426] trunk/Source
Revision
101426
Author
oli...@apple.com
Date
2011-11-29 15:36:33 -0800 (Tue, 29 Nov 2011)

Log Message

Allow WebCore to describe typed arrays to JSC
https://bugs.webkit.org/show_bug.cgi?id=73355

Reviewed by Gavin Barraclough.

Source/_javascript_Core:

Allow globaldata to track the structure of typed arrays.

* runtime/JSGlobalData.h:
(JSC::TypedArrayDescriptor::TypedArrayDescriptor):

Source/WebCore:

Update bindings codegen to report the data layout to JSC.

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateHeader):
(GenerateImplementation):
* bindings/scripts/test/JS/JSFloat64Array.cpp:
(WebCore::JSFloat64Array::finishCreation):
* bindings/scripts/test/JS/JSFloat64Array.h:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (101425 => 101426)


--- trunk/Source/_javascript_Core/ChangeLog	2011-11-29 22:46:17 UTC (rev 101425)
+++ trunk/Source/_javascript_Core/ChangeLog	2011-11-29 23:36:33 UTC (rev 101426)
@@ -1,3 +1,15 @@
+2011-11-29  Oliver Hunt  <oli...@apple.com>
+
+        Allow WebCore to describe typed arrays to JSC
+        https://bugs.webkit.org/show_bug.cgi?id=73355
+
+        Reviewed by Gavin Barraclough.
+
+        Allow globaldata to track the structure of typed arrays.
+
+        * runtime/JSGlobalData.h:
+        (JSC::TypedArrayDescriptor::TypedArrayDescriptor):
+
 2011-11-28  Filip Pizlo  <fpi...@apple.com>
 
         DFG debugCall() mechanism only works on X86 and X86-64

Modified: trunk/Source/_javascript_Core/runtime/ClassInfo.h (101425 => 101426)


--- trunk/Source/_javascript_Core/runtime/ClassInfo.h	2011-11-29 22:46:17 UTC (rev 101425)
+++ trunk/Source/_javascript_Core/runtime/ClassInfo.h	2011-11-29 23:36:33 UTC (rev 101426)
@@ -135,7 +135,8 @@
         &ClassName::defineOwnProperty, \
         &ClassName::getOwnPropertyDescriptor, \
     }, \
-    sizeof(ClassName)
+    sizeof(ClassName), \
+    ClassName::TypedArrayStorageType
 
     struct ClassInfo {
         /**
@@ -184,6 +185,8 @@
         MethodTable methodTable;
 
         size_t cellSize;
+        
+        TypedArrayType typedArrayStorageType;
     };
 
 } // namespace JSC

Modified: trunk/Source/_javascript_Core/runtime/JSCell.h (101425 => 101426)


--- trunk/Source/_javascript_Core/runtime/JSCell.h	2011-11-29 22:46:17 UTC (rev 101425)
+++ trunk/Source/_javascript_Core/runtime/JSCell.h	2011-11-29 23:36:33 UTC (rev 101426)
@@ -45,6 +45,18 @@
         IncludeDontEnumProperties
     };
 
+    enum TypedArrayType {
+        TypedArrayNone,
+        TypedArrayInt8,
+        TypedArrayInt16,
+        TypedArrayInt32,
+        TypedArrayUint8,
+        TypedArrayUint16,
+        TypedArrayUint32,
+        TypedArrayFloat32,
+        TypedArrayFloat64
+    };
+
     class JSCell {
         friend class JSValue;
         friend class MarkedBlock;
@@ -131,6 +143,7 @@
         Structure* unvalidatedStructure() { return m_structure.unvalidatedGet(); }
 #endif
         
+        static const TypedArrayType TypedArrayStorageType = TypedArrayNone;
     protected:
 
         void finishCreation(JSGlobalData&);

Modified: trunk/Source/_javascript_Core/runtime/JSGlobalData.h (101425 => 101426)


--- trunk/Source/_javascript_Core/runtime/JSGlobalData.h	2011-11-29 22:46:17 UTC (rev 101425)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalData.h	2011-11-29 23:36:33 UTC (rev 101426)
@@ -103,6 +103,24 @@
         ThreadStackTypeSmall
     };
 
+    struct TypedArrayDescriptor {
+        TypedArrayDescriptor()
+            : m_vptr(0)
+            , m_storageOffset(0)
+            , m_lengthOffset(0)
+        {
+        }
+        TypedArrayDescriptor(void* vptr, size_t storageOffset, size_t lengthOffset)
+            : m_vptr(vptr)
+            , m_storageOffset(storageOffset)
+            , m_lengthOffset(lengthOffset)
+        {
+        }
+        void* m_vptr;
+        size_t m_storageOffset;
+        size_t m_lengthOffset;
+    };
+    
     class JSGlobalData : public RefCounted<JSGlobalData> {
     public:
         // WebCore has a one-to-one mapping of threads to JSGlobalDatas;
@@ -319,6 +337,22 @@
         unsigned m_timeoutCount;
 #endif
 
+#define registerTypedArrayFunction(type, capitalizedType) \
+        void registerTypedArrayDescriptor(const capitalizedType##Array*, const TypedArrayDescriptor& descriptor) \
+        { \
+            ASSERT(!m_##type##ArrayDescriptor.m_vptr || m_##type##ArrayDescriptor.m_vptr == descriptor.m_vptr); \
+            m_##type##ArrayDescriptor = descriptor; \
+        }
+        registerTypedArrayFunction(int8, Int8);
+        registerTypedArrayFunction(int16, Int16);
+        registerTypedArrayFunction(int32, Int32);
+        registerTypedArrayFunction(uint8, Uint8);
+        registerTypedArrayFunction(uint16, Uint16);
+        registerTypedArrayFunction(uint32, Uint32);
+        registerTypedArrayFunction(float32, Float32);
+        registerTypedArrayFunction(float64, Float64);
+#undef registerTypedArrayFunction
+
     private:
         JSGlobalData(GlobalDataType, ThreadStackType, HeapSize);
         static JSGlobalData*& sharedInstanceInternal();
@@ -330,6 +364,14 @@
 #if ENABLE(GC_VALIDATION)
         bool m_isInitializingObject;
 #endif
+        TypedArrayDescriptor m_int8ArrayDescriptor;
+        TypedArrayDescriptor m_int16ArrayDescriptor;
+        TypedArrayDescriptor m_int32ArrayDescriptor;
+        TypedArrayDescriptor m_uint8ArrayDescriptor;
+        TypedArrayDescriptor m_uint16ArrayDescriptor;
+        TypedArrayDescriptor m_uint32ArrayDescriptor;
+        TypedArrayDescriptor m_float32ArrayDescriptor;
+        TypedArrayDescriptor m_float64ArrayDescriptor;
     };
 
 #if ENABLE(GC_VALIDATION)

Modified: trunk/Source/WebCore/ChangeLog (101425 => 101426)


--- trunk/Source/WebCore/ChangeLog	2011-11-29 22:46:17 UTC (rev 101425)
+++ trunk/Source/WebCore/ChangeLog	2011-11-29 23:36:33 UTC (rev 101426)
@@ -1,3 +1,19 @@
+2011-11-29  Oliver Hunt  <oli...@apple.com>
+
+        Allow WebCore to describe typed arrays to JSC
+        https://bugs.webkit.org/show_bug.cgi?id=73355
+
+        Reviewed by Gavin Barraclough.
+
+        Update bindings codegen to report the data layout to JSC.
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateHeader):
+        (GenerateImplementation):
+        * bindings/scripts/test/JS/JSFloat64Array.cpp:
+        (WebCore::JSFloat64Array::finishCreation):
+        * bindings/scripts/test/JS/JSFloat64Array.h:
+
 2011-11-29  Tony Chang  <t...@chromium.org>
 
         Rename some flexbox functions to be less confusing

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (101425 => 101426)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2011-11-29 22:46:17 UTC (rev 101425)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2011-11-29 23:36:33 UTC (rev 101426)
@@ -938,6 +938,21 @@
         push(@headerContent, "    }\n");
     }
 
+    if (IsTypedArrayType($implType) and ($implType ne "ArrayBufferView") and ($implType ne "ArrayBuffer")) {
+        push(@headerContent, "    static const JSC::TypedArrayType TypedArrayStorageType = JSC::");
+        push(@headerContent, "TypedArrayInt8") if $implType eq "Int8Array";
+        push(@headerContent, "TypedArrayInt16") if $implType eq "Int16Array";
+        push(@headerContent, "TypedArrayInt32") if $implType eq "Int32Array";
+        push(@headerContent, "TypedArrayUint8") if $implType eq "Uint8Array";
+        push(@headerContent, "TypedArrayUint16") if $implType eq "Uint16Array";
+        push(@headerContent, "TypedArrayUint32") if $implType eq "Uint32Array";
+        push(@headerContent, "TypedArrayFloat32") if $implType eq "Float32Array";
+        push(@headerContent, "TypedArrayFloat64") if $implType eq "Float64Array";
+        push(@headerContent, ";\n");
+        push(@headerContent, "    intptr_t m_storageLength;\n");
+        push(@headerContent, "    void* m_storage;\n");
+    }
+
     push(@headerContent, "protected:\n");
     # Constructor
     if ($interfaceName eq "DOMWindow") {
@@ -1604,6 +1619,12 @@
         push(@implContent, "void ${className}::finishCreation(JSGlobalData& globalData)\n");
         push(@implContent, "{\n");
         push(@implContent, "    Base::finishCreation(globalData);\n");
+        if (IsTypedArrayType($implType) and ($implType ne "ArrayBufferView") and ($implType ne "ArrayBuffer")) {
+            push(@implContent, "    TypedArrayDescriptor descriptor(vptr(), OBJECT_OFFSETOF(${className}, m_storage), OBJECT_OFFSETOF(${className}, m_storageLength));\n");
+            push(@implContent, "    globalData.registerTypedArrayDescriptor(impl(), descriptor);\n");
+            push(@implContent, "    m_storage = impl()->data();\n");
+            push(@implContent, "    m_storageLength = impl()->length();\n");
+        }
         push(@implContent, "    ASSERT(inherits(&s_info));\n");
         push(@implContent, "}\n\n");
     }

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSFloat64Array.cpp (101425 => 101426)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSFloat64Array.cpp	2011-11-29 22:46:17 UTC (rev 101425)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSFloat64Array.cpp	2011-11-29 23:36:33 UTC (rev 101426)
@@ -165,6 +165,10 @@
 void JSFloat64Array::finishCreation(JSGlobalData& globalData)
 {
     Base::finishCreation(globalData);
+    TypedArrayDescriptor descriptor(vptr(), OBJECT_OFFSETOF(JSFloat64Array, m_storage), OBJECT_OFFSETOF(JSFloat64Array, m_storageLength));
+    globalData.registerTypedArrayDescriptor(impl(), descriptor);
+    m_storage = impl()->data();
+    m_storageLength = impl()->length();
     ASSERT(inherits(&s_info));
 }
 

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSFloat64Array.h (101425 => 101426)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSFloat64Array.h	2011-11-29 22:46:17 UTC (rev 101425)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSFloat64Array.h	2011-11-29 23:36:33 UTC (rev 101426)
@@ -57,6 +57,9 @@
     {
         return static_cast<Float64Array*>(Base::impl());
     }
+    static const TypedArrayType TypedArrayStorageType = TypedArrayFloat64;
+    intptr_t m_storageLength;
+    void* m_storage;
 protected:
     JSFloat64Array(JSC::Structure*, JSDOMGlobalObject*, PassRefPtr<Float64Array>);
     void finishCreation(JSC::JSGlobalData&);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to