Title: [281369] trunk
Revision
281369
Author
ysuz...@apple.com
Date
2021-08-21 05:10:09 -0700 (Sat, 21 Aug 2021)

Log Message

[JSC] Enable Array#findLast method
https://bugs.webkit.org/show_bug.cgi?id=229355

Reviewed by Saam Barati.

JSTests:

* stress/unscopables.js:

Source/_javascript_Core:

This patch enables Array#findLast and Array#findLastIndex methods.

* runtime/ArrayPrototype.cpp: Order of unscopables is alphabet ordering (https://tc39.es/ecma262/#sec-array.prototype-@@unscopables)
(JSC::ArrayPrototype::finishCreation):
* runtime/OptionsList.h:

LayoutTests:

* inspector/model/remote-object-get-properties-expected.txt:
* js/Object-getOwnPropertyNames-expected.txt:
* js/array-unscopables-properties-expected.txt:
* js/script-tests/Object-getOwnPropertyNames.js:
* js/script-tests/array-unscopables-properties.js:

Modified Paths

Diff

Modified: trunk/JSTests/ChangeLog (281368 => 281369)


--- trunk/JSTests/ChangeLog	2021-08-21 07:56:13 UTC (rev 281368)
+++ trunk/JSTests/ChangeLog	2021-08-21 12:10:09 UTC (rev 281369)
@@ -1,3 +1,12 @@
+2021-08-21  Yusuke Suzuki  <ysuz...@apple.com>
+
+        [JSC] Enable Array#findLast method
+        https://bugs.webkit.org/show_bug.cgi?id=229355
+
+        Reviewed by Saam Barati.
+
+        * stress/unscopables.js:
+
 2021-08-17  Mikhail R. Gadelha  <mikh...@igalia.com>
 
         Unreviewed. Skip failing MIPS tests

Modified: trunk/JSTests/stress/unscopables.js (281368 => 281369)


--- trunk/JSTests/stress/unscopables.js	2021-08-21 07:56:13 UTC (rev 281368)
+++ trunk/JSTests/stress/unscopables.js	2021-08-21 12:10:09 UTC (rev 281369)
@@ -11,7 +11,7 @@
 
     test(typeof unscopables, "object");
     test(unscopables.__proto__, undefined);
-    test(String(Object.keys(unscopables).sort()), "at,copyWithin,entries,fill,find,findIndex,flat,flatMap,includes,keys,values");
+    test(String(Object.keys(unscopables).sort()), "at,copyWithin,entries,fill,find,findIndex,findLast,findLastIndex,flat,flatMap,includes,keys,values");
 }());
 
 (function () {

Modified: trunk/LayoutTests/ChangeLog (281368 => 281369)


--- trunk/LayoutTests/ChangeLog	2021-08-21 07:56:13 UTC (rev 281368)
+++ trunk/LayoutTests/ChangeLog	2021-08-21 12:10:09 UTC (rev 281369)
@@ -1,3 +1,16 @@
+2021-08-21  Yusuke Suzuki  <ysuz...@apple.com>
+
+        [JSC] Enable Array#findLast method
+        https://bugs.webkit.org/show_bug.cgi?id=229355
+
+        Reviewed by Saam Barati.
+
+        * inspector/model/remote-object-get-properties-expected.txt:
+        * js/Object-getOwnPropertyNames-expected.txt:
+        * js/array-unscopables-properties-expected.txt:
+        * js/script-tests/Object-getOwnPropertyNames.js:
+        * js/script-tests/array-unscopables-properties.js:
+
 2021-08-21  Youenn Fablet  <you...@apple.com>
 
         Prevent AudioSession category from moving out of PlayAndRecord too quickly

Modified: trunk/LayoutTests/inspector/model/remote-object-get-properties-expected.txt (281368 => 281369)


--- trunk/LayoutTests/inspector/model/remote-object-get-properties-expected.txt	2021-08-21 07:56:13 UTC (rev 281368)
+++ trunk/LayoutTests/inspector/model/remote-object-get-properties-expected.txt	2021-08-21 12:10:09 UTC (rev 281369)
@@ -82,7 +82,9 @@
     keys
     entries
     find
+    findLast
     findIndex
+    findLastIndex
     includes
     copyWithin
     at
@@ -136,7 +138,9 @@
     keys
     entries
     find
+    findLast
     findIndex
+    findLastIndex
     includes
     copyWithin
     at
@@ -175,7 +179,9 @@
     keys
     entries
     find
+    findLast
     findIndex
+    findLastIndex
     includes
     copyWithin
     at
@@ -214,7 +220,9 @@
     keys
     entries
     find
+    findLast
     findIndex
+    findLastIndex
     includes
     copyWithin
     at

Modified: trunk/LayoutTests/js/Object-getOwnPropertyNames-expected.txt (281368 => 281369)


--- trunk/LayoutTests/js/Object-getOwnPropertyNames-expected.txt	2021-08-21 07:56:13 UTC (rev 281368)
+++ trunk/LayoutTests/js/Object-getOwnPropertyNames-expected.txt	2021-08-21 12:10:09 UTC (rev 281369)
@@ -47,7 +47,7 @@
 PASS getSortedOwnPropertyNames(Function) is ['length', 'name', 'prototype']
 PASS getSortedOwnPropertyNames(Function.prototype) is ['apply', 'arguments', 'bind', 'call', 'caller', 'constructor', 'length', 'name', 'toString']
 PASS getSortedOwnPropertyNames(Array) is ['from', 'isArray', 'length', 'name', 'of', 'prototype']
-PASS getSortedOwnPropertyNames(Array.prototype) is ['at', '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']
+PASS getSortedOwnPropertyNames(Array.prototype) is ['at', 'concat', 'constructor', 'copyWithin', 'entries', 'every', 'fill', 'filter', 'find', 'findIndex', 'findLast', 'findLastIndex', 'flat', 'flatMap', 'forEach', 'includes', 'indexOf', 'join', 'keys', 'lastIndexOf', 'length', 'map', 'pop', 'push', 'reduce', 'reduceRight', 'reverse', 'shift', 'slice', 'some', 'sort', 'splice', 'toLocaleString', 'toString', 'unshift', 'values']
 PASS getSortedOwnPropertyNames(String) is ['fromCharCode', 'fromCodePoint', 'length', 'name', 'prototype', 'raw']
 PASS getSortedOwnPropertyNames(String.prototype) is ['anchor', 'at', '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']
 PASS getSortedOwnPropertyNames(Boolean) is ['length', 'name', 'prototype']

Modified: trunk/LayoutTests/js/array-unscopables-properties-expected.txt (281368 => 281369)


--- trunk/LayoutTests/js/array-unscopables-properties-expected.txt	2021-08-21 07:56:13 UTC (rev 281368)
+++ trunk/LayoutTests/js/array-unscopables-properties-expected.txt	2021-08-21 12:10:09 UTC (rev 281369)
@@ -34,6 +34,14 @@
 PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "findIndex").writable is true
 PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "findIndex").enumerable is true
 PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "findIndex").configurable is true
