Changeset 203937 in webkit


Ignore:
Timestamp:
Jul 29, 2016, 7:02:48 PM (9 years ago)
Author:
keith_miller@apple.com
Message:

TypedArray super constructor has some incompatabilities
https://bugs.webkit.org/show_bug.cgi?id=160369

Reviewed by Filip Pizlo.

This patch fixes the length proprety of the TypedArray super constructor.
Additionally, the TypedArray super constructor should no longer be callable.

Also, this patch fixes the expected result of some test262 tests.

  • runtime/JSTypedArrayViewConstructor.cpp:

(JSC::JSTypedArrayViewConstructor::finishCreation):
(JSC::constructTypedArrayView):
(JSC::JSTypedArrayViewConstructor::getCallData):

  • tests/test262.yaml:
Location:
trunk/Source/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r203925 r203937  
     12016-07-29  Keith Miller  <keith_miller@apple.com>
     2
     3        TypedArray super constructor has some incompatabilities
     4        https://bugs.webkit.org/show_bug.cgi?id=160369
     5
     6        Reviewed by Filip Pizlo.
     7
     8        This patch fixes the length proprety of the TypedArray super constructor.
     9        Additionally, the TypedArray super constructor should no longer be callable.
     10
     11        Also, this patch fixes the expected result of some test262 tests.
     12
     13        * runtime/JSTypedArrayViewConstructor.cpp:
     14        (JSC::JSTypedArrayViewConstructor::finishCreation):
     15        (JSC::constructTypedArrayView):
     16        (JSC::JSTypedArrayViewConstructor::getCallData):
     17        * tests/test262.yaml:
     18
    1192016-07-29  Jonathan Bedard  <jbedard@apple.com>
    220
  • trunk/Source/JavaScriptCore/runtime/JSTypedArrayViewConstructor.cpp

    r202890 r203937  
    5050    Base::finishCreation(vm, "TypedArray");
    5151    putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, DontEnum | DontDelete | ReadOnly);
    52     putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(3), DontEnum | DontDelete | ReadOnly);
     52    putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(0), DontEnum | ReadOnly);
    5353    putDirectNonIndexAccessor(vm, vm.propertyNames->speciesSymbol, speciesSymbol, Accessor | ReadOnly | DontEnum);
    5454
     
    6464
    6565
    66 // The only way we can call this function is through Reflect.construct or if they mucked with the TypedArray prototype chain.
    67 // In either case we are ok with this being slow.
     66
    6867static EncodedJSValue JSC_HOST_CALL constructTypedArrayView(ExecState* exec)
    6968{
    70     JSValue value = exec->newTarget();
    71 
    72     JSObject* object = jsDynamicCast<JSObject*>(value);
    73     if (!object)
    74         return JSValue::encode(throwTypeError(exec, ASCIILiteral("new.target passed to TypedArray is not an object.")));
    75 
    76     ConstructData data;
    77     if (object->methodTable()->getConstructData(object, data) == ConstructType::None)
    78         return JSValue::encode(throwTypeError(exec, ASCIILiteral("new.target passed to TypedArray is not a valid constructor.")));
    79 
    80     for (; !value.isNull(); value = jsCast<JSObject*>(value)->getPrototypeDirect()) {
    81         if (jsDynamicCast<JSTypedArrayViewConstructor*>(value))
    82             return JSValue::encode(throwTypeError(exec, ASCIILiteral("Unable to find TypedArray constructor that inherits from TypedArray.")));
    83         if (jsDynamicCast<JSGenericTypedArrayViewConstructor<JSInt8Array>*>(value))
    84             return constructGenericTypedArrayView<JSInt8Array>(exec);
    85         if (jsDynamicCast<JSGenericTypedArrayViewConstructor<JSInt16Array>*>(value))
    86             return constructGenericTypedArrayView<JSInt16Array>(exec);
    87         if (jsDynamicCast<JSGenericTypedArrayViewConstructor<JSInt32Array>*>(value))
    88             return constructGenericTypedArrayView<JSInt32Array>(exec);
    89         if (jsDynamicCast<JSGenericTypedArrayViewConstructor<JSUint8Array>*>(value))
    90             return constructGenericTypedArrayView<JSUint8Array>(exec);
    91         if (jsDynamicCast<JSGenericTypedArrayViewConstructor<JSUint16Array>*>(value))
    92             return constructGenericTypedArrayView<JSUint16Array>(exec);
    93         if (jsDynamicCast<JSGenericTypedArrayViewConstructor<JSUint32Array>*>(value))
    94             return constructGenericTypedArrayView<JSUint32Array>(exec);
    95         if (jsDynamicCast<JSGenericTypedArrayViewConstructor<JSUint8ClampedArray>*>(value))
    96             return constructGenericTypedArrayView<JSUint8ClampedArray>(exec);
    97         if (jsDynamicCast<JSGenericTypedArrayViewConstructor<JSFloat32Array>*>(value))
    98             return constructGenericTypedArrayView<JSFloat32Array>(exec);
    99         if (jsDynamicCast<JSGenericTypedArrayViewConstructor<JSFloat64Array>*>(value))
    100             return constructGenericTypedArrayView<JSFloat64Array>(exec);
    101     }
    102    
    103     return JSValue::encode(throwTypeError(exec, ASCIILiteral("Unable to find TypedArray constructor in prototype-chain, hit null.")));
     69    return throwVMTypeError(exec, ASCIILiteral("%TypedArray% should not be called directly"));
    10470}
    10571
     
    11278CallType JSTypedArrayViewConstructor::getCallData(JSCell*, CallData& callData)
    11379{
    114     callData.native.function = nullptr;
    115     return CallType::None;
     80    callData.native.function = constructTypedArrayView;
     81    return CallType::Host;
    11682}
    11783
  • trunk/Source/JavaScriptCore/tests/test262.yaml

    r203499 r203937  
    4525745257  cmd: runTest262 :normal, "NoException", ["../../../harness/assert.js", "../../../harness/sta.js", "../../../harness/testTypedArray.js"], [:strict]
    4525845258- path: test262/test/built-ins/TypedArray/length.js
    45259   cmd: runTest262 :fail, "NoException", ["../../../harness/assert.js", "../../../harness/sta.js", "../../../harness/propertyHelper.js", "../../../harness/testTypedArray.js"], []
     45259  cmd: runTest262 :normal, "NoException", ["../../../harness/assert.js", "../../../harness/sta.js", "../../../harness/propertyHelper.js", "../../../harness/testTypedArray.js"], []
    4526045260- path: test262/test/built-ins/TypedArray/length.js
    45261   cmd: runTest262 :fail, "NoException", ["../../../harness/assert.js", "../../../harness/sta.js", "../../../harness/propertyHelper.js", "../../../harness/testTypedArray.js"], [:strict]
     45261  cmd: runTest262 :normal, "NoException", ["../../../harness/assert.js", "../../../harness/sta.js", "../../../harness/propertyHelper.js", "../../../harness/testTypedArray.js"], [:strict]
    4526245262- path: test262/test/built-ins/TypedArray/name.js
    4526345263  cmd: runTest262 :normal, "NoException", ["../../../harness/assert.js", "../../../harness/sta.js", "../../../harness/propertyHelper.js", "../../../harness/testTypedArray.js"], []
     
    4631346313  cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js", "../../../../../harness/testTypedArray.js"], [:strict]
    4631446314- path: test262/test/built-ins/TypedArray/prototype/indexOf/strict-comparison.js
    46315   cmd: runTest262 :fail, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js", "../../../../../harness/testTypedArray.js"], []
     46315  cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js", "../../../../../harness/testTypedArray.js"], []
    4631646316- path: test262/test/built-ins/TypedArray/prototype/indexOf/strict-comparison.js
    46317   cmd: runTest262 :fail, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js", "../../../../../harness/testTypedArray.js"], [:strict]
     46317  cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js", "../../../../../harness/testTypedArray.js"], [:strict]
    4631846318- path: test262/test/built-ins/TypedArray/prototype/indexOf/this-is-not-object.js
    4631946319  cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js", "../../../../../harness/testTypedArray.js"], []
     
    4648946489  cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js", "../../../../../harness/testTypedArray.js"], [:strict]
    4649046490- path: test262/test/built-ins/TypedArray/prototype/lastIndexOf/strict-comparison.js
    46491   cmd: runTest262 :fail, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js", "../../../../../harness/testTypedArray.js"], []
     46491  cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js", "../../../../../harness/testTypedArray.js"], []
    4649246492- path: test262/test/built-ins/TypedArray/prototype/lastIndexOf/strict-comparison.js
    46493   cmd: runTest262 :fail, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js", "../../../../../harness/testTypedArray.js"], [:strict]
     46493  cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js", "../../../../../harness/testTypedArray.js"], [:strict]
    4649446494- path: test262/test/built-ins/TypedArray/prototype/lastIndexOf/this-is-not-object.js
    4649546495  cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js", "../../../../../harness/testTypedArray.js"], []
Note: See TracChangeset for help on using the changeset viewer.