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 552273002: Implement ToLength from ES6 section 7.1.15 (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 months 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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' 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 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true; 584 if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true;
585 // x is +0 and y is -0 or vice versa. 585 // x is +0 and y is -0 or vice versa.
586 if (x === 0 && y === 0 && %_IsMinusZero(x) != %_IsMinusZero(y)) { 586 if (x === 0 && y === 0 && %_IsMinusZero(x) != %_IsMinusZero(y)) {
587 return false; 587 return false;
588 } 588 }
589 } 589 }
590 return x === y; 590 return x === y;
591 } 591 }
592 592
593 593
594 // ES6, draft 08-24-14, section 7.1.15
rossberg 2014/09/10 07:29:51 Nit: move this next to ToInteger
caitp (gmail) 2014/09/10 11:49:40 Acknowledged.
595 function ToLength(arg) {
596 arg = ToInteger(arg);
597 if (arg < +0) return 0;
rossberg 2014/09/10 07:29:51 Nit: remove the +
caitp (gmail) 2014/09/10 11:49:40 Acknowledged.
598 return arg < $Number.MAX_SAFE_INTEGER ? arg : $Number.MAX_SAFE_INTEGER;
599 }
600
601
594 /* --------------------------------- 602 /* ---------------------------------
595 - - - U t i l i t i e s - - - 603 - - - U t i l i t i e s - - -
596 --------------------------------- 604 ---------------------------------
597 */ 605 */
598 606
599 // Returns if the given x is a primitive value - not an object or a 607 // Returns if the given x is a primitive value - not an object or a
600 // function. 608 // function.
601 function IsPrimitive(x) { 609 function IsPrimitive(x) {
602 // Even though the type of null is "object", null is still 610 // Even though the type of null is "object", null is still
603 // considered a primitive value. IS_SPEC_OBJECT handles this correctly 611 // considered a primitive value. IS_SPEC_OBJECT handles this correctly
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 return i; 656 return i;
649 } 657 }
650 658
651 659
652 // NOTE: Setting the prototype for Array must take place as early as 660 // NOTE: Setting the prototype for Array must take place as early as
653 // possible due to code generation for array literals. When 661 // possible due to code generation for array literals. When
654 // generating code for a array literal a boilerplate array is created 662 // generating code for a array literal a boilerplate array is created
655 // that is cloned when running the code. It is essential that the 663 // that is cloned when running the code. It is essential that the
656 // boilerplate gets the right prototype. 664 // boilerplate gets the right prototype.
657 %FunctionSetPrototype($Array, new $Array(0)); 665 %FunctionSetPrototype($Array, new $Array(0));
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698