+PASS Array.prototype[Symbol.unscopables]["findLast"] is true
+PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "findLast").writable is true
+PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "findLast").enumerable is true
+PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "findLast").configurable is true
+PASS Array.prototype[Symbol.unscopables]["findLastIndex"] is true
+PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "findLastIndex").writable is true
+PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "findLastIndex").enumerable is true
+PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "findLastIndex").configurable is true
 PASS Array.prototype[Symbol.unscopables]["flat"] is true
 PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "flat").writable is true
 PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "flat").enumerable is true

Modified: trunk/LayoutTests/js/script-tests/Object-getOwnPropertyNames.js (281368 => 281369)


--- trunk/LayoutTests/js/script-tests/Object-getOwnPropertyNames.js	2021-08-21 07:56:13 UTC (rev 281368)
+++ trunk/LayoutTests/js/script-tests/Object-getOwnPropertyNames.js	2021-08-21 12:10:09 UTC (rev 281369)
@@ -56,7 +56,7 @@
     "Function": "['length', 'name', 'prototype']",
     "Function.prototype": "['apply', 'arguments', 'bind', 'call', 'caller', 'constructor', 'length', 'name', 'toString']",
     "Array": "['from', 'isArray', 'length', 'name', 'of', 'prototype']",
-    "Array.prototype": "['at', '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']",
+    "Array.prototype": "['at', 'concat', 'constructor', 'copyWithin', 'entries', 'every', 'fill', 'filter', 'find', 'findIndex', 'findLast', 'findLastIndex', 'flat', 'flatMap', 'forEach', 'includes', 'indexOf', 'join', 'keys', 'lastIndexOf', 'length', 'map', 'pop', 'push', 'reduce', 'reduceRight', 'reverse', 'shift', 'slice', 'some', 'sort', 'splice', 'toLocaleString', 'toString', 'unshift', 'values']",
     "String": "['fromCharCode', 'fromCodePoint', 'length', 'name', 'prototype', 'raw']",
     "String.prototype": "['anchor', 'at', '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']",
     "Boolean": "['length', 'name', 'prototype']",

Modified: trunk/LayoutTests/js/script-tests/array-unscopables-properties.js (281368 => 281369)


--- trunk/LayoutTests/js/script-tests/array-unscopables-properties.js	2021-08-21 07:56:13 UTC (rev 281368)
+++ trunk/LayoutTests/js/script-tests/array-unscopables-properties.js	2021-08-21 12:10:09 UTC (rev 281369)
@@ -13,6 +13,8 @@
     "fill",
     "find",
     "findIndex",
+    "findLast",
+    "findLastIndex",
     "flat",
     "flatMap",
     "includes",

Modified: trunk/Source/_javascript_Core/ChangeLog (281368 => 281369)


--- trunk/Source/_javascript_Core/ChangeLog	2021-08-21 07:56:13 UTC (rev 281368)
+++ trunk/Source/_javascript_Core/ChangeLog	2021-08-21 12:10:09 UTC (rev 281369)
@@ -1,3 +1,16 @@
+2021-08-21  Yusuke Suzuki  <ysuz...@apple.com>
+
+        [JSC] Enable Array#findLast method
+        https://bugs.webkit.org/show_bug.cgi?id=229355
+
+        Reviewed by Saam Barati.
+
+        This patch enables Array#findLast and Array#findLastIndex methods.
+
+        * runtime/ArrayPrototype.cpp: Order of unscopables is alphabet ordering (https://tc39.es/ecma262/#sec-array.prototype-@@unscopables)
+        (JSC::ArrayPrototype::finishCreation):
+        * runtime/OptionsList.h:
+
 2021-08-20  Yusuke Suzuki  <ysuz...@apple.com>
 
         [JSC] Simplify moveIntsToDouble

Modified: trunk/Source/_javascript_Core/runtime/ArrayPrototype.cpp (281368 => 281369)


--- trunk/Source/_javascript_Core/runtime/ArrayPrototype.cpp	2021-08-21 07:56:13 UTC (rev 281368)
+++ trunk/Source/_javascript_Core/runtime/ArrayPrototype.cpp	2021-08-21 12:10:09 UTC (rev 281369)
@@ -127,11 +127,14 @@
     JSObject* unscopables = constructEmptyObject(vm, globalObject->nullPrototypeObjectStructure());
     unscopables->convertToDictionary(vm);
     const Identifier* const unscopableNames[] = {
+        Options::useAtMethod() ? &vm.propertyNames->builtinNames().atPublicName() : nullptr,
         &vm.propertyNames->builtinNames().copyWithinPublicName(),
         &vm.propertyNames->builtinNames().entriesPublicName(),
         &vm.propertyNames->builtinNames().fillPublicName(),
         &vm.propertyNames->builtinNames().findPublicName(),
         &vm.propertyNames->builtinNames().findIndexPublicName(),
+        Options::useArrayFindLastMethod() ? &vm.propertyNames->builtinNames().findLastPublicName() : nullptr,
+        Options::useArrayFindLastMethod() ? &vm.propertyNames->builtinNames().findLastIndexPublicName() : nullptr,
         &vm.propertyNames->builtinNames().flatPublicName(),
         &vm.propertyNames->builtinNames().flatMapPublicName(),
         &vm.propertyNames->builtinNames().includesPublicName(),
@@ -138,14 +141,10 @@
         &vm.propertyNames->builtinNames().keysPublicName(),
         &vm.propertyNames->builtinNames().valuesPublicName()
     };
-    if (Options::useArrayFindLastMethod()) {
-        unscopables->putDirect(vm, vm.propertyNames->builtinNames().findLastPublicName(), jsBoolean(true));
-        unscopables->putDirect(vm, vm.propertyNames->builtinNames().findLastIndexPublicName(), jsBoolean(true));
+    for (const auto* unscopableName : unscopableNames) {
+        if (unscopableName)
+            unscopables->putDirect(vm, *unscopableName, jsBoolean(true));
     }
-    if (Options::useAtMethod())
-        unscopables->putDirect(vm, vm.propertyNames->builtinNames().atPublicName(), jsBoolean(true));
-    for (const auto* unscopableName : unscopableNames)
-        unscopables->putDirect(vm, *unscopableName, jsBoolean(true));
     putDirectWithoutTransition(vm, vm.propertyNames->unscopablesSymbol, unscopables, PropertyAttribute::DontEnum | PropertyAttribute::ReadOnly);
 }
 

Modified: trunk/Source/_javascript_Core/runtime/OptionsList.h (281368 => 281369)


--- trunk/Source/_javascript_Core/runtime/OptionsList.h	2021-08-21 07:56:13 UTC (rev 281368)
+++ trunk/Source/_javascript_Core/runtime/OptionsList.h	2021-08-21 12:10:09 UTC (rev 281369)
@@ -553,7 +553,7 @@
     v(Bool, useDataICInOptimizingJIT, false, Normal, nullptr) \
     v(Bool, useDataICSharing, false, Normal, nullptr) \
     v(Bool, useTemporal, false, Normal, "Expose the Temporal object.") \
-    v(Bool, useArrayFindLastMethod, false, Normal, "Expose the findLast() and findLastIndex() methods on Array and %TypedArray%.") \
+    v(Bool, useArrayFindLastMethod, true, Normal, "Expose the findLast() and findLastIndex() methods on Array and %TypedArray%.") \
 
 
 enum OptionEquivalence {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to