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

Side by Side Diff: src/js/array.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/builtins/builtins-typedarray.cc ('k') | src/js/typedarray.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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, extrasUtils) { 5 (function(global, utils, extrasUtils) {
6 6
7 "use strict"; 7 "use strict";
8 8
9 %CheckIsBootstrapping(); 9 %CheckIsBootstrapping();
10 10
(...skipping 1252 matching lines...) Expand 10 before | Expand all | Expand 10 after
1263 1263
1264 // Pull out the length so that side effects are visible before the 1264 // Pull out the length so that side effects are visible before the
1265 // callback function is checked. 1265 // callback function is checked.
1266 var array = TO_OBJECT(this); 1266 var array = TO_OBJECT(this);
1267 var length = TO_LENGTH(array.length); 1267 var length = TO_LENGTH(array.length);
1268 return InnerArrayReduceRight(callback, current, array, length, 1268 return InnerArrayReduceRight(callback, current, array, length,
1269 arguments.length); 1269 arguments.length);
1270 } 1270 }
1271 1271
1272 1272
1273 function InnerArrayCopyWithin(target, start, end, array, length) { 1273 // ES#sec-array.prototype.copywithin
1274 // (Array.prototype.copyWithin ( target, start [ , end ] )
1275 function ArrayCopyWithin(target, start, end) {
1276 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.copyWithin");
1277
1278 var array = TO_OBJECT(this);
1279 var length = TO_LENGTH(array.length);
1280
1274 target = TO_INTEGER(target); 1281 target = TO_INTEGER(target);
1275 var to; 1282 var to;
1276 if (target < 0) { 1283 if (target < 0) {
1277 to = MaxSimple(length + target, 0); 1284 to = MaxSimple(length + target, 0);
1278 } else { 1285 } else {
1279 to = MinSimple(target, length); 1286 to = MinSimple(target, length);
1280 } 1287 }
1281 1288
1282 start = TO_INTEGER(start); 1289 start = TO_INTEGER(start);
1283 var from; 1290 var from;
(...skipping 27 matching lines...) Expand all
1311 } 1318 }
1312 from = from + direction; 1319 from = from + direction;
1313 to = to + direction; 1320 to = to + direction;
1314 count--; 1321 count--;
1315 } 1322 }
1316 1323
1317 return array; 1324 return array;
1318 } 1325 }
1319 1326
1320 1327
1321 // ES6 draft 03-17-15, section 22.1.3.3
1322 function ArrayCopyWithin(target, start, end) {
1323 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.copyWithin");
1324
1325 var array = TO_OBJECT(this);
1326 var length = TO_LENGTH(array.length);
1327
1328 return InnerArrayCopyWithin(target, start, end, array, length);
1329 }
1330
1331
1332 function InnerArrayFind(predicate, thisArg, array, length) { 1328 function InnerArrayFind(predicate, thisArg, array, length) {
1333 if (!IS_CALLABLE(predicate)) { 1329 if (!IS_CALLABLE(predicate)) {
1334 throw %make_type_error(kCalledNonCallable, predicate); 1330 throw %make_type_error(kCalledNonCallable, predicate);
1335 } 1331 }
1336 1332
1337 for (var i = 0; i < length; i++) { 1333 for (var i = 0; i < length; i++) {
1338 var element = array[i]; 1334 var element = array[i];
1339 if (%_Call(predicate, thisArg, element, i, array)) { 1335 if (%_Call(predicate, thisArg, element, i, array)) {
1340 return element; 1336 return element;
1341 } 1337 }
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
1618 1614
1619 // ------------------------------------------------------------------- 1615 // -------------------------------------------------------------------
1620 // Exports 1616 // Exports
1621 1617
1622 utils.Export(function(to) { 1618 utils.Export(function(to) {
1623 to.ArrayFrom = ArrayFrom; 1619 to.ArrayFrom = ArrayFrom;
1624 to.ArrayJoin = ArrayJoin; 1620 to.ArrayJoin = ArrayJoin;
1625 to.ArrayPush = ArrayPush; 1621 to.ArrayPush = ArrayPush;
1626 to.ArrayToString = ArrayToString; 1622 to.ArrayToString = ArrayToString;
1627 to.ArrayValues = IteratorFunctions.values, 1623 to.ArrayValues = IteratorFunctions.values,
1628 to.InnerArrayCopyWithin = InnerArrayCopyWithin;
1629 to.InnerArrayEvery = InnerArrayEvery; 1624 to.InnerArrayEvery = InnerArrayEvery;
1630 to.InnerArrayFill = InnerArrayFill; 1625 to.InnerArrayFill = InnerArrayFill;
1631 to.InnerArrayFilter = InnerArrayFilter; 1626 to.InnerArrayFilter = InnerArrayFilter;
1632 to.InnerArrayFind = InnerArrayFind; 1627 to.InnerArrayFind = InnerArrayFind;
1633 to.InnerArrayFindIndex = InnerArrayFindIndex; 1628 to.InnerArrayFindIndex = InnerArrayFindIndex;
1634 to.InnerArrayForEach = InnerArrayForEach; 1629 to.InnerArrayForEach = InnerArrayForEach;
1635 to.InnerArrayJoin = InnerArrayJoin; 1630 to.InnerArrayJoin = InnerArrayJoin;
1636 to.InnerArrayLastIndexOf = InnerArrayLastIndexOf; 1631 to.InnerArrayLastIndexOf = InnerArrayLastIndexOf;
1637 to.InnerArrayReduce = InnerArrayReduce; 1632 to.InnerArrayReduce = InnerArrayReduce;
1638 to.InnerArrayReduceRight = InnerArrayReduceRight; 1633 to.InnerArrayReduceRight = InnerArrayReduceRight;
(...skipping 10 matching lines...) Expand all
1649 "array_pop", ArrayPop, 1644 "array_pop", ArrayPop,
1650 "array_push", ArrayPush, 1645 "array_push", ArrayPush,
1651 "array_shift", ArrayShift, 1646 "array_shift", ArrayShift,
1652 "array_splice", ArraySplice, 1647 "array_splice", ArraySplice,
1653 "array_slice", ArraySlice, 1648 "array_slice", ArraySlice,
1654 "array_unshift", ArrayUnshift, 1649 "array_unshift", ArrayUnshift,
1655 "array_values_iterator", IteratorFunctions.values, 1650 "array_values_iterator", IteratorFunctions.values,
1656 ]); 1651 ]);
1657 1652
1658 }); 1653 });
OLDNEW
« no previous file with comments | « src/builtins/builtins-typedarray.cc ('k') | src/js/typedarray.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698