| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 (function(global, utils) { | 5 (function(global, utils) { |
| 6 | 6 |
| 7 "use strict"; | 7 "use strict"; |
| 8 | 8 |
| 9 %CheckIsBootstrapping(); | 9 %CheckIsBootstrapping(); |
| 10 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 var InnerArrayForEach; | 28 var InnerArrayForEach; |
| 29 var InnerArrayJoin; | 29 var InnerArrayJoin; |
| 30 var InnerArrayReduce; | 30 var InnerArrayReduce; |
| 31 var InnerArrayReduceRight; | 31 var InnerArrayReduceRight; |
| 32 var InnerArraySome; | 32 var InnerArraySome; |
| 33 var InnerArraySort; | 33 var InnerArraySort; |
| 34 var InnerArrayToLocaleString; | 34 var InnerArrayToLocaleString; |
| 35 var InternalArray = utils.InternalArray; | 35 var InternalArray = utils.InternalArray; |
| 36 var MaxSimple; | 36 var MaxSimple; |
| 37 var MinSimple; | 37 var MinSimple; |
| 38 var PackedArrayReverse; | |
| 39 var SpeciesConstructor; | 38 var SpeciesConstructor; |
| 40 var ToPositiveInteger; | 39 var ToPositiveInteger; |
| 41 var ToIndex; | 40 var ToIndex; |
| 42 var iteratorSymbol = utils.ImportNow("iterator_symbol"); | 41 var iteratorSymbol = utils.ImportNow("iterator_symbol"); |
| 43 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); | 42 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); |
| 44 | 43 |
| 45 macro TYPED_ARRAYS(FUNCTION) | 44 macro TYPED_ARRAYS(FUNCTION) |
| 46 // arrayIds below should be synchronized with Runtime_TypedArrayInitialize. | 45 // arrayIds below should be synchronized with Runtime_TypedArrayInitialize. |
| 47 FUNCTION(1, Uint8Array, 1) | 46 FUNCTION(1, Uint8Array, 1) |
| 48 FUNCTION(2, Int8Array, 1) | 47 FUNCTION(2, Int8Array, 1) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 74 InnerArrayFindIndex = from.InnerArrayFindIndex; | 73 InnerArrayFindIndex = from.InnerArrayFindIndex; |
| 75 InnerArrayForEach = from.InnerArrayForEach; | 74 InnerArrayForEach = from.InnerArrayForEach; |
| 76 InnerArrayJoin = from.InnerArrayJoin; | 75 InnerArrayJoin = from.InnerArrayJoin; |
| 77 InnerArrayReduce = from.InnerArrayReduce; | 76 InnerArrayReduce = from.InnerArrayReduce; |
| 78 InnerArrayReduceRight = from.InnerArrayReduceRight; | 77 InnerArrayReduceRight = from.InnerArrayReduceRight; |
| 79 InnerArraySome = from.InnerArraySome; | 78 InnerArraySome = from.InnerArraySome; |
| 80 InnerArraySort = from.InnerArraySort; | 79 InnerArraySort = from.InnerArraySort; |
| 81 InnerArrayToLocaleString = from.InnerArrayToLocaleString; | 80 InnerArrayToLocaleString = from.InnerArrayToLocaleString; |
| 82 MaxSimple = from.MaxSimple; | 81 MaxSimple = from.MaxSimple; |
| 83 MinSimple = from.MinSimple; | 82 MinSimple = from.MinSimple; |
| 84 PackedArrayReverse = from.PackedArrayReverse; | |
| 85 SpeciesConstructor = from.SpeciesConstructor; | 83 SpeciesConstructor = from.SpeciesConstructor; |
| 86 ToPositiveInteger = from.ToPositiveInteger; | 84 ToPositiveInteger = from.ToPositiveInteger; |
| 87 ToIndex = from.ToIndex; | 85 ToIndex = from.ToIndex; |
| 88 }); | 86 }); |
| 89 | 87 |
| 90 // --------------- Typed Arrays --------------------- | 88 // --------------- Typed Arrays --------------------- |
| 91 | 89 |
| 92 function TypedArrayDefaultConstructor(typedArray) { | 90 function TypedArrayDefaultConstructor(typedArray) { |
| 93 switch (%_ClassOf(typedArray)) { | 91 switch (%_ClassOf(typedArray)) { |
| 94 macro TYPED_ARRAY_CONSTRUCTOR_CASE(ARRAY_ID, NAME, ELEMENT_SIZE) | 92 macro TYPED_ARRAY_CONSTRUCTOR_CASE(ARRAY_ID, NAME, ELEMENT_SIZE) |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 function TypedArrayFindIndex(predicate, thisArg) { | 438 function TypedArrayFindIndex(predicate, thisArg) { |
| 441 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); | 439 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); |
| 442 | 440 |
| 443 var length = %_TypedArrayGetLength(this); | 441 var length = %_TypedArrayGetLength(this); |
| 444 | 442 |
| 445 return InnerArrayFindIndex(predicate, thisArg, this, length); | 443 return InnerArrayFindIndex(predicate, thisArg, this, length); |
| 446 } | 444 } |
| 447 %FunctionSetLength(TypedArrayFindIndex, 1); | 445 %FunctionSetLength(TypedArrayFindIndex, 1); |
| 448 | 446 |
| 449 | 447 |
| 450 // ES6 draft 05-18-15, section 22.2.3.21 | |
| 451 function TypedArrayReverse() { | |
| 452 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); | |
| 453 | |
| 454 var length = %_TypedArrayGetLength(this); | |
| 455 | |
| 456 return PackedArrayReverse(this, length); | |
| 457 } | |
| 458 | |
| 459 // ES6 draft 05-18-15, section 22.2.3.25 | 448 // ES6 draft 05-18-15, section 22.2.3.25 |
| 460 function TypedArraySort(comparefn) { | 449 function TypedArraySort(comparefn) { |
| 461 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); | 450 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); |
| 462 | 451 |
| 463 var length = %_TypedArrayGetLength(this); | 452 var length = %_TypedArrayGetLength(this); |
| 464 | 453 |
| 465 if (IS_UNDEFINED(comparefn)) { | 454 if (IS_UNDEFINED(comparefn)) { |
| 466 return %TypedArraySortFast(this); | 455 return %TypedArraySortFast(this); |
| 467 } | 456 } |
| 468 | 457 |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 "every", TypedArrayEvery, | 649 "every", TypedArrayEvery, |
| 661 "fill", TypedArrayFill, | 650 "fill", TypedArrayFill, |
| 662 "filter", TypedArrayFilter, | 651 "filter", TypedArrayFilter, |
| 663 "find", TypedArrayFind, | 652 "find", TypedArrayFind, |
| 664 "findIndex", TypedArrayFindIndex, | 653 "findIndex", TypedArrayFindIndex, |
| 665 "join", TypedArrayJoin, | 654 "join", TypedArrayJoin, |
| 666 "forEach", TypedArrayForEach, | 655 "forEach", TypedArrayForEach, |
| 667 "map", TypedArrayMap, | 656 "map", TypedArrayMap, |
| 668 "reduce", TypedArrayReduce, | 657 "reduce", TypedArrayReduce, |
| 669 "reduceRight", TypedArrayReduceRight, | 658 "reduceRight", TypedArrayReduceRight, |
| 670 "reverse", TypedArrayReverse, | |
| 671 "slice", TypedArraySlice, | 659 "slice", TypedArraySlice, |
| 672 "some", TypedArraySome, | 660 "some", TypedArraySome, |
| 673 "sort", TypedArraySort, | 661 "sort", TypedArraySort, |
| 674 "toLocaleString", TypedArrayToLocaleString | 662 "toLocaleString", TypedArrayToLocaleString |
| 675 ]); | 663 ]); |
| 676 | 664 |
| 677 %AddNamedProperty(GlobalTypedArray.prototype, "toString", ArrayToString, | 665 %AddNamedProperty(GlobalTypedArray.prototype, "toString", ArrayToString, |
| 678 DONT_ENUM); | 666 DONT_ENUM); |
| 679 | 667 |
| 680 | 668 |
| 681 macro SETUP_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE) | 669 macro SETUP_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE) |
| 682 %SetCode(GlobalNAME, NAMEConstructor); | 670 %SetCode(GlobalNAME, NAMEConstructor); |
| 683 %FunctionSetPrototype(GlobalNAME, new GlobalObject()); | 671 %FunctionSetPrototype(GlobalNAME, new GlobalObject()); |
| 684 %InternalSetPrototype(GlobalNAME, GlobalTypedArray); | 672 %InternalSetPrototype(GlobalNAME, GlobalTypedArray); |
| 685 %InternalSetPrototype(GlobalNAME.prototype, GlobalTypedArray.prototype); | 673 %InternalSetPrototype(GlobalNAME.prototype, GlobalTypedArray.prototype); |
| 686 | 674 |
| 687 %AddNamedProperty(GlobalNAME, "BYTES_PER_ELEMENT", ELEMENT_SIZE, | 675 %AddNamedProperty(GlobalNAME, "BYTES_PER_ELEMENT", ELEMENT_SIZE, |
| 688 READ_ONLY | DONT_ENUM | DONT_DELETE); | 676 READ_ONLY | DONT_ENUM | DONT_DELETE); |
| 689 | 677 |
| 690 %AddNamedProperty(GlobalNAME.prototype, | 678 %AddNamedProperty(GlobalNAME.prototype, |
| 691 "constructor", global.NAME, DONT_ENUM); | 679 "constructor", global.NAME, DONT_ENUM); |
| 692 %AddNamedProperty(GlobalNAME.prototype, | 680 %AddNamedProperty(GlobalNAME.prototype, |
| 693 "BYTES_PER_ELEMENT", ELEMENT_SIZE, | 681 "BYTES_PER_ELEMENT", ELEMENT_SIZE, |
| 694 READ_ONLY | DONT_ENUM | DONT_DELETE); | 682 READ_ONLY | DONT_ENUM | DONT_DELETE); |
| 695 endmacro | 683 endmacro |
| 696 | 684 |
| 697 TYPED_ARRAYS(SETUP_TYPED_ARRAY) | 685 TYPED_ARRAYS(SETUP_TYPED_ARRAY) |
| 698 | 686 |
| 699 }) | 687 }) |
| OLD | NEW |