Changeset 190429 in webkit


Ignore:
Timestamp:
Oct 1, 2015 1:20:10 PM (8 years ago)
Author:
keith_miller@apple.com
Message:

[ES6] Add TypedArray.prototype functionality.
https://bugs.webkit.org/show_bug.cgi?id=148035

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.

(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::JSGenericTypedArrayView::toAdaptorNativeFromValue):
(JSC::JSGenericTypedArrayView::setRangeToValue):
(JSC::JSGenericTypedArrayView::sort):
(JSC::JSGenericTypedArrayView::purifyArray):
(JSC::JSGenericTypedArrayView::sortComparison):
(JSC::JSGenericTypedArrayView::sortFloat):

  • 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.
  • tests/es6.yaml:
  • tests/stress/resources/standalone-pre.js: Added.

(description):
(debug):
(escapeString):
(testPassed):
(testFailed):
(areNumbersEqual):
(areArraysEqual):
(isMinusZero):
(isTypedArray):
(isResultCorrect):
(stringify):
(shouldBe):
(dfgShouldBe):
(shouldBeType):
(shouldBeTrue):
(shouldBeFalse):
(shouldBeNaN):
(shouldBeNull):
(shouldBeEqualToString):
(shouldBeUndefined):
(shouldNotThrow):
(shouldThrow):
(dfgCompiled):
(dfgIncrement):
(noInline):
(finishJSTest):

  • tests/stress/resources/typedarray-test-helper-functions.js: Added.

(forEachTypedArray):
(isSameFunctionForEachTypedArrayPrototype.eq):
(isSameFunctionForEachTypedArrayPrototype):
(hasSameValues):
(foo):
(testPrototypeFunctionHelper):
(testPrototypeFunctionOnSigned):
(testPrototypeFunctionOnFloat):
(testPrototypeFunction):
(tester):
(testPrototypeReceivesArray):

  • tests/stress/typedarray-copyWithin.js: Added.
  • tests/stress/typedarray-every.js: Added.

(isBigEnough):
(isBigEnoughAndChange):
(isBigEnoughAndException):

  • tests/stress/typedarray-fill.js: Added.
  • tests/stress/typedarray-filter.js: Added.

(keepEven):
(keepEvenAndChange):
(isBigEnoughAndException):

  • tests/stress/typedarray-find.js: Added.

(keepEven):
(keepEvenAndChange):
(isBigEnoughAndException):

  • tests/stress/typedarray-findIndex.js: Added.

(keepEven):
(keepEvenAndChange):
(isBigEnoughAndException):

  • tests/stress/typedarray-forEach.js: Added.

(checkCorrect.let.list):
(checkCorrect):
(createChecker):
(foo):
(changeArray):
(isBigEnoughAndException):

  • tests/stress/typedarray-indexOf.js: Added.

(keepEven):

  • tests/stress/typedarray-lastIndexOf.js: Added.
  • tests/stress/typedarray-map.js: Added.

(even):
(evenAndChange):
(isBigEnoughAndException):

  • tests/stress/typedarray-reduce.js: Added.

(createArray):
(sum):
(createArrayAndChange):
(isBigEnoughAndException):

  • tests/stress/typedarray-reduceRight.js: Added.

(createArray):
(sum):
(createArrayAndChange):
(isBigEnoughAndException):

  • tests/stress/typedarray-slice.js: Added.
  • tests/stress/typedarray-some.js: Added.

(isBigEnough):
(isBigEnoughAndChange):
(isBigEnoughAndException):

  • tests/stress/typedarray-sort.js: Added.

(sortBackwards):
(compareException):

LayoutTests:

Fixed tests for new toString behavior on TypedArrays.

  • fast/canvas/webgl/type-conversion-test-expected.txt:
  • fast/dom/Window/window-postmessage-clone-expected.txt:
