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

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: 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 $defaultNumber; 14 var $defaultNumber;
15 var $defaultString; 15 var $defaultString;
16 var $NaN; 16 var $NaN;
17 var $nonNumberToNumber; 17 var $nonNumberToNumber;
18 var $nonStringToString; 18 var $nonStringToString;
19 var $sameValue; 19 var $sameValue;
20 var $sameValueZero; 20 var $sameValueZero;
21 var $toInteger; 21 var $toInteger;
22 var $toLength; 22 var $toLength;
23 var $toName; 23 var $toName;
24 var $toNumber; 24 var $toNumber;
25 var $toPositiveInteger; 25 var $toPositiveInteger;
26 var $toPrimitive; 26 var $toPrimitive;
27 var $toString; 27 var $toString;
28 28
29 var harmony_tolength = false;
30
29 (function(global, utils) { 31 (function(global, utils) {
30 32
31 %CheckIsBootstrapping(); 33 %CheckIsBootstrapping();
32 34
33 var GlobalArray = global.Array; 35 var GlobalArray = global.Array;
34 var GlobalBoolean = global.Boolean; 36 var GlobalBoolean = global.Boolean;
35 var GlobalString = global.String; 37 var GlobalString = global.String;
36 var GlobalNumber = global.Number; 38 var GlobalNumber = global.Number;
37 39
38 // ---------------------------------------------------------------------------- 40 // ----------------------------------------------------------------------------
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 707
706 708
707 // ES6, draft 08-24-14, section 7.1.15 709 // ES6, draft 08-24-14, section 7.1.15
708 function ToLength(arg) { 710 function ToLength(arg) {
709 arg = ToInteger(arg); 711 arg = ToInteger(arg);
710 if (arg < 0) return 0; 712 if (arg < 0) return 0;
711 return arg < GlobalNumber.MAX_SAFE_INTEGER ? arg 713 return arg < GlobalNumber.MAX_SAFE_INTEGER ? arg
712 : GlobalNumber.MAX_SAFE_INTEGER; 714 : GlobalNumber.MAX_SAFE_INTEGER;
713 } 715 }
714 716
717 function ToLengthFlagged(arg) {
Camillo Bruni 2015/09/08 07:18:07 I would create a TO_LENGTH macro out of this (see
aperez 2015/09/09 12:48:43 Acknowledged.
718 return (harmony_tolength) ? ToLength(arg) : TO_UINT32(arg);
719 }
715 720
716 // ES5, section 9.12 721 // ES5, section 9.12
717 function SameValue(x, y) { 722 function SameValue(x, y) {
718 if (typeof x != typeof y) return false; 723 if (typeof x != typeof y) return false;
719 if (IS_NUMBER(x)) { 724 if (IS_NUMBER(x)) {
720 if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true; 725 if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true;
721 // x is +0 and y is -0 or vice versa. 726 // x is +0 and y is -0 or vice versa.
722 if (x === 0 && y === 0 && %_IsMinusZero(x) != %_IsMinusZero(y)) { 727 if (x === 0 && y === 0 && %_IsMinusZero(x) != %_IsMinusZero(y)) {
723 return false; 728 return false;
724 } 729 }
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 "to_string_fun", ToString, 901 "to_string_fun", ToString,
897 ]); 902 ]);
898 903
899 utils.Export(function(to) { 904 utils.Export(function(to) {
900 to.ToBoolean = ToBoolean; 905 to.ToBoolean = ToBoolean;
901 to.ToLength = ToLength; 906 to.ToLength = ToLength;
902 to.ToName = ToName; 907 to.ToName = ToName;
903 to.ToNumber = ToNumber; 908 to.ToNumber = ToNumber;
904 to.ToPrimitive = ToPrimitive; 909 to.ToPrimitive = ToPrimitive;
905 to.ToString = ToString; 910 to.ToString = ToString;
911 to.ToLengthFlagged = ToLengthFlagged;
906 }); 912 });
907 913
908 }) 914 })
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698