Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 |
| (...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 725 } | 725 } |
| 726 | 726 |
| 727 | 727 |
| 728 // ECMA-262, section 9.4, page 34. | 728 // ECMA-262, section 9.4, page 34. |
| 729 function ToInteger(x) { | 729 function ToInteger(x) { |
| 730 if (%_IsSmi(x)) return x; | 730 if (%_IsSmi(x)) return x; |
| 731 return %NumberToInteger(ToNumber(x)); | 731 return %NumberToInteger(ToNumber(x)); |
| 732 } | 732 } |
| 733 | 733 |
| 734 | 734 |
| 735 // ES6, draft 08-24-14, section 7.1.15 | 735 // ES6, section 7.1.15 |
| 736 function ToLength(arg) { | 736 function ToLength(arg) { |
| 737 arg = ToInteger(arg); | 737 arg = TO_NUMBER_INLINE(arg); |
|
adamk
2015/08/24 22:42:17
Not sure what the state of the art is...should thi
| |
| 738 if (arg < 0) return 0; | 738 if (arg <= 0) return 0; |
| 739 return arg < GlobalNumber.MAX_SAFE_INTEGER ? arg | 739 arg = %_MathFloor(arg); |
| 740 : GlobalNumber.MAX_SAFE_INTEGER; | 740 return arg < kMaxSafeInteger ? arg : kMaxSafeInteger; |
| 741 } | 741 } |
| 742 | 742 |
| 743 | 743 |
| 744 // ES5, section 9.12 | 744 // ES5, section 9.12 |
| 745 function SameValue(x, y) { | 745 function SameValue(x, y) { |
| 746 if (typeof x != typeof y) return false; | 746 if (typeof x != typeof y) return false; |
| 747 if (IS_NUMBER(x)) { | 747 if (IS_NUMBER(x)) { |
| 748 if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true; | 748 if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true; |
| 749 // x is +0 and y is -0 or vice versa. | 749 // x is +0 and y is -0 or vice versa. |
| 750 if (x === 0 && y === 0 && %_IsMinusZero(x) != %_IsMinusZero(y)) { | 750 if (x === 0 && y === 0 && %_IsMinusZero(x) != %_IsMinusZero(y)) { |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 921 to["to_string_fun"] = ToString; | 921 to["to_string_fun"] = ToString; |
| 922 }); | 922 }); |
| 923 | 923 |
| 924 utils.Export(function(to) { | 924 utils.Export(function(to) { |
| 925 to.ToBoolean = ToBoolean; | 925 to.ToBoolean = ToBoolean; |
| 926 to.ToNumber = ToNumber; | 926 to.ToNumber = ToNumber; |
| 927 to.ToString = ToString; | 927 to.ToString = ToString; |
| 928 }) | 928 }) |
| 929 | 929 |
| 930 }) | 930 }) |
| OLD | NEW |