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

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

Issue 2671233002: [typedarrays] move %TypedArray%.prototype.copyWithin to C++ (Closed)
Patch Set: make win32 happy Created 3 years, 10 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 InnerArrayCopyWithin;
24 var InnerArrayEvery; 23 var InnerArrayEvery;
25 var InnerArrayFill; 24 var InnerArrayFill;
26 var InnerArrayFilter; 25 var InnerArrayFilter;
27 var InnerArrayFind; 26 var InnerArrayFind;
28 var InnerArrayFindIndex; 27 var InnerArrayFindIndex;
29 var InnerArrayForEach; 28 var InnerArrayForEach;
30 var InnerArrayJoin; 29 var InnerArrayJoin;
31 var InnerArrayReduce; 30 var InnerArrayReduce;
32 var InnerArrayReduceRight; 31 var InnerArrayReduceRight;
33 var InnerArraySome; 32 var InnerArraySome;
(...skipping 27 matching lines...) Expand all
61 endmacro 60 endmacro
62 61
63 TYPED_ARRAYS(DECLARE_GLOBALS) 62 TYPED_ARRAYS(DECLARE_GLOBALS)
64 63
65 var GlobalTypedArray = %object_get_prototype_of(GlobalUint8Array); 64 var GlobalTypedArray = %object_get_prototype_of(GlobalUint8Array);
66 65
67 utils.Import(function(from) { 66 utils.Import(function(from) {
68 ArrayValues = from.ArrayValues; 67 ArrayValues = from.ArrayValues;
69 GetIterator = from.GetIterator; 68 GetIterator = from.GetIterator;
70 GetMethod = from.GetMethod; 69 GetMethod = from.GetMethod;
71 InnerArrayCopyWithin = from.InnerArrayCopyWithin;
72 InnerArrayEvery = from.InnerArrayEvery; 70 InnerArrayEvery = from.InnerArrayEvery;
73 InnerArrayFill = from.InnerArrayFill; 71 InnerArrayFill = from.InnerArrayFill;
74 InnerArrayFilter = from.InnerArrayFilter; 72 InnerArrayFilter = from.InnerArrayFilter;
75 InnerArrayFind = from.InnerArrayFind; 73 InnerArrayFind = from.InnerArrayFind;
76 InnerArrayFindIndex = from.InnerArrayFindIndex; 74 InnerArrayFindIndex = from.InnerArrayFindIndex;
77 InnerArrayForEach = from.InnerArrayForEach; 75 InnerArrayForEach = from.InnerArrayForEach;
78 InnerArrayJoin = from.InnerArrayJoin; 76 InnerArrayJoin = from.InnerArrayJoin;
79 InnerArrayReduce = from.InnerArrayReduce; 77 InnerArrayReduce = from.InnerArrayReduce;
80 InnerArrayReduceRight = from.InnerArrayReduceRight; 78 InnerArrayReduceRight = from.InnerArrayReduceRight;
81 InnerArraySome = from.InnerArraySome; 79 InnerArraySome = from.InnerArraySome;
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 %FunctionSetLength(TypedArraySet, 1); 429 %FunctionSetLength(TypedArraySet, 1);
432 430
433 function TypedArrayGetToStringTag() { 431 function TypedArrayGetToStringTag() {
434 if (!IS_TYPEDARRAY(this)) return; 432 if (!IS_TYPEDARRAY(this)) return;
435 var name = %_ClassOf(this); 433 var name = %_ClassOf(this);
436 if (IS_UNDEFINED(name)) return; 434 if (IS_UNDEFINED(name)) return;
437 return name; 435 return name;
438 } 436 }
439 437
440 438
441 function TypedArrayCopyWithin(target, start, end) {
442 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
443
444 var length = %_TypedArrayGetLength(this);
445
446 // TODO(littledan): Replace with a memcpy for better performance
447 return InnerArrayCopyWithin(target, start, end, this, length);
448 }
449 %FunctionSetLength(TypedArrayCopyWithin, 2);
450
451
452 // ES6 draft 05-05-15, section 22.2.3.7 439 // ES6 draft 05-05-15, section 22.2.3.7
453 function TypedArrayEvery(f, receiver) { 440 function TypedArrayEvery(f, receiver) {
454 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); 441 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
455 442
456 var length = %_TypedArrayGetLength(this); 443 var length = %_TypedArrayGetLength(this);
457 444
458 return InnerArrayEvery(f, receiver, this, length); 445 return InnerArrayEvery(f, receiver, this, length);
459 } 446 }
460 %FunctionSetLength(TypedArrayEvery, 1); 447 %FunctionSetLength(TypedArrayEvery, 1);
461 448
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 %SetCode(GlobalTypedArray, TypedArrayConstructor); 838 %SetCode(GlobalTypedArray, TypedArrayConstructor);
852 utils.InstallFunctions(GlobalTypedArray, DONT_ENUM, [ 839 utils.InstallFunctions(GlobalTypedArray, DONT_ENUM, [
853 "from", TypedArrayFrom, 840 "from", TypedArrayFrom,
854 "of", TypedArrayOf 841 "of", TypedArrayOf
855 ]); 842 ]);
856 utils.InstallGetter(GlobalTypedArray.prototype, toStringTagSymbol, 843 utils.InstallGetter(GlobalTypedArray.prototype, toStringTagSymbol,
857 TypedArrayGetToStringTag); 844 TypedArrayGetToStringTag);
858 utils.InstallFunctions(GlobalTypedArray.prototype, DONT_ENUM, [ 845 utils.InstallFunctions(GlobalTypedArray.prototype, DONT_ENUM, [
859 "subarray", TypedArraySubArray, 846 "subarray", TypedArraySubArray,
860 "set", TypedArraySet, 847 "set", TypedArraySet,
861 "copyWithin", TypedArrayCopyWithin,
862 "every", TypedArrayEvery, 848 "every", TypedArrayEvery,
863 "fill", TypedArrayFill, 849 "fill", TypedArrayFill,
864 "filter", TypedArrayFilter, 850 "filter", TypedArrayFilter,
865 "find", TypedArrayFind, 851 "find", TypedArrayFind,
866 "findIndex", TypedArrayFindIndex, 852 "findIndex", TypedArrayFindIndex,
867 "includes", TypedArrayIncludes, 853 "includes", TypedArrayIncludes,
868 "indexOf", TypedArrayIndexOf, 854 "indexOf", TypedArrayIndexOf,
869 "join", TypedArrayJoin, 855 "join", TypedArrayJoin,
870 "lastIndexOf", TypedArrayLastIndexOf, 856 "lastIndexOf", TypedArrayLastIndexOf,
871 "forEach", TypedArrayForEach, 857 "forEach", TypedArrayForEach,
(...skipping 23 matching lines...) Expand all
895 %AddNamedProperty(GlobalNAME.prototype, 881 %AddNamedProperty(GlobalNAME.prototype,
896 "constructor", global.NAME, DONT_ENUM); 882 "constructor", global.NAME, DONT_ENUM);
897 %AddNamedProperty(GlobalNAME.prototype, 883 %AddNamedProperty(GlobalNAME.prototype,
898 "BYTES_PER_ELEMENT", ELEMENT_SIZE, 884 "BYTES_PER_ELEMENT", ELEMENT_SIZE,
899 READ_ONLY | DONT_ENUM | DONT_DELETE); 885 READ_ONLY | DONT_ENUM | DONT_DELETE);
900 endmacro 886 endmacro
901 887
902 TYPED_ARRAYS(SETUP_TYPED_ARRAY) 888 TYPED_ARRAYS(SETUP_TYPED_ARRAY)
903 889
904 }) 890 })
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698