Title: [272215] trunk
Revision
272215
Author
[email protected]
Date
2021-02-02 09:45:21 -0800 (Tue, 02 Feb 2021)

Log Message

Support BigInt64Array/BigUint64Array in structured-cloning
https://bugs.webkit.org/show_bug.cgi?id=221247

Reviewed by Alexey Shvayka.

Source/WebCore:

This patch adds BigInt64Array/BigUint64Array support in structured-cloning so that
we can serialize and deserialize BigInt64Array/BigUint64Array.

* bindings/js/SerializedScriptValue.cpp:
(WebCore::typedArrayElementSize):
(WebCore::CloneSerializer::dumpArrayBufferView):
(WebCore::CloneDeserializer::readArrayBufferView):

LayoutTests:

* storage/indexeddb/resources/structured-clone.js:
* storage/indexeddb/structured-clone-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (272214 => 272215)


--- trunk/LayoutTests/ChangeLog	2021-02-02 17:37:46 UTC (rev 272214)
+++ trunk/LayoutTests/ChangeLog	2021-02-02 17:45:21 UTC (rev 272215)
@@ -1,3 +1,13 @@
+2021-02-02  Yusuke Suzuki  <[email protected]>
+
+        Support BigInt64Array/BigUint64Array in structured-cloning
+        https://bugs.webkit.org/show_bug.cgi?id=221247
+
+        Reviewed by Alexey Shvayka.
+
+        * storage/indexeddb/resources/structured-clone.js:
+        * storage/indexeddb/structured-clone-expected.txt:
+
 2021-02-02  Youenn Fablet  <[email protected]>
 
         Use WebRTC GPU process flag for MediaRecorder

Modified: trunk/LayoutTests/storage/indexeddb/resources/structured-clone.js (272214 => 272215)


--- trunk/LayoutTests/storage/indexeddb/resources/structured-clone.js	2021-02-02 17:37:46 UTC (rev 272214)
+++ trunk/LayoutTests/storage/indexeddb/resources/structured-clone.js	2021-02-02 17:45:21 UTC (rev 272215)
@@ -513,7 +513,9 @@
         "new Int32Array([0x00000000, 0x00000001, 0xFFFFFFFE, 0xFFFFFFFF])",
         "new Uint8ClampedArray([0, 1, 254, 255])",
         "new Float32Array([-Infinity, -1.5, -1, -0.5, 0, 0.5, 1, 1.5, Infinity, NaN])",
-        "new Float64Array([-Infinity, -Number.MAX_VALUE, -Number.MIN_VALUE, 0, Number.MIN_VALUE, Number.MAX_VALUE, Infinity, NaN])"
+        "new Float64Array([-Infinity, -Number.MAX_VALUE, -Number.MIN_VALUE, 0, Number.MIN_VALUE, Number.MAX_VALUE, Infinity, NaN])",
+        "new BigInt64Array([0x7fffffffffffffffn, 1n, 0n, -1n, -0x8000000000000000n])",
+        "new BigUint64Array([0n, 0xffffffffffffffffn])",
     ], callback);
 }
 

Modified: trunk/LayoutTests/storage/indexeddb/structured-clone-expected.txt (272214 => 272215)


--- trunk/LayoutTests/storage/indexeddb/structured-clone-expected.txt	2021-02-02 17:37:46 UTC (rev 272214)
+++ trunk/LayoutTests/storage/indexeddb/structured-clone-expected.txt	2021-02-02 17:45:21 UTC (rev 272215)
@@ -810,6 +810,29 @@
 PASS is(test_data[5], result[5]) is true
 PASS is(test_data[6], result[6]) is true
 PASS is(test_data[7], result[7]) is true
+value = new BigInt64Array([0x7fffffffffffffffn, 1n, 0n, -1n, -0x8000000000000000n])
+transaction = db.transaction('storeName', 'readwrite')
+store = transaction.objectStore('storeName')
+store.put(value, 'key')
+store.get('key')
+PASS test_data !== result is true
+PASS Object.prototype.toString.call(result) is Object.prototype.toString.call(test_data)
+PASS test_data.length === result.length is true
+PASS is(test_data[0], result[0]) is true
+PASS is(test_data[1], result[1]) is true
+PASS is(test_data[2], result[2]) is true
+PASS is(test_data[3], result[3]) is true
+PASS is(test_data[4], result[4]) is true
+value = new BigUint64Array([0n, 0xffffffffffffffffn])
+transaction = db.transaction('storeName', 'readwrite')
+store = transaction.objectStore('storeName')
+store.put(value, 'key')
+store.get('key')
+PASS test_data !== result is true
+PASS Object.prototype.toString.call(result) is Object.prototype.toString.call(test_data)
+PASS test_data.length === result.length is true
+PASS is(test_data[0], result[0]) is true
+PASS is(test_data[1], result[1]) is true
 
 Testing Arrays
 test_data = []

Modified: trunk/Source/WebCore/ChangeLog (272214 => 272215)


--- trunk/Source/WebCore/ChangeLog	2021-02-02 17:37:46 UTC (rev 272214)
+++ trunk/Source/WebCore/ChangeLog	2021-02-02 17:45:21 UTC (rev 272215)
@@ -1,3 +1,18 @@
+2021-02-02  Yusuke Suzuki  <[email protected]>
+
+        Support BigInt64Array/BigUint64Array in structured-cloning
+        https://bugs.webkit.org/show_bug.cgi?id=221247
+
+        Reviewed by Alexey Shvayka.
+
+        This patch adds BigInt64Array/BigUint64Array support in structured-cloning so that
+        we can serialize and deserialize BigInt64Array/BigUint64Array.
+
+        * bindings/js/SerializedScriptValue.cpp:
+        (WebCore::typedArrayElementSize):
+        (WebCore::CloneSerializer::dumpArrayBufferView):
+        (WebCore::CloneDeserializer::readArrayBufferView):
+
 2021-02-02  Chris Dumez  <[email protected]>
 
         Unreviewed, address post-landing review comment by Darin Adler for r272211.

Modified: trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp (272214 => 272215)


--- trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp	2021-02-02 17:37:46 UTC (rev 272214)
+++ trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp	2021-02-02 17:45:21 UTC (rev 272215)
@@ -199,7 +199,9 @@
     Int32ArrayTag = 6,
     Uint32ArrayTag = 7,
     Float32ArrayTag = 8,
-    Float64ArrayTag = 9
+    Float64ArrayTag = 9,
+    BigInt64ArrayTag = 10,
+    BigUint64ArrayTag = 11,
 };
 
 static unsigned typedArrayElementSize(ArrayBufferViewSubtag tag)
@@ -218,6 +220,8 @@
     case Float32ArrayTag:
         return 4;
     case Float64ArrayTag:
+    case BigInt64ArrayTag:
+    case BigUint64ArrayTag:
         return 8;
     default:
         return 0;
@@ -925,6 +929,10 @@
             write(Float32ArrayTag);
         else if (obj->inherits<JSFloat64Array>(vm))
             write(Float64ArrayTag);
+        else if (obj->inherits<JSBigInt64Array>(vm))
+            write(BigInt64ArrayTag);
+        else if (obj->inherits<JSBigUint64Array>(vm))
+            write(BigUint64ArrayTag);
         else
             return false;
 
@@ -2401,6 +2409,12 @@
         case Float64ArrayTag:
             arrayBufferView = toJS(m_lexicalGlobalObject, m_globalObject, Float64Array::tryCreate(WTFMove(arrayBuffer), byteOffset, length).get());
             return true;
+        case BigInt64ArrayTag:
+            arrayBufferView = toJS(m_lexicalGlobalObject, m_globalObject, BigInt64Array::tryCreate(WTFMove(arrayBuffer), byteOffset, length).get());
+            return true;
+        case BigUint64ArrayTag:
+            arrayBufferView = toJS(m_lexicalGlobalObject, m_globalObject, BigUint64Array::tryCreate(WTFMove(arrayBuffer), byteOffset, length).get());
+            return true;
         default:
             return false;
         }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to