Changeset 268760 in webkit
- Timestamp:
- Oct 20, 2020, 2:23:53 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 15 edited
- 1 moved
-
JSTests/ChangeLog (modified) (1 diff)
-
JSTests/stress/at-method.js (moved) (moved from trunk/JSTests/stress/item-method.js ) (2 diffs)
-
JSTests/stress/unscopables.js (modified) (2 diffs)
-
JSTests/test262/config.yaml (modified) (1 diff)
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/inspector/model/remote-object-get-properties-expected.txt (modified) (4 diffs)
-
LayoutTests/js/Object-getOwnPropertyNames-expected.txt (modified) (1 diff)
-
LayoutTests/js/array-unscopables-properties-expected.txt (modified) (1 diff)
-
LayoutTests/js/script-tests/Object-getOwnPropertyNames.js (modified) (1 diff)
-
LayoutTests/js/script-tests/array-unscopables-properties.js (modified) (1 diff)
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/builtins/ArrayPrototype.js (modified) (1 diff)
-
Source/JavaScriptCore/builtins/TypedArrayPrototype.js (modified) (1 diff)
-
Source/JavaScriptCore/runtime/ArrayPrototype.cpp (modified) (2 diffs)
-
Source/JavaScriptCore/runtime/JSTypedArrayViewPrototype.cpp (modified) (1 diff)
-
Source/JavaScriptCore/runtime/OptionsList.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r268710 r268760 1 2020-10-20 Ross Kirsling <ross.kirsling@sony.com> 2 3 [JSC] Rename item() to at() and move it behind a flag 4 https://bugs.webkit.org/show_bug.cgi?id=217942 5 6 Reviewed by Yusuke Suzuki. 7 8 * stress/at-method.js: Renamed from JSTests/stress/item-method.js. 9 * test262/config.yaml: Add skips until the feature is renamed. 10 1 11 2020-10-19 Alexey Shvayka <shvaikalesh@gmail.com> 2 12 -
trunk/JSTests/stress/at-method.js
r268759 r268760 1 //@ requireOptions("--useAtMethod=1") 2 1 3 function shouldBe(actual, expected) { 2 4 if (actual !== expected) … … 16 18 } 17 19 18 shouldBe(Array.prototype. item.length, 1);19 shouldThrowTypeError(() => Array.prototype. item.call(undefined));20 shouldThrowTypeError(() => Array.prototype. item.call(null));20 shouldBe(Array.prototype.at.length, 1); 21 shouldThrowTypeError(() => Array.prototype.at.call(undefined)); 22 shouldThrowTypeError(() => Array.prototype.at.call(null)); 21 23 22 24 const array = [42, 'b', true]; 23 25 // intentionally go one too far to ensure that we get undefined instead of wrapping 24 26 for (let i = 0; i <= array.length; i++) { 25 shouldBe(array. item(i), array[i]);26 shouldBe(array. item(-i - 1), array[array.length - i - 1]);27 shouldBe(array.at(i), array[i]); 28 shouldBe(array.at(-i - 1), array[array.length - i - 1]); 27 29 } 28 shouldBe(array. item(), array[0]);29 shouldBe(array. item(null), array[0]);30 shouldBe(array. item({ valueOf: () => -1 }), array[array.length - 1]);30 shouldBe(array.at(), array[0]); 31 shouldBe(array.at(null), array[0]); 32 shouldBe(array.at({ valueOf: () => -1 }), array[array.length - 1]); 31 33 32 34 const weirdArrayLike = { length: 1, get '0'() { return 3; }, get '1'() { throw 'oops'; } }; 33 shouldBe(Array.prototype. item.call(weirdArrayLike, 0), 3);34 shouldBe(Array.prototype. item.call(weirdArrayLike, 1), undefined);35 shouldBe(Array.prototype.at.call(weirdArrayLike, 0), 3); 36 shouldBe(Array.prototype.at.call(weirdArrayLike, 1), undefined); 35 37 36 38 for (const TA of [Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array]) { 37 shouldBe(TA.prototype. item.length, 1);38 shouldThrowTypeError(() => TA.prototype. item.call([]));39 shouldBe(TA.prototype.at.length, 1); 40 shouldThrowTypeError(() => TA.prototype.at.call([])); 39 41 40 42 const ta = [1, 2, 3]; 41 43 // intentionally go one too far to ensure that we get undefined instead of wrapping 42 44 for (let i = 0; i <= ta.length; i++) { 43 shouldBe(ta. item(i), ta[i]);44 shouldBe(ta. item(-i - 1), ta[ta.length - i - 1]);45 shouldBe(ta.at(i), ta[i]); 46 shouldBe(ta.at(-i - 1), ta[ta.length - i - 1]); 45 47 } 46 shouldBe(ta. item(), ta[0]);47 shouldBe(ta. item(null), ta[0]);48 shouldBe(ta. item({ valueOf: () => -1 }), ta[ta.length - 1]);48 shouldBe(ta.at(), ta[0]); 49 shouldBe(ta.at(null), ta[0]); 50 shouldBe(ta.at({ valueOf: () => -1 }), ta[ta.length - 1]); 49 51 } -
trunk/JSTests/stress/unscopables.js
r267912 r268760 1 //@ requireOptions("--useAtMethod=1") 2 1 3 function test(actual, expected) { 2 4 if (actual !== expected) … … 10 12 test(typeof unscopables, "object"); 11 13 test(unscopables.__proto__, undefined); 12 test(String(Object.keys(unscopables).sort()), " copyWithin,entries,fill,find,findIndex,flat,flatMap,includes,item,keys,values");14 test(String(Object.keys(unscopables).sort()), "at,copyWithin,entries,fill,find,findIndex,flat,flatMap,includes,keys,values"); 13 15 }()); 14 16 -
trunk/JSTests/test262/config.yaml
r268501 r268760 27 27 - top-level-await 28 28 - Intl.ListFormat 29 30 # remove once it's been renamed in test262 31 - Array.prototype.item 32 - TypedArray.prototype.item 29 33 30 34 # remove once it's no longer in test262 -
trunk/LayoutTests/ChangeLog
r268759 r268760 1 2020-10-20 Ross Kirsling <ross.kirsling@sony.com> 2 3 [JSC] Rename item() to at() and move it behind a flag 4 https://bugs.webkit.org/show_bug.cgi?id=217942 5 6 Reviewed by Yusuke Suzuki. 7 8 * inspector/model/remote-object-get-properties-expected.txt: 9 * js/array-unscopables-properties-expected.txt: 10 * js/Object-getOwnPropertyNames-expected.txt: 11 * js/script-tests/Object-getOwnPropertyNames.js: 12 * js/script-tests/array-unscopables-properties.js: 13 1 14 2020-10-20 Diego Pino Garcia <dpino@igalia.com> 2 15 -
trunk/LayoutTests/inspector/model/remote-object-get-properties-expected.txt
r267814 r268760 86 86 includes 87 87 copyWithin 88 item89 88 constructor 90 89 Symbol(Symbol.iterator) … … 140 139 includes 141 140 copyWithin 142 item143 141 constructor 144 142 Symbol(Symbol.iterator) … … 179 177 includes 180 178 copyWithin 181 item182 179 constructor 183 180 Symbol(Symbol.iterator) … … 218 215 includes 219 216 copyWithin 220 item221 217 constructor 222 218 Symbol(Symbol.iterator) -
trunk/LayoutTests/js/Object-getOwnPropertyNames-expected.txt
r268165 r268760 48 48 PASS getSortedOwnPropertyNames(Function.prototype) is ['apply', 'arguments', 'bind', 'call', 'caller', 'constructor', 'length', 'name', 'toString'] 49 49 PASS getSortedOwnPropertyNames(Array) is ['from', 'isArray', 'length', 'name', 'of', 'prototype'] 50 PASS getSortedOwnPropertyNames(Array.prototype) is ['concat', 'constructor', 'copyWithin', 'entries', 'every', 'fill', 'filter', 'find', 'findIndex', 'flat', 'flatMap', 'forEach', 'includes', 'indexOf', ' item', 'join', 'keys', 'lastIndexOf', 'length', 'map', 'pop', 'push', 'reduce', 'reduceRight', 'reverse', 'shift', 'slice', 'some', 'sort', 'splice', 'toLocaleString', 'toString', 'unshift', 'values']50 PASS getSortedOwnPropertyNames(Array.prototype) is ['concat', 'constructor', 'copyWithin', 'entries', 'every', 'fill', 'filter', 'find', 'findIndex', 'flat', 'flatMap', 'forEach', 'includes', 'indexOf', 'join', 'keys', 'lastIndexOf', 'length', 'map', 'pop', 'push', 'reduce', 'reduceRight', 'reverse', 'shift', 'slice', 'some', 'sort', 'splice', 'toLocaleString', 'toString', 'unshift', 'values'] 51 51 PASS getSortedOwnPropertyNames(String) is ['fromCharCode', 'fromCodePoint', 'length', 'name', 'prototype', 'raw'] 52 52 PASS getSortedOwnPropertyNames(String.prototype) is ['anchor', 'big', 'blink', 'bold', 'charAt', 'charCodeAt', 'codePointAt', 'concat', 'constructor', 'endsWith', 'fixed', 'fontcolor', 'fontsize', 'includes', 'indexOf', 'italics', 'lastIndexOf', 'length', 'link', 'localeCompare', 'match', 'matchAll', 'normalize', 'padEnd', 'padStart', 'repeat', 'replace', 'replaceAll', 'search', 'slice', 'small', 'split', 'startsWith', 'strike', 'sub', 'substr', 'substring', 'sup', 'toLocaleLowerCase', 'toLocaleUpperCase', 'toLowerCase', 'toString', 'toUpperCase', 'trim', 'trimEnd', 'trimLeft', 'trimRight', 'trimStart', 'valueOf'] -
trunk/LayoutTests/js/array-unscopables-properties-expected.txt
r267912 r268760 43 43 PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "includes").enumerable is true 44 44 PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "includes").configurable is true 45 PASS Array.prototype[Symbol.unscopables]["item"] is true46 PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "item").writable is true47 PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "item").enumerable is true48 PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "item").configurable is true49 45 PASS Array.prototype[Symbol.unscopables]["keys"] is true 50 46 PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "keys").writable is true -
trunk/LayoutTests/js/script-tests/Object-getOwnPropertyNames.js
r268165 r268760 57 57 "Function.prototype": "['apply', 'arguments', 'bind', 'call', 'caller', 'constructor', 'length', 'name', 'toString']", 58 58 "Array": "['from', 'isArray', 'length', 'name', 'of', 'prototype']", 59 "Array.prototype": "['concat', 'constructor', 'copyWithin', 'entries', 'every', 'fill', 'filter', 'find', 'findIndex', 'flat', 'flatMap', 'forEach', 'includes', 'indexOf', ' item', 'join', 'keys', 'lastIndexOf', 'length', 'map', 'pop', 'push', 'reduce', 'reduceRight', 'reverse', 'shift', 'slice', 'some', 'sort', 'splice', 'toLocaleString', 'toString', 'unshift', 'values']",59 "Array.prototype": "['concat', 'constructor', 'copyWithin', 'entries', 'every', 'fill', 'filter', 'find', 'findIndex', 'flat', 'flatMap', 'forEach', 'includes', 'indexOf', 'join', 'keys', 'lastIndexOf', 'length', 'map', 'pop', 'push', 'reduce', 'reduceRight', 'reverse', 'shift', 'slice', 'some', 'sort', 'splice', 'toLocaleString', 'toString', 'unshift', 'values']", 60 60 "String": "['fromCharCode', 'fromCodePoint', 'length', 'name', 'prototype', 'raw']", 61 61 "String.prototype": "['anchor', 'big', 'blink', 'bold', 'charAt', 'charCodeAt', 'codePointAt', 'concat', 'constructor', 'endsWith', 'fixed', 'fontcolor', 'fontsize', 'includes', 'indexOf', 'italics', 'lastIndexOf', 'length', 'link', 'localeCompare', 'match', 'matchAll', 'normalize', 'padEnd', 'padStart', 'repeat', 'replace', 'replaceAll', 'search', 'slice', 'small', 'split', 'startsWith', 'strike', 'sub', 'substr', 'substring', 'sup', 'toLocaleLowerCase', 'toLocaleUpperCase', 'toLowerCase', 'toString', 'toUpperCase', 'trim', 'trimEnd', 'trimLeft', 'trimRight', 'trimStart', 'valueOf']", -
trunk/LayoutTests/js/script-tests/array-unscopables-properties.js
r267912 r268760 16 16 "flatMap", 17 17 "includes", 18 "item",19 18 "keys", 20 19 "values" -
trunk/Source/JavaScriptCore/ChangeLog
r268716 r268760 1 2020-10-20 Ross Kirsling <ross.kirsling@sony.com> 2 3 [JSC] Rename item() to at() and move it behind a flag 4 https://bugs.webkit.org/show_bug.cgi?id=217942 5 6 Reviewed by Yusuke Suzuki. 7 8 {Array, %TypedArray%}.prototype.item is official web-incompatible, 9 but it is expected to be renamed to `at` instead of being scrapped entirely: 10 https://github.com/tc39/proposal-item-method/issues/34 11 12 This patch performs the renaming, but does so behind a runtime flag since this has yet to achieve consensus. 13 14 * builtins/ArrayPrototype.js: 15 (at): 16 (item): Deleted. 17 * builtins/TypedArrayPrototype.js: 18 (at): 19 (item): Deleted. 20 * runtime/ArrayPrototype.cpp: 21 (JSC::ArrayPrototype::finishCreation): 22 * runtime/JSTypedArrayViewPrototype.cpp: 23 (JSC::JSTypedArrayViewPrototype::finishCreation): 24 * runtime/OptionsList.h: 25 1 26 2020-10-20 Philippe Normand <pnormand@igalia.com> and Pavel Feldman <pavel.feldman@gmail.com> 2 27 -
trunk/Source/JavaScriptCore/builtins/ArrayPrototype.js
r268715 r268760 688 688 } 689 689 690 function item(index)691 { 692 "use strict"; 693 694 var array = @toObject(this, "Array.prototype. itemrequires that |this| not be null or undefined");690 function at(index) 691 { 692 "use strict"; 693 694 var array = @toObject(this, "Array.prototype.at requires that |this| not be null or undefined"); 695 695 var length = @toLength(array.length); 696 696 -
trunk/Source/JavaScriptCore/builtins/TypedArrayPrototype.js
r268715 r268760 386 386 } 387 387 388 function item(index)388 function at(index) 389 389 { 390 390 "use strict"; -
trunk/Source/JavaScriptCore/runtime/ArrayPrototype.cpp
r268489 r268760 111 111 JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().includesPublicName(), arrayPrototypeIncludesCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum)); 112 112 JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().copyWithinPublicName(), arrayPrototypeCopyWithinCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum)); 113 JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().itemPublicName(), arrayPrototypeItemCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum)); 113 114 if (Options::useAtMethod()) 115 JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().atPublicName(), arrayPrototypeAtCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum)); 114 116 115 117 putDirectWithoutTransition(vm, vm.propertyNames->builtinNames().entriesPrivateName(), getDirect(vm, vm.propertyNames->builtinNames().entriesPublicName()), static_cast<unsigned>(PropertyAttribute::ReadOnly)); … … 129 131 &vm.propertyNames->builtinNames().flatMapPublicName(), 130 132 &vm.propertyNames->builtinNames().includesPublicName(), 131 &vm.propertyNames->builtinNames().itemPublicName(),132 133 &vm.propertyNames->builtinNames().keysPublicName(), 133 134 &vm.propertyNames->builtinNames().valuesPublicName() 134 135 }; 136 if (Options::useAtMethod()) 137 unscopables->putDirect(vm, vm.propertyNames->builtinNames().atPublicName(), jsBoolean(true)); 135 138 for (const auto* unscopableName : unscopableNames) 136 139 unscopables->putDirect(vm, *unscopableName, jsBoolean(true)); -
trunk/Source/JavaScriptCore/runtime/JSTypedArrayViewPrototype.cpp
r267814 r268760 376 376 JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->subarray, typedArrayPrototypeSubarrayCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum)); 377 377 JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->toLocaleString, typedArrayPrototypeToLocaleStringCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum)); 378 JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().itemPublicName(), typedArrayPrototypeItemCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum)); 378 379 if (Options::useAtMethod()) 380 JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().atPublicName(), typedArrayPrototypeAtCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum)); 379 381 380 382 JSFunction* toStringTagFunction = JSFunction::create(vm, globalObject, 0, "get [Symbol.toStringTag]"_s, typedArrayViewProtoGetterFuncToStringTag, NoIntrinsic); -
trunk/Source/JavaScriptCore/runtime/OptionsList.h
r268284 r268760 492 492 v(Bool, useWeakRefs, true, Normal, "Expose the WeakRef constructor.") \ 493 493 v(Bool, useIntlDateTimeFormatDayPeriod, true, Normal, "Expose the Intl.DateTimeFormat dayPeriod feature.") \ 494 v(Bool, useAtMethod, false, Normal, "Expose the at() method on Array and %TypedArray%.") \ 494 495 v(Bool, useArrayAllocationProfiling, true, Normal, "If true, we will use our normal array allocation profiling. If false, the allocation profile will always claim to be undecided.") \ 495 496 v(Bool, forcePolyProto, false, Normal, "If true, create_this will always create an object with a poly proto structure.") \
Note:
See TracChangeset
for help on using the changeset viewer.