Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(997)

Side by Side Diff: src/js/typedarray.js

Issue 1560763002: Add Array support for @@species and subclassing (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Last couple comments Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/js/prologue.js ('k') | src/messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
22 var InnerArrayEvery; 22 var InnerArrayEvery;
23 var InnerArrayFill; 23 var InnerArrayFill;
24 var InnerArrayFilter; 24 var InnerArrayFilter;
25 var InnerArrayFind; 25 var InnerArrayFind;
26 var InnerArrayFindIndex; 26 var InnerArrayFindIndex;
27 var InnerArrayForEach; 27 var InnerArrayForEach;
28 var InnerArrayIncludes; 28 var InnerArrayIncludes;
29 var InnerArrayIndexOf; 29 var InnerArrayIndexOf;
30 var InnerArrayJoin; 30 var InnerArrayJoin;
31 var InnerArrayLastIndexOf; 31 var InnerArrayLastIndexOf;
32 var InnerArrayMap;
33 var InnerArrayReduce; 32 var InnerArrayReduce;
34 var InnerArrayReduceRight; 33 var InnerArrayReduceRight;
35 var InnerArraySome; 34 var InnerArraySome;
36 var InnerArraySort; 35 var InnerArraySort;
37 var InnerArrayToLocaleString; 36 var InnerArrayToLocaleString;
38 var InternalArray = utils.InternalArray; 37 var InternalArray = utils.InternalArray;
39 var IsNaN; 38 var IsNaN;
40 var MakeRangeError; 39 var MakeRangeError;
41 var MakeTypeError; 40 var MakeTypeError;
42 var MaxSimple; 41 var MaxSimple;
(...skipping 30 matching lines...) Expand all
73 InnerArrayEvery = from.InnerArrayEvery; 72 InnerArrayEvery = from.InnerArrayEvery;
74 InnerArrayFill = from.InnerArrayFill; 73 InnerArrayFill = from.InnerArrayFill;
75 InnerArrayFilter = from.InnerArrayFilter; 74 InnerArrayFilter = from.InnerArrayFilter;
76 InnerArrayFind = from.InnerArrayFind; 75 InnerArrayFind = from.InnerArrayFind;
77 InnerArrayFindIndex = from.InnerArrayFindIndex; 76 InnerArrayFindIndex = from.InnerArrayFindIndex;
78 InnerArrayForEach = from.InnerArrayForEach; 77 InnerArrayForEach = from.InnerArrayForEach;
79 InnerArrayIncludes = from.InnerArrayIncludes; 78 InnerArrayIncludes = from.InnerArrayIncludes;
80 InnerArrayIndexOf = from.InnerArrayIndexOf; 79 InnerArrayIndexOf = from.InnerArrayIndexOf;
81 InnerArrayJoin = from.InnerArrayJoin; 80 InnerArrayJoin = from.InnerArrayJoin;
82 InnerArrayLastIndexOf = from.InnerArrayLastIndexOf; 81 InnerArrayLastIndexOf = from.InnerArrayLastIndexOf;
83 InnerArrayMap = from.InnerArrayMap;
84 InnerArrayReduce = from.InnerArrayReduce; 82 InnerArrayReduce = from.InnerArrayReduce;
85 InnerArrayReduceRight = from.InnerArrayReduceRight; 83 InnerArrayReduceRight = from.InnerArrayReduceRight;
86 InnerArraySome = from.InnerArraySome; 84 InnerArraySome = from.InnerArraySome;
87 InnerArraySort = from.InnerArraySort; 85 InnerArraySort = from.InnerArraySort;
88 InnerArrayToLocaleString = from.InnerArrayToLocaleString; 86 InnerArrayToLocaleString = from.InnerArrayToLocaleString;
89 IsNaN = from.IsNaN; 87 IsNaN = from.IsNaN;
90 MakeRangeError = from.MakeRangeError; 88 MakeRangeError = from.MakeRangeError;
91 MakeTypeError = from.MakeTypeError; 89 MakeTypeError = from.MakeTypeError;
92 MakeTypeError = from.MakeTypeError; 90 MakeTypeError = from.MakeTypeError;
93 MaxSimple = from.MaxSimple; 91 MaxSimple = from.MaxSimple;
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 if (!%_IsTypedArray(this)) throw MakeTypeError(kNotTypedArray); 484 if (!%_IsTypedArray(this)) throw MakeTypeError(kNotTypedArray);
487 485
488 var length = %_TypedArrayGetLength(this); 486 var length = %_TypedArrayGetLength(this);
489 487
490 return InnerArrayFill(value, start, end, this, length); 488 return InnerArrayFill(value, start, end, this, length);
491 } 489 }
492 %FunctionSetLength(TypedArrayFill, 1); 490 %FunctionSetLength(TypedArrayFill, 1);
493 491
494 492
495 // ES6 draft 07-15-13, section 22.2.3.9 493 // ES6 draft 07-15-13, section 22.2.3.9
496 function TypedArrayFilter(predicate, thisArg) { 494 function TypedArrayFilter(f, thisArg) {
497 if (!%_IsTypedArray(this)) throw MakeTypeError(kNotTypedArray); 495 if (!%_IsTypedArray(this)) throw MakeTypeError(kNotTypedArray);
498 496
499 var length = %_TypedArrayGetLength(this); 497 var length = %_TypedArrayGetLength(this);
500 var array = InnerArrayFilter(predicate, thisArg, this, length); 498 if (!IS_CALLABLE(f)) throw MakeTypeError(kCalledNonCallable, f);
501 return ConstructTypedArrayLike(this, array); 499 var result = new InternalArray();
500 InnerArrayFilter(f, thisArg, this, length, result);
501 var captured = result.length;
502 var output = ConstructTypedArrayLike(this, captured);
503 for (var i = 0; i < captured; i++) {
504 output[i] = result[i];
505 }
506 return output;
502 } 507 }
503 %FunctionSetLength(TypedArrayFilter, 1); 508 %FunctionSetLength(TypedArrayFilter, 1);
504 509
505 510
506 // ES6 draft 07-15-13, section 22.2.3.10 511 // ES6 draft 07-15-13, section 22.2.3.10
507 function TypedArrayFind(predicate, thisArg) { 512 function TypedArrayFind(predicate, thisArg) {
508 if (!%_IsTypedArray(this)) throw MakeTypeError(kNotTypedArray); 513 if (!%_IsTypedArray(this)) throw MakeTypeError(kNotTypedArray);
509 514
510 var length = %_TypedArrayGetLength(this); 515 var length = %_TypedArrayGetLength(this);
511 516
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 590
586 var length = %_TypedArrayGetLength(this); 591 var length = %_TypedArrayGetLength(this);
587 592
588 return InnerArrayLastIndexOf(this, element, index, length, 593 return InnerArrayLastIndexOf(this, element, index, length,
589 %_ArgumentsLength()); 594 %_ArgumentsLength());
590 } 595 }
591 %FunctionSetLength(TypedArrayLastIndexOf, 1); 596 %FunctionSetLength(TypedArrayLastIndexOf, 1);
592 597
593 598
594 // ES6 draft 07-15-13, section 22.2.3.18 599 // ES6 draft 07-15-13, section 22.2.3.18
595 function TypedArrayMap(predicate, thisArg) { 600 function TypedArrayMap(f, thisArg) {
596 if (!%_IsTypedArray(this)) throw MakeTypeError(kNotTypedArray); 601 if (!%_IsTypedArray(this)) throw MakeTypeError(kNotTypedArray);
597 602
598 // TODO(littledan): Preallocate rather than making an intermediate
599 // InternalArray, for better performance.
600 var length = %_TypedArrayGetLength(this); 603 var length = %_TypedArrayGetLength(this);
601 var array = InnerArrayMap(predicate, thisArg, this, length); 604 var result = ConstructTypedArrayLike(this, length);
602 return ConstructTypedArrayLike(this, array); 605 if (!IS_CALLABLE(f)) throw MakeTypeError(kCalledNonCallable, f);
606 for (var i = 0; i < length; i++) {
607 var element = this[i];
608 result[i] = %_Call(f, thisArg, element, i, this);
609 }
610 return result;
603 } 611 }
604 %FunctionSetLength(TypedArrayMap, 1); 612 %FunctionSetLength(TypedArrayMap, 1);
605 613
606 614
607 // ES6 draft 05-05-15, section 22.2.3.24 615 // ES6 draft 05-05-15, section 22.2.3.24
608 function TypedArraySome(f, receiver) { 616 function TypedArraySome(f, receiver) {
609 if (!%_IsTypedArray(this)) throw MakeTypeError(kNotTypedArray); 617 if (!%_IsTypedArray(this)) throw MakeTypeError(kNotTypedArray);
610 618
611 var length = %_TypedArrayGetLength(this); 619 var length = %_TypedArrayGetLength(this);
612 620
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 "setUint32", DataViewSetUint32JS, 944 "setUint32", DataViewSetUint32JS,
937 945
938 "getFloat32", DataViewGetFloat32JS, 946 "getFloat32", DataViewGetFloat32JS,
939 "setFloat32", DataViewSetFloat32JS, 947 "setFloat32", DataViewSetFloat32JS,
940 948
941 "getFloat64", DataViewGetFloat64JS, 949 "getFloat64", DataViewGetFloat64JS,
942 "setFloat64", DataViewSetFloat64JS 950 "setFloat64", DataViewSetFloat64JS
943 ]); 951 ]);
944 952
945 }) 953 })
OLDNEW
« no previous file with comments | « src/js/prologue.js ('k') | src/messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698