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 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 // x is +0 and y is -0 or vice versa. | 606 // x is +0 and y is -0 or vice versa. |
607 if (x === 0 && y === 0 && %_IsMinusZero(x) != %_IsMinusZero(y)) { | 607 if (x === 0 && y === 0 && %_IsMinusZero(x) != %_IsMinusZero(y)) { |
608 return false; | 608 return false; |
609 } | 609 } |
610 } | 610 } |
611 return x === y; | 611 return x === y; |
612 } | 612 } |
613 | 613 |
614 // ES6, section 7.2.4 | 614 // ES6, section 7.2.4 |
615 function SameValueZero(x, y) { | 615 function SameValueZero(x, y) { |
616 if (typeof x != typeof y) return false; | 616 if (x === y) return true; |
617 if (IS_NUMBER(x)) { | 617 return IS_NUMBER(x) && NUMBER_IS_NAN(x) && IS_NUMBER(y) && NUMBER_IS_NAN(y); |
618 if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true; | |
619 } | |
620 return x === y; | |
621 } | 618 } |
| 619 %SetInlineBuiltinFlag(SameValueZero); |
622 | 620 |
623 | 621 |
624 /* --------------------------------- | 622 /* --------------------------------- |
625 - - - U t i l i t i e s - - - | 623 - - - U t i l i t i e s - - - |
626 --------------------------------- | 624 --------------------------------- |
627 */ | 625 */ |
628 | 626 |
629 // Returns if the given x is a primitive value - not an object or a | 627 // Returns if the given x is a primitive value - not an object or a |
630 // function. | 628 // function. |
631 function IsPrimitive(x) { | 629 function IsPrimitive(x) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 return i; | 685 return i; |
688 } | 686 } |
689 | 687 |
690 | 688 |
691 // NOTE: Setting the prototype for Array must take place as early as | 689 // NOTE: Setting the prototype for Array must take place as early as |
692 // possible due to code generation for array literals. When | 690 // possible due to code generation for array literals. When |
693 // generating code for a array literal a boilerplate array is created | 691 // generating code for a array literal a boilerplate array is created |
694 // that is cloned when running the code. It is essential that the | 692 // that is cloned when running the code. It is essential that the |
695 // boilerplate gets the right prototype. | 693 // boilerplate gets the right prototype. |
696 %FunctionSetPrototype($Array, new $Array(0)); | 694 %FunctionSetPrototype($Array, new $Array(0)); |
OLD | NEW |