| 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 11 matching lines...) Expand all Loading... |
| 22 var GlobalObject = global.Object; | 22 var GlobalObject = global.Object; |
| 23 var InnerArrayFilter; | 23 var InnerArrayFilter; |
| 24 var InnerArrayFind; | 24 var InnerArrayFind; |
| 25 var InnerArrayFindIndex; | 25 var InnerArrayFindIndex; |
| 26 var InnerArrayJoin; | 26 var InnerArrayJoin; |
| 27 var InnerArraySort; | 27 var InnerArraySort; |
| 28 var InnerArrayToLocaleString; | 28 var InnerArrayToLocaleString; |
| 29 var InternalArray = utils.InternalArray; | 29 var InternalArray = utils.InternalArray; |
| 30 var MaxSimple; | 30 var MaxSimple; |
| 31 var MinSimple; | 31 var MinSimple; |
| 32 var PackedArrayReverse; | |
| 33 var SpeciesConstructor; | 32 var SpeciesConstructor; |
| 34 var ToPositiveInteger; | 33 var ToPositiveInteger; |
| 35 var ToIndex; | 34 var ToIndex; |
| 36 var iteratorSymbol = utils.ImportNow("iterator_symbol"); | 35 var iteratorSymbol = utils.ImportNow("iterator_symbol"); |
| 37 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); | 36 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); |
| 38 | 37 |
| 39 macro TYPED_ARRAYS(FUNCTION) | 38 macro TYPED_ARRAYS(FUNCTION) |
| 40 // arrayIds below should be synchronized with Runtime_TypedArrayInitialize. | 39 // arrayIds below should be synchronized with Runtime_TypedArrayInitialize. |
| 41 FUNCTION(1, Uint8Array, 1) | 40 FUNCTION(1, Uint8Array, 1) |
| 42 FUNCTION(2, Int8Array, 1) | 41 FUNCTION(2, Int8Array, 1) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 62 GetIterator = from.GetIterator; | 61 GetIterator = from.GetIterator; |
| 63 GetMethod = from.GetMethod; | 62 GetMethod = from.GetMethod; |
| 64 InnerArrayFilter = from.InnerArrayFilter; | 63 InnerArrayFilter = from.InnerArrayFilter; |
| 65 InnerArrayFind = from.InnerArrayFind; | 64 InnerArrayFind = from.InnerArrayFind; |
| 66 InnerArrayFindIndex = from.InnerArrayFindIndex; | 65 InnerArrayFindIndex = from.InnerArrayFindIndex; |
| 67 InnerArrayJoin = from.InnerArrayJoin; | 66 InnerArrayJoin = from.InnerArrayJoin; |
| 68 InnerArraySort = from.InnerArraySort; | 67 InnerArraySort = from.InnerArraySort; |
| 69 InnerArrayToLocaleString = from.InnerArrayToLocaleString; | 68 InnerArrayToLocaleString = from.InnerArrayToLocaleString; |
| 70 MaxSimple = from.MaxSimple; | 69 MaxSimple = from.MaxSimple; |
| 71 MinSimple = from.MinSimple; | 70 MinSimple = from.MinSimple; |
| 72 PackedArrayReverse = from.PackedArrayReverse; | |
| 73 SpeciesConstructor = from.SpeciesConstructor; | 71 SpeciesConstructor = from.SpeciesConstructor; |
| 74 ToPositiveInteger = from.ToPositiveInteger; | 72 ToPositiveInteger = from.ToPositiveInteger; |
| 75 ToIndex = from.ToIndex; | 73 ToIndex = from.ToIndex; |
| 76 }); | 74 }); |
| 77 | 75 |
| 78 // --------------- Typed Arrays --------------------- | 76 // --------------- Typed Arrays --------------------- |
| 79 | 77 |
| 80 function TypedArrayDefaultConstructor(typedArray) { | 78 function TypedArrayDefaultConstructor(typedArray) { |
| 81 switch (%_ClassOf(typedArray)) { | 79 switch (%_ClassOf(typedArray)) { |
| 82 macro TYPED_ARRAY_CONSTRUCTOR_CASE(ARRAY_ID, NAME, ELEMENT_SIZE) | 80 macro TYPED_ARRAY_CONSTRUCTOR_CASE(ARRAY_ID, NAME, ELEMENT_SIZE) |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 function TypedArrayFindIndex(predicate, thisArg) { | 423 function TypedArrayFindIndex(predicate, thisArg) { |
| 426 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); | 424 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); |
| 427 | 425 |
| 428 var length = %_TypedArrayGetLength(this); | 426 var length = %_TypedArrayGetLength(this); |
| 429 | 427 |
| 430 return InnerArrayFindIndex(predicate, thisArg, this, length); | 428 return InnerArrayFindIndex(predicate, thisArg, this, length); |
| 431 } | 429 } |
| 432 %FunctionSetLength(TypedArrayFindIndex, 1); | 430 %FunctionSetLength(TypedArrayFindIndex, 1); |
| 433 | 431 |
| 434 | 432 |
| 435 // ES6 draft 05-18-15, section 22.2.3.21 | |
| 436 function TypedArrayReverse() { | |
| 437 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); | |
| 438 | |
| 439 var length = %_TypedArrayGetLength(this); | |
| 440 | |
| 441 return PackedArrayReverse(this, length); | |
| 442 } | |
| 443 | |
| 444 // ES6 draft 05-18-15, section 22.2.3.25 | 433 // ES6 draft 05-18-15, section 22.2.3.25 |
| 445 function TypedArraySort(comparefn) { | 434 function TypedArraySort(comparefn) { |
| 446 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); | 435 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); |
| 447 | 436 |
| 448 var length = %_TypedArrayGetLength(this); | 437 var length = %_TypedArrayGetLength(this); |
| 449 | 438 |
| 450 if (IS_UNDEFINED(comparefn)) { | 439 if (IS_UNDEFINED(comparefn)) { |
| 451 return %TypedArraySortFast(this); | 440 return %TypedArraySortFast(this); |
| 452 } | 441 } |
| 453 | 442 |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 "set", TypedArraySet, | 694 "set", TypedArraySet, |
| 706 "every", TypedArrayEvery, | 695 "every", TypedArrayEvery, |
| 707 "filter", TypedArrayFilter, | 696 "filter", TypedArrayFilter, |
| 708 "find", TypedArrayFind, | 697 "find", TypedArrayFind, |
| 709 "findIndex", TypedArrayFindIndex, | 698 "findIndex", TypedArrayFindIndex, |
| 710 "join", TypedArrayJoin, | 699 "join", TypedArrayJoin, |
| 711 "forEach", TypedArrayForEach, | 700 "forEach", TypedArrayForEach, |
| 712 "map", TypedArrayMap, | 701 "map", TypedArrayMap, |
| 713 "reduce", TypedArrayReduce, | 702 "reduce", TypedArrayReduce, |
| 714 "reduceRight", TypedArrayReduceRight, | 703 "reduceRight", TypedArrayReduceRight, |
| 715 "reverse", TypedArrayReverse, | |
| 716 "slice", TypedArraySlice, | 704 "slice", TypedArraySlice, |
| 717 "some", TypedArraySome, | 705 "some", TypedArraySome, |
| 718 "sort", TypedArraySort, | 706 "sort", TypedArraySort, |
| 719 "toLocaleString", TypedArrayToLocaleString | 707 "toLocaleString", TypedArrayToLocaleString |
| 720 ]); | 708 ]); |
| 721 | 709 |
| 722 %AddNamedProperty(GlobalTypedArray.prototype, "toString", ArrayToString, | 710 %AddNamedProperty(GlobalTypedArray.prototype, "toString", ArrayToString, |
| 723 DONT_ENUM); | 711 DONT_ENUM); |
| 724 | 712 |
| 725 | 713 |
| 726 macro SETUP_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE) | 714 macro SETUP_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE) |
| 727 %SetCode(GlobalNAME, NAMEConstructor); | 715 %SetCode(GlobalNAME, NAMEConstructor); |
| 728 %FunctionSetPrototype(GlobalNAME, new GlobalObject()); | 716 %FunctionSetPrototype(GlobalNAME, new GlobalObject()); |
| 729 %InternalSetPrototype(GlobalNAME, GlobalTypedArray); | 717 %InternalSetPrototype(GlobalNAME, GlobalTypedArray); |
| 730 %InternalSetPrototype(GlobalNAME.prototype, GlobalTypedArray.prototype); | 718 %InternalSetPrototype(GlobalNAME.prototype, GlobalTypedArray.prototype); |
| 731 | 719 |
| 732 %AddNamedProperty(GlobalNAME, "BYTES_PER_ELEMENT", ELEMENT_SIZE, | 720 %AddNamedProperty(GlobalNAME, "BYTES_PER_ELEMENT", ELEMENT_SIZE, |
| 733 READ_ONLY | DONT_ENUM | DONT_DELETE); | 721 READ_ONLY | DONT_ENUM | DONT_DELETE); |
| 734 | 722 |
| 735 %AddNamedProperty(GlobalNAME.prototype, | 723 %AddNamedProperty(GlobalNAME.prototype, |
| 736 "constructor", global.NAME, DONT_ENUM); | 724 "constructor", global.NAME, DONT_ENUM); |
| 737 %AddNamedProperty(GlobalNAME.prototype, | 725 %AddNamedProperty(GlobalNAME.prototype, |
| 738 "BYTES_PER_ELEMENT", ELEMENT_SIZE, | 726 "BYTES_PER_ELEMENT", ELEMENT_SIZE, |
| 739 READ_ONLY | DONT_ENUM | DONT_DELETE); | 727 READ_ONLY | DONT_ENUM | DONT_DELETE); |
| 740 endmacro | 728 endmacro |
| 741 | 729 |
| 742 TYPED_ARRAYS(SETUP_TYPED_ARRAY) | 730 TYPED_ARRAYS(SETUP_TYPED_ARRAY) |
| 743 | 731 |
| 744 }) | 732 }) |
| OLD | NEW |