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

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

Issue 2697593002: Reland [typedarrays] move %TypedArray%.prototype.copyWithin to C++ (Closed)
Patch Set: update comment 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
« no previous file with comments | « src/js/array.js ('k') | test/mjsunit/es6/regress/regress-5929-1.js » ('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
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 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 %FunctionSetLength(TypedArraySet, 1); 428 %FunctionSetLength(TypedArraySet, 1);
431 429
432 function TypedArrayGetToStringTag() { 430 function TypedArrayGetToStringTag() {
433 if (!IS_TYPEDARRAY(this)) return; 431 if (!IS_TYPEDARRAY(this)) return;
434 var name = %_ClassOf(this); 432 var name = %_ClassOf(this);
435 if (IS_UNDEFINED(name)) return; 433 if (IS_UNDEFINED(name)) return;
436 return name; 434 return name;
437 } 435 }
438 436
439 437
440 function TypedArrayCopyWithin(target, start, end) {
441 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
442
443 var length = %_TypedArrayGetLength(this);
444
445 // TODO(littledan): Replace with a memcpy for better performance
446 return InnerArrayCopyWithin(target, start, end, this, length);
447 }
448 %FunctionSetLength(TypedArrayCopyWithin, 2);
449
450
451 // ES6 draft 05-05-15, section 22.2.3.7 438 // ES6 draft 05-05-15, section 22.2.3.7
452 function TypedArrayEvery(f, receiver) { 439 function TypedArrayEvery(f, receiver) {
453 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); 440 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
454 441
455 var length = %_TypedArrayGetLength(this); 442 var length = %_TypedArrayGetLength(this);
456 443
457 return InnerArrayEvery(f, receiver, this, length); 444 return InnerArrayEvery(f, receiver, this, length);
458 } 445 }
459 %FunctionSetLength(TypedArrayEvery, 1); 446 %FunctionSetLength(TypedArrayEvery, 1);
460 447
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 %SetCode(GlobalTypedArray, TypedArrayConstructor); 837 %SetCode(GlobalTypedArray, TypedArrayConstructor);
851 utils.InstallFunctions(GlobalTypedArray, DONT_ENUM, [ 838 utils.InstallFunctions(GlobalTypedArray, DONT_ENUM, [
852 "from", TypedArrayFrom, 839 "from", TypedArrayFrom,
853 "of", TypedArrayOf 840 "of", TypedArrayOf
854 ]); 841 ]);
855 utils.InstallGetter(GlobalTypedArray.prototype, toStringTagSymbol, 842 utils.InstallGetter(GlobalTypedArray.prototype, toStringTagSymbol,
856 TypedArrayGetToStringTag); 843 TypedArrayGetToStringTag);
857 utils.InstallFunctions(GlobalTypedArray.prototype, DONT_ENUM, [ 844 utils.InstallFunctions(GlobalTypedArray.prototype, DONT_ENUM, [
858 "subarray", TypedArraySubArray, 845 "subarray", TypedArraySubArray,
859 "set", TypedArraySet, 846 "set", TypedArraySet,
860 "copyWithin", TypedArrayCopyWithin,
861 "every", TypedArrayEvery, 847 "every", TypedArrayEvery,
862 "fill", TypedArrayFill, 848 "fill", TypedArrayFill,
863 "filter", TypedArrayFilter, 849 "filter", TypedArrayFilter,
864 "find", TypedArrayFind, 850 "find", TypedArrayFind,
865 "findIndex", TypedArrayFindIndex, 851 "findIndex", TypedArrayFindIndex,
866 "includes", TypedArrayIncludes, 852 "includes", TypedArrayIncludes,
867 "indexOf", TypedArrayIndexOf, 853 "indexOf", TypedArrayIndexOf,
868 "join", TypedArrayJoin, 854 "join", TypedArrayJoin,
869 "lastIndexOf", TypedArrayLastIndexOf, 855 "lastIndexOf", TypedArrayLastIndexOf,
870 "forEach", TypedArrayForEach, 856 "forEach", TypedArrayForEach,
(...skipping 23 matching lines...) Expand all
894 %AddNamedProperty(GlobalNAME.prototype, 880 %AddNamedProperty(GlobalNAME.prototype,
895 "constructor", global.NAME, DONT_ENUM); 881 "constructor", global.NAME, DONT_ENUM);
896 %AddNamedProperty(GlobalNAME.prototype, 882 %AddNamedProperty(GlobalNAME.prototype,
897 "BYTES_PER_ELEMENT", ELEMENT_SIZE, 883 "BYTES_PER_ELEMENT", ELEMENT_SIZE,
898 READ_ONLY | DONT_ENUM | DONT_DELETE); 884 READ_ONLY | DONT_ENUM | DONT_DELETE);
899 endmacro 885 endmacro
900 886
901 TYPED_ARRAYS(SETUP_TYPED_ARRAY) 887 TYPED_ARRAYS(SETUP_TYPED_ARRAY)
902 888
903 }) 889 })
OLDNEW
« no previous file with comments | « src/js/array.js ('k') | test/mjsunit/es6/regress/regress-5929-1.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698