Changeset 267603 in webkit
- Timestamp:
- Sep 25, 2020, 3:54:55 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
-
JSTests/ChangeLog (modified) (1 diff)
-
JSTests/stress/typedarray-of.js (modified) (1 diff)
-
JSTests/test262/expectations.yaml (modified) (2 diffs)
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/builtins/BuiltinNames.h (modified) (1 diff)
-
Source/JavaScriptCore/builtins/TypedArrayConstructor.js (modified) (5 diffs)
-
Source/JavaScriptCore/runtime/JSGenericTypedArrayViewConstructor.h (modified) (2 diffs)
-
Source/JavaScriptCore/runtime/JSGenericTypedArrayViewConstructorInlines.h (modified) (2 diffs)
-
Source/JavaScriptCore/runtime/JSGlobalObject.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r267564 r267603 1 2020-09-25 Ross Kirsling <ross.kirsling@sony.com> 2 3 %TypedArray%.{from, of} no longer perform AllocateTypedArray 4 https://bugs.webkit.org/show_bug.cgi?id=216991 5 6 Reviewed by Yusuke Suzuki. 7 8 * stress/typedarray-of.js: 9 Fix test. 10 11 * test262/expectations.yaml: 12 Mark twelve test cases as passing. 13 1 14 2020-09-25 Alexey Shvayka <shvaikalesh@gmail.com> 2 15 -
trunk/JSTests/stress/typedarray-of.js
r264304 r267603 15 15 shouldBeTrue("testConstructorFunction('of', '(1,2,3)', [1,2,3])"); 16 16 17 shouldThrow("testConstructorFunction('of', '.call(false)', false)", "'TypeError: TypedArray.of requires its this argument to subclass a TypedArrayconstructor'");18 shouldThrow("testConstructorFunction('of', '.call({})', false)", "'TypeError: TypedArray.of requires its this argument to subclass a TypedArrayconstructor'");19 shouldThrow("testConstructorFunction('of', '.call([])', false)", "'TypeError: TypedArray.of requires its this argument to subclass a TypedArrayconstructor'");17 shouldThrow("testConstructorFunction('of', '.call(false)', false)", "'TypeError: TypedArray.of requires |this| to be a constructor'"); 18 shouldThrow("testConstructorFunction('of', '.call({})', false)", "'TypeError: TypedArray.of requires |this| to be a constructor'"); 19 shouldThrow("testConstructorFunction('of', '.call([])', false)", "'TypeError: TypedArray.of requires |this| to be a constructor'"); 20 20 21 21 finishJSTest(); -
trunk/JSTests/test262/expectations.yaml
r267559 r267603 1312 1312 default: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all (Testing with Float64Array.)' 1313 1313 strict mode: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all (Testing with Float64Array.)' 1314 test/built-ins/TypedArrayConstructors/from/custom-ctor-returns-other-instance.js:1315 default: 'TypeError: TypedArray.from requires its this argument subclass a TypedArray constructor (Testing with Float64Array.)'1316 strict mode: 'TypeError: TypedArray.from requires its this argument subclass a TypedArray constructor (Testing with Float64Array.)'1317 test/built-ins/TypedArrayConstructors/from/custom-ctor.js:1318 default: 'Test262Error: Expected a Test262Error but got a TypeError (Testing with Float64Array.)'1319 strict mode: 'Test262Error: Expected a Test262Error but got a TypeError (Testing with Float64Array.)'1320 test/built-ins/TypedArrayConstructors/from/new-instance-using-custom-ctor.js:1321 default: 'TypeError: TypedArray.from requires its this argument subclass a TypedArray constructor (Testing with Float64Array.)'1322 strict mode: 'TypeError: TypedArray.from requires its this argument subclass a TypedArray constructor (Testing with Float64Array.)'1323 1314 test/built-ins/TypedArrayConstructors/from/set-value-abrupt-completion.js: 1324 1315 default: 'Test262Error: interrupted source iteration Expected SameValue(«1», «[object Object]») to be true (Testing with Float64Array.)' … … 1369 1360 default: 'Test262Error: ToNumber runs before ToInteger(index) Expected a Test262Error to be thrown but no exception was thrown at all (Testing with Float64Array.)' 1370 1361 strict mode: 'Test262Error: ToNumber runs before ToInteger(index) Expected a Test262Error to be thrown but no exception was thrown at all (Testing with Float64Array.)' 1371 test/built-ins/TypedArrayConstructors/of/custom-ctor-returns-other-instance.js:1372 default: 'TypeError: TypedArray.of requires its this argument to subclass a TypedArray constructor (Testing with Float64Array.)'1373 strict mode: 'TypeError: TypedArray.of requires its this argument to subclass a TypedArray constructor (Testing with Float64Array.)'1374 test/built-ins/TypedArrayConstructors/of/custom-ctor.js:1375 default: 'Test262Error: Expected a Test262Error but got a TypeError (Testing with Float64Array.)'1376 strict mode: 'Test262Error: Expected a Test262Error but got a TypeError (Testing with Float64Array.)'1377 test/built-ins/TypedArrayConstructors/of/new-instance-using-custom-ctor.js:1378 default: 'TypeError: TypedArray.of requires its this argument to subclass a TypedArray constructor (Testing with Float64Array.)'1379 strict mode: 'TypeError: TypedArray.of requires its this argument to subclass a TypedArray constructor (Testing with Float64Array.)'1380 1362 test/intl402/DateTimeFormat/prototype/formatRange/en-US.js: 1381 1363 default: 'Test262Error: Expected SameValue(«1/3/2019 – 1/5/2019», «1/3/2019 – 1/5/2019») to be true' -
trunk/Source/JavaScriptCore/ChangeLog
r267594 r267603 1 2020-09-25 Ross Kirsling <ross.kirsling@sony.com> 2 3 %TypedArray%.{from, of} no longer perform AllocateTypedArray 4 https://bugs.webkit.org/show_bug.cgi?id=216991 5 6 Reviewed by Yusuke Suzuki. 7 8 Back in ES2015, %TypedArray%.of and %TypedArray%.from appear to have been based on the abstract operation 9 AllocateTypedArray, which involved crawling the prototype chain to find the appropriate constructor and 10 only permitted `this` to be a (derived) typed array. 11 12 This appears to have gone away as of ES2016 -- we simply expect `this` to be a constructor and verify that it 13 produced a typed array (of sufficient length). 14 15 * builtins/BuiltinNames.h: 16 * builtins/TypedArrayConstructor.js: 17 (of): 18 (from): 19 (allocateInt8Array): Deleted. 20 (allocateInt16Array): Deleted. 21 (allocateInt32Array): Deleted. 22 (allocateUint32Array): Deleted. 23 (allocateUint16Array): Deleted. 24 (allocateUint8Array): Deleted. 25 (allocateUint8ClampedArray): Deleted. 26 (allocateFloat32Array): Deleted. 27 (allocateFloat64Array): Deleted. 28 * runtime/JSGenericTypedArrayViewConstructor.h: 29 * runtime/JSGenericTypedArrayViewConstructorInlines.h: 30 (JSC::JSGenericTypedArrayViewConstructor<ViewClass>::finishCreation): 31 (JSC::JSGenericTypedArrayViewConstructor<ViewClass>::create): 32 * runtime/JSGlobalObject.cpp: 33 (JSC::JSGlobalObject::init): 34 1 35 2020-09-25 Yusuke Suzuki <ysuzuki@apple.com> 2 36 -
trunk/Source/JavaScriptCore/builtins/BuiltinNames.h
r267519 r267603 91 91 macro(set) \ 92 92 macro(shift) \ 93 macro(allocateTypedArray) \94 93 macro(Int8Array) \ 95 94 macro(Int16Array) \ -
trunk/Source/JavaScriptCore/builtins/TypedArrayConstructor.js
r265907 r267603 24 24 */ 25 25 26 // According to the spec we are supposed to crawl the prototype chain looking27 // for the a TypedArray constructor. The way we implement this is with a28 // private function, @alloctateTypedArray, on each of the prototypes.29 // This enables us to optimize this lookup in the inline cache.30 31 26 function of(/* items... */) 32 27 { 33 28 "use strict"; 34 29 var len = arguments.length; 35 var constructFunction = @getByIdDirectPrivate(this, "allocateTypedArray");36 if (constructFunction === @undefined)37 @throwTypeError("TypedArray.of requires its this argument to subclass a TypedArray constructor");38 30 39 var result = constructFunction(len); 31 if (!@isConstructor(this)) 32 @throwTypeError("TypedArray.of requires |this| to be a constructor"); 33 34 var result = new this(len); 35 if (@typedArrayLength(result) < len) 36 @throwTypeError("TypedArray.of constructed typed array of insufficient length"); 40 37 41 38 for (var i = 0; i < len; i++) … … 49 46 "use strict"; 50 47 48 if (!@isConstructor(this)) 49 @throwTypeError("TypedArray.from requires |this| to be a constructor"); 50 51 51 var mapFn = @argument(1); 52 53 52 var thisArg; 54 55 53 if (mapFn !== @undefined) { 56 54 if (!@isCallable(mapFn)) … … 86 84 } 87 85 88 var constructFunction = @getByIdDirectPrivate(this, "allocateTypedArray"); 89 if (constructFunction === @undefined) 90 @throwTypeError("TypedArray.from requires its this argument subclass a TypedArray constructor"); 91 92 var result = constructFunction(k); 86 var result = new this(k); 87 if (@typedArrayLength(result) < k) 88 @throwTypeError("TypedArray.from constructed typed array of insufficient length"); 93 89 94 90 for (var i = 0; i < k; i++) 95 91 result[i] = accumulator[i]; 96 97 92 98 93 return result; … … 101 96 var arrayLikeLength = @toLength(arrayLike.length); 102 97 103 var constructFunction = @getByIdDirectPrivate(this, "allocateTypedArray"); 104 if (constructFunction === @undefined) 105 @throwTypeError("this does not subclass a TypedArray constructor"); 106 107 var result = constructFunction(arrayLikeLength); 98 var result = new this(arrayLikeLength); 99 if (@typedArrayLength(result) < arrayLikeLength) 100 @throwTypeError("TypedArray.from constructed typed array of insufficient length"); 108 101 109 102 var k = 0; … … 119 112 return result; 120 113 } 121 122 function allocateInt8Array(length)123 {124 return new @Int8Array(length);125 }126 127 function allocateInt16Array(length)128 {129 return new @Int16Array(length);130 }131 132 function allocateInt32Array(length)133 {134 return new @Int32Array(length);135 }136 137 function allocateUint32Array(length)138 {139 return new @Uint32Array(length);140 }141 142 function allocateUint16Array(length)143 {144 return new @Uint16Array(length);145 }146 147 function allocateUint8Array(length)148 {149 return new @Uint8Array(length);150 }151 152 function allocateUint8ClampedArray(length)153 {154 return new @Uint8ClampedArray(length);155 }156 157 function allocateFloat32Array(length)158 {159 return new @Float32Array(length);160 }161 162 function allocateFloat64Array(length)163 {164 return new @Float64Array(length);165 } -
trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewConstructor.h
r267594 r267603 58 58 59 59 static JSGenericTypedArrayViewConstructor* create( 60 VM&, JSGlobalObject*, Structure*, JSObject* prototype, const String& name , FunctionExecutable* privateAllocator);60 VM&, JSGlobalObject*, Structure*, JSObject* prototype, const String& name); 61 61 62 62 // FIXME: We should fix the warnings for extern-template in JSObject template classes: https://bugs.webkit.org/show_bug.cgi?id=161979 … … 127 127 private: 128 128 JSGenericTypedArrayViewConstructor(VM&, Structure*); 129 void finishCreation(VM&, JSGlobalObject*, JSObject* prototype, const String& name , FunctionExecutable* privateAllocator);129 void finishCreation(VM&, JSGlobalObject*, JSObject* prototype, const String& name); 130 130 }; 131 131 -
trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewConstructorInlines.h
r267594 r267603 45 45 46 46 template<typename ViewClass> 47 void JSGenericTypedArrayViewConstructor<ViewClass>::finishCreation(VM& vm, JSGlobalObject* globalObject, JSObject* prototype, const String& name, FunctionExecutable* privateAllocator)47 void JSGenericTypedArrayViewConstructor<ViewClass>::finishCreation(VM& vm, JSGlobalObject*, JSObject* prototype, const String& name) 48 48 { 49 49 Base::finishCreation(vm, ViewClass::TypedArrayStorageType == TypeDataView ? 1 : 3, name, PropertyAdditionMode::WithoutStructureTransition); 50 50 putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly); 51 51 putDirectWithoutTransition(vm, vm.propertyNames->BYTES_PER_ELEMENT, jsNumber(ViewClass::elementSize), PropertyAttribute::DontEnum | PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete); 52 53 if (privateAllocator)54 putDirectBuiltinFunction(vm, globalObject, vm.propertyNames->builtinNames().allocateTypedArrayPrivateName(), privateAllocator, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly);55 52 } 56 53 … … 59 56 JSGenericTypedArrayViewConstructor<ViewClass>::create( 60 57 VM& vm, JSGlobalObject* globalObject, Structure* structure, JSObject* prototype, 61 const String& name , FunctionExecutable* privateAllocator)58 const String& name) 62 59 { 63 60 JSGenericTypedArrayViewConstructor* result = 64 61 new (NotNull, allocateCell<JSGenericTypedArrayViewConstructor>(vm.heap)) 65 62 JSGenericTypedArrayViewConstructor(vm, structure); 66 result->finishCreation(vm, globalObject, prototype, name , privateAllocator);63 result->finishCreation(vm, globalObject, prototype, name); 67 64 return result; 68 65 } -
trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp
r267594 r267603 707 707 init.setPrototype(JS ## type ## ArrayPrototype::create(init.vm, init.global, JS ## type ## ArrayPrototype::createStructure(init.vm, init.global, init.global->m_typedArrayProto.get(init.global)))); \ 708 708 init.setStructure(JS ## type ## Array::createStructure(init.vm, init.global, init.prototype)); \ 709 init.setConstructor(JS ## type ## ArrayConstructor::create(init.vm, init.global, JS ## type ## ArrayConstructor::createStructure(init.vm, init.global, init.global->m_typedArraySuperConstructor.get(init.global)), init.prototype, #type "Array"_s , typedArrayConstructorAllocate ## type ## ArrayCodeGenerator(init.vm))); \709 init.setConstructor(JS ## type ## ArrayConstructor::create(init.vm, init.global, JS ## type ## ArrayConstructor::createStructure(init.vm, init.global, init.global->m_typedArraySuperConstructor.get(init.global)), init.prototype, #type "Array"_s)); \ 710 710 init.global->putDirect(init.vm, init.vm.propertyNames->builtinNames().type ## ArrayPrivateName(), init.constructor, static_cast<unsigned>(PropertyAttribute::DontEnum)); \ 711 711 }); … … 717 717 init.setPrototype(JSDataViewPrototype::create(init.vm, JSDataViewPrototype::createStructure(init.vm, init.global, init.global->m_objectPrototype.get()))); 718 718 init.setStructure(JSDataView::createStructure(init.vm, init.global, init.prototype)); 719 init.setConstructor(JSDataViewConstructor::create(init.vm, init.global, JSDataViewConstructor::createStructure(init.vm, init.global, init.global->m_functionPrototype.get()), init.prototype, "DataView"_s , nullptr));719 init.setConstructor(JSDataViewConstructor::create(init.vm, init.global, JSDataViewConstructor::createStructure(init.vm, init.global, init.global->m_functionPrototype.get()), init.prototype, "DataView"_s)); 720 720 }); 721 721
Note:
See TracChangeset
for help on using the changeset viewer.