Changeset 281369 in webkit


Ignore:
Timestamp:
Aug 21, 2021 5:10:09 AM (11 months ago)
Author:
ysuzuki@apple.com
Message:

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

Reviewed by Saam Barati.

JSTests:

  • stress/unscopables.js:

Source/JavaScriptCore:

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

(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:
Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r281156 r281369  
     12021-08-21  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Enable Array#findLast method
     4        https://bugs.webkit.org/show_bug.cgi?id=229355
     5
     6        Reviewed by Saam Barati.
     7
     8        * stress/unscopables.js:
     9
    1102021-08-17  Mikhail R. Gadelha  <mikhail@igalia.com>
    211
  • trunk/JSTests/stress/unscopables.js

    r268760 r281369  
    1212    test(typeof unscopables, "object");
    1313    test(unscopables.__proto__, undefined);
    14     test(String(Object.keys(unscopables).sort()), "at,copyWithin,entries,fill,find,findIndex,flat,flatMap,includes,keys,values");
     14    test(String(Object.keys(unscopables).sort()), "at,copyWithin,entries,fill,find,findIndex,findLast,findLastIndex,flat,flatMap,includes,keys,values");
    1515}());
    1616
  • trunk/LayoutTests/ChangeLog

    r281367 r281369  
     12021-08-21  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Enable Array#findLast method
     4        https://bugs.webkit.org/show_bug.cgi?id=229355
     5
     6        Reviewed by Saam Barati.
     7
     8        * inspector/model/remote-object-get-properties-expected.txt:
     9        * js/Object-getOwnPropertyNames-expected.txt:
     10        * js/array-unscopables-properties-expected.txt:
     11        * js/script-tests/Object-getOwnPropertyNames.js:
     12        * js/script-tests/array-unscopables-properties.js:
     13
    1142021-08-21  Youenn Fablet  <youenn@apple.com>
    215
  • trunk/LayoutTests/inspector/model/remote-object-get-properties-expected.txt

    r280289 r281369  
    8383    entries
    8484    find
     85    findLast
    8586    findIndex
     87    findLastIndex
    8688    includes
    8789    copyWithin
     
    137139    entries
    138140    find
     141    findLast
    139142    findIndex
     143    findLastIndex
    140144    includes
    141145    copyWithin
     
    176180    entries
    177181    find
     182    findLast
    178183    findIndex
     184    findLastIndex
    179185    includes
    180186    copyWithin
     
    215221    entries
    216222    find
     223    findLast
    217224    findIndex
     225    findLastIndex
    218226    includes
    219227    copyWithin
  • trunk/LayoutTests/js/Object-getOwnPropertyNames-expected.txt

    r280289 r281369  
    4848PASS getSortedOwnPropertyNames(Function.prototype) is ['apply', 'arguments', 'bind', 'call', 'caller', 'constructor', 'length', 'name', 'toString']
    4949PASS getSortedOwnPropertyNames(Array) is ['from', 'isArray', 'length', 'name', 'of', 'prototype']
    50 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']
     50PASS 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']
    5151PASS getSortedOwnPropertyNames(String) is ['fromCharCode', 'fromCodePoint', 'length', 'name', 'prototype', 'raw']
    5252PASS 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']
  • trunk/LayoutTests/js/array-unscopables-properties-expected.txt

    r270550 r281369  
    3535PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "findIndex").enumerable is true
    3636PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "findIndex").configurable is true
     37PASS Array.prototype[Symbol.unscopables]["findLast"] is true
     38PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "findLast").writable is true
     39PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "findLast").enumerable is true
     40PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "findLast").configurable is true
     41PASS Array.prototype[Symbol.unscopables]["findLastIndex"] is true
     42PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "findLastIndex").writable is true
     43PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "findLastIndex").enumerable is true
     44PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "findLastIndex").configurable is true
    3745PASS Array.prototype[Symbol.unscopables]["flat"] is true
    3846PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "flat").writable is true
  • trunk/LayoutTests/js/script-tests/Object-getOwnPropertyNames.js

    r280289 r281369  
    5757    "Function.prototype": "['apply', 'arguments', 'bind', 'call', 'caller', 'constructor', 'length', 'name', 'toString']",
    5858    "Array": "['from', 'isArray', 'length', 'name', 'of', 'prototype']",
    59     "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']",
     59    "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']",
    6060    "String": "['fromCharCode', 'fromCodePoint', 'length', 'name', 'prototype', 'raw']",
    6161    "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']",
  • trunk/LayoutTests/js/script-tests/array-unscopables-properties.js

    r270550 r281369  
    1414    "find",
    1515    "findIndex",
     16    "findLast",
     17    "findLastIndex",
    1618    "flat",
    1719    "flatMap",
  • trunk/Source/JavaScriptCore/ChangeLog

    r281355 r281369  
     12021-08-21  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Enable Array#findLast method
     4        https://bugs.webkit.org/show_bug.cgi?id=229355
     5
     6        Reviewed by Saam Barati.
     7
     8        This patch enables Array#findLast and Array#findLastIndex methods.
     9
     10        * runtime/ArrayPrototype.cpp: Order of unscopables is alphabet ordering (https://tc39.es/ecma262/#sec-array.prototype-@@unscopables)
     11        (JSC::ArrayPrototype::finishCreation):
     12        * runtime/OptionsList.h:
     13
    1142021-08-20  Yusuke Suzuki  <ysuzuki@apple.com>
    215
  • trunk/Source/JavaScriptCore/runtime/ArrayPrototype.cpp

    r280761 r281369  
    128128    unscopables->convertToDictionary(vm);
    129129    const Identifier* const unscopableNames[] = {
     130        Options::useAtMethod() ? &vm.propertyNames->builtinNames().atPublicName() : nullptr,
    130131        &vm.propertyNames->builtinNames().copyWithinPublicName(),
    131132        &vm.propertyNames->builtinNames().entriesPublicName(),
     
    133134        &vm.propertyNames->builtinNames().findPublicName(),
    134135        &vm.propertyNames->builtinNames().findIndexPublicName(),
     136        Options::useArrayFindLastMethod() ? &vm.propertyNames->builtinNames().findLastPublicName() : nullptr,
     137        Options::useArrayFindLastMethod() ? &vm.propertyNames->builtinNames().findLastIndexPublicName() : nullptr,
    135138        &vm.propertyNames->builtinNames().flatPublicName(),
    136139        &vm.propertyNames->builtinNames().flatMapPublicName(),
     
    139142        &vm.propertyNames->builtinNames().valuesPublicName()
    140143    };
    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     }
    145     if (Options::useAtMethod())
    146         unscopables->putDirect(vm, vm.propertyNames->builtinNames().atPublicName(), jsBoolean(true));
    147     for (const auto* unscopableName : unscopableNames)
    148         unscopables->putDirect(vm, *unscopableName, jsBoolean(true));
     144    for (const auto* unscopableName : unscopableNames) {
     145        if (unscopableName)
     146            unscopables->putDirect(vm, *unscopableName, jsBoolean(true));
     147    }
    149148    putDirectWithoutTransition(vm, vm.propertyNames->unscopablesSymbol, unscopables, PropertyAttribute::DontEnum | PropertyAttribute::ReadOnly);
    150149}
  • trunk/Source/JavaScriptCore/runtime/OptionsList.h

    r281178 r281369  
    554554    v(Bool, useDataICSharing, false, Normal, nullptr) \
    555555    v(Bool, useTemporal, false, Normal, "Expose the Temporal object.") \
    556     v(Bool, useArrayFindLastMethod, false, Normal, "Expose the findLast() and findLastIndex() methods on Array and %TypedArray%.") \
     556    v(Bool, useArrayFindLastMethod, true, Normal, "Expose the findLast() and findLastIndex() methods on Array and %TypedArray%.") \
    557557
    558558
Note: See TracChangeset for help on using the changeset viewer.