Changeset 272215 in webkit


Ignore:
Timestamp:
Feb 2, 2021 9:45:21 AM (18 months ago)
Author:
ysuzuki@apple.com
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:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r272206 r272215  
     12021-02-02  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        Support BigInt64Array/BigUint64Array in structured-cloning
     4        https://bugs.webkit.org/show_bug.cgi?id=221247
     5
     6        Reviewed by Alexey Shvayka.
     7
     8        * storage/indexeddb/resources/structured-clone.js:
     9        * storage/indexeddb/structured-clone-expected.txt:
     10
    1112021-02-02  Youenn Fablet  <youenn@apple.com>
    212
  • trunk/LayoutTests/storage/indexeddb/resources/structured-clone.js

    r264661 r272215  
    514514        "new Uint8ClampedArray([0, 1, 254, 255])",
    515515        "new Float32Array([-Infinity, -1.5, -1, -0.5, 0, 0.5, 1, 1.5, Infinity, NaN])",
    516         "new Float64Array([-Infinity, -Number.MAX_VALUE, -Number.MIN_VALUE, 0, Number.MIN_VALUE, Number.MAX_VALUE, Infinity, NaN])"
     516        "new Float64Array([-Infinity, -Number.MAX_VALUE, -Number.MIN_VALUE, 0, Number.MIN_VALUE, Number.MAX_VALUE, Infinity, NaN])",
     517        "new BigInt64Array([0x7fffffffffffffffn, 1n, 0n, -1n, -0x8000000000000000n])",
     518        "new BigUint64Array([0n, 0xffffffffffffffffn])",
    517519    ], callback);
    518520}
  • trunk/LayoutTests/storage/indexeddb/structured-clone-expected.txt

    r264661 r272215  
    811811PASS is(test_data[6], result[6]) is true
    812812PASS is(test_data[7], result[7]) is true
     813value = new BigInt64Array([0x7fffffffffffffffn, 1n, 0n, -1n, -0x8000000000000000n])
     814transaction = db.transaction('storeName', 'readwrite')
     815store = transaction.objectStore('storeName')
     816store.put(value, 'key')
     817store.get('key')
     818PASS test_data !== result is true
     819PASS Object.prototype.toString.call(result) is Object.prototype.toString.call(test_data)
     820PASS test_data.length === result.length is true
     821PASS is(test_data[0], result[0]) is true
     822PASS is(test_data[1], result[1]) is true
     823PASS is(test_data[2], result[2]) is true
     824PASS is(test_data[3], result[3]) is true
     825PASS is(test_data[4], result[4]) is true
     826value = new BigUint64Array([0n, 0xffffffffffffffffn])
     827transaction = db.transaction('storeName', 'readwrite')
     828store = transaction.objectStore('storeName')
     829store.put(value, 'key')
     830store.get('key')
     831PASS test_data !== result is true
     832PASS Object.prototype.toString.call(result) is Object.prototype.toString.call(test_data)
     833PASS test_data.length === result.length is true
     834PASS is(test_data[0], result[0]) is true
     835PASS is(test_data[1], result[1]) is true
    813836
    814837Testing Arrays
  • trunk/Source/WebCore/ChangeLog

    r272214 r272215  
     12021-02-02  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        Support BigInt64Array/BigUint64Array in structured-cloning
     4        https://bugs.webkit.org/show_bug.cgi?id=221247
     5
     6        Reviewed by Alexey Shvayka.
     7
     8        This patch adds BigInt64Array/BigUint64Array support in structured-cloning so that
     9        we can serialize and deserialize BigInt64Array/BigUint64Array.
     10
     11        * bindings/js/SerializedScriptValue.cpp:
     12        (WebCore::typedArrayElementSize):
     13        (WebCore::CloneSerializer::dumpArrayBufferView):
     14        (WebCore::CloneDeserializer::readArrayBufferView):
     15
    1162021-02-02  Chris Dumez  <cdumez@apple.com>
    217
  • trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp

    r271269 r272215  
    200200    Uint32ArrayTag = 7,
    201201    Float32ArrayTag = 8,
    202     Float64ArrayTag = 9
     202    Float64ArrayTag = 9,
     203    BigInt64ArrayTag = 10,
     204    BigUint64ArrayTag = 11,
    203205};
    204206
     
    219221        return 4;
    220222    case Float64ArrayTag:
     223    case BigInt64ArrayTag:
     224    case BigUint64ArrayTag:
    221225        return 8;
    222226    default:
     
    926930        else if (obj->inherits<JSFloat64Array>(vm))
    927931            write(Float64ArrayTag);
     932        else if (obj->inherits<JSBigInt64Array>(vm))
     933            write(BigInt64ArrayTag);
     934        else if (obj->inherits<JSBigUint64Array>(vm))
     935            write(BigUint64ArrayTag);
    928936        else
    929937            return false;
     
    24012409        case Float64ArrayTag:
    24022410            arrayBufferView = toJS(m_lexicalGlobalObject, m_globalObject, Float64Array::tryCreate(WTFMove(arrayBuffer), byteOffset, length).get());
     2411            return true;
     2412        case BigInt64ArrayTag:
     2413            arrayBufferView = toJS(m_lexicalGlobalObject, m_globalObject, BigInt64Array::tryCreate(WTFMove(arrayBuffer), byteOffset, length).get());
     2414            return true;
     2415        case BigUint64ArrayTag:
     2416            arrayBufferView = toJS(m_lexicalGlobalObject, m_globalObject, BigUint64Array::tryCreate(WTFMove(arrayBuffer), byteOffset, length).get());
    24032417            return true;
    24042418        default:
Note: See TracChangeset for help on using the changeset viewer.