Changeset 279937 in webkit
- Timestamp:
- Jul 14, 2021 8:11:53 PM (12 months ago)
- Location:
- trunk
- Files:
-
- 8 added
- 10 edited
-
JSTests/ChangeLog (modified) (1 diff)
-
JSTests/stress/typedarray-findLast.js (added)
-
JSTests/stress/typedarray-findLastIndex.js (added)
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/js/array-findLast-expected.txt (added)
-
LayoutTests/js/array-findLast.html (added)
-
LayoutTests/js/array-findLastIndex-expected.txt (added)
-
LayoutTests/js/array-findLastIndex.html (added)
-
LayoutTests/js/script-tests/array-findLast.js (added)
-
LayoutTests/js/script-tests/array-findLastIndex.js (added)
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/builtins/ArrayPrototype.js (modified) (2 diffs)
-
Source/JavaScriptCore/builtins/TypedArrayPrototype.js (modified) (2 diffs)
-
Source/JavaScriptCore/runtime/ArrayPrototype.cpp (modified) (2 diffs)
-
Source/JavaScriptCore/runtime/JSTypedArrayViewPrototype.cpp (modified) (1 diff)
-
Source/JavaScriptCore/runtime/OptionsList.h (modified) (1 diff)
-
Source/WebInspectorUI/ChangeLog (modified) (1 diff)
-
Source/WebInspectorUI/UserInterface/Models/NativeFunctionParameters.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r279923 r279937 1 2021-07-14 Devin Rousso <drousso@apple.com> 2 3 Implement Array.prototype.findLast and Array.prototype.findLastIndex 4 https://bugs.webkit.org/show_bug.cgi?id=227939 5 6 Reviewed by Yusuke Suzuki. 7 8 * stress/typedarray-findLast.js: Added. 9 (keepEven): 10 (keepEvenAndChange): 11 (isBigEnoughAndException): 12 13 * stress/typedarray-findLastIndex.js: Added. 14 (keepEven): 15 (keepEvenAndChange): 16 (isBigEnoughAndException): 17 1 18 2021-07-14 Keith Miller <keith_miller@apple.com> 2 19 -
trunk/LayoutTests/ChangeLog
r279936 r279937 1 2021-07-14 Devin Rousso <drousso@apple.com> 2 3 Implement Array.prototype.findLast and Array.prototype.findLastIndex 4 https://bugs.webkit.org/show_bug.cgi?id=227939 5 6 Reviewed by Yusuke Suzuki. 7 8 * js/array-findLast.html: Added. 9 * js/array-findLast-expected.txt: Added. 10 * js/script-tests/array-findLast.js: Added. 11 (passUndefined): 12 (passZero): 13 (passNull): 14 (passFalse): 15 (passEmptyString): 16 (passEven): 17 (passAfter5): 18 (toObject): 19 (findItemAddedDuringSearch): 20 (numberOfCallbacksInFindInArrayWithHoles): 21 (throwError): 22 23 * js/array-findLastIndex.html: Added. 24 * js/array-findLastIndex-expected.txt: Added. 25 * js/script-tests/array-findLastIndex.js: Added. 26 (passUndefined): 27 (passZero): 28 (passNull): 29 (passFalse): 30 (passEmptyString): 31 (passEven): 32 (passAfter5): 33 (toObject): 34 (findItemAddedDuringSearch): 35 (numberOfCallbacksInFindIndexInArrayWithHoles): 36 (throwError): 37 1 38 2021-07-14 Eric Hutchison <ehutchison@apple.com> 2 39 -
trunk/Source/JavaScriptCore/ChangeLog
r279927 r279937 1 2021-07-14 Devin Rousso <drousso@apple.com> 2 3 Implement Array.prototype.findLast and Array.prototype.findLastIndex 4 https://bugs.webkit.org/show_bug.cgi?id=227939 5 6 Reviewed by Yusuke Suzuki. 7 8 * builtins/ArrayPrototype.js: 9 (findLast): Added. 10 (findLastIndex): Added. 11 (JSC::ArrayPrototype::finishCreation): 12 * runtime/JSTypedArrayViewPrototype.cpp: 13 14 * builtins/TypedArrayPrototype.js: 15 (findLast): Added. 16 (findLastIndex): Added. 17 * runtime/ArrayPrototype.cpp: 18 (JSC::JSTypedArrayViewPrototype::finishCreation): 19 20 * runtime/OptionsList.h: 21 1 22 2021-07-14 Michael Saboff <msaboff@apple.com> 2 23 -
trunk/Source/JavaScriptCore/builtins/ArrayPrototype.js
r273617 r279937 255 255 } 256 256 257 function findLast(callback /*, thisArg */) 258 { 259 "use strict"; 260 261 var array = @toObject(this, "Array.prototype.findLast requires that |this| not be null or undefined"); 262 var length = @toLength(array.length); 263 264 if (!@isCallable(callback)) 265 @throwTypeError("Array.prototype.findLast callback must be a function"); 266 267 var thisArg = @argument(1); 268 for (var i = length - 1; i >= 0; i--) { 269 var element = array[i]; 270 if (callback.@call(thisArg, element, i, array)) 271 return element; 272 } 273 return @undefined; 274 } 275 257 276 function findIndex(callback /*, thisArg */) 258 277 { … … 267 286 var thisArg = @argument(1); 268 287 for (var i = 0; i < length; i++) { 288 if (callback.@call(thisArg, array[i], i, array)) 289 return i; 290 } 291 return -1; 292 } 293 294 function findLastIndex(callback /*, thisArg */) 295 { 296 "use strict"; 297 298 var array = @toObject(this, "Array.prototype.findLastIndex requires that |this| not be null or undefined"); 299 var length = @toLength(array.length); 300 301 if (!@isCallable(callback)) 302 @throwTypeError("Array.prototype.findLastIndex callback must be a function"); 303 304 var thisArg = @argument(1); 305 for (var i = length - 1; i >= 0; i--) { 269 306 if (callback.@call(thisArg, array[i], i, array)) 270 307 return i; -
trunk/Source/JavaScriptCore/builtins/TypedArrayPrototype.js
r276612 r279937 87 87 } 88 88 89 function findLast(callback /* [, thisArg] */) 90 { 91 "use strict"; 92 var length = @typedArrayLength(this); 93 var thisArg = @argument(1); 94 95 if (!@isCallable(callback)) 96 @throwTypeError("TypedArray.prototype.findLast callback must be a function"); 97 98 for (var i = length - 1; i >= 0; i--) { 99 var element = this[i]; 100 if (callback.@call(thisArg, element, i, this)) 101 return element; 102 } 103 return @undefined; 104 } 105 89 106 function findIndex(callback /* [, thisArg] */) 90 107 { … … 97 114 98 115 for (var i = 0; i < length; i++) { 116 if (callback.@call(thisArg, this[i], i, this)) 117 return i; 118 } 119 return -1; 120 } 121 122 function findLastIndex(callback /* [, thisArg] */) 123 { 124 "use strict"; 125 var length = @typedArrayLength(this); 126 var thisArg = @argument(1); 127 128 if (!@isCallable(callback)) 129 @throwTypeError("TypedArray.prototype.findLastIndex callback must be a function"); 130 131 for (var i = length - 1; i >= 0; i--) { 99 132 if (callback.@call(thisArg, this[i], i, this)) 100 133 return i; -
trunk/Source/JavaScriptCore/runtime/ArrayPrototype.cpp
r278338 r279937 109 109 JSC_NATIVE_INTRINSIC_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().entriesPublicName(), arrayProtoFuncEntries, static_cast<unsigned>(PropertyAttribute::DontEnum), 0, ArrayEntriesIntrinsic); 110 110 JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().findPublicName(), arrayPrototypeFindCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum)); 111 if (Options::useArrayFindLastMethod()) 112 JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().findLastPublicName(), arrayPrototypeFindLastCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum)); 111 113 JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().findIndexPublicName(), arrayPrototypeFindIndexCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum)); 114 if (Options::useArrayFindLastMethod()) 115 JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().findLastIndexPublicName(), arrayPrototypeFindLastIndexCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum)); 112 116 JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().includesPublicName(), arrayPrototypeIncludesCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum)); 113 117 JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().copyWithinPublicName(), arrayPrototypeCopyWithinCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum)); … … 135 139 &vm.propertyNames->builtinNames().valuesPublicName() 136 140 }; 141 if (Options::useArrayFindLastMethod()) { 142 unscopables->putDirect(vm, vm.propertyNames->builtinNames().findLastPublicName(), jsBoolean(true)); 143 unscopables->putDirect(vm, vm.propertyNames->builtinNames().findLastIndexPublicName(), jsBoolean(true)); 144 } 137 145 if (Options::useAtMethod()) 138 146 unscopables->putDirect(vm, vm.propertyNames->builtinNames().atPublicName(), jsBoolean(true)); -
trunk/Source/JavaScriptCore/runtime/JSTypedArrayViewPrototype.cpp
r276719 r279937 454 454 JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().fillPublicName(), typedArrayViewProtoFuncFill, static_cast<unsigned>(PropertyAttribute::DontEnum), 1); 455 455 JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION("find", typedArrayPrototypeFindCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum)); 456 if (Options::useArrayFindLastMethod()) 457 JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().findLastPublicName(), typedArrayPrototypeFindLastCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum)); 456 458 JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION("findIndex", typedArrayPrototypeFindIndexCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum)); 459 if (Options::useArrayFindLastMethod()) 460 JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().findLastIndexPublicName(), typedArrayPrototypeFindLastIndexCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum)); 457 461 JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->forEach, typedArrayPrototypeForEachCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum)); 458 462 JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("indexOf", typedArrayViewProtoFuncIndexOf, static_cast<unsigned>(PropertyAttribute::DontEnum), 1); -
trunk/Source/JavaScriptCore/runtime/OptionsList.h
r279630 r279937 551 551 v(Bool, useDataICSharing, false, Normal, nullptr) \ 552 552 v(Bool, useTemporal, false, Normal, "Expose the Temporal object.") \ 553 v(Bool, useArrayFindLastMethod, false, Normal, "Expose the findLast() and findLastIndex() methods on Array and %TypedArray%.") \ 553 554 554 555 -
trunk/Source/WebInspectorUI/ChangeLog
r279862 r279937 1 2021-07-14 Devin Rousso <drousso@apple.com> 2 3 Implement Array.prototype.findLast and Array.prototype.findLastIndex 4 https://bugs.webkit.org/show_bug.cgi?id=227939 5 6 Reviewed by Yusuke Suzuki. 7 8 * UserInterface/Models/NativeFunctionParameters.js: 9 1 10 2021-07-12 Patrick Angle <pangle@apple.com> 2 11 -
trunk/Source/WebInspectorUI/UserInterface/Models/NativeFunctionParameters.js
r277547 r279937 250 250 find: "callback, [thisArg]", 251 251 findIndex: "callback, [thisArg]", 252 findLast: "callback, [thisArg]", 253 findLastIndex: "callback, [thisArg]", 252 254 forEach: "callback, [thisArg]", 253 255 includes: "searchValue, [startIndex=0]",
Note: See TracChangeset
for help on using the changeset viewer.