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

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

Issue 2697593002: Reland [typedarrays] move %TypedArray%.prototype.copyWithin to C++ (Closed)
Patch Set: bigger fatter DCHECKs 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 // ES6 draft 03-17-15, section 22.1.3.3
Camillo Bruni 2017/02/15 13:36:28 nit: please use sec reference instead of the (poss
caitp 2017/02/15 13:51:27 Done.
1274 function ArrayCopyWithin(target, start, end) {
1275 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.copyWithin");
1276
1277 var array = TO_OBJECT(this);
1278 var length = TO_LENGTH(array.length);
1279
1274 target = TO_INTEGER(target); 1280 target = TO_INTEGER(target);
1275 var to; 1281 var to;
1276 if (target < 0) { 1282 if (target < 0) {
1277 to = MaxSimple(length + target, 0); 1283 to = MaxSimple(length + target, 0);
1278 } else { 1284 } else {
1279 to = MinSimple(target, length); 1285 to = MinSimple(target, length);
1280 } 1286 }
1281 1287
1282 start = TO_INTEGER(start); 1288 start = TO_INTEGER(start);
1283 var from; 1289 var from;
(...skipping 27 matching lines...) Expand all
1311 } 1317 }
1312 from = from + direction; 1318 from = from + direction;
1313 to = to + direction; 1319 to = to + direction;
1314 count--; 1320 count--;
1315 } 1321 }
1316 1322
1317 return array; 1323 return array;
1318 } 1324 }
1319 1325
1320 1326
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) { 1327 function InnerArrayFind(predicate, thisArg, array, length) {
1333 if (!IS_CALLABLE(predicate)) { 1328 if (!IS_CALLABLE(predicate)) {
1334 throw %make_type_error(kCalledNonCallable, predicate); 1329 throw %make_type_error(kCalledNonCallable, predicate);
1335 } 1330 }
1336 1331
1337 for (var i = 0; i < length; i++) { 1332 for (var i = 0; i < length; i++) {
1338 var element = array[i]; 1333 var element = array[i];
1339 if (%_Call(predicate, thisArg, element, i, array)) { 1334 if (%_Call(predicate, thisArg, element, i, array)) {
1340 return element; 1335 return element;
1341 } 1336 }
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
1618 1613
1619 // ------------------------------------------------------------------- 1614 // -------------------------------------------------------------------
1620 // Exports 1615 // Exports
1621 1616
1622 utils.Export(function(to) { 1617 utils.Export(function(to) {
1623 to.ArrayFrom = ArrayFrom; 1618 to.ArrayFrom = ArrayFrom;
1624 to.ArrayJoin = ArrayJoin; 1619 to.ArrayJoin = ArrayJoin;
1625 to.ArrayPush = ArrayPush; 1620 to.ArrayPush = ArrayPush;
1626 to.ArrayToString = ArrayToString; 1621 to.ArrayToString = ArrayToString;
1627 to.ArrayValues = IteratorFunctions.values, 1622 to.ArrayValues = IteratorFunctions.values,
1628 to.InnerArrayCopyWithin = InnerArrayCopyWithin;
1629 to.InnerArrayEvery = InnerArrayEvery; 1623 to.InnerArrayEvery = InnerArrayEvery;
1630 to.InnerArrayFill = InnerArrayFill; 1624 to.InnerArrayFill = InnerArrayFill;
1631 to.InnerArrayFilter = InnerArrayFilter; 1625 to.InnerArrayFilter = InnerArrayFilter;
1632 to.InnerArrayFind = InnerArrayFind; 1626 to.InnerArrayFind = InnerArrayFind;
1633 to.InnerArrayFindIndex = InnerArrayFindIndex; 1627 to.InnerArrayFindIndex = InnerArrayFindIndex;
1634 to.InnerArrayForEach = InnerArrayForEach; 1628 to.InnerArrayForEach = InnerArrayForEach;
1635 to.InnerArrayJoin = InnerArrayJoin; 1629 to.InnerArrayJoin = InnerArrayJoin;
1636 to.InnerArrayLastIndexOf = InnerArrayLastIndexOf; 1630 to.InnerArrayLastIndexOf = InnerArrayLastIndexOf;
1637 to.InnerArrayReduce = InnerArrayReduce; 1631 to.InnerArrayReduce = InnerArrayReduce;
1638 to.InnerArrayReduceRight = InnerArrayReduceRight; 1632 to.InnerArrayReduceRight = InnerArrayReduceRight;
(...skipping 10 matching lines...) Expand all
1649 "array_pop", ArrayPop, 1643 "array_pop", ArrayPop,
1650 "array_push", ArrayPush, 1644 "array_push", ArrayPush,
1651 "array_shift", ArrayShift, 1645 "array_shift", ArrayShift,
1652 "array_splice", ArraySplice, 1646 "array_splice", ArraySplice,
1653 "array_slice", ArraySlice, 1647 "array_slice", ArraySlice,
1654 "array_unshift", ArrayUnshift, 1648 "array_unshift", ArrayUnshift,
1655 "array_values_iterator", IteratorFunctions.values, 1649 "array_values_iterator", IteratorFunctions.values,
1656 ]); 1650 ]);
1657 1651
1658 }); 1652 });
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