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

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

Issue 1394303003: Revert of Use simple/fast macro version of MinMax in JS (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 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/arraybuffer.js ('k') | src/harmony-atomics.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 var GetIterator; 14 var GetIterator;
15 var GetMethod; 15 var GetMethod;
16 var GlobalArray = global.Array; 16 var GlobalArray = global.Array;
17 var iteratorSymbol = utils.ImportNow("iterator_symbol"); 17 var iteratorSymbol = utils.ImportNow("iterator_symbol");
18 var MathMax;
19 var MathMin;
18 var ObjectIsFrozen; 20 var ObjectIsFrozen;
19 var ObjectDefineProperty; 21 var ObjectDefineProperty;
20 22
21 utils.Import(function(from) { 23 utils.Import(function(from) {
22 GetIterator = from.GetIterator; 24 GetIterator = from.GetIterator;
23 GetMethod = from.GetMethod; 25 GetMethod = from.GetMethod;
26 MathMax = from.MathMax;
27 MathMin = from.MathMin;
24 ObjectIsFrozen = from.ObjectIsFrozen; 28 ObjectIsFrozen = from.ObjectIsFrozen;
25 ObjectDefineProperty = from.ObjectDefineProperty; 29 ObjectDefineProperty = from.ObjectDefineProperty;
26 }); 30 });
27 31
28 // ------------------------------------------------------------------- 32 // -------------------------------------------------------------------
29 33
30 function InnerArrayCopyWithin(target, start, end, array, length) { 34 function InnerArrayCopyWithin(target, start, end, array, length) {
31 target = TO_INTEGER(target); 35 target = TO_INTEGER(target);
32 var to; 36 var to;
33 if (target < 0) { 37 if (target < 0) {
34 to = MAX_SIMPLE(length + target, 0); 38 to = MathMax(length + target, 0);
35 } else { 39 } else {
36 to = MIN_SIMPLE(target, length); 40 to = MathMin(target, length);
37 } 41 }
38 42
39 start = TO_INTEGER(start); 43 start = TO_INTEGER(start);
40 var from; 44 var from;
41 if (start < 0) { 45 if (start < 0) {
42 from = MAX_SIMPLE(length + start, 0); 46 from = MathMax(length + start, 0);
43 } else { 47 } else {
44 from = MIN_SIMPLE(start, length); 48 from = MathMin(start, length);
45 } 49 }
46 50
47 end = IS_UNDEFINED(end) ? length : TO_INTEGER(end); 51 end = IS_UNDEFINED(end) ? length : TO_INTEGER(end);
48 var final; 52 var final;
49 if (end < 0) { 53 if (end < 0) {
50 final = MAX_SIMPLE(length + end, 0); 54 final = MathMax(length + end, 0);
51 } else { 55 } else {
52 final = MIN_SIMPLE(end, length); 56 final = MathMin(end, length);
53 } 57 }
54 58
55 var count = MIN_SIMPLE(final - from, length - to); 59 var count = MathMin(final - from, length - to);
56 var direction = 1; 60 var direction = 1;
57 if (from < to && to < (from + count)) { 61 if (from < to && to < (from + count)) {
58 direction = -1; 62 direction = -1;
59 from = from + count - 1; 63 from = from + count - 1;
60 to = to + count - 1; 64 to = to + count - 1;
61 } 65 }
62 66
63 while (count > 0) { 67 while (count > 0) {
64 if (from in array) { 68 if (from in array) {
65 array[to] = array[from]; 69 array[to] = array[from];
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 289
286 utils.Export(function(to) { 290 utils.Export(function(to) {
287 to.ArrayFrom = ArrayFrom; 291 to.ArrayFrom = ArrayFrom;
288 to.InnerArrayCopyWithin = InnerArrayCopyWithin; 292 to.InnerArrayCopyWithin = InnerArrayCopyWithin;
289 to.InnerArrayFill = InnerArrayFill; 293 to.InnerArrayFill = InnerArrayFill;
290 to.InnerArrayFind = InnerArrayFind; 294 to.InnerArrayFind = InnerArrayFind;
291 to.InnerArrayFindIndex = InnerArrayFindIndex; 295 to.InnerArrayFindIndex = InnerArrayFindIndex;
292 }); 296 });
293 297
294 }) 298 })
OLDNEW
« no previous file with comments | « src/arraybuffer.js ('k') | src/harmony-atomics.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698