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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 var CALL_FUNCTION_PROXY_AS_CONSTRUCTOR; | 55 var CALL_FUNCTION_PROXY_AS_CONSTRUCTOR; |
56 var APPLY_PREPARE; | 56 var APPLY_PREPARE; |
57 var REFLECT_APPLY_PREPARE; | 57 var REFLECT_APPLY_PREPARE; |
58 var REFLECT_CONSTRUCT_PREPARE; | 58 var REFLECT_CONSTRUCT_PREPARE; |
59 var STACK_OVERFLOW; | 59 var STACK_OVERFLOW; |
60 var TO_OBJECT; | 60 var TO_OBJECT; |
61 var TO_NUMBER; | 61 var TO_NUMBER; |
62 var TO_STRING; | 62 var TO_STRING; |
63 var TO_NAME; | 63 var TO_NAME; |
64 | 64 |
65 var STRING_LENGTH_STUB; | 65 var StringLengthTF_STUB; |
| 66 var MathFloor_STUB; |
66 | 67 |
67 var $defaultNumber; | 68 var $defaultNumber; |
68 var $defaultString; | 69 var $defaultString; |
69 var $NaN; | 70 var $NaN; |
70 var $nonNumberToNumber; | 71 var $nonNumberToNumber; |
71 var $nonStringToString; | 72 var $nonStringToString; |
72 var $sameValue; | 73 var $sameValue; |
73 var $sameValueZero; | 74 var $sameValueZero; |
74 var $toBoolean; | 75 var $toBoolean; |
75 var $toInt32; | 76 var $toInt32; |
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 TO_NAME = function TO_NAME() { | 744 TO_NAME = function TO_NAME() { |
744 return %$toName(this); | 745 return %$toName(this); |
745 } | 746 } |
746 | 747 |
747 | 748 |
748 /* ----------------------------------------------- | 749 /* ----------------------------------------------- |
749 - - - J a v a S c r i p t S t u b s - - - | 750 - - - J a v a S c r i p t S t u b s - - - |
750 ----------------------------------------------- | 751 ----------------------------------------------- |
751 */ | 752 */ |
752 | 753 |
753 STRING_LENGTH_STUB = function STRING_LENGTH_STUB(name) { | 754 StringLengthTF_STUB = function StringLengthTF_STUB(receiver, name) { |
754 var receiver = this; // implicit first parameter | |
755 return %_StringGetLength(%_JSValueGetValue(receiver)); | 755 return %_StringGetLength(%_JSValueGetValue(receiver)); |
756 } | 756 } |
757 | 757 |
| 758 MathFloor_STUB = function MathFloor_STUB(f, i, v) { |
| 759 // |f| is calling function's JSFunction |
| 760 // |i| is TypeFeedbackVector slot # of callee's CallIC for Math.floor call |
| 761 // |v| is the value to floor |
| 762 var r = %_MathFloor(+v); |
| 763 if (%_IsMinusZero(r)) { |
| 764 // Collect type feedback when the result of the floor is -0. This is |
| 765 // accomplished by storing a sentinel in the second, "extra" |
| 766 // TypeFeedbackVector slot corresponding to the Math.floor CallIC call in |
| 767 // the caller's TypeVector. |
| 768 %_FixedArraySet(%_GetTypeFeedbackVector(f), ((i|0)+1)|0, 1); |
| 769 return -0; |
| 770 } |
| 771 // Return integers in smi range as smis. |
| 772 var trunc = r|0; |
| 773 if (trunc === r) { |
| 774 return trunc; |
| 775 } |
| 776 return r; |
| 777 } |
| 778 |
758 | 779 |
759 /* ------------------------------------- | 780 /* ------------------------------------- |
760 - - - C o n v e r s i o n s - - - | 781 - - - C o n v e r s i o n s - - - |
761 ------------------------------------- | 782 ------------------------------------- |
762 */ | 783 */ |
763 | 784 |
764 // ECMA-262, section 9.1, page 30. Use null/undefined for no hint, | 785 // ECMA-262, section 9.1, page 30. Use null/undefined for no hint, |
765 // (1) for number hint, and (2) for string hint. | 786 // (1) for number hint, and (2) for string hint. |
766 function ToPrimitive(x, hint) { | 787 function ToPrimitive(x, hint) { |
767 // Fast case check. | 788 // Fast case check. |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
991 $toLength = ToLength; | 1012 $toLength = ToLength; |
992 $toName = ToName; | 1013 $toName = ToName; |
993 $toNumber = ToNumber; | 1014 $toNumber = ToNumber; |
994 $toObject = ToObject; | 1015 $toObject = ToObject; |
995 $toPositiveInteger = ToPositiveInteger; | 1016 $toPositiveInteger = ToPositiveInteger; |
996 $toPrimitive = ToPrimitive; | 1017 $toPrimitive = ToPrimitive; |
997 $toString = ToString; | 1018 $toString = ToString; |
998 $toUint32 = ToUint32; | 1019 $toUint32 = ToUint32; |
999 | 1020 |
1000 }) | 1021 }) |
OLD | NEW |