Changeset 270371 in webkit


Ignore:
Timestamp:
Dec 2, 2020 2:57:13 PM (20 months ago)
Author:
Ross Kirsling
Message:

%TypedArray%#slice shouldn't care about source buffer detachment if there's nothing to copy
https://bugs.webkit.org/show_bug.cgi?id=219451

Reviewed by Yusuke Suzuki.

JSTests:

  • test262/expectations.yaml:

Mark four test cases as passing.

Source/JavaScriptCore:

From https://tc39.es/ecma262/#sec-%typedarray%.prototype.slice:

  1. Let A be ? TypedArraySpeciesCreate(O, « 𝔽(count) »).
  2. If count > 0, then
    1. If IsDetachedBuffer(O.ViewedArrayBuffer?) is true, throw a TypeError exception. ...
  3. Return A.

We had step 14.a raised above 14; this patch fixes the ordering.

  • runtime/JSGenericTypedArrayViewPrototypeFunctions.h:

(JSC::genericTypedArrayViewProtoFuncSlice):

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r270344 r270371  
     12020-12-02  Ross Kirsling  <ross.kirsling@sony.com>
     2
     3        %TypedArray%#slice shouldn't care about source buffer detachment if there's nothing to copy
     4        https://bugs.webkit.org/show_bug.cgi?id=219451
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        * test262/expectations.yaml:
     9        Mark four test cases as passing.
     10
    1112020-12-02  Dmitry Bezhetskov  <dbezhetskov@igalia.com>
    212
  • trunk/JSTests/test262/expectations.yaml

    r270005 r270371  
    833833  default: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all (Testing with Float64Array.)'
    834834  strict mode: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all (Testing with Float64Array.)'
    835 test/built-ins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-other-targettype.js:
    836   default: 'TypeError: Underlying ArrayBuffer has been detached from the view (Testing with Float64Array.)'
    837   strict mode: 'TypeError: Underlying ArrayBuffer has been detached from the view (Testing with Float64Array.)'
    838 test/built-ins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-same-targettype.js:
    839   default: 'TypeError: Underlying ArrayBuffer has been detached from the view (Testing with Float64Array.)'
    840   strict mode: 'TypeError: Underlying ArrayBuffer has been detached from the view (Testing with Float64Array.)'
    841835test/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-to-number-detachbuffer.js:
    842836  default: 'Test262Error: Expected a TypeError but got a RangeError (Testing with Float64Array.)'
  • trunk/Source/JavaScriptCore/ChangeLog

    r270344 r270371  
     12020-12-02  Ross Kirsling  <ross.kirsling@sony.com>
     2
     3        %TypedArray%#slice shouldn't care about source buffer detachment if there's nothing to copy
     4        https://bugs.webkit.org/show_bug.cgi?id=219451
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        From https://tc39.es/ecma262/#sec-%typedarray%.prototype.slice:
     9          13. Let A be ? TypedArraySpeciesCreate(O, « 𝔽(count) »).
     10          14. If count > 0, then
     11            a. If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
     12            ...
     13          15. Return A.
     14
     15        We had step 14.a raised above 14; this patch fixes the ordering.
     16
     17        * runtime/JSGenericTypedArrayViewPrototypeFunctions.h:
     18        (JSC::genericTypedArrayViewProtoFuncSlice):
     19
    1202020-12-02  Dmitry Bezhetskov  <dbezhetskov@igalia.com>
    221
  • trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewPrototypeFunctions.h

    r269670 r270371  
    453453    });
    454454    RETURN_IF_EXCEPTION(scope, encodedJSValue());
    455 
    456455    ASSERT(!result->isDetached());
    457     if (thisObject->isDetached())
    458         return throwVMTypeError(globalObject, scope, typedArrayBufferHasBeenDetachedErrorMessage);
    459456
    460457    // We return early here since we don't allocate a backing store if length is 0 and memmove does not like nullptrs
    461458    if (!length)
    462459        return JSValue::encode(result);
     460
     461    if (thisObject->isDetached())
     462        return throwVMTypeError(globalObject, scope, typedArrayBufferHasBeenDetachedErrorMessage);
    463463
    464464    // The species constructor may return an array with any arbitrary length.
Note: See TracChangeset for help on using the changeset viewer.