Chromium Code Reviews| Index: src/runtime.js |
| diff --git a/src/runtime.js b/src/runtime.js |
| index d9e1fe5c994030f40461167faac8b3df4d60ff22..d4849d9b131fcaea70efbadbe5cf64b39c460502 100644 |
| --- a/src/runtime.js |
| +++ b/src/runtime.js |
| @@ -576,6 +576,15 @@ function ToInt32(x) { |
| return %NumberToJSInt32(ToNumber(x)); |
| } |
| +// ES6, section 7.1.15 |
| +function ToLength(x) { |
| + if (%_IsSmi(x) && x > 0) return x; // not >= since -0 >= +0 |
|
mathias
2014/09/18 06:16:32
Same here.
Dmitry Lomov (no reviews)
2014/09/18 06:26:46
if %_IsSmi(x) then x can only be +0 (-0 is not Sm
|
| + |
| + var len = ToInteger(x); |
| + if (len <= 0) return 0; |
| + return MathMin(len, $Number.MAX_SAFE_INTEGER); |
| +} |
| + |
| // ES5, section 9.12 |
| function SameValue(x, y) { |
| @@ -590,6 +599,15 @@ function SameValue(x, y) { |
| return x === y; |
| } |
| +// ES6, section 7.2.4 |
| +function SameValueZero(x, y) { |
| + if (typeof x != typeof y) return false; |
| + if (IS_NUMBER(x)) { |
| + if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true; |
| + } |
| + return x === y; |
| +} |
| + |
| /* --------------------------------- |
| - - - U t i l i t i e s - - - |