Location:
trunk
Files:
21 added
19 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r190423 r190429  
     12015-10-01  Keith Miller  <keith_miller@apple.com>
     2
     3        [ES6] Add TypedArray.prototype functionality.
     4        https://bugs.webkit.org/show_bug.cgi?id=148035
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Fixed tests for new toString behavior on TypedArrays.
     9
     10        * fast/canvas/webgl/type-conversion-test-expected.txt:
     11        * fast/dom/Window/window-postmessage-clone-expected.txt:
     12
    1132015-10-01  Brent Fulgham  <bfulgham@apple.com>
    214
  • trunk/LayoutTests/fast/canvas/webgl/type-conversion-test-expected.txt

    r190385 r190429  
    766766PASS context.uniform4f(loc, 0, 0, 0, argument) is undefined.
    767767
    768 testing type of TypedArray : value = [object Float32Array]
     768testing type of TypedArray : value = 0
    769769PASS context.bindAttribLocation(program, argument, 'foo') is undefined.
    770770PASS context.blendColor(argument, argument, argument, argument) is undefined.
  • trunk/LayoutTests/fast/dom/Window/window-postmessage-clone-expected.txt

    r190385 r190429  
    4747LOG: [object Map] => [object Object]
    4848PASS: eventData is [object ImageData] of type object
    49 PASS: eventData is [object Uint8ClampedArray] of type object
     49PASS: eventData is 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143 of type object
    5050PASS: eventData is [object ImageData] of type object
    51 PASS: eventData is [object Uint8ClampedArray] of type object
     51PASS: eventData is 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143 of type object
    5252PASS: eventData is 42 of type number
    5353PASS: eventData is 42 of type number
  • trunk/Source/JavaScriptCore/CMakeLists.txt

    r190390 r190429  
    575575    runtime/JSTypedArrayConstructors.cpp
    576576    runtime/JSTypedArrayPrototypes.cpp
     577    runtime/JSTypedArrayViewPrototype.cpp
    577578    runtime/JSTypedArrays.cpp
    578579    runtime/JSWeakMap.cpp
     
    10891090    ${JAVASCRIPTCORE_DIR}/builtins/StringConstructor.js
    10901091    ${JAVASCRIPTCORE_DIR}/builtins/StringIterator.prototype.js
     1092    ${JAVASCRIPTCORE_DIR}/builtins/TypedArray.prototype.js
    10911093)
    10921094
  • trunk/Source/JavaScriptCore/ChangeLog

    r190414 r190429  
     12015-10-01  Keith Miller  <keith_miller@apple.com>
     2
     3        [ES6] Add TypedArray.prototype functionality.
     4        https://bugs.webkit.org/show_bug.cgi?id=148035
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        This patch should add most of the functionality for
     9        the prototype properties of TypedArray objects in ES6.
     10        There are a few exceptions to this, which will be added
     11        in upcoming patches:
     12
     13        1) First we do not use the species constructor for some
     14        of the TypedArray prototype functions (namely: map, filter,
     15        slice, and subarray). That will need to be added when
     16        species constructors are finished.
     17
     18        2) TypedArrays still have a length, byteOffset, byteLength,
     19        and buffer are still attached to the TypedArray instance (in
     20        the spec they are on the TypedArray.prototype instance object)
     21        since the JIT currently assumes those properties are fixed.
     22
     23        3) The TypedArray.constructor property is not added yet
     24        as it should point to the TypedArray instance object,
     25        which will be added in a future patch.
     26
     27        * CMakeLists.txt:
     28        * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
     29        * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters:
     30        * JavaScriptCore.xcodeproj/project.pbxproj:
     31        * builtins/TypedArray.prototype.js: Added.
     32        (every):
     33        (find):
     34        (findIndex):
     35        (forEach):
     36        (some):
     37        (sort.min):
     38        (sort.merge):
     39        (sort.mergeSort):
     40        (sort):
     41        (reduce):
     42        (reduceRight):
     43        (map):
     44        (filter):
     45        (toLocaleString):
     46        * runtime/ArrayPrototype.cpp:
     47        * runtime/ArrayPrototype.h:
     48        * runtime/CommonIdentifiers.h:
     49        * runtime/JSGenericTypedArrayView.h:
     50        (JSC::JSGenericTypedArrayView::toAdaptorNativeFromValue):
     51        (JSC::JSGenericTypedArrayView::setRangeToValue):
     52        (JSC::JSGenericTypedArrayView::sort):
     53        (JSC::JSGenericTypedArrayView::purifyArray):
     54        (JSC::JSGenericTypedArrayView::sortComparison):
     55        (JSC::JSGenericTypedArrayView::sortFloat):
     56        * runtime/JSGenericTypedArrayViewInlines.h:
     57        * runtime/JSGenericTypedArrayViewPrototypeFunctions.h: Added.
     58        (JSC::argumentClampedIndexFromStartOrEnd):
     59        (JSC::genericTypedArrayViewProtoFuncSet):
     60        (JSC::genericTypedArrayViewProtoFuncEntries):
     61        (JSC::genericTypedArrayViewProtoFuncCopyWithin):
     62        (JSC::genericTypedArrayViewProtoFuncFill):
     63        (JSC::genericTypedArrayViewProtoFuncIndexOf):
     64        (JSC::genericTypedArrayViewProtoFuncJoin):
     65        (JSC::genericTypedArrayViewProtoFuncKeys):
     66        (JSC::genericTypedArrayViewProtoFuncLastIndexOf):
     67        (JSC::genericTypedArrayViewProtoGetterFuncLength):
     68        (JSC::genericTypedArrayViewProtoGetterFuncByteLength):
     69        (JSC::genericTypedArrayViewProtoGetterFuncByteOffset):
     70        (JSC::genericTypedArrayViewProtoFuncReverse):
     71        (JSC::genericTypedArrayViewPrivateFuncSort):
     72        (JSC::genericTypedArrayViewProtoFuncSlice):
     73        (JSC::genericTypedArrayViewProtoFuncSubarray):
     74        (JSC::typedArrayViewProtoFuncValues):
     75        * runtime/JSGenericTypedArrayViewPrototypeInlines.h:
     76        (JSC::JSGenericTypedArrayViewPrototype<ViewClass>::finishCreation):
     77        (JSC::genericTypedArrayViewProtoFuncSet): Deleted.
     78        (JSC::genericTypedArrayViewProtoFuncSubarray): Deleted.
     79        * runtime/JSGlobalObject.cpp:
     80        (JSC::JSGlobalObject::init):
     81        * runtime/JSObject.h:
     82        * runtime/JSTypedArrayPrototypes.cpp:
     83        * runtime/JSTypedArrayPrototypes.h:
     84        * runtime/JSTypedArrayViewPrototype.cpp: Added.
     85        (JSC::typedArrayViewPrivateFuncLength):
     86        (JSC::typedArrayViewPrivateFuncSort):
     87        (JSC::typedArrayViewProtoFuncSet):
     88        (JSC::typedArrayViewProtoFuncEntries):
     89        (JSC::typedArrayViewProtoFuncCopyWithin):
     90        (JSC::typedArrayViewProtoFuncFill):
     91        (JSC::typedArrayViewProtoFuncLastIndexOf):
     92        (JSC::typedArrayViewProtoFuncIndexOf):
     93        (JSC::typedArrayViewProtoFuncJoin):
     94        (JSC::typedArrayViewProtoFuncKeys):
     95        (JSC::typedArrayViewProtoGetterFuncLength):
     96        (JSC::typedArrayViewProtoGetterFuncByteLength):
     97        (JSC::typedArrayViewProtoGetterFuncByteOffset):
     98        (JSC::typedArrayViewProtoFuncReverse):
     99        (JSC::typedArrayViewProtoFuncSubarray):
     100        (JSC::typedArrayViewProtoFuncSlice):
     101        (JSC::typedArrayViewProtoFuncValues):
     102        (JSC::JSTypedArrayViewPrototype::JSTypedArrayViewPrototype):
     103        (JSC::JSTypedArrayViewPrototype::finishCreation):
     104        (JSC::JSTypedArrayViewPrototype::create):
     105        (JSC::JSTypedArrayViewPrototype::createStructure):
     106        * runtime/JSTypedArrayViewPrototype.h: Copied from Source/JavaScriptCore/runtime/JSTypedArrayPrototypes.cpp.
     107        * tests/es6.yaml:
     108        * tests/stress/resources/standalone-pre.js: Added.
     109        (description):
     110        (debug):
     111        (escapeString):
     112        (testPassed):
     113        (testFailed):
     114        (areNumbersEqual):
     115        (areArraysEqual):
     116        (isMinusZero):
     117        (isTypedArray):
     118        (isResultCorrect):
     119        (stringify):
     120        (shouldBe):
     121        (dfgShouldBe):
     122        (shouldBeType):
     123        (shouldBeTrue):
     124        (shouldBeFalse):
     125        (shouldBeNaN):
     126        (shouldBeNull):
     127        (shouldBeEqualToString):
     128        (shouldBeUndefined):
     129        (shouldNotThrow):
     130        (shouldThrow):
     131        (dfgCompiled):
     132        (dfgIncrement):
     133        (noInline):
     134        (finishJSTest):
     135        * tests/stress/resources/typedarray-test-helper-functions.js: Added.
     136        (forEachTypedArray):
     137        (isSameFunctionForEachTypedArrayPrototype.eq):
     138        (isSameFunctionForEachTypedArrayPrototype):
     139        (hasSameValues):
     140        (foo):
     141        (testPrototypeFunctionHelper):
     142        (testPrototypeFunctionOnSigned):
     143        (testPrototypeFunctionOnFloat):
     144        (testPrototypeFunction):
     145        (tester):
     146        (testPrototypeReceivesArray):
     147        * tests/stress/typedarray-copyWithin.js: Added.
     148        * tests/stress/typedarray-every.js: Added.
     149        (isBigEnough):
     150        (isBigEnoughAndChange):
     151        (isBigEnoughAndException):
     152        * tests/stress/typedarray-fill.js: Added.
     153        * tests/stress/typedarray-filter.js: Added.
     154        (keepEven):
     155        (keepEvenAndChange):
     156        (isBigEnoughAndException):
     157        * tests/stress/typedarray-find.js: Added.
     158        (keepEven):
     159        (keepEvenAndChange):
     160        (isBigEnoughAndException):
     161        * tests/stress/typedarray-findIndex.js: Added.
     162        (keepEven):
     163        (keepEvenAndChange):
     164        (isBigEnoughAndException):
     165        * tests/stress/typedarray-forEach.js: Added.
     166        (checkCorrect.let.list):
     167        (checkCorrect):
     168        (createChecker):
     169        (foo):
     170        (changeArray):
     171        (isBigEnoughAndException):
     172        * tests/stress/typedarray-indexOf.js: Added.
     173        (keepEven):
     174        * tests/stress/typedarray-lastIndexOf.js: Added.
     175        * tests/stress/typedarray-map.js: Added.
     176        (even):
     177        (evenAndChange):
     178        (isBigEnoughAndException):
     179        * tests/stress/typedarray-reduce.js: Added.
     180        (createArray):
     181        (sum):
     182        (createArrayAndChange):
     183        (isBigEnoughAndException):
     184        * tests/stress/typedarray-reduceRight.js: Added.
     185        (createArray):
     186        (sum):
     187        (createArrayAndChange):
     188        (isBigEnoughAndException):
     189        * tests/stress/typedarray-slice.js: Added.
     190        * tests/stress/typedarray-some.js: Added.
     191        (isBigEnough):
     192        (isBigEnoughAndChange):
     193        (isBigEnoughAndException):
     194        * tests/stress/typedarray-sort.js: Added.
     195        (sortBackwards):
     196        (compareException):
     197
    11982015-10-01  Yusuke Suzuki  <utatane.tea@gmail.com>
    2199
  • trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj

    r190385 r190429  
    825825    <ClCompile Include="..\runtime\JSTypedArrayPrototypes.cpp" />
    826826    <ClCompile Include="..\runtime\JSTypedArrays.cpp" />
     827    <ClCompile Include="..\runtime\JSTypedArrayViewPrototype.cpp" />
    827828    <ClCompile Include="..\runtime\JSEnvironmentRecord.cpp" />
    828829    <ClCompile Include="..\runtime\JSWeakMap.cpp" />
     
    16521653    <ClInclude Include="..\runtime\JSGenericTypedArrayViewInlines.h" />
    16531654    <ClInclude Include="..\runtime\JSGenericTypedArrayViewPrototype.h" />
     1655    <ClInclude Include="..\runtime\JSGenericTypedArrayViewPrototypeFunctions.h" />
    16541656    <ClInclude Include="..\runtime\JSGenericTypedArrayViewPrototypeInlines.h" />
    16551657    <ClInclude Include="..\runtime\JSGlobalObject.h" />
     
    16961698    <ClInclude Include="..\runtime\JSTypedArrayPrototypes.h" />
    16971699    <ClInclude Include="..\runtime\JSTypedArrays.h" />
     1700    <ClInclude Include="..\runtime\JSTypedArrayViewPrototype.h" />
    16981701    <ClInclude Include="..\runtime\JSUint16Array.h" />
    16991702    <ClInclude Include="..\runtime\JSUint32Array.h" />
  • trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters

    r190385 r190429  
    10841084      <Filter>runtime</Filter>
    10851085    </ClCompile>
     1086    <ClCompile Include="..\runtime\JSTypedArrayViewPrototype.cpp">
     1087      <Filter>runtime</Filter>
     1088    </ClCompile>
    10861089    <ClCompile Include="..\runtime\DataView.cpp">
    10871090      <Filter>runtime</Filter>
     
    33793382      <Filter>runtime</Filter>
    33803383    </ClInclude>
     3384    <ClInclude Include="..\runtime\JSGenericTypedArrayViewPrototypeFunctions.h">
     3385      <Filter>runtime</Filter>
     3386    </ClInclude>
    33813387    <ClInclude Include="..\runtime\JSInternalPromise.h">
    33823388      <Filter>runtime</Filter>
     
    34543460      <Filter>runtime</Filter>
    34553461    </ClInclude>
     3462    <ClInclude Include="..\runtime\JSTypedArrayViewPrototype.h">
     3463      <Filter>runtime</Filter>
     3464    </ClCompile>
    34563465    <ClInclude Include="..\runtime\JSUint16Array.h">
    34573466      <Filter>runtime</Filter>
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r190385 r190429  
    972972                52C952B719A289850069B386 /* TypeProfiler.h in Headers */ = {isa = PBXBuildFile; fileRef = 52C952B619A289850069B386 /* TypeProfiler.h */; settings = {ATTRIBUTES = (Private, ); }; };
    973973                52C952B919A28A1C0069B386 /* TypeProfiler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 52C952B819A28A1C0069B386 /* TypeProfiler.cpp */; };
     974                53917E7B1B7906FA000EBD33 /* JSGenericTypedArrayViewPrototypeFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = 53917E7A1B7906E4000EBD33 /* JSGenericTypedArrayViewPrototypeFunctions.h */; };
    974975                5D53726F0E1C54880021E549 /* Tracing.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D53726E0E1C54880021E549 /* Tracing.h */; };
    975976                5D5D8AD10E0D0EBE00F9C692 /* libedit.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D5D8AD00E0D0EBE00F9C692 /* libedit.dylib */; };
     
    17171718                C4F4B6F61A05C984005CAB76 /* objc_generator_templates.py in Headers */ = {isa = PBXBuildFile; fileRef = C4F4B6D81A05C76F005CAB76 /* objc_generator_templates.py */; settings = {ATTRIBUTES = (Private, ); }; };
    17181719                DC00039319D8BE6F00023EB0 /* DFGPreciseLocalClobberize.h in Headers */ = {isa = PBXBuildFile; fileRef = DC00039019D8BE6F00023EB0 /* DFGPreciseLocalClobberize.h */; };
     1720                DEA7E2441BBC677200D78440 /* JSTypedArrayViewPrototype.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53F256E11B87E28000B4B768 /* JSTypedArrayViewPrototype.cpp */; };
     1721                DEA7E2451BBC677F00D78440 /* JSTypedArrayViewPrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = 53917E7C1B791106000EBD33 /* JSTypedArrayViewPrototype.h */; settings = {ATTRIBUTES = (Private, ); }; };
    17191722                E124A8F70E555775003091F1 /* OpaqueJSString.h in Headers */ = {isa = PBXBuildFile; fileRef = E124A8F50E555775003091F1 /* OpaqueJSString.h */; settings = {ATTRIBUTES = (Private, ); }; };
    17201723                E124A8F80E555775003091F1 /* OpaqueJSString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E124A8F60E555775003091F1 /* OpaqueJSString.cpp */; };
     
    27882791                52C952B619A289850069B386 /* TypeProfiler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TypeProfiler.h; sourceTree = "<group>"; };
    27892792                52C952B819A28A1C0069B386 /* TypeProfiler.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TypeProfiler.cpp; sourceTree = "<group>"; };
     2793                53917E7A1B7906E4000EBD33 /* JSGenericTypedArrayViewPrototypeFunctions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSGenericTypedArrayViewPrototypeFunctions.h; sourceTree = "<group>"; };
     2794                53917E7C1B791106000EBD33 /* JSTypedArrayViewPrototype.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSTypedArrayViewPrototype.h; sourceTree = "<group>"; };
     2795                53917E831B791CB8000EBD33 /* TypedArray.prototype.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = TypedArray.prototype.js; path = builtins/TypedArray.prototype.js; sourceTree = SOURCE_ROOT; };
     2796                53F256E11B87E28000B4B768 /* JSTypedArrayViewPrototype.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSTypedArrayViewPrototype.cpp; sourceTree = "<group>"; };
    27902797                5540758418F4A37500602A5D /* CompileRuntimeToLLVMIR.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = CompileRuntimeToLLVMIR.xcconfig; sourceTree = "<group>"; };
    27912798                593D43CCA0BBE06D89C59707 /* MapDataInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MapDataInlines.h; sourceTree = "<group>"; };
     
    48134820                                0F2B66C617B6B5AB00A7AE3F /* JSGenericTypedArrayViewInlines.h */,
    48144821                                0F2B66C717B6B5AB00A7AE3F /* JSGenericTypedArrayViewPrototype.h */,
     4822                                53917E7A1B7906E4000EBD33 /* JSGenericTypedArrayViewPrototypeFunctions.h */,
    48154823                                0F2B66C817B6B5AB00A7AE3F /* JSGenericTypedArrayViewPrototypeInlines.h */,
    48164824                                797E07A71B8FCFB9008400BA /* JSGlobalLexicalEnvironment.cpp */,
     
    48974905                                0F2B66D017B6B5AB00A7AE3F /* JSTypedArrays.cpp */,
    48984906                                0F2B66D117B6B5AB00A7AE3F /* JSTypedArrays.h */,
     4907                                53F256E11B87E28000B4B768 /* JSTypedArrayViewPrototype.cpp */,
     4908                                53917E7C1B791106000EBD33 /* JSTypedArrayViewPrototype.h */,
    48994909                                6507D2970E871E4A00D7D896 /* JSTypeInfo.h */,
    49004910                                0F2B66D417B6B5AB00A7AE3F /* JSUint16Array.h */,
     
    58925902                                7CF9BC601B65D9B1009DB1EF /* StringConstructor.js */,
    58935903                                7CF9BC611B65D9B1009DB1EF /* StringIterator.prototype.js */,
     5904                                53917E831B791CB8000EBD33 /* TypedArray.prototype.js */,
    58945905                        );
    58955906                        path = builtins;
     
    62286239                                0F3A1BFA1A9ECB7D000DE01A /* DFGPutStackSinkingPhase.h in Headers */,
    62296240                                86EC9DD11328DF82002B2AD7 /* DFGRegisterBank.h in Headers */,
     6241                                DEA7E2451BBC677F00D78440 /* JSTypedArrayViewPrototype.h in Headers */,
    62306242                                0F2FCCFC18A60070001A27F8 /* DFGSafepoint.h in Headers */,
    62316243                                A77A424317A0BBFD00A8DB81 /* DFGSafeToExecute.h in Headers */,
     
    63686380                                A54E8EB018BFFBBB00556D28 /* GCSegmentedArray.h in Headers */,
    63696381                                A54E8EB118BFFBBE00556D28 /* GCSegmentedArrayInlines.h in Headers */,
    6370                                 C2239D1B16262BDD005AC5FD /* GCThread.h in Headers */,
    63716382                                A532439418569709002ED692 /* generate-combined-inspector-json.py in Headers */,
    63726383                                C4703CC0192844960013FBEA /* generate-inspector-protocol-bindings.py in Headers */,
     
    65516562                                A7B4ACAF1484C9CE00B38A36 /* JSExportMacros.h in Headers */,
    65526563                                0F2B66EF17B6B5AB00A7AE3F /* JSFloat32Array.h in Headers */,
     6564                                53917E7B1B7906FA000EBD33 /* JSGenericTypedArrayViewPrototypeFunctions.h in Headers */,
    65536565                                0F2B66F017B6B5AB00A7AE3F /* JSFloat64Array.h in Headers */,
    65546566                                BC18C41F0E16F5CD00B34460 /* JSFunction.h in Headers */,
     
    77267738                                0F766D2F15A8DCE0008F363E /* GCAwareJITStubRoutine.cpp in Sources */,
    77277739                                2ADFA26318EF3540004F9FCC /* GCLogging.cpp in Sources */,
    7728                                 C2239D1A16262BDD005AC5FD /* GCThread.cpp in Sources */,
    77297740                                0F93329F14CA7DCA0085F3C6 /* GetByIdStatus.cpp in Sources */,
    77307741                                0F0332C318B01763005F979A /* GetByIdVariant.cpp in Sources */,
     
    79627973                                95742F650DD11F5A000917FB /* Profile.cpp in Sources */,
    79637974                                95CD45760E1C4FDD0085358E /* ProfileGenerator.cpp in Sources */,
     7975                                DEA7E2441BBC677200D78440 /* JSTypedArrayViewPrototype.cpp in Sources */,
    79647976                                95AB83560DA43C3000BC83F3 /* ProfileNode.cpp in Sources */,
    79657977                                0FF729AD166AD35C000F5BA3 /* ProfilerBytecode.cpp in Sources */,
  • trunk/Source/JavaScriptCore/runtime/ArrayPrototype.cpp

    r190385 r190429  
    4747namespace JSC {
    4848
    49 EncodedJSValue JSC_HOST_CALL arrayProtoFuncToString(ExecState*);
    5049EncodedJSValue JSC_HOST_CALL arrayProtoFuncToLocaleString(ExecState*);
    5150EncodedJSValue JSC_HOST_CALL arrayProtoFuncConcat(ExecState*);
  • trunk/Source/JavaScriptCore/runtime/ArrayPrototype.h

    r190385 r190429  
    4747};
    4848
     49EncodedJSValue JSC_HOST_CALL arrayProtoFuncToString(ExecState*);
    4950EncodedJSValue JSC_HOST_CALL arrayProtoFuncValues(ExecState*);
    5051
  • trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h

    r190401 r190429  
    293293    macro(getOwnPropertyNames) \
    294294    macro(TypeError) \
     295    macro(typedArrayLength) \
     296    macro(typedArraySort) \
    295297    macro(undefined) \
    296298    macro(BuiltinLog) \
  • trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayView.h

    r190385 r190429  
    8888public:
    8989    typedef JSArrayBufferView Base;
     90    typedef typename Adaptor::Type ElementType;
     91
    9092    static const unsigned StructureFlags = Base::StructureFlags | OverridesGetPropertyNames | OverridesGetOwnPropertySlot | InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero;
    9193
     
    169171        return true;
    170172    }
    171    
     173
     174    static Optional<typename Adaptor::Type> toAdaptorNativeFromValue(ExecState* exec, JSValue jsValue)
     175    {
     176        typename Adaptor::Type value = toNativeFromValue<Adaptor>(exec, jsValue);
     177        if (exec->hadException())
     178            return Nullopt;
     179        return value;
     180    }
     181
     182    bool setRangeToValue(ExecState* exec, unsigned start, unsigned end, JSValue jsValue)
     183    {
     184        ASSERT(0 <= start && start <= end && end <= m_length);
     185
     186        typename Adaptor::Type value = toNativeFromValue<Adaptor>(exec, jsValue);
     187        if (exec->hadException())
     188            return false;
     189
     190        // We might want to do something faster here (e.g. SIMD) if this is too slow.
     191        typename Adaptor::Type* array = typedVector();
     192        for (unsigned i = start; i < end; ++i)
     193            array[i] = value;
     194
     195        return true;
     196    }
     197
     198    void sort()
     199    {
     200        switch (Adaptor::typeValue) {
     201        case TypeFloat32:
     202            sortFloat<int32_t>();
     203            break;
     204        case TypeFloat64:
     205            sortFloat<int64_t>();
     206            break;
     207        default: {
     208            ElementType* array = typedVector();
     209            std::sort(array, array + m_length);
     210            break;
     211        }
     212        }
     213    }
     214
    172215    bool canAccessRangeQuickly(unsigned offset, unsigned length)
    173216    {
     
    258301        ExecState*, JSGenericTypedArrayView<OtherAdaptor>*,
    259302        unsigned offset, unsigned length);
     303
     304    // The ECMA 6 spec states that floating point Typed Arrays should have the following ordering:
     305    //
     306    // -Inifinity < negative finite numbers < -0.0 < 0.0 < positive finite numbers < Infinity < NaN
     307    // Note: regardless of the sign or exact representation of a NaN it is greater than all other values.
     308    //
     309    // An interesting fact about IEEE 754 floating point numbers is that have an adjacent representation
     310    // i.e. for any finite floating point x there does not exist a finite floating point y such that
     311    // ((float) ((int) x + 1)) > y > x (where int represents a signed bit integer with the same number
     312    // of bits as float). Thus, if we have an array of floating points if we view it as an
     313    // array of signed bit integers it will sort in the format we desire. Note, denormal
     314    // numbers fit this property as they are floating point numbers with a exponent field of all
     315    // zeros so they will be closer to the signed zeros than any normalized number.
     316    //
     317    // All the processors we support, however, use twos complement. Fortunately, if you compare a signed
     318    // bit number as if it were twos complement the result will be correct assuming both numbers are not
     319    // negative. e.g.
     320    //
     321    //    - <=> - = reversed (-30 > -20 = true)
     322    //    + <=> + = ordered (30 > 20 = true)
     323    //    - <=> + = ordered (-30 > 20 = false)
     324    //    + <=> - = ordered (30 > -20 = true)
     325    //
     326    // For NaN, we normalize the NaN to a peticular representation; the sign bit is 0, all exponential bits
     327    // are 1 and only the MSB of the mantissa is 1. So, NaN is recognized as the largest integral numbers.
     328
     329    void purifyArray()
     330    {
     331        ElementType* array = typedVector();
     332        for (unsigned i = 0; i < m_length; i++)
     333            array[i] = purifyNaN(array[i]);
     334    }
     335
     336    template<typename IntegralType>
     337    static bool ALWAYS_INLINE sortComparison(IntegralType a, IntegralType b)
     338    {
     339        if (a >= 0 || b >= 0)
     340            return a < b;
     341        return a > b;
     342    }
     343
     344    template<typename IntegralType>
     345    void sortFloat()
     346    {
     347        ASSERT(sizeof(IntegralType) == sizeof(ElementType));
     348
     349        // Since there might be another view that sets the bits of
     350        // our floats to NaNs with negative sign bits we need to
     351        // purify the array.
     352        // We use a separate function here to avoid the strict aliasing rule.
     353        // We could use a union but ASAN seems to frown upon that.
     354        purifyArray();
     355
     356        IntegralType* array = reinterpret_cast<IntegralType*>(typedVector());
     357        std::sort(array, array + m_length, sortComparison<IntegralType>);
     358
     359    }
     360
    260361};
    261362
  • trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewInlines.h

    r190385 r190429  
    3131#include "Error.h"
    3232#include "ExceptionHelpers.h"
     33#include "JSArrayBuffer.h"
    3334#include "JSGenericTypedArrayView.h"
    3435#include "Reject.h"
  • trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewPrototypeInlines.h

    r190385 r190429  
    11/*
    2  * Copyright (C) 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013-2015 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2727#define JSGenericTypedArrayViewPrototypeInlines_h
    2828
    29 #include "Error.h"
    30 #include "ExceptionHelpers.h"
    31 #include "JSFunction.h"
    3229#include "JSGenericTypedArrayViewPrototype.h"
    33 #include <wtf/StdLibExtras.h>
    3430
    3531namespace JSC {
    36 
    37 template<typename ViewClass>
    38 EncodedJSValue JSC_HOST_CALL genericTypedArrayViewProtoFuncSet(ExecState* exec)
    39 {
    40     ViewClass* thisObject = jsDynamicCast<ViewClass*>(exec->thisValue());
    41     if (!thisObject)
    42         return throwVMError(exec, createTypeError(exec, "Receiver should be a typed array view"));
    4332   
    44     if (!exec->argumentCount())
    45         return throwVMError(exec, createTypeError(exec, "Expected at least one argument"));
    46    
    47     JSObject* sourceArray = jsDynamicCast<JSObject*>(exec->uncheckedArgument(0));
    48     if (!sourceArray)
    49         return throwVMError(exec, createTypeError(exec, "First argument should be an object"));
    50    
    51     unsigned offset;
    52     if (exec->argumentCount() >= 2) {
    53         offset = exec->uncheckedArgument(1).toUInt32(exec);
    54         if (exec->hadException())
    55             return JSValue::encode(jsUndefined());
    56     } else
    57         offset = 0;
    58    
    59     unsigned length = sourceArray->get(exec, exec->vm().propertyNames->length).toUInt32(exec);
    60     if (exec->hadException())
    61         return JSValue::encode(jsUndefined());
    62    
    63     thisObject->set(exec, sourceArray, offset, length);
    64     return JSValue::encode(jsUndefined());
    65 }
    66 
    67 template<typename ViewClass>
    68 EncodedJSValue JSC_HOST_CALL genericTypedArrayViewProtoFuncSubarray(ExecState* exec)
    69 {
    70     JSFunction* callee = jsCast<JSFunction*>(exec->callee());
    71    
    72     ViewClass* thisObject = jsDynamicCast<ViewClass*>(exec->thisValue());
    73     if (!thisObject)
    74         return throwVMError(exec, createTypeError(exec, "Receiver should be a typed array view"));
    75    
    76     if (!exec->argumentCount())
    77         return throwVMError(exec, createTypeError(exec, "Expected at least one argument"));
    78    
    79     int32_t begin = exec->uncheckedArgument(0).toInt32(exec);
    80     if (exec->hadException())
    81         return JSValue::encode(jsUndefined());
    82    
    83     int32_t end;
    84     if (exec->argumentCount() >= 2) {
    85         end = exec->uncheckedArgument(1).toInt32(exec);
    86         if (exec->hadException())
    87             return JSValue::encode(jsUndefined());
    88     } else
    89         end = thisObject->length();
    90    
    91     // Get the length here; later assert that the length didn't change.
    92     unsigned thisLength = thisObject->length();
    93    
    94     // Handle negative indices: -x => length - x
    95     if (begin < 0)
    96         begin = std::max(static_cast<int>(thisLength + begin), 0);
    97     if (end < 0)
    98         end = std::max(static_cast<int>(thisLength + end), 0);
    99    
    100     // Clamp the indices to the bounds of the array.
    101     ASSERT(begin >= 0);
    102     ASSERT(end >= 0);
    103     begin = std::min(begin, static_cast<int32_t>(thisLength));
    104     end = std::min(end, static_cast<int32_t>(thisLength));
    105    
    106     // Clamp end to begin.
    107     end = std::max(begin, end);
    108    
    109     ASSERT(end >= begin);
    110     unsigned offset = begin;
    111     unsigned length = end - begin;
    112    
    113     RefPtr<ArrayBuffer> arrayBuffer = thisObject->buffer();
    114     RELEASE_ASSERT(thisLength == thisObject->length());
    115    
    116     Structure* structure =
    117         callee->globalObject()->typedArrayStructure(ViewClass::TypedArrayStorageType);
    118    
    119     ViewClass* result = ViewClass::create(
    120         exec, structure, arrayBuffer,
    121         thisObject->byteOffset() + offset * ViewClass::elementSize,
    122         length);
    123    
    124     return JSValue::encode(result);
    125 }
    126 
    12733template<typename ViewClass>
    12834JSGenericTypedArrayViewPrototype<ViewClass>::JSGenericTypedArrayViewPrototype(VM& vm, Structure* structure)
     
    13339template<typename ViewClass>
    13440void JSGenericTypedArrayViewPrototype<ViewClass>::finishCreation(
    135     VM& vm, JSGlobalObject* globalObject)
     41    VM& vm, JSGlobalObject*)
    13642{
    13743    Base::finishCreation(vm);
    13844   
    13945    ASSERT(inherits(info()));
    140    
    141     JSC_NATIVE_FUNCTION(vm.propertyNames->set, genericTypedArrayViewProtoFuncSet<ViewClass>, DontEnum, 2);
    142     JSC_NATIVE_FUNCTION(vm.propertyNames->subarray, genericTypedArrayViewProtoFuncSubarray<ViewClass>, DontEnum, 2);
     46
    14347    putDirect(vm, vm.propertyNames->BYTES_PER_ELEMENT, jsNumber(ViewClass::elementSize), DontEnum | ReadOnly | DontDelete);
     48
    14449}
    14550
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp

    r190385 r190429  
    100100#include "JSTypedArrayConstructors.h"
    101101#include "JSTypedArrayPrototypes.h"
     102#include "JSTypedArrayViewPrototype.h"
    102103#include "JSTypedArrays.h"
    103104#include "JSWASMModule.h"
     
    295296    m_objectPrototype->putDirectNonIndexAccessor(vm, vm.propertyNames->underscoreProto, protoAccessor, Accessor | DontEnum);
    296297    m_functionPrototype->structure()->setPrototypeWithoutTransition(vm, m_objectPrototype.get());
    297    
    298     m_typedArrays[toIndex(TypeInt8)].prototype.set(vm, this, JSInt8ArrayPrototype::create(vm, this, JSInt8ArrayPrototype::createStructure(vm, this, m_objectPrototype.get())));
    299     m_typedArrays[toIndex(TypeInt16)].prototype.set(vm, this, JSInt16ArrayPrototype::create(vm, this, JSInt16ArrayPrototype::createStructure(vm, this, m_objectPrototype.get())));
    300     m_typedArrays[toIndex(TypeInt32)].prototype.set(vm, this, JSInt32ArrayPrototype::create(vm, this, JSInt32ArrayPrototype::createStructure(vm, this, m_objectPrototype.get())));
    301     m_typedArrays[toIndex(TypeUint8)].prototype.set(vm, this, JSUint8ArrayPrototype::create(vm, this, JSUint8ArrayPrototype::createStructure(vm, this, m_objectPrototype.get())));
    302     m_typedArrays[toIndex(TypeUint8Clamped)].prototype.set(vm, this, JSUint8ClampedArrayPrototype::create(vm, this, JSUint8ClampedArrayPrototype::createStructure(vm, this, m_objectPrototype.get())));
    303     m_typedArrays[toIndex(TypeUint16)].prototype.set(vm, this, JSUint16ArrayPrototype::create(vm, this, JSUint16ArrayPrototype::createStructure(vm, this, m_objectPrototype.get())));
    304     m_typedArrays[toIndex(TypeUint32)].prototype.set(vm, this, JSUint32ArrayPrototype::create(vm, this, JSUint32ArrayPrototype::createStructure(vm, this, m_objectPrototype.get())));
    305     m_typedArrays[toIndex(TypeFloat32)].prototype.set(vm, this, JSFloat32ArrayPrototype::create(vm, this, JSFloat32ArrayPrototype::createStructure(vm, this, m_objectPrototype.get())));
    306     m_typedArrays[toIndex(TypeFloat64)].prototype.set(vm, this, JSFloat64ArrayPrototype::create(vm, this, JSFloat64ArrayPrototype::createStructure(vm, this, m_objectPrototype.get())));
     298
     299    JSTypedArrayViewPrototype* typedArrayProto = JSTypedArrayViewPrototype::create(vm, this, JSTypedArrayViewPrototype::createStructure(vm, this, m_objectPrototype.get()));
     300
     301    m_typedArrays[toIndex(TypeInt8)].prototype.set(vm, this, JSInt8ArrayPrototype::create(vm, this, JSInt8ArrayPrototype::createStructure(vm, this, typedArrayProto)));
     302    m_typedArrays[toIndex(TypeInt16)].prototype.set(vm, this, JSInt16ArrayPrototype::create(vm, this, JSInt16ArrayPrototype::createStructure(vm, this, typedArrayProto)));
     303    m_typedArrays[toIndex(TypeInt32)].prototype.set(vm, this, JSInt32ArrayPrototype::create(vm, this, JSInt32ArrayPrototype::createStructure(vm, this, typedArrayProto)));
     304    m_typedArrays[toIndex(TypeUint8)].prototype.set(vm, this, JSUint8ArrayPrototype::create(vm, this, JSUint8ArrayPrototype::createStructure(vm, this, typedArrayProto)));
     305    m_typedArrays[toIndex(TypeUint8Clamped)].prototype.set(vm, this, JSUint8ClampedArrayPrototype::create(vm, this, JSUint8ClampedArrayPrototype::createStructure(vm, this, typedArrayProto)));
     306    m_typedArrays[toIndex(TypeUint16)].prototype.set(vm, this, JSUint16ArrayPrototype::create(vm, this, JSUint16ArrayPrototype::createStructure(vm, this, typedArrayProto)));
     307    m_typedArrays[toIndex(TypeUint32)].prototype.set(vm, this, JSUint32ArrayPrototype::create(vm, this, JSUint32ArrayPrototype::createStructure(vm, this, typedArrayProto)));
     308    m_typedArrays[toIndex(TypeFloat32)].prototype.set(vm, this, JSFloat32ArrayPrototype::create(vm, this, JSFloat32ArrayPrototype::createStructure(vm, this, typedArrayProto)));
     309    m_typedArrays[toIndex(TypeFloat64)].prototype.set(vm, this, JSFloat64ArrayPrototype::create(vm, this, JSFloat64ArrayPrototype::createStructure(vm, this, typedArrayProto)));
    307310    m_typedArrays[toIndex(TypeDataView)].prototype.set(vm, this, JSDataViewPrototype::create(vm, JSDataViewPrototype::createStructure(vm, this, m_objectPrototype.get())));
    308311   
     
    488491    JSFunction* privateFuncToLength = JSFunction::createBuiltinFunction(vm, globalObjectToLengthCodeGenerator(vm), this);
    489492    JSFunction* privateFuncToInteger = JSFunction::createBuiltinFunction(vm, globalObjectToIntegerCodeGenerator(vm), this);
     493    JSFunction* privateFuncTypedArrayLength = JSFunction::create(vm, this, 0, String(), typedArrayViewPrivateFuncLength);
     494    JSFunction* privateFuncTypedArraySort = JSFunction::create(vm, this, 0, String(), typedArrayViewPrivateFuncSort);
    490495
    491496    GlobalPropertyInfo staticGlobals[] = {
     
    499504        GlobalPropertyInfo(vm.propertyNames->enqueueJobPrivateName, JSFunction::create(vm, this, 0, String(), enqueueJob), DontEnum | DontDelete | ReadOnly),
    500505        GlobalPropertyInfo(vm.propertyNames->TypeErrorPrivateName, m_typeErrorConstructor.get(), DontEnum | DontDelete | ReadOnly),
     506        GlobalPropertyInfo(vm.propertyNames->typedArrayLengthPrivateName, privateFuncTypedArrayLength, DontEnum | DontDelete | ReadOnly),
     507        GlobalPropertyInfo(vm.propertyNames->typedArraySortPrivateName, privateFuncTypedArraySort, DontEnum | DontDelete | ReadOnly),
    501508        GlobalPropertyInfo(vm.propertyNames->BuiltinLogPrivateName, builtinLog, DontEnum | DontDelete | ReadOnly),
    502509        GlobalPropertyInfo(vm.propertyNames->ArrayPrivateName, arrayConstructor, DontEnum | DontDelete | ReadOnly),
  • trunk/Source/JavaScriptCore/runtime/JSObject.h

    r190385 r190429  
    14761476        vm, globalObject, makeIdentifier(vm, (jsName)), (generatorName)(vm), (attributes))
    14771477
     1478// Helper for defining native getters on properties.
     1479#define JSC_NATIVE_GETTER(jsName, cppName, attributes, length) do { \
     1480        Identifier ident = makeIdentifier(vm, (jsName)); \
     1481        GetterSetter* accessor = GetterSetter::create(vm, globalObject); \
     1482        JSFunction* function = JSFunction::create(vm, globalObject, (length), ident.string(), (cppName)); \
     1483        accessor->setGetter(vm, globalObject, function); \
     1484        putDirectNonIndexAccessor(vm, ident, accessor, (attributes) | Accessor); \
     1485    } while (false)
     1486
     1487
    14781488} // namespace JSC
    14791489
  • trunk/Source/JavaScriptCore/runtime/JSTypedArrayPrototypes.cpp

    r190385 r190429  
    3232namespace JSC {
    3333
     34const ClassInfo JSTypedArrayViewPrototype::s_info = {"Prototype", &JSTypedArrayViewPrototype::Base::s_info, 0,
     35    CREATE_METHOD_TABLE(JSTypedArrayViewPrototype)};
     36
    3437#define MAKE_S_INFO(type) \
    3538    template<> const ClassInfo JS##type##Prototype::s_info = {#type "Prototype", &JS##type##Prototype::Base::s_info, 0, CREATE_METHOD_TABLE(JS##type##Prototype)}
  • trunk/Source/JavaScriptCore/runtime/JSTypedArrayPrototypes.h

    r190385 r190429  
    2828
    2929#include "JSGenericTypedArrayViewPrototype.h"
     30#include "JSTypedArrayViewPrototype.h"
    3031#include "JSTypedArrays.h"
    3132
  • trunk/Source/JavaScriptCore/runtime/JSTypedArrayViewPrototype.h

    r190426 r190429  
    11/*
    2  * Copyright (C) 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2015 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2121 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    2222 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
     23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2424 */
    2525
    26 #include "config.h"
    27 #include "JSTypedArrayPrototypes.h"
     26#ifndef JSTypedArrayViewPrototype_h
     27#define JSTypedArrayViewPrototype_h
    2828
    29 #include "JSGenericTypedArrayViewPrototypeInlines.h"
    30 #include "JSCInlines.h"
     29#include "JSObject.h"
    3130
    3231namespace JSC {
    3332
    34 #define MAKE_S_INFO(type) \
    35     template<> const ClassInfo JS##type##Prototype::s_info = {#type "Prototype", &JS##type##Prototype::Base::s_info, 0, CREATE_METHOD_TABLE(JS##type##Prototype)}
     33class JSTypedArrayViewPrototype : public JSNonFinalObject {
     34public:
     35    typedef JSNonFinalObject Base;
    3636
    37 MAKE_S_INFO(Int8Array);
    38 MAKE_S_INFO(Int16Array);
    39 MAKE_S_INFO(Int32Array);
    40 MAKE_S_INFO(Uint8Array);
    41 MAKE_S_INFO(Uint8ClampedArray);
    42 MAKE_S_INFO(Uint16Array);
    43 MAKE_S_INFO(Uint32Array);
    44 MAKE_S_INFO(Float32Array);
    45 MAKE_S_INFO(Float64Array);
     37protected:
     38    JSTypedArrayViewPrototype(VM&, Structure*);
     39    void finishCreation(VM&, JSGlobalObject*);
    4640
     41public:
     42    static JSTypedArrayViewPrototype* create(VM&, JSGlobalObject*, Structure*);
     43
     44    DECLARE_INFO;
     45
     46    static Structure* createStructure(VM&, JSGlobalObject*, JSValue prototype);
     47};
     48
     49EncodedJSValue JSC_HOST_CALL typedArrayViewPrivateFuncSort(ExecState*);
     50EncodedJSValue JSC_HOST_CALL typedArrayViewPrivateFuncLength(ExecState*);
     51
     52   
    4753} // namespace JSC
    4854
     55#endif /* JSTypedArrayViewPrototype_h */
  • trunk/Source/JavaScriptCore/tests/es6.yaml

    r190385 r190429  
    11201120  cmd: runES6 :fail
    11211121- path: es6/typed_arrays_%TypedArray%.prototype.copyWithin.js
    1122   cmd: runES6 :fail
     1122  cmd: runES6 :normal
    11231123- path: es6/typed_arrays_%TypedArray%.prototype.entries.js
    1124   cmd: runES6 :fail
     1124  cmd: runES6 :normal
    11251125- path: es6/typed_arrays_%TypedArray%.prototype.every.js
    1126   cmd: runES6 :fail
     1126  cmd: runES6 :normal
    11271127- path: es6/typed_arrays_%TypedArray%.prototype.fill.js
    1128   cmd: runES6 :fail
     1128  cmd: runES6 :normal
    11291129- path: es6/typed_arrays_%TypedArray%.prototype.filter.js
    1130   cmd: runES6 :fail
     1130  cmd: runES6 :normal
    11311131- path: es6/typed_arrays_%TypedArray%.prototype.find.js
    1132   cmd: runES6 :fail
     1132  cmd: runES6 :normal
    11331133- path: es6/typed_arrays_%TypedArray%.prototype.findIndex.js
    1134   cmd: runES6 :fail
     1134  cmd: runES6 :normal
    11351135- path: es6/typed_arrays_%TypedArray%.prototype.forEach.js
    1136   cmd: runES6 :fail
     1136  cmd: runES6 :normal
    11371137- path: es6/typed_arrays_%TypedArray%.prototype.indexOf.js
    1138   cmd: runES6 :fail
     1138  cmd: runES6 :normal
    11391139- path: es6/typed_arrays_%TypedArray%.prototype.join.js
    1140   cmd: runES6 :fail
     1140  cmd: runES6 :normal
    11411141- path: es6/typed_arrays_%TypedArray%.prototype.keys.js
    1142   cmd: runES6 :fail
     1142  cmd: runES6 :normal
    11431143- path: es6/typed_arrays_%TypedArray%.prototype.lastIndexOf.js
    1144   cmd: runES6 :fail
     1144  cmd: runES6 :normal
    11451145- path: es6/typed_arrays_%TypedArray%.prototype.map.js
    1146   cmd: runES6 :fail
     1146  cmd: runES6 :normal
    11471147- path: es6/typed_arrays_%TypedArray%.prototype.reduce.js
    1148   cmd: runES6 :fail
     1148  cmd: runES6 :normal
    11491149- path: es6/typed_arrays_%TypedArray%.prototype.reduceRight.js
    1150   cmd: runES6 :fail
     1150  cmd: runES6 :normal
    11511151- path: es6/typed_arrays_%TypedArray%.prototype.reverse.js
    1152   cmd: runES6 :fail
     1152  cmd: runES6 :normal
    11531153- path: es6/typed_arrays_%TypedArray%.prototype.slice.js
    1154   cmd: runES6 :fail
     1154  cmd: runES6 :normal
    11551155- path: es6/typed_arrays_%TypedArray%.prototype.some.js
    1156   cmd: runES6 :fail
     1156  cmd: runES6 :normal
    11571157- path: es6/typed_arrays_%TypedArray%.prototype.sort.js
    1158   cmd: runES6 :fail
     1158  cmd: runES6 :normal
    11591159- path: es6/typed_arrays_%TypedArray%.prototype.values.js
    1160   cmd: runES6 :fail
     1160  cmd: runES6 :normal
    11611161- path: es6/typed_arrays_%TypedArray%.prototype[Symbol.iterator].js
    1162   cmd: runES6 :fail
     1162  cmd: runES6 :normal
    11631163- path: es6/typed_arrays_%TypedArray%[Symbol.species].js
    11641164  cmd: runES6 :fail
Note: See TracChangeset for help on using the changeset viewer.