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

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

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

Powered by Google App Engine
This is Rietveld 408576698