[ES6] Add TypedArray.prototype functionality.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Aug 2015 22:57:07 +0000 (22:57 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Aug 2015 22:57:07 +0000 (22:57 +0000)
commite6fe1e7758c8c2295817c8735229d442ee9b1779
treeb749e483be944b3249eef3b53e99d6b2aee93a9a
parent08ee18fa1a58bfc188d2998c5e5e6e5874a7aa0e
[ES6] Add TypedArray.prototype functionality.
https://bugs.webkit.org/show_bug.cgi?id=148035

Patch by Keith Miller <keith_miller@apple.com> on 2015-08-27
Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

This patch should add most of the functionality for
the prototype properties of TypedArray objects in ES6.
There are a few exceptions to this, which will be added
in upcoming patches:

1) First we do not use the species constructor for some
of the TypedArray prototype functions (namely: map, filter,
slice, and subarray). That will need to be added when
species constructors are finished.

2) TypedArrays still have a length, byteOffset, byteLength,
and buffer are still attached to the TypedArray instance (in
the spec they are on the TypedArray.prototype instance object)
since the JIT currently assumes those properties are fixed.

3) The TypedArray.constructor property is not added yet
as it should point to the TypedArray instance object,
which will be added in a future patch.

* CMakeLists.txt:
* JavaScriptCore.xcodeproj/project.pbxproj:
* builtins/TypedArray.prototype.js: Added.
(every):
(find):
(findIndex):
(forEach):
(some):
(sort.min):
(sort.merge):
(sort.mergeSort):
(sort):
(reduce):
(reduceRight):
(map):
(filter):
(toLocaleString):
* runtime/ArrayPrototype.cpp:
* runtime/ArrayPrototype.h:
* runtime/CommonIdentifiers.h:
* runtime/JSGenericTypedArrayView.h:
(JSC::sortFloat):
(JSC::JSGenericTypedArrayView::toAdaptorNativeFromValue):
(JSC::JSGenericTypedArrayView::setRangeToValue):
(JSC::JSGenericTypedArrayView::sort):
* runtime/JSGenericTypedArrayViewInlines.h:
* runtime/JSGenericTypedArrayViewPrototypeFunctions.h: Added.
(JSC::argumentClampedIndexFromStartOrEnd):
(JSC::genericTypedArrayViewProtoFuncSet):
(JSC::genericTypedArrayViewProtoFuncEntries):
(JSC::genericTypedArrayViewProtoFuncCopyWithin):
(JSC::genericTypedArrayViewProtoFuncFill):
(JSC::genericTypedArrayViewProtoFuncIndexOf):
(JSC::genericTypedArrayViewProtoFuncJoin):
(JSC::genericTypedArrayViewProtoFuncKeys):
(JSC::genericTypedArrayViewProtoFuncLastIndexOf):
(JSC::genericTypedArrayViewProtoGetterFuncLength):
(JSC::genericTypedArrayViewProtoGetterFuncByteLength):
(JSC::genericTypedArrayViewProtoGetterFuncByteOffset):
(JSC::genericTypedArrayViewProtoFuncReverse):
(JSC::genericTypedArrayViewPrivateFuncSort):
(JSC::genericTypedArrayViewProtoFuncSlice):
(JSC::genericTypedArrayViewProtoFuncSubarray):
(JSC::typedArrayViewProtoFuncValues):
* runtime/JSGenericTypedArrayViewPrototypeInlines.h:
(JSC::JSGenericTypedArrayViewPrototype<ViewClass>::finishCreation):
(JSC::genericTypedArrayViewProtoFuncSet): Deleted.
(JSC::genericTypedArrayViewProtoFuncSubarray): Deleted.
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
* runtime/JSObject.h:
* runtime/JSTypedArrayPrototypes.cpp:
* runtime/JSTypedArrayPrototypes.h:
* runtime/JSTypedArrayViewPrototype.cpp: Added.
(JSC::typedArrayViewPrivateFuncLength):
(JSC::typedArrayViewPrivateFuncSort):
(JSC::typedArrayViewProtoFuncSet):
(JSC::typedArrayViewProtoFuncEntries):
(JSC::typedArrayViewProtoFuncCopyWithin):
(JSC::typedArrayViewProtoFuncFill):
(JSC::typedArrayViewProtoFuncLastIndexOf):
(JSC::typedArrayViewProtoFuncIndexOf):
(JSC::typedArrayViewProtoFuncJoin):
(JSC::typedArrayViewProtoFuncKeys):
(JSC::typedArrayViewProtoGetterFuncLength):
(JSC::typedArrayViewProtoGetterFuncByteLength):
(JSC::typedArrayViewProtoGetterFuncByteOffset):
(JSC::typedArrayViewProtoFuncReverse):
(JSC::typedArrayViewProtoFuncSubarray):
(JSC::typedArrayViewProtoFuncSlice):
(JSC::typedArrayViewProtoFuncValues):
(JSC::JSTypedArrayViewPrototype::JSTypedArrayViewPrototype):
(JSC::JSTypedArrayViewPrototype::finishCreation):
(JSC::JSTypedArrayViewPrototype::create):
(JSC::JSTypedArrayViewPrototype::createStructure):
* runtime/JSTypedArrayViewPrototype.h: Copied from Source/JavaScriptCore/runtime/JSTypedArrayPrototypes.cpp.

LayoutTests:

Added tests for the TypedArray.prototype functions.
All the tests use the typedarray-test-helper-function.js
to run the test on each TypedArray.

* fast/canvas/webgl/type-conversion-test-expected.txt:
* js/script-tests/typedarray-copyWithin.js: Added.
* js/script-tests/typedarray-every.js: Added.
(isBigEnough):
(isBigEnoughAndChange):
(isBigEnoughAndException):
* js/script-tests/typedarray-fill.js: Added.
* js/script-tests/typedarray-filter.js: Added.
(keepEven):
(keepEvenAndChange):
(isBigEnoughAndException):
* js/script-tests/typedarray-find.js: Added.
(keepEven):
(keepEvenAndChange):
(isBigEnoughAndException):
* js/script-tests/typedarray-findIndex.js: Added.
(keepEven):
(keepEvenAndChange):
(isBigEnoughAndException):
* js/script-tests/typedarray-forEach.js: Added.
(.checkCorrect.let.list):
(.checkCorrect):
(createChecker):
(foo):
(changeArray):
(isBigEnoughAndException):
* js/script-tests/typedarray-indexOf.js: Added.
(keepEven):
* js/script-tests/typedarray-lastIndexOf.js: Added.
* js/script-tests/typedarray-map.js: Added.
(even):
(evenAndChange):
(isBigEnoughAndException):
* js/script-tests/typedarray-reduce.js: Added.
(createArray):
(sum):
(createArrayAndChange):
(isBigEnoughAndException):
* js/script-tests/typedarray-reduceRight.js: Added.
(createArray):
(sum):
(createArrayAndChange):
(isBigEnoughAndException):
* js/script-tests/typedarray-slice.js: Added.
* js/script-tests/typedarray-some.js: Added.
(isBigEnough):
(isBigEnoughAndChange):
(isBigEnoughAndException):
* js/script-tests/typedarray-sort.js: Added.
(sortBackwards):
(compareException):
* js/script-tests/typedarray-test-helper-functions.js: Added.
(forEachTypedArray):
(isSameFunctionForEachTypedArrayPrototype.eq):
(isSameFunctionForEachTypedArrayPrototype):
(hasSameValues):
(.foo):
(testPrototypeFunctionHelper):
(testPrototypeFunctionOnSigned):
(testPrototypeFunctionOnFloat):
(testPrototypeFunction):
* js/typedarray-copyWithin-expected.txt: Added.
* js/typedarray-copyWithin.html: Added.
* js/typedarray-every-expected.txt: Added.
* js/typedarray-every.html: Added.
* js/typedarray-fill-expected.txt: Added.
* js/typedarray-fill.html: Added.
* js/typedarray-filter-expected.txt: Added.
* js/typedarray-filter.html: Added.
* js/typedarray-find-expected.txt: Added.
* js/typedarray-find.html: Added.
* js/typedarray-findIndex-expected.txt: Added.
* js/typedarray-findIndex.html: Added.
* js/typedarray-forEach-expected.txt: Added.
* js/typedarray-forEach.html: Added.
* js/typedarray-indexOf-expected.txt: Added.
* js/typedarray-indexOf.html: Added.
* js/typedarray-lastIndexOf-expected.txt: Added.
* js/typedarray-lastIndexOf.html: Added.
* js/typedarray-map-expected.txt: Added.
* js/typedarray-map.html: Added.
* js/typedarray-reduce-expected.txt: Added.
* js/typedarray-reduce.html: Added.
* js/typedarray-reduceRight-expected.txt: Added.
* js/typedarray-reduceRight.html: Added.
* js/typedarray-slice-expected.txt: Added.
* js/typedarray-slice.html: Added.
* js/typedarray-some-expected.txt: Added.
* js/typedarray-some.html: Added.
* js/typedarray-sort-expected.txt: Added.
* js/typedarray-sort.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@189064 268f45cc-cd09-0410-ab3c-d52691b4dbfc
66 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/canvas/webgl/type-conversion-test-expected.txt
LayoutTests/fast/dom/Window/window-postmessage-clone-expected.txt
LayoutTests/js/script-tests/typedarray-copyWithin.js [new file with mode: 0644]
LayoutTests/js/script-tests/typedarray-every.js [new file with mode: 0644]
LayoutTests/js/script-tests/typedarray-fill.js [new file with mode: 0644]
LayoutTests/js/script-tests/typedarray-filter.js [new file with mode: 0644]
LayoutTests/js/script-tests/typedarray-find.js [new file with mode: 0644]
LayoutTests/js/script-tests/typedarray-findIndex.js [new file with mode: 0644]
LayoutTests/js/script-tests/typedarray-forEach.js [new file with mode: 0644]
LayoutTests/js/script-tests/typedarray-indexOf.js [new file with mode: 0644]
LayoutTests/js/script-tests/typedarray-lastIndexOf.js [new file with mode: 0644]
LayoutTests/js/script-tests/typedarray-map.js [new file with mode: 0644]
LayoutTests/js/script-tests/typedarray-reduce.js [new file with mode: 0644]
LayoutTests/js/script-tests/typedarray-reduceRight.js [new file with mode: 0644]
LayoutTests/js/script-tests/typedarray-slice.js [new file with mode: 0644]
LayoutTests/js/script-tests/typedarray-some.js [new file with mode: 0644]
LayoutTests/js/script-tests/typedarray-sort.js [new file with mode: 0644]
LayoutTests/js/script-tests/typedarray-test-helper-functions.js [new file with mode: 0644]
LayoutTests/js/typedarray-copyWithin-expected.txt [new file with mode: 0644]
LayoutTests/js/typedarray-copyWithin.html [new file with mode: 0644]
LayoutTests/js/typedarray-every-expected.txt [new file with mode: 0644]
LayoutTests/js/typedarray-every.html [new file with mode: 0644]
LayoutTests/js/typedarray-fill-expected.txt [new file with mode: 0644]
LayoutTests/js/typedarray-fill.html [new file with mode: 0644]
LayoutTests/js/typedarray-filter-expected.txt [new file with mode: 0644]
LayoutTests/js/typedarray-filter.html [new file with mode: 0644]
LayoutTests/js/typedarray-find-expected.txt [new file with mode: 0644]
LayoutTests/js/typedarray-find.html [new file with mode: 0644]
LayoutTests/js/typedarray-findIndex-expected.txt [new file with mode: 0644]
LayoutTests/js/typedarray-findIndex.html [new file with mode: 0644]
LayoutTests/js/typedarray-forEach-expected.txt [new file with mode: 0644]
LayoutTests/js/typedarray-forEach.html [new file with mode: 0644]
LayoutTests/js/typedarray-indexOf-expected.txt [new file with mode: 0644]
LayoutTests/js/typedarray-indexOf.html [new file with mode: 0644]
LayoutTests/js/typedarray-lastIndexOf-expected.txt [new file with mode: 0644]
LayoutTests/js/typedarray-lastIndexOf.html [new file with mode: 0644]
LayoutTests/js/typedarray-map-expected.txt [new file with mode: 0644]
LayoutTests/js/typedarray-map.html [new file with mode: 0644]
LayoutTests/js/typedarray-reduce-expected.txt [new file with mode: 0644]
LayoutTests/js/typedarray-reduce.html [new file with mode: 0644]
LayoutTests/js/typedarray-reduceRight-expected.txt [new file with mode: 0644]
LayoutTests/js/typedarray-reduceRight.html [new file with mode: 0644]
LayoutTests/js/typedarray-slice-expected.txt [new file with mode: 0644]
LayoutTests/js/typedarray-slice.html [new file with mode: 0644]
LayoutTests/js/typedarray-some-expected.txt [new file with mode: 0644]
LayoutTests/js/typedarray-some.html [new file with mode: 0644]
LayoutTests/js/typedarray-sort-expected.txt [new file with mode: 0644]
LayoutTests/js/typedarray-sort.html [new file with mode: 0644]
Source/JavaScriptCore/CMakeLists.txt
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
Source/JavaScriptCore/builtins/TypedArray.prototype.js [new file with mode: 0644]
Source/JavaScriptCore/runtime/ArrayPrototype.cpp
Source/JavaScriptCore/runtime/ArrayPrototype.h
Source/JavaScriptCore/runtime/CommonIdentifiers.h
Source/JavaScriptCore/runtime/JSGenericTypedArrayView.h
Source/JavaScriptCore/runtime/JSGenericTypedArrayViewInlines.h
Source/JavaScriptCore/runtime/JSGenericTypedArrayViewPrototypeFunctions.h [new file with mode: 0644]
Source/JavaScriptCore/runtime/JSGenericTypedArrayViewPrototypeInlines.h
Source/JavaScriptCore/runtime/JSGlobalObject.cpp
Source/JavaScriptCore/runtime/JSObject.h
Source/JavaScriptCore/runtime/JSTypedArrayPrototypes.cpp
Source/JavaScriptCore/runtime/JSTypedArrayPrototypes.h
Source/JavaScriptCore/runtime/JSTypedArrayViewPrototype.cpp [new file with mode: 0644]
Source/JavaScriptCore/runtime/JSTypedArrayViewPrototype.h [new file with mode: 0644]