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

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

Issue 2735563002: Migrate %TypedArray%.prototype.fill to C++ (Closed)
Patch Set: typo Created 3 years, 9 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
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
11 // ------------------------------------------------------------------- 11 // -------------------------------------------------------------------
12 // Imports 12 // Imports
13 13
14 // array.js has to come before typedarray.js for this to work 14 // array.js has to come before typedarray.js for this to work
15 var ArrayToString = utils.ImportNow("ArrayToString"); 15 var ArrayToString = utils.ImportNow("ArrayToString");
16 var ArrayValues; 16 var ArrayValues;
17 var GetIterator; 17 var GetIterator;
18 var GetMethod; 18 var GetMethod;
19 var GlobalArray = global.Array; 19 var GlobalArray = global.Array;
20 var GlobalArrayBuffer = global.ArrayBuffer; 20 var GlobalArrayBuffer = global.ArrayBuffer;
21 var GlobalArrayBufferPrototype = GlobalArrayBuffer.prototype; 21 var GlobalArrayBufferPrototype = GlobalArrayBuffer.prototype;
22 var GlobalObject = global.Object; 22 var GlobalObject = global.Object;
23 var InnerArrayEvery; 23 var InnerArrayEvery;
24 var InnerArrayFill;
25 var InnerArrayFilter; 24 var InnerArrayFilter;
26 var InnerArrayFind; 25 var InnerArrayFind;
27 var InnerArrayFindIndex; 26 var InnerArrayFindIndex;
28 var InnerArrayForEach; 27 var InnerArrayForEach;
29 var InnerArrayJoin; 28 var InnerArrayJoin;
30 var InnerArrayReduce; 29 var InnerArrayReduce;
31 var InnerArrayReduceRight; 30 var InnerArrayReduceRight;
32 var InnerArraySome; 31 var InnerArraySome;
33 var InnerArraySort; 32 var InnerArraySort;
34 var InnerArrayToLocaleString; 33 var InnerArrayToLocaleString;
(...skipping 26 matching lines...) Expand all
61 60
62 TYPED_ARRAYS(DECLARE_GLOBALS) 61 TYPED_ARRAYS(DECLARE_GLOBALS)
63 62
64 var GlobalTypedArray = %object_get_prototype_of(GlobalUint8Array); 63 var GlobalTypedArray = %object_get_prototype_of(GlobalUint8Array);
65 64
66 utils.Import(function(from) { 65 utils.Import(function(from) {
67 ArrayValues = from.ArrayValues; 66 ArrayValues = from.ArrayValues;
68 GetIterator = from.GetIterator; 67 GetIterator = from.GetIterator;
69 GetMethod = from.GetMethod; 68 GetMethod = from.GetMethod;
70 InnerArrayEvery = from.InnerArrayEvery; 69 InnerArrayEvery = from.InnerArrayEvery;
71 InnerArrayFill = from.InnerArrayFill;
72 InnerArrayFilter = from.InnerArrayFilter; 70 InnerArrayFilter = from.InnerArrayFilter;
73 InnerArrayFind = from.InnerArrayFind; 71 InnerArrayFind = from.InnerArrayFind;
74 InnerArrayFindIndex = from.InnerArrayFindIndex; 72 InnerArrayFindIndex = from.InnerArrayFindIndex;
75 InnerArrayForEach = from.InnerArrayForEach; 73 InnerArrayForEach = from.InnerArrayForEach;
76 InnerArrayJoin = from.InnerArrayJoin; 74 InnerArrayJoin = from.InnerArrayJoin;
77 InnerArrayReduce = from.InnerArrayReduce; 75 InnerArrayReduce = from.InnerArrayReduce;
78 InnerArrayReduceRight = from.InnerArrayReduceRight; 76 InnerArrayReduceRight = from.InnerArrayReduceRight;
79 InnerArraySome = from.InnerArraySome; 77 InnerArraySome = from.InnerArraySome;
80 InnerArraySort = from.InnerArraySort; 78 InnerArraySort = from.InnerArraySort;
81 InnerArrayToLocaleString = from.InnerArrayToLocaleString; 79 InnerArrayToLocaleString = from.InnerArrayToLocaleString;
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 function TypedArrayForEach(f, receiver) { 431 function TypedArrayForEach(f, receiver) {
434 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); 432 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
435 433
436 var length = %_TypedArrayGetLength(this); 434 var length = %_TypedArrayGetLength(this);
437 435
438 InnerArrayForEach(f, receiver, this, length); 436 InnerArrayForEach(f, receiver, this, length);
439 } 437 }
440 %FunctionSetLength(TypedArrayForEach, 1); 438 %FunctionSetLength(TypedArrayForEach, 1);
441 439
442 440
443 // ES6 draft 04-05-14 section 22.2.3.8
444 function TypedArrayFill(value, start, end) {
445 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
446
447 var length = %_TypedArrayGetLength(this);
448
449 return InnerArrayFill(value, start, end, this, length);
450 }
451 %FunctionSetLength(TypedArrayFill, 1);
452
453
454 // ES6 draft 07-15-13, section 22.2.3.9 441 // ES6 draft 07-15-13, section 22.2.3.9
455 function TypedArrayFilter(f, thisArg) { 442 function TypedArrayFilter(f, thisArg) {
456 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); 443 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
457 444
458 var length = %_TypedArrayGetLength(this); 445 var length = %_TypedArrayGetLength(this);
459 if (!IS_CALLABLE(f)) throw %make_type_error(kCalledNonCallable, f); 446 if (!IS_CALLABLE(f)) throw %make_type_error(kCalledNonCallable, f);
460 var result = new InternalArray(); 447 var result = new InternalArray();
461 InnerArrayFilter(f, thisArg, this, length, result); 448 InnerArrayFilter(f, thisArg, this, length, result);
462 var captured = result.length; 449 var captured = result.length;
463 var output = TypedArraySpeciesCreate(this, captured); 450 var output = TypedArraySpeciesCreate(this, captured);
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 utils.InstallFunctions(GlobalTypedArray, DONT_ENUM, [ 756 utils.InstallFunctions(GlobalTypedArray, DONT_ENUM, [
770 "from", TypedArrayFrom, 757 "from", TypedArrayFrom,
771 "of", TypedArrayOf 758 "of", TypedArrayOf
772 ]); 759 ]);
773 utils.InstallGetter(GlobalTypedArray.prototype, toStringTagSymbol, 760 utils.InstallGetter(GlobalTypedArray.prototype, toStringTagSymbol,
774 TypedArrayGetToStringTag); 761 TypedArrayGetToStringTag);
775 utils.InstallFunctions(GlobalTypedArray.prototype, DONT_ENUM, [ 762 utils.InstallFunctions(GlobalTypedArray.prototype, DONT_ENUM, [
776 "subarray", TypedArraySubArray, 763 "subarray", TypedArraySubArray,
777 "set", TypedArraySet, 764 "set", TypedArraySet,
778 "every", TypedArrayEvery, 765 "every", TypedArrayEvery,
779 "fill", TypedArrayFill,
780 "filter", TypedArrayFilter, 766 "filter", TypedArrayFilter,
781 "find", TypedArrayFind, 767 "find", TypedArrayFind,
782 "findIndex", TypedArrayFindIndex, 768 "findIndex", TypedArrayFindIndex,
783 "indexOf", TypedArrayIndexOf, 769 "indexOf", TypedArrayIndexOf,
784 "join", TypedArrayJoin, 770 "join", TypedArrayJoin,
785 "lastIndexOf", TypedArrayLastIndexOf, 771 "lastIndexOf", TypedArrayLastIndexOf,
786 "forEach", TypedArrayForEach, 772 "forEach", TypedArrayForEach,
787 "map", TypedArrayMap, 773 "map", TypedArrayMap,
788 "reduce", TypedArrayReduce, 774 "reduce", TypedArrayReduce,
789 "reduceRight", TypedArrayReduceRight, 775 "reduceRight", TypedArrayReduceRight,
(...skipping 20 matching lines...) Expand all
810 %AddNamedProperty(GlobalNAME.prototype, 796 %AddNamedProperty(GlobalNAME.prototype,
811 "constructor", global.NAME, DONT_ENUM); 797 "constructor", global.NAME, DONT_ENUM);
812 %AddNamedProperty(GlobalNAME.prototype, 798 %AddNamedProperty(GlobalNAME.prototype,
813 "BYTES_PER_ELEMENT", ELEMENT_SIZE, 799 "BYTES_PER_ELEMENT", ELEMENT_SIZE,
814 READ_ONLY | DONT_ENUM | DONT_DELETE); 800 READ_ONLY | DONT_ENUM | DONT_DELETE);
815 endmacro 801 endmacro
816 802
817 TYPED_ARRAYS(SETUP_TYPED_ARRAY) 803 TYPED_ARRAYS(SETUP_TYPED_ARRAY)
818 804
819 }) 805 })
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698