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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 var CONCAT_ITERABLE_TO_ARRAY; | 56 var CONCAT_ITERABLE_TO_ARRAY; |
57 var APPLY_PREPARE; | 57 var APPLY_PREPARE; |
58 var REFLECT_APPLY_PREPARE; | 58 var REFLECT_APPLY_PREPARE; |
59 var REFLECT_CONSTRUCT_PREPARE; | 59 var REFLECT_CONSTRUCT_PREPARE; |
60 var STACK_OVERFLOW; | 60 var STACK_OVERFLOW; |
61 var TO_OBJECT; | 61 var TO_OBJECT; |
62 var TO_NUMBER; | 62 var TO_NUMBER; |
63 var TO_STRING; | 63 var TO_STRING; |
64 var TO_NAME; | 64 var TO_NAME; |
65 | 65 |
66 var StringLengthTFStub; | |
67 var StringAddTFStub; | |
68 var MathFloorStub; | |
69 | |
70 var $defaultNumber; | 66 var $defaultNumber; |
71 var $defaultString; | 67 var $defaultString; |
72 var $NaN; | 68 var $NaN; |
73 var $nonNumberToNumber; | 69 var $nonNumberToNumber; |
74 var $nonStringToString; | 70 var $nonStringToString; |
75 var $sameValue; | 71 var $sameValue; |
76 var $sameValueZero; | 72 var $sameValueZero; |
77 var $toBoolean; | 73 var $toBoolean; |
78 var $toInt32; | 74 var $toInt32; |
79 var $toInteger; | 75 var $toInteger; |
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
744 return %$toString(this); | 740 return %$toString(this); |
745 } | 741 } |
746 | 742 |
747 | 743 |
748 // Convert the receiver to a string or symbol - forward to ToName. | 744 // Convert the receiver to a string or symbol - forward to ToName. |
749 TO_NAME = function TO_NAME() { | 745 TO_NAME = function TO_NAME() { |
750 return %$toName(this); | 746 return %$toName(this); |
751 } | 747 } |
752 | 748 |
753 | 749 |
754 /* ----------------------------------------------- | |
755 - - - J a v a S c r i p t S t u b s - - - | |
756 ----------------------------------------------- | |
757 */ | |
758 | |
759 StringLengthTFStub = function StringLengthTFStub(call_conv, minor_key) { | |
760 var stub = function(receiver, name, i, v) { | |
761 // i and v are dummy parameters mandated by the InterfaceDescriptor, | |
762 // (LoadWithVectorDescriptor). | |
763 return %_StringGetLength(%_JSValueGetValue(receiver)); | |
764 } | |
765 return stub; | |
766 } | |
767 | |
768 StringAddTFStub = function StringAddTFStub(call_conv, minor_key) { | |
769 var stub = function(left, right) { | |
770 return %StringAdd(left, right); | |
771 } | |
772 return stub; | |
773 } | |
774 | |
775 MathFloorStub = function MathFloorStub(call_conv, minor_key) { | |
776 var stub = function(f, i, v) { | |
777 // |f| is calling function's JSFunction | |
778 // |i| is TypeFeedbackVector slot # of callee's CallIC for Math.floor call | |
779 // |v| is the value to floor | |
780 var r = %_MathFloor(+v); | |
781 if (%_IsMinusZero(r)) { | |
782 // Collect type feedback when the result of the floor is -0. This is | |
783 // accomplished by storing a sentinel in the second, "extra" | |
784 // TypeFeedbackVector slot corresponding to the Math.floor CallIC call in | |
785 // the caller's TypeVector. | |
786 %_FixedArraySet(%_GetTypeFeedbackVector(f), ((i|0)+1)|0, 1); | |
787 return -0; | |
788 } | |
789 // Return integers in smi range as smis. | |
790 var trunc = r|0; | |
791 if (trunc === r) { | |
792 return trunc; | |
793 } | |
794 return r; | |
795 } | |
796 return stub; | |
797 } | |
798 | |
799 | |
800 /* ------------------------------------- | 750 /* ------------------------------------- |
801 - - - C o n v e r s i o n s - - - | 751 - - - C o n v e r s i o n s - - - |
802 ------------------------------------- | 752 ------------------------------------- |
803 */ | 753 */ |
804 | 754 |
805 // ECMA-262, section 9.1, page 30. Use null/undefined for no hint, | 755 // ECMA-262, section 9.1, page 30. Use null/undefined for no hint, |
806 // (1) for number hint, and (2) for string hint. | 756 // (1) for number hint, and (2) for string hint. |
807 function ToPrimitive(x, hint) { | 757 function ToPrimitive(x, hint) { |
808 // Fast case check. | 758 // Fast case check. |
809 if (IS_STRING(x)) return x; | 759 if (IS_STRING(x)) return x; |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1041 $toLength = ToLength; | 991 $toLength = ToLength; |
1042 $toName = ToName; | 992 $toName = ToName; |
1043 $toNumber = ToNumber; | 993 $toNumber = ToNumber; |
1044 $toObject = ToObject; | 994 $toObject = ToObject; |
1045 $toPositiveInteger = ToPositiveInteger; | 995 $toPositiveInteger = ToPositiveInteger; |
1046 $toPrimitive = ToPrimitive; | 996 $toPrimitive = ToPrimitive; |
1047 $toString = ToString; | 997 $toString = ToString; |
1048 $toUint32 = ToUint32; | 998 $toUint32 = ToUint32; |
1049 | 999 |
1050 }) | 1000 }) |
OLD | NEW |