⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 269832 in webkit


Ignore:
Timestamp:
Nov 15, 2020, 11:58:07 AM (6 years ago)
Author:
ysuzuki@apple.com
Message:

[JSC] Wasm should get byte length from source typed array
https://bugs.webkit.org/show_bug.cgi?id=218955

Reviewed by Sam Weinig.

LayoutTests/imported/w3c:

  • web-platform-tests/wasm/jsapi/constructor/validate.any-expected.txt:
  • web-platform-tests/wasm/jsapi/constructor/validate.any.worker-expected.txt:

Source/JavaScriptCore:

WebAssembly's module source should be read with byteLength instead of length of typed-array.

  • runtime/JSArrayBufferView.cpp:

(JSC::JSArrayBufferView::byteLength const):
(JSC::JSArrayBufferView::slowDownAndWasteMemory):

  • runtime/JSArrayBufferView.h:
  • wasm/js/JSWebAssemblyHelpers.h:

(JSC::getWasmBufferFromValue):

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r269820 r269832  
     12020-11-15  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Wasm should get byte length from source typed array
     4        https://bugs.webkit.org/show_bug.cgi?id=218955
     5
     6        Reviewed by Sam Weinig.
     7
     8        * web-platform-tests/wasm/jsapi/constructor/validate.any-expected.txt:
     9        * web-platform-tests/wasm/jsapi/constructor/validate.any.worker-expected.txt:
     10
    1112020-11-14  Rob Buis  <rbuis@igalia.com>
    212
  • trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/constructor/validate.any-expected.txt

    r267649 r269832  
    3333PASS Validating module [0 61 73 6d 1 0 0 0] in Uint8Array
    3434PASS Validating module [0 61 73 6d 1 0 0 0] in Int8Array
    35 FAIL Validating module [0 61 73 6d 1 0 0 0] in Uint16Array assert_equals: expected true but got false
    36 FAIL Validating module [0 61 73 6d 1 0 0 0] in Int16Array assert_equals: expected true but got false
    37 FAIL Validating module [0 61 73 6d 1 0 0 0] in Uint32Array assert_equals: expected true but got false
    38 FAIL Validating module [0 61 73 6d 1 0 0 0] in Int32Array assert_equals: expected true but got false
     35PASS Validating module [0 61 73 6d 1 0 0 0] in Uint16Array
     36PASS Validating module [0 61 73 6d 1 0 0 0] in Int16Array
     37PASS Validating module [0 61 73 6d 1 0 0 0] in Uint32Array
     38PASS Validating module [0 61 73 6d 1 0 0 0] in Int32Array
    3939PASS Validating module [0 61 73 6d 0 0 0 0] in Uint8Array
    4040PASS Validating module [0 61 73 6d 0 0 0 0] in Int8Array
     
    5757PASS Validating module [0 61 73 6d 1 0 0 0 0 2 1 61] in Uint8Array
    5858PASS Validating module [0 61 73 6d 1 0 0 0 0 2 1 61] in Int8Array
    59 FAIL Validating module [0 61 73 6d 1 0 0 0 0 2 1 61] in Uint16Array assert_equals: expected true but got false
    60 FAIL Validating module [0 61 73 6d 1 0 0 0 0 2 1 61] in Int16Array assert_equals: expected true but got false
    61 FAIL Validating module [0 61 73 6d 1 0 0 0 0 2 1 61] in Uint32Array assert_equals: expected true but got false
    62 FAIL Validating module [0 61 73 6d 1 0 0 0 0 2 1 61] in Int32Array assert_equals: expected true but got false
     59PASS Validating module [0 61 73 6d 1 0 0 0 0 2 1 61] in Uint16Array
     60PASS Validating module [0 61 73 6d 1 0 0 0 0 2 1 61] in Int16Array
     61PASS Validating module [0 61 73 6d 1 0 0 0 0 2 1 61] in Uint32Array
     62PASS Validating module [0 61 73 6d 1 0 0 0 0 2 1 61] in Int32Array
    6363PASS Stray argument
    6464
  • trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/constructor/validate.any.worker-expected.txt

    r267649 r269832  
    3333PASS Validating module [0 61 73 6d 1 0 0 0] in Uint8Array
    3434PASS Validating module [0 61 73 6d 1 0 0 0] in Int8Array
    35 FAIL Validating module [0 61 73 6d 1 0 0 0] in Uint16Array assert_equals: expected true but got false
    36 FAIL Validating module [0 61 73 6d 1 0 0 0] in Int16Array assert_equals: expected true but got false
    37 FAIL Validating module [0 61 73 6d 1 0 0 0] in Uint32Array assert_equals: expected true but got false
    38 FAIL Validating module [0 61 73 6d 1 0 0 0] in Int32Array assert_equals: expected true but got false
     35PASS Validating module [0 61 73 6d 1 0 0 0] in Uint16Array
     36PASS Validating module [0 61 73 6d 1 0 0 0] in Int16Array
     37PASS Validating module [0 61 73 6d 1 0 0 0] in Uint32Array
     38PASS Validating module [0 61 73 6d 1 0 0 0] in Int32Array
    3939PASS Validating module [0 61 73 6d 0 0 0 0] in Uint8Array
    4040PASS Validating module [0 61 73 6d 0 0 0 0] in Int8Array
     
    5757PASS Validating module [0 61 73 6d 1 0 0 0 0 2 1 61] in Uint8Array
    5858PASS Validating module [0 61 73 6d 1 0 0 0 0 2 1 61] in Int8Array
    59 FAIL Validating module [0 61 73 6d 1 0 0 0 0 2 1 61] in Uint16Array assert_equals: expected true but got false
    60 FAIL Validating module [0 61 73 6d 1 0 0 0 0 2 1 61] in Int16Array assert_equals: expected true but got false
    61 FAIL Validating module [0 61 73 6d 1 0 0 0 0 2 1 61] in Uint32Array assert_equals: expected true but got false
    62 FAIL Validating module [0 61 73 6d 1 0 0 0 0 2 1 61] in Int32Array assert_equals: expected true but got false
     59PASS Validating module [0 61 73 6d 1 0 0 0 0 2 1 61] in Uint16Array
     60PASS Validating module [0 61 73 6d 1 0 0 0 0 2 1 61] in Int16Array
     61PASS Validating module [0 61 73 6d 1 0 0 0 0 2 1 61] in Uint32Array
     62PASS Validating module [0 61 73 6d 1 0 0 0 0 2 1 61] in Int32Array
    6363PASS Stray argument
    6464
  • trunk/Source/JavaScriptCore/ChangeLog

    r269814 r269832  
     12020-11-15  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Wasm should get byte length from source typed array
     4        https://bugs.webkit.org/show_bug.cgi?id=218955
     5
     6        Reviewed by Sam Weinig.
     7
     8        WebAssembly's module source should be read with byteLength instead of length of typed-array.
     9
     10        * runtime/JSArrayBufferView.cpp:
     11        (JSC::JSArrayBufferView::byteLength const):
     12        (JSC::JSArrayBufferView::slowDownAndWasteMemory):
     13        * runtime/JSArrayBufferView.h:
     14        * wasm/js/JSWebAssemblyHelpers.h:
     15        (JSC::getWasmBufferFromValue):
     16
    1172020-11-14  Don Olmstead  <don.olmstead@sony.com>
    218
  • trunk/Source/JavaScriptCore/runtime/JSArrayBufferView.cpp

    r269343 r269832  
    234234    FOR_EACH_TYPED_ARRAY_TYPE_EXCLUDING_DATA_VIEW(FACTORY)
    235235#undef FACTORY
     236    1, // DataViewType
    236237};
    237238
     
    242243static inline size_t elementSize(JSType type)
    243244{
    244     ASSERT(type >= Int8ArrayType && type <= Float64ArrayType);
     245    ASSERT(type >= Int8ArrayType && type <= DataViewType);
     246    static_assert(Float64ArrayType + 1 == DataViewType);
    245247    return ElementSizeData[type - Int8ArrayType];
     248}
     249
     250unsigned JSArrayBufferView::byteLength() const
     251{
     252    return length() * elementSize(type());
    246253}
    247254
     
    270277
    271278    RefPtr<ArrayBuffer> buffer;
    272     unsigned byteLength = m_length * elementSize(type());
     279    unsigned byteLength = this->byteLength();
    273280
    274281    switch (m_mode) {
  • trunk/Source/JavaScriptCore/runtime/JSArrayBufferView.h

    r269343 r269832  
    196196
    197197    unsigned length() const { return m_length; }
     198    unsigned byteLength() const;
    198199
    199200    DECLARE_EXPORT_INFO;
  • trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyHelpers.h

    r269343 r269832  
    8585
    8686    uint8_t* base = arrayBufferView ? static_cast<uint8_t*>(arrayBufferView->vector()) : static_cast<uint8_t*>(arrayBuffer->impl()->data());
    87     size_t byteSize = arrayBufferView ? arrayBufferView->length() : arrayBuffer->impl()->byteLength();
     87    size_t byteSize = arrayBufferView ? arrayBufferView->byteLength() : arrayBuffer->impl()->byteLength();
    8888    return { base, byteSize };
    8989}
Note: See TracChangeset for help on using the changeset viewer.