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 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
765 return stub; | 765 return stub; |
766 } | 766 } |
767 | 767 |
768 StringAddTFStub = function StringAddTFStub(call_conv, minor_key) { | 768 StringAddTFStub = function StringAddTFStub(call_conv, minor_key) { |
769 var stub = function(left, right) { | 769 var stub = function(left, right) { |
770 return %StringAdd(left, right); | 770 return %StringAdd(left, right); |
771 } | 771 } |
772 return stub; | 772 return stub; |
773 } | 773 } |
774 | 774 |
775 const kTurboFanICCallModeMask = 1; | |
776 const kTurboFanICCallForUnptimizedCode = 0; | |
777 const kTurboFanICCallForOptimizedCode = 1; | |
778 | |
775 MathFloorStub = function MathFloorStub(call_conv, minor_key) { | 779 MathFloorStub = function MathFloorStub(call_conv, minor_key) { |
776 var stub = function(f, i, v) { | 780 var call_from_optimized_ic = function(f, i, tv, receiver, v) { |
777 // |f| is calling function's JSFunction | 781 "use strict"; |
782 // |f| is this function's JSFunction | |
778 // |i| is TypeFeedbackVector slot # of callee's CallIC for Math.floor call | 783 // |i| is TypeFeedbackVector slot # of callee's CallIC for Math.floor call |
784 // |receiver| is receiver, should not be used | |
785 // |tv| is the calling function's type vector | |
779 // |v| is the value to floor | 786 // |v| is the value to floor |
787 if (f !== %_FixedArrayGet(tv, i|0)) { | |
788 return %_CallFunction(receiver, v, f); | |
789 } | |
780 var r = %_MathFloor(+v); | 790 var r = %_MathFloor(+v); |
781 if (%_IsMinusZero(r)) { | 791 if (%_IsMinusZero(r)) { |
782 // Collect type feedback when the result of the floor is -0. This is | 792 // Collect type feedback when the result of the floor is -0. This is |
783 // accomplished by storing a sentinel in the second, "extra" | 793 // accomplished by storing a sentinel in the second, "extra" |
784 // TypeFeedbackVector slot corresponding to the Math.floor CallIC call in | 794 // TypeFeedbackVector slot corresponding to the Math.floor CallIC call in |
785 // the caller's TypeVector. | 795 // the caller's TypeVector. |
786 %_FixedArraySet(%_GetTypeFeedbackVector(f), ((i|0)+1)|0, 1); | 796 %_FixedArraySet(tv, ((i|0)+1)|0, 1); |
mvstanton
2015/07/08 09:42:29
It would be cool if expressions like ((i|0)+1)|0 c
danno
2015/07/08 13:08:40
Acknowledged.
| |
787 return -0; | 797 return -0; |
788 } | 798 } |
789 // Return integers in smi range as smis. | 799 // Return integers in smi range as smis. |
790 var trunc = r|0; | 800 var trunc = r|0; |
791 if (trunc === r) { | 801 if (trunc === r) { |
792 return trunc; | 802 return trunc; |
793 } | 803 } |
794 return r; | 804 return r; |
795 } | 805 } |
796 return stub; | 806 var call_mode = (minor_key & kTurboFanICCallModeMask); |
807 if (call_mode == kTurboFanICCallForOptimizedCode) { | |
808 return call_from_optimized_ic; | |
809 } else { | |
810 %SetForceInlineFlag(call_from_optimized_ic); | |
811 var call_from_unoptimized_ic = function(f, i, receiver, v) { | |
812 var tv = %_GetTypeFeedbackVector(%_GetCallerJSFunction()); | |
813 return call_from_optimized_ic(f, i, tv, receiver, v); | |
814 } | |
815 return call_from_unoptimized_ic; | |
816 } | |
797 } | 817 } |
798 | 818 |
799 | 819 |
800 /* ------------------------------------- | 820 /* ------------------------------------- |
801 - - - C o n v e r s i o n s - - - | 821 - - - C o n v e r s i o n s - - - |
802 ------------------------------------- | 822 ------------------------------------- |
803 */ | 823 */ |
804 | 824 |
805 // ECMA-262, section 9.1, page 30. Use null/undefined for no hint, | 825 // ECMA-262, section 9.1, page 30. Use null/undefined for no hint, |
806 // (1) for number hint, and (2) for string hint. | 826 // (1) for number hint, and (2) for string hint. |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1041 $toLength = ToLength; | 1061 $toLength = ToLength; |
1042 $toName = ToName; | 1062 $toName = ToName; |
1043 $toNumber = ToNumber; | 1063 $toNumber = ToNumber; |
1044 $toObject = ToObject; | 1064 $toObject = ToObject; |
1045 $toPositiveInteger = ToPositiveInteger; | 1065 $toPositiveInteger = ToPositiveInteger; |
1046 $toPrimitive = ToPrimitive; | 1066 $toPrimitive = ToPrimitive; |
1047 $toString = ToString; | 1067 $toString = ToString; |
1048 $toUint32 = ToUint32; | 1068 $toUint32 = ToUint32; |
1049 | 1069 |
1050 }) | 1070 }) |
OLD | NEW |