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

Side by Side Diff: src/harmony-typedarray.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/harmony-atomics.js ('k') | src/json.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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
(...skipping 30 matching lines...) Expand all
41 var InnerArrayFindIndex; 41 var InnerArrayFindIndex;
42 var InnerArrayForEach; 42 var InnerArrayForEach;
43 var InnerArrayIndexOf; 43 var InnerArrayIndexOf;
44 var InnerArrayJoin; 44 var InnerArrayJoin;
45 var InnerArrayLastIndexOf; 45 var InnerArrayLastIndexOf;
46 var InnerArrayMap; 46 var InnerArrayMap;
47 var InnerArraySome; 47 var InnerArraySome;
48 var InnerArraySort; 48 var InnerArraySort;
49 var InnerArrayToLocaleString; 49 var InnerArrayToLocaleString;
50 var IsNaN; 50 var IsNaN;
51 var MathMax;
52 var MathMin;
51 var PackedArrayReverse; 53 var PackedArrayReverse;
52 54
53 utils.Import(function(from) { 55 utils.Import(function(from) {
54 ArrayFrom = from.ArrayFrom; 56 ArrayFrom = from.ArrayFrom;
55 ArrayToString = from.ArrayToString; 57 ArrayToString = from.ArrayToString;
56 InnerArrayCopyWithin = from.InnerArrayCopyWithin; 58 InnerArrayCopyWithin = from.InnerArrayCopyWithin;
57 InnerArrayEvery = from.InnerArrayEvery; 59 InnerArrayEvery = from.InnerArrayEvery;
58 InnerArrayFill = from.InnerArrayFill; 60 InnerArrayFill = from.InnerArrayFill;
59 InnerArrayFilter = from.InnerArrayFilter; 61 InnerArrayFilter = from.InnerArrayFilter;
60 InnerArrayFind = from.InnerArrayFind; 62 InnerArrayFind = from.InnerArrayFind;
61 InnerArrayFindIndex = from.InnerArrayFindIndex; 63 InnerArrayFindIndex = from.InnerArrayFindIndex;
62 InnerArrayForEach = from.InnerArrayForEach; 64 InnerArrayForEach = from.InnerArrayForEach;
63 InnerArrayIndexOf = from.InnerArrayIndexOf; 65 InnerArrayIndexOf = from.InnerArrayIndexOf;
64 InnerArrayJoin = from.InnerArrayJoin; 66 InnerArrayJoin = from.InnerArrayJoin;
65 InnerArrayLastIndexOf = from.InnerArrayLastIndexOf; 67 InnerArrayLastIndexOf = from.InnerArrayLastIndexOf;
66 InnerArrayMap = from.InnerArrayMap; 68 InnerArrayMap = from.InnerArrayMap;
67 InnerArrayReduce = from.InnerArrayReduce; 69 InnerArrayReduce = from.InnerArrayReduce;
68 InnerArrayReduceRight = from.InnerArrayReduceRight; 70 InnerArrayReduceRight = from.InnerArrayReduceRight;
69 InnerArraySome = from.InnerArraySome; 71 InnerArraySome = from.InnerArraySome;
70 InnerArraySort = from.InnerArraySort; 72 InnerArraySort = from.InnerArraySort;
71 InnerArrayToLocaleString = from.InnerArrayToLocaleString; 73 InnerArrayToLocaleString = from.InnerArrayToLocaleString;
72 IsNaN = from.IsNaN; 74 IsNaN = from.IsNaN;
75 MathMax = from.MathMax;
76 MathMin = from.MathMin;
73 PackedArrayReverse = from.PackedArrayReverse; 77 PackedArrayReverse = from.PackedArrayReverse;
74 }); 78 });
75 79
76 // ------------------------------------------------------------------- 80 // -------------------------------------------------------------------
77 81
78 function ConstructTypedArray(constructor, arg) { 82 function ConstructTypedArray(constructor, arg) {
79 // TODO(littledan): This is an approximation of the spec, which requires 83 // TODO(littledan): This is an approximation of the spec, which requires
80 // that only real TypedArray classes should be accepted (22.2.2.1.1) 84 // that only real TypedArray classes should be accepted (22.2.2.1.1)
81 if (!%IsConstructor(constructor) || IS_UNDEFINED(constructor.prototype) || 85 if (!%IsConstructor(constructor) || IS_UNDEFINED(constructor.prototype) ||
82 !%HasOwnProperty(constructor.prototype, "BYTES_PER_ELEMENT")) { 86 !%HasOwnProperty(constructor.prototype, "BYTES_PER_ELEMENT")) {
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 312
309 313
310 function TypedArraySlice(start, end) { 314 function TypedArraySlice(start, end) {
311 if (!%_IsTypedArray(this)) throw MakeTypeError(kNotTypedArray); 315 if (!%_IsTypedArray(this)) throw MakeTypeError(kNotTypedArray);
312 var len = %_TypedArrayGetLength(this); 316 var len = %_TypedArrayGetLength(this);
313 317
314 var relativeStart = TO_INTEGER(start); 318 var relativeStart = TO_INTEGER(start);
315 319
316 var k; 320 var k;
317 if (relativeStart < 0) { 321 if (relativeStart < 0) {
318 k = MAX_SIMPLE(len + relativeStart, 0); 322 k = MathMax(len + relativeStart, 0);
319 } else { 323 } else {
320 k = MIN_SIMPLE(relativeStart, len); 324 k = MathMin(relativeStart, len);
321 } 325 }
322 326
323 var relativeEnd; 327 var relativeEnd;
324 if (IS_UNDEFINED(end)) { 328 if (IS_UNDEFINED(end)) {
325 relativeEnd = len; 329 relativeEnd = len;
326 } else { 330 } else {
327 relativeEnd = TO_INTEGER(end); 331 relativeEnd = TO_INTEGER(end);
328 } 332 }
329 333
330 var final; 334 var final;
331 if (relativeEnd < 0) { 335 if (relativeEnd < 0) {
332 final = MAX_SIMPLE(len + relativeEnd, 0); 336 final = MathMax(len + relativeEnd, 0);
333 } else { 337 } else {
334 final = MIN_SIMPLE(relativeEnd, len); 338 final = MathMin(relativeEnd, len);
335 } 339 }
336 340
337 var count = MAX_SIMPLE(final - k, 0); 341 var count = MathMax(final - k, 0);
338 var array = ConstructTypedArrayLike(this, count); 342 var array = ConstructTypedArrayLike(this, count);
339 // The code below is the 'then' branch; the 'else' branch species 343 // The code below is the 'then' branch; the 'else' branch species
340 // a memcpy. Because V8 doesn't canonicalize NaN, the difference is 344 // a memcpy. Because V8 doesn't canonicalize NaN, the difference is
341 // unobservable. 345 // unobservable.
342 var n = 0; 346 var n = 0;
343 while (k < final) { 347 while (k < final) {
344 var kValue = this[k]; 348 var kValue = this[k];
345 // TODO(littledan): The spec says to throw on an error in setting; 349 // TODO(littledan): The spec says to throw on an error in setting;
346 // does this throw? 350 // does this throw?
347 array[n] = kValue; 351 array[n] = kValue;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 "some", TypedArraySome, 403 "some", TypedArraySome,
400 "sort", TypedArraySort, 404 "sort", TypedArraySort,
401 "toString", TypedArrayToString, 405 "toString", TypedArrayToString,
402 "toLocaleString", TypedArrayToLocaleString 406 "toLocaleString", TypedArrayToLocaleString
403 ]); 407 ]);
404 endmacro 408 endmacro
405 409
406 TYPED_ARRAYS(EXTEND_TYPED_ARRAY) 410 TYPED_ARRAYS(EXTEND_TYPED_ARRAY)
407 411
408 }) 412 })
OLDNEW
« no previous file with comments | « src/harmony-atomics.js ('k') | src/json.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698