[JSC] Implement Array.prototype.flatMap and Array.prototype.flatten
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Feb 2018 10:43:13 +0000 (10:43 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Feb 2018 10:43:13 +0000 (10:43 +0000)
commitd00e5473cc82bd90436dffae7e270c0c012b07dd
tree8afebe2b4a7e3ec38e743137293bd7f70902e3f1
parent598f99d7727529e8c44cfb6cad2ff2659d915c6a
[JSC] Implement Array.prototype.flatMap and Array.prototype.flatten
https://bugs.webkit.org/show_bug.cgi?id=182440

Reviewed by Darin Adler.

JSTests:

* stress/array-flatmap.js: Added.
(shouldBe):
(shouldBeArray):
(shouldThrow):
(var):
* stress/array-flatten.js: Added.
(shouldBe):
(shouldBeArray):
* test262.yaml:
* test262/test/built-ins/Array/prototype/flatMap/depth-always-one.js:
(3.flatMap):
Pick test262 82c6148980332febe92a544a1fb653718e9fdb57 change.

Source/JavaScriptCore:

This patch implements Array.prototype.flatMap and Array.prototype.flatten
since they are now stage 3 [1].

[1]: https://tc39.github.io/proposal-flatMap/#sec-FlattenIntoArray

* builtins/ArrayPrototype.js:
(filter):
(map):
(globalPrivate.concatSlowPath):
(globalPrivate.arraySpeciesCreate):
(globalPrivate.flattenIntoArray):
(flatten):
(globalPrivate.flattenIntoArrayWithCallback):
We separate flattenIntoArray from flattenIntoArrayWithCallback due to performance reason.
We carefully keep both functions small to encourage inlining.

(flatMap):
* runtime/ArrayPrototype.cpp:
(JSC::ArrayPrototype::finishCreation):

LayoutTests:

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

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@228266 268f45cc-cd09-0410-ab3c-d52691b4dbfc
12 files changed:
JSTests/ChangeLog
JSTests/stress/array-flatmap.js [new file with mode: 0644]
JSTests/stress/array-flatten.js [new file with mode: 0644]
JSTests/test262.yaml
JSTests/test262/test/built-ins/Array/prototype/flatMap/depth-always-one.js
LayoutTests/ChangeLog
LayoutTests/inspector/model/remote-object-get-properties-expected.txt
LayoutTests/js/Object-getOwnPropertyNames-expected.txt
LayoutTests/js/script-tests/Object-getOwnPropertyNames.js
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/builtins/ArrayPrototype.js
Source/JavaScriptCore/runtime/ArrayPrototype.cpp