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 15 matching lines...) Expand all Loading... |
26 | 26 |
27 var harmony_tolength = false; | 27 var harmony_tolength = false; |
28 | 28 |
29 (function(global, utils) { | 29 (function(global, utils) { |
30 | 30 |
31 %CheckIsBootstrapping(); | 31 %CheckIsBootstrapping(); |
32 | 32 |
33 var GlobalArray = global.Array; | 33 var GlobalArray = global.Array; |
34 var GlobalBoolean = global.Boolean; | 34 var GlobalBoolean = global.Boolean; |
35 var GlobalString = global.String; | 35 var GlobalString = global.String; |
36 var GlobalNumber = global.Number; | |
37 var isConcatSpreadableSymbol = | 36 var isConcatSpreadableSymbol = |
38 utils.ImportNow("is_concat_spreadable_symbol"); | 37 utils.ImportNow("is_concat_spreadable_symbol"); |
39 | 38 |
40 // ---------------------------------------------------------------------------- | 39 // ---------------------------------------------------------------------------- |
41 | 40 |
42 /* ----------------------------------- | 41 /* ----------------------------------- |
43 - - - C o m p a r i s o n - - - | 42 - - - C o m p a r i s o n - - - |
44 ----------------------------------- | 43 ----------------------------------- |
45 */ | 44 */ |
46 | 45 |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 function ToInteger(x) { | 294 function ToInteger(x) { |
296 if (%_IsSmi(x)) return x; | 295 if (%_IsSmi(x)) return x; |
297 return %NumberToInteger(ToNumber(x)); | 296 return %NumberToInteger(ToNumber(x)); |
298 } | 297 } |
299 | 298 |
300 | 299 |
301 // ES6, draft 08-24-14, section 7.1.15 | 300 // ES6, draft 08-24-14, section 7.1.15 |
302 function ToLength(arg) { | 301 function ToLength(arg) { |
303 arg = ToInteger(arg); | 302 arg = ToInteger(arg); |
304 if (arg < 0) return 0; | 303 if (arg < 0) return 0; |
305 return arg < GlobalNumber.MAX_SAFE_INTEGER ? arg | 304 return arg < kMaxSafeInteger ? arg : kMaxSafeInteger; |
306 : GlobalNumber.MAX_SAFE_INTEGER; | |
307 } | 305 } |
308 | 306 |
309 | 307 |
310 // ES5, section 9.12 | 308 // ES5, section 9.12 |
311 function SameValue(x, y) { | 309 function SameValue(x, y) { |
312 if (typeof x != typeof y) return false; | 310 if (typeof x != typeof y) return false; |
313 if (IS_NUMBER(x)) { | 311 if (IS_NUMBER(x)) { |
314 if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true; | 312 if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true; |
315 // x is +0 and y is -0 or vice versa. | 313 // x is +0 and y is -0 or vice versa. |
316 if (x === 0 && y === 0 && %_IsMinusZero(x) != %_IsMinusZero(y)) { | 314 if (x === 0 && y === 0 && %_IsMinusZero(x) != %_IsMinusZero(y)) { |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 | 453 |
456 utils.Export(function(to) { | 454 utils.Export(function(to) { |
457 to.ToBoolean = ToBoolean; | 455 to.ToBoolean = ToBoolean; |
458 to.ToLength = ToLength; | 456 to.ToLength = ToLength; |
459 to.ToNumber = ToNumber; | 457 to.ToNumber = ToNumber; |
460 to.ToPrimitive = ToPrimitive; | 458 to.ToPrimitive = ToPrimitive; |
461 to.ToString = ToString; | 459 to.ToString = ToString; |
462 }); | 460 }); |
463 | 461 |
464 }) | 462 }) |
OLD | NEW |