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

Side by Side Diff: src/runtime.js

Issue 1309243003: ES6: Array.prototype.slice and friends should use ToLength instead of ToUint32 (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Use a TO_LENGTH macro instead of the ToLengthFlagged function Created 5 years, 3 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
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 // This files contains runtime support implemented in JavaScript. 5 // This files contains runtime support implemented in JavaScript.
6 6
7 // CAUTION: Some of the functions specified in this file are called 7 // CAUTION: Some of the functions specified in this file are called
8 // directly from compiled code. These are the functions with names in 8 // directly from compiled code. These are the functions with names in
9 // ALL CAPS. The compiled code passes the first argument in 'this'. 9 // ALL CAPS. The compiled code passes the first argument in 'this'.
10 10
11 11
12 // The following declarations are shared with other native JS files. 12 // The following declarations are shared with other native JS files.
13 // They are all declared at this one spot to avoid redeclaration errors. 13 // They are all declared at this one spot to avoid redeclaration errors.
14 var $defaultString; 14 var $defaultString;
15 var $NaN; 15 var $NaN;
16 var $nonNumberToNumber; 16 var $nonNumberToNumber;
17 var $nonStringToString; 17 var $nonStringToString;
18 var $sameValue; 18 var $sameValue;
19 var $sameValueZero; 19 var $sameValueZero;
20 var $toInteger; 20 var $toInteger;
21 var $toLength; 21 var $toLength;
22 var $toNumber; 22 var $toNumber;
23 var $toPositiveInteger; 23 var $toPositiveInteger;
24 var $toPrimitive; 24 var $toPrimitive;
25 var $toString; 25 var $toString;
26 26
27 var harmony_tolength = false;
28
27 (function(global, utils) { 29 (function(global, utils) {
28 30
29 %CheckIsBootstrapping(); 31 %CheckIsBootstrapping();
30 32
31 var GlobalArray = global.Array; 33 var GlobalArray = global.Array;
32 var GlobalBoolean = global.Boolean; 34 var GlobalBoolean = global.Boolean;
33 var GlobalString = global.String; 35 var GlobalString = global.String;
34 var GlobalNumber = global.Number; 36 var GlobalNumber = global.Number;
35 var isConcatSpreadableSymbol = 37 var isConcatSpreadableSymbol =
36 utils.ImportNow("is_concat_spreadable_symbol"); 38 utils.ImportNow("is_concat_spreadable_symbol");
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 648
647 649
648 // ES6, draft 08-24-14, section 7.1.15 650 // ES6, draft 08-24-14, section 7.1.15
649 function ToLength(arg) { 651 function ToLength(arg) {
650 arg = ToInteger(arg); 652 arg = ToInteger(arg);
651 if (arg < 0) return 0; 653 if (arg < 0) return 0;
652 return arg < GlobalNumber.MAX_SAFE_INTEGER ? arg 654 return arg < GlobalNumber.MAX_SAFE_INTEGER ? arg
653 : GlobalNumber.MAX_SAFE_INTEGER; 655 : GlobalNumber.MAX_SAFE_INTEGER;
654 } 656 }
655 657
656
aperez 2015/09/09 18:20:45 Also, I noticed this bogus line removal here. I'm
657 // ES5, section 9.12 658 // ES5, section 9.12
658 function SameValue(x, y) { 659 function SameValue(x, y) {
659 if (typeof x != typeof y) return false; 660 if (typeof x != typeof y) return false;
660 if (IS_NUMBER(x)) { 661 if (IS_NUMBER(x)) {
661 if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true; 662 if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true;
662 // x is +0 and y is -0 or vice versa. 663 // x is +0 and y is -0 or vice versa.
663 if (x === 0 && y === 0 && %_IsMinusZero(x) != %_IsMinusZero(y)) { 664 if (x === 0 && y === 0 && %_IsMinusZero(x) != %_IsMinusZero(y)) {
664 return false; 665 return false;
665 } 666 }
666 } 667 }
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 831
831 utils.Export(function(to) { 832 utils.Export(function(to) {
832 to.ToBoolean = ToBoolean; 833 to.ToBoolean = ToBoolean;
833 to.ToLength = ToLength; 834 to.ToLength = ToLength;
834 to.ToNumber = ToNumber; 835 to.ToNumber = ToNumber;
835 to.ToPrimitive = ToPrimitive; 836 to.ToPrimitive = ToPrimitive;
836 to.ToString = ToString; 837 to.ToString = ToString;
837 }); 838 });
838 839
839 }) 840 })
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698