Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/runtime.js

Issue 771863002: Add Array.prototype.includes (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase on master Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/harmony-array-includes.js ('k') | test/mjsunit/harmony/array-includes.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 if (IS_NUMBER(x)) { 594 if (IS_NUMBER(x)) {
595 if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true; 595 if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true;
596 // x is +0 and y is -0 or vice versa. 596 // x is +0 and y is -0 or vice versa.
597 if (x === 0 && y === 0 && %_IsMinusZero(x) != %_IsMinusZero(y)) { 597 if (x === 0 && y === 0 && %_IsMinusZero(x) != %_IsMinusZero(y)) {
598 return false; 598 return false;
599 } 599 }
600 } 600 }
601 return x === y; 601 return x === y;
602 } 602 }
603 603
604 // ES6, section 7.2.4
605 function SameValueZero(x, y) {
606 if (typeof x != typeof y) return false;
607 if (IS_NUMBER(x)) {
608 if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true;
609 }
610 return x === y;
611 }
612
604 613
605 /* --------------------------------- 614 /* ---------------------------------
606 - - - U t i l i t i e s - - - 615 - - - U t i l i t i e s - - -
607 --------------------------------- 616 ---------------------------------
608 */ 617 */
609 618
610 // Returns if the given x is a primitive value - not an object or a 619 // Returns if the given x is a primitive value - not an object or a
611 // function. 620 // function.
612 function IsPrimitive(x) { 621 function IsPrimitive(x) {
613 // Even though the type of null is "object", null is still 622 // Even though the type of null is "object", null is still
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 return i; 668 return i;
660 } 669 }
661 670
662 671
663 // NOTE: Setting the prototype for Array must take place as early as 672 // NOTE: Setting the prototype for Array must take place as early as
664 // possible due to code generation for array literals. When 673 // possible due to code generation for array literals. When
665 // generating code for a array literal a boilerplate array is created 674 // generating code for a array literal a boilerplate array is created
666 // that is cloned when running the code. It is essential that the 675 // that is cloned when running the code. It is essential that the
667 // boilerplate gets the right prototype. 676 // boilerplate gets the right prototype.
668 %FunctionSetPrototype($Array, new $Array(0)); 677 %FunctionSetPrototype($Array, new $Array(0));
OLDNEW
« no previous file with comments | « src/harmony-array-includes.js ('k') | test/mjsunit/harmony/array-includes.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698