| 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 545 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 556 } | 556 } | 
| 557 | 557 | 
| 558 | 558 | 
| 559 // ECMA-262, section 9.4, page 34. | 559 // ECMA-262, section 9.4, page 34. | 
| 560 function ToInteger(x) { | 560 function ToInteger(x) { | 
| 561   if (%_IsSmi(x)) return x; | 561   if (%_IsSmi(x)) return x; | 
| 562   return %NumberToInteger(ToNumber(x)); | 562   return %NumberToInteger(ToNumber(x)); | 
| 563 } | 563 } | 
| 564 | 564 | 
| 565 | 565 | 
|  | 566 // ES6, draft 08-24-14, section 7.1.15 | 
|  | 567 function ToLength(arg) { | 
|  | 568   arg = ToInteger(arg); | 
|  | 569   if (arg < 0) return 0; | 
|  | 570   return arg < $Number.MAX_SAFE_INTEGER ? arg : $Number.MAX_SAFE_INTEGER; | 
|  | 571 } | 
|  | 572 | 
|  | 573 | 
| 566 // ECMA-262, section 9.6, page 34. | 574 // ECMA-262, section 9.6, page 34. | 
| 567 function ToUint32(x) { | 575 function ToUint32(x) { | 
| 568   if (%_IsSmi(x) && x >= 0) return x; | 576   if (%_IsSmi(x) && x >= 0) return x; | 
| 569   return %NumberToJSUint32(ToNumber(x)); | 577   return %NumberToJSUint32(ToNumber(x)); | 
| 570 } | 578 } | 
| 571 | 579 | 
| 572 | 580 | 
| 573 // ECMA-262, section 9.5, page 34 | 581 // ECMA-262, section 9.5, page 34 | 
| 574 function ToInt32(x) { | 582 function ToInt32(x) { | 
| 575   if (%_IsSmi(x)) return x; | 583   if (%_IsSmi(x)) return x; | 
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 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)); | 
| OLD | NEW | 
|---|