OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 #include "src/ic/ic.h" | 5 #include "src/ic/ic.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api.h" | 8 #include "src/api.h" |
9 #include "src/arguments.h" | 9 #include "src/arguments.h" |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 2624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2635 return *result; | 2635 return *result; |
2636 } | 2636 } |
2637 | 2637 |
2638 | 2638 |
2639 MaybeHandle<Object> BinaryOpIC::Transition( | 2639 MaybeHandle<Object> BinaryOpIC::Transition( |
2640 Handle<AllocationSite> allocation_site, Handle<Object> left, | 2640 Handle<AllocationSite> allocation_site, Handle<Object> left, |
2641 Handle<Object> right) { | 2641 Handle<Object> right) { |
2642 BinaryOpICState state(isolate(), target()->extra_ic_state()); | 2642 BinaryOpICState state(isolate(), target()->extra_ic_state()); |
2643 | 2643 |
2644 // Compute the actual result using the builtin for the binary operation. | 2644 // Compute the actual result using the builtin for the binary operation. |
2645 Object* builtin = isolate()->js_builtins_object()->javascript_builtin( | 2645 Object* builtin = isolate()->native_context()->get( |
2646 TokenToJSBuiltin(state.op(), state.strength())); | 2646 TokenToContextIndex(state.op(), state.strength())); |
2647 Handle<JSFunction> function = handle(JSFunction::cast(builtin), isolate()); | 2647 Handle<JSFunction> function = handle(JSFunction::cast(builtin), isolate()); |
2648 Handle<Object> result; | 2648 Handle<Object> result; |
2649 ASSIGN_RETURN_ON_EXCEPTION( | 2649 ASSIGN_RETURN_ON_EXCEPTION( |
2650 isolate(), result, Execution::Call(isolate(), function, left, 1, &right), | 2650 isolate(), result, Execution::Call(isolate(), function, left, 1, &right), |
2651 Object); | 2651 Object); |
2652 | 2652 |
2653 // Do not try to update the target if the code was marked for lazy | 2653 // Do not try to update the target if the code was marked for lazy |
2654 // deoptimization. (Since we do not relocate addresses in these | 2654 // deoptimization. (Since we do not relocate addresses in these |
2655 // code objects, an attempt to access the target could fail.) | 2655 // code objects, an attempt to access the target could fail.) |
2656 if (AddressIsDeoptimizedCode()) { | 2656 if (AddressIsDeoptimizedCode()) { |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2875 } | 2875 } |
2876 | 2876 |
2877 | 2877 |
2878 RUNTIME_FUNCTION(Runtime_Unreachable) { | 2878 RUNTIME_FUNCTION(Runtime_Unreachable) { |
2879 UNREACHABLE(); | 2879 UNREACHABLE(); |
2880 CHECK(false); | 2880 CHECK(false); |
2881 return isolate->heap()->undefined_value(); | 2881 return isolate->heap()->undefined_value(); |
2882 } | 2882 } |
2883 | 2883 |
2884 | 2884 |
2885 Builtins::JavaScript BinaryOpIC::TokenToJSBuiltin(Token::Value op, | 2885 int BinaryOpIC::TokenToContextIndex(Token::Value op, Strength strength) { |
2886 Strength strength) { | |
2887 if (is_strong(strength)) { | 2886 if (is_strong(strength)) { |
2888 switch (op) { | 2887 switch (op) { |
2889 default: UNREACHABLE(); | 2888 default: UNREACHABLE(); |
2890 case Token::ADD: return Builtins::ADD_STRONG; | 2889 case Token::ADD: |
2891 case Token::SUB: return Builtins::SUB_STRONG; | 2890 return Context::ADD_STRONG_BUILTIN_INDEX; |
2892 case Token::MUL: return Builtins::MUL_STRONG; | 2891 case Token::SUB: |
2893 case Token::DIV: return Builtins::DIV_STRONG; | 2892 return Context::SUB_STRONG_BUILTIN_INDEX; |
2894 case Token::MOD: return Builtins::MOD_STRONG; | 2893 case Token::MUL: |
2895 case Token::BIT_OR: return Builtins::BIT_OR_STRONG; | 2894 return Context::MUL_STRONG_BUILTIN_INDEX; |
2896 case Token::BIT_AND: return Builtins::BIT_AND_STRONG; | 2895 case Token::DIV: |
2897 case Token::BIT_XOR: return Builtins::BIT_XOR_STRONG; | 2896 return Context::DIV_STRONG_BUILTIN_INDEX; |
2898 case Token::SAR: return Builtins::SAR_STRONG; | 2897 case Token::MOD: |
2899 case Token::SHR: return Builtins::SHR_STRONG; | 2898 return Context::MOD_STRONG_BUILTIN_INDEX; |
2900 case Token::SHL: return Builtins::SHL_STRONG; | 2899 case Token::BIT_OR: |
| 2900 return Context::BIT_OR_STRONG_BUILTIN_INDEX; |
| 2901 case Token::BIT_AND: |
| 2902 return Context::BIT_AND_STRONG_BUILTIN_INDEX; |
| 2903 case Token::BIT_XOR: |
| 2904 return Context::BIT_XOR_STRONG_BUILTIN_INDEX; |
| 2905 case Token::SAR: |
| 2906 return Context::SAR_STRONG_BUILTIN_INDEX; |
| 2907 case Token::SHR: |
| 2908 return Context::SHR_STRONG_BUILTIN_INDEX; |
| 2909 case Token::SHL: |
| 2910 return Context::SHL_STRONG_BUILTIN_INDEX; |
2901 } | 2911 } |
2902 } else { | 2912 } else { |
2903 switch (op) { | 2913 switch (op) { |
2904 default: UNREACHABLE(); | 2914 default: UNREACHABLE(); |
2905 case Token::ADD: return Builtins::ADD; | 2915 case Token::ADD: |
2906 case Token::SUB: return Builtins::SUB; | 2916 return Context::ADD_BUILTIN_INDEX; |
2907 case Token::MUL: return Builtins::MUL; | 2917 case Token::SUB: |
2908 case Token::DIV: return Builtins::DIV; | 2918 return Context::SUB_BUILTIN_INDEX; |
2909 case Token::MOD: return Builtins::MOD; | 2919 case Token::MUL: |
2910 case Token::BIT_OR: return Builtins::BIT_OR; | 2920 return Context::MUL_BUILTIN_INDEX; |
2911 case Token::BIT_AND: return Builtins::BIT_AND; | 2921 case Token::DIV: |
2912 case Token::BIT_XOR: return Builtins::BIT_XOR; | 2922 return Context::DIV_BUILTIN_INDEX; |
2913 case Token::SAR: return Builtins::SAR; | 2923 case Token::MOD: |
2914 case Token::SHR: return Builtins::SHR; | 2924 return Context::MOD_BUILTIN_INDEX; |
2915 case Token::SHL: return Builtins::SHL; | 2925 case Token::BIT_OR: |
| 2926 return Context::BIT_OR_BUILTIN_INDEX; |
| 2927 case Token::BIT_AND: |
| 2928 return Context::BIT_AND_BUILTIN_INDEX; |
| 2929 case Token::BIT_XOR: |
| 2930 return Context::BIT_XOR_BUILTIN_INDEX; |
| 2931 case Token::SAR: |
| 2932 return Context::SAR_BUILTIN_INDEX; |
| 2933 case Token::SHR: |
| 2934 return Context::SHR_BUILTIN_INDEX; |
| 2935 case Token::SHL: |
| 2936 return Context::SHL_BUILTIN_INDEX; |
2916 } | 2937 } |
2917 } | 2938 } |
2918 } | 2939 } |
2919 | 2940 |
2920 | 2941 |
2921 Handle<Object> ToBooleanIC::ToBoolean(Handle<Object> object) { | 2942 Handle<Object> ToBooleanIC::ToBoolean(Handle<Object> object) { |
2922 ToBooleanStub stub(isolate(), target()->extra_ic_state()); | 2943 ToBooleanStub stub(isolate(), target()->extra_ic_state()); |
2923 bool to_boolean_value = stub.UpdateStatus(object); | 2944 bool to_boolean_value = stub.UpdateStatus(object); |
2924 Handle<Code> code = stub.GetCode(); | 2945 Handle<Code> code = stub.GetCode(); |
2925 set_target(*code); | 2946 set_target(*code); |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3099 KeyedLoadICNexus nexus(vector, vector_slot); | 3120 KeyedLoadICNexus nexus(vector, vector_slot); |
3100 KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus); | 3121 KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus); |
3101 ic.UpdateState(receiver, key); | 3122 ic.UpdateState(receiver, key); |
3102 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, ic.Load(receiver, key)); | 3123 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, ic.Load(receiver, key)); |
3103 } | 3124 } |
3104 | 3125 |
3105 return *result; | 3126 return *result; |
3106 } | 3127 } |
3107 } // namespace internal | 3128 } // namespace internal |
3108 } // namespace v8 | 3129 } // namespace v8 |
OLD | NEW |