| 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 | |
| 779 MathFloorStub = function MathFloorStub(call_conv, minor_key) { | 775 MathFloorStub = function MathFloorStub(call_conv, minor_key) { |
| 780 var call_from_optimized_ic = function(f, i, tv, receiver, v) { | 776 var stub = function(f, i, v) { |
| 781 "use strict"; | 777 // |f| is calling function's JSFunction |
| 782 // |f| is this function's JSFunction | |
| 783 // |i| is TypeFeedbackVector slot # of callee's CallIC for Math.floor call | 778 // |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 | |
| 786 // |v| is the value to floor | 779 // |v| is the value to floor |
| 787 if (f !== %_FixedArrayGet(tv, i|0)) { | |
| 788 return %_CallFunction(receiver, v, f); | |
| 789 } | |
| 790 var r = %_MathFloor(+v); | 780 var r = %_MathFloor(+v); |
| 791 if (%_IsMinusZero(r)) { | 781 if (%_IsMinusZero(r)) { |
| 792 // Collect type feedback when the result of the floor is -0. This is | 782 // Collect type feedback when the result of the floor is -0. This is |
| 793 // accomplished by storing a sentinel in the second, "extra" | 783 // accomplished by storing a sentinel in the second, "extra" |
| 794 // TypeFeedbackVector slot corresponding to the Math.floor CallIC call in | 784 // TypeFeedbackVector slot corresponding to the Math.floor CallIC call in |
| 795 // the caller's TypeVector. | 785 // the caller's TypeVector. |
| 796 %_FixedArraySet(tv, ((i|0)+1)|0, 1); | 786 %_FixedArraySet(%_GetTypeFeedbackVector(f), ((i|0)+1)|0, 1); |
| 797 return -0; | 787 return -0; |
| 798 } | 788 } |
| 799 // Return integers in smi range as smis. | 789 // Return integers in smi range as smis. |
| 800 var trunc = r|0; | 790 var trunc = r|0; |
| 801 if (trunc === r) { | 791 if (trunc === r) { |
| 802 return trunc; | 792 return trunc; |
| 803 } | 793 } |
| 804 return r; | 794 return r; |
| 805 } | 795 } |
| 806 var call_mode = (minor_key & kTurboFanICCallModeMask); | 796 return stub; |
| 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 } | |
| 817 } | 797 } |
| 818 | 798 |
| 819 | 799 |
| 820 /* ------------------------------------- | 800 /* ------------------------------------- |
| 821 - - - C o n v e r s i o n s - - - | 801 - - - C o n v e r s i o n s - - - |
| 822 ------------------------------------- | 802 ------------------------------------- |
| 823 */ | 803 */ |
| 824 | 804 |
| 825 // ECMA-262, section 9.1, page 30. Use null/undefined for no hint, | 805 // ECMA-262, section 9.1, page 30. Use null/undefined for no hint, |
| 826 // (1) for number hint, and (2) for string hint. | 806 // (1) for number hint, and (2) for string hint. |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1061 $toLength = ToLength; | 1041 $toLength = ToLength; |
| 1062 $toName = ToName; | 1042 $toName = ToName; |
| 1063 $toNumber = ToNumber; | 1043 $toNumber = ToNumber; |
| 1064 $toObject = ToObject; | 1044 $toObject = ToObject; |
| 1065 $toPositiveInteger = ToPositiveInteger; | 1045 $toPositiveInteger = ToPositiveInteger; |
| 1066 $toPrimitive = ToPrimitive; | 1046 $toPrimitive = ToPrimitive; |
| 1067 $toString = ToString; | 1047 $toString = ToString; |
| 1068 $toUint32 = ToUint32; | 1048 $toUint32 = ToUint32; |
| 1069 | 1049 |
| 1070 }) | 1050 }) |
| OLD | NEW |