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' and | 9 // ALL CAPS. The compiled code passes the first argument in 'this' and |
10 // it does not push the function onto the stack. This means that you | 10 // it does not push the function onto the stack. This means that you |
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 if (IS_NUMBER(x)) { | 591 if (IS_NUMBER(x)) { |
592 if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true; | 592 if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true; |
593 // x is +0 and y is -0 or vice versa. | 593 // x is +0 and y is -0 or vice versa. |
594 if (x === 0 && y === 0 && %_IsMinusZero(x) != %_IsMinusZero(y)) { | 594 if (x === 0 && y === 0 && %_IsMinusZero(x) != %_IsMinusZero(y)) { |
595 return false; | 595 return false; |
596 } | 596 } |
597 } | 597 } |
598 return x === y; | 598 return x === y; |
599 } | 599 } |
600 | 600 |
| 601 // ES6, section 7.2.4 |
| 602 function SameValueZero(x, y) { |
| 603 if (typeof x != typeof y) return false; |
| 604 if (IS_NUMBER(x)) { |
| 605 if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true; |
| 606 } |
| 607 return x === y; |
| 608 } |
| 609 |
601 | 610 |
602 /* --------------------------------- | 611 /* --------------------------------- |
603 - - - U t i l i t i e s - - - | 612 - - - U t i l i t i e s - - - |
604 --------------------------------- | 613 --------------------------------- |
605 */ | 614 */ |
606 | 615 |
607 // Returns if the given x is a primitive value - not an object or a | 616 // Returns if the given x is a primitive value - not an object or a |
608 // function. | 617 // function. |
609 function IsPrimitive(x) { | 618 function IsPrimitive(x) { |
610 // Even though the type of null is "object", null is still | 619 // Even though the type of null is "object", null is still |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 return i; | 665 return i; |
657 } | 666 } |
658 | 667 |
659 | 668 |
660 // NOTE: Setting the prototype for Array must take place as early as | 669 // NOTE: Setting the prototype for Array must take place as early as |
661 // possible due to code generation for array literals. When | 670 // possible due to code generation for array literals. When |
662 // generating code for a array literal a boilerplate array is created | 671 // generating code for a array literal a boilerplate array is created |
663 // that is cloned when running the code. It is essential that the | 672 // that is cloned when running the code. It is essential that the |
664 // boilerplate gets the right prototype. | 673 // boilerplate gets the right prototype. |
665 %FunctionSetPrototype($Array, new $Array(0)); | 674 %FunctionSetPrototype($Array, new $Array(0)); |
OLD | NEW |