Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: src/ic/ic.cc

Issue 1333843002: [runtime] Move binary operator fallbacks into the runtime. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: No need for frame states in bytecode handlers. Add test case. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 2627 matching lines...) Expand 10 before | Expand all | Expand 10 after
2638 return *result; 2638 return *result;
2639 } 2639 }
2640 2640
2641 2641
2642 MaybeHandle<Object> BinaryOpIC::Transition( 2642 MaybeHandle<Object> BinaryOpIC::Transition(
2643 Handle<AllocationSite> allocation_site, Handle<Object> left, 2643 Handle<AllocationSite> allocation_site, Handle<Object> left,
2644 Handle<Object> right) { 2644 Handle<Object> right) {
2645 BinaryOpICState state(isolate(), target()->extra_ic_state()); 2645 BinaryOpICState state(isolate(), target()->extra_ic_state());
2646 2646
2647 // Compute the actual result using the builtin for the binary operation. 2647 // Compute the actual result using the builtin for the binary operation.
2648 Object* builtin = isolate()->native_context()->get(
2649 TokenToContextIndex(state.op(), state.strength()));
2650 Handle<JSFunction> function = handle(JSFunction::cast(builtin), isolate());
2651 Handle<Object> result; 2648 Handle<Object> result;
2652 ASSIGN_RETURN_ON_EXCEPTION( 2649 switch (state.op()) {
2653 isolate(), result, Execution::Call(isolate(), function, left, 1, &right), 2650 default:
2654 Object); 2651 UNREACHABLE();
2652 case Token::ADD:
2653 ASSIGN_RETURN_ON_EXCEPTION(
2654 isolate(), result,
2655 Object::Add(isolate(), left, right, state.strength()), Object);
2656 break;
2657 case Token::SUB:
2658 ASSIGN_RETURN_ON_EXCEPTION(
2659 isolate(), result,
2660 Object::Subtract(isolate(), left, right, state.strength()), Object);
2661 break;
2662 case Token::MUL:
2663 ASSIGN_RETURN_ON_EXCEPTION(
2664 isolate(), result,
2665 Object::Multiply(isolate(), left, right, state.strength()), Object);
2666 break;
2667 case Token::DIV:
2668 ASSIGN_RETURN_ON_EXCEPTION(
2669 isolate(), result,
2670 Object::Divide(isolate(), left, right, state.strength()), Object);
2671 break;
2672 case Token::MOD:
2673 ASSIGN_RETURN_ON_EXCEPTION(
2674 isolate(), result,
2675 Object::Modulus(isolate(), left, right, state.strength()), Object);
2676 break;
2677 case Token::BIT_OR:
2678 ASSIGN_RETURN_ON_EXCEPTION(
2679 isolate(), result,
2680 Object::BitwiseOr(isolate(), left, right, state.strength()), Object);
2681 break;
2682 case Token::BIT_AND:
2683 ASSIGN_RETURN_ON_EXCEPTION(
2684 isolate(), result,
2685 Object::BitwiseAnd(isolate(), left, right, state.strength()), Object);
2686 break;
2687 case Token::BIT_XOR:
2688 ASSIGN_RETURN_ON_EXCEPTION(
2689 isolate(), result,
2690 Object::BitwiseXor(isolate(), left, right, state.strength()), Object);
2691 break;
2692 case Token::SAR:
2693 ASSIGN_RETURN_ON_EXCEPTION(
2694 isolate(), result,
2695 Object::ShiftRight(isolate(), left, right, state.strength()), Object);
2696 break;
2697 case Token::SHR:
2698 ASSIGN_RETURN_ON_EXCEPTION(
2699 isolate(), result,
2700 Object::ShiftRightLogical(isolate(), left, right, state.strength()),
2701 Object);
2702 break;
2703 case Token::SHL:
2704 ASSIGN_RETURN_ON_EXCEPTION(
2705 isolate(), result,
2706 Object::ShiftLeft(isolate(), left, right, state.strength()), Object);
2707 break;
2708 }
2655 2709
2656 // Do not try to update the target if the code was marked for lazy 2710 // Do not try to update the target if the code was marked for lazy
2657 // deoptimization. (Since we do not relocate addresses in these 2711 // deoptimization. (Since we do not relocate addresses in these
2658 // code objects, an attempt to access the target could fail.) 2712 // code objects, an attempt to access the target could fail.)
2659 if (AddressIsDeoptimizedCode()) { 2713 if (AddressIsDeoptimizedCode()) {
2660 return result; 2714 return result;
2661 } 2715 }
2662 2716
2663 // Execution::Call can execute arbitrary JavaScript, hence potentially 2717 // Execution::Call can execute arbitrary JavaScript, hence potentially
2664 // update the state of this very IC, so we must update the stored state. 2718 // update the state of this very IC, so we must update the stored state.
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
2878 } 2932 }
2879 2933
2880 2934
2881 RUNTIME_FUNCTION(Runtime_Unreachable) { 2935 RUNTIME_FUNCTION(Runtime_Unreachable) {
2882 UNREACHABLE(); 2936 UNREACHABLE();
2883 CHECK(false); 2937 CHECK(false);
2884 return isolate->heap()->undefined_value(); 2938 return isolate->heap()->undefined_value();
2885 } 2939 }
2886 2940
2887 2941
2888 int BinaryOpIC::TokenToContextIndex(Token::Value op, Strength strength) {
2889 if (is_strong(strength)) {
2890 switch (op) {
2891 default: UNREACHABLE();
2892 case Token::ADD:
2893 return Context::ADD_STRONG_BUILTIN_INDEX;
2894 case Token::SUB:
2895 return Context::SUB_STRONG_BUILTIN_INDEX;
2896 case Token::MUL:
2897 return Context::MUL_STRONG_BUILTIN_INDEX;
2898 case Token::DIV:
2899 return Context::DIV_STRONG_BUILTIN_INDEX;
2900 case Token::MOD:
2901 return Context::MOD_STRONG_BUILTIN_INDEX;
2902 case Token::BIT_OR:
2903 return Context::BIT_OR_STRONG_BUILTIN_INDEX;
2904 case Token::BIT_AND:
2905 return Context::BIT_AND_STRONG_BUILTIN_INDEX;
2906 case Token::BIT_XOR:
2907 return Context::BIT_XOR_STRONG_BUILTIN_INDEX;
2908 case Token::SAR:
2909 return Context::SAR_STRONG_BUILTIN_INDEX;
2910 case Token::SHR:
2911 return Context::SHR_STRONG_BUILTIN_INDEX;
2912 case Token::SHL:
2913 return Context::SHL_STRONG_BUILTIN_INDEX;
2914 }
2915 } else {
2916 switch (op) {
2917 default: UNREACHABLE();
2918 case Token::ADD:
2919 return Context::ADD_BUILTIN_INDEX;
2920 case Token::SUB:
2921 return Context::SUB_BUILTIN_INDEX;
2922 case Token::MUL:
2923 return Context::MUL_BUILTIN_INDEX;
2924 case Token::DIV:
2925 return Context::DIV_BUILTIN_INDEX;
2926 case Token::MOD:
2927 return Context::MOD_BUILTIN_INDEX;
2928 case Token::BIT_OR:
2929 return Context::BIT_OR_BUILTIN_INDEX;
2930 case Token::BIT_AND:
2931 return Context::BIT_AND_BUILTIN_INDEX;
2932 case Token::BIT_XOR:
2933 return Context::BIT_XOR_BUILTIN_INDEX;
2934 case Token::SAR:
2935 return Context::SAR_BUILTIN_INDEX;
2936 case Token::SHR:
2937 return Context::SHR_BUILTIN_INDEX;
2938 case Token::SHL:
2939 return Context::SHL_BUILTIN_INDEX;
2940 }
2941 }
2942 }
2943
2944
2945 Handle<Object> ToBooleanIC::ToBoolean(Handle<Object> object) { 2942 Handle<Object> ToBooleanIC::ToBoolean(Handle<Object> object) {
2946 ToBooleanStub stub(isolate(), target()->extra_ic_state()); 2943 ToBooleanStub stub(isolate(), target()->extra_ic_state());
2947 bool to_boolean_value = stub.UpdateStatus(object); 2944 bool to_boolean_value = stub.UpdateStatus(object);
2948 Handle<Code> code = stub.GetCode(); 2945 Handle<Code> code = stub.GetCode();
2949 set_target(*code); 2946 set_target(*code);
2950 return handle(Smi::FromInt(to_boolean_value ? 1 : 0), isolate()); 2947 return handle(Smi::FromInt(to_boolean_value ? 1 : 0), isolate());
2951 } 2948 }
2952 2949
2953 2950
2954 RUNTIME_FUNCTION(Runtime_ToBooleanIC_Miss) { 2951 RUNTIME_FUNCTION(Runtime_ToBooleanIC_Miss) {
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
3123 KeyedLoadICNexus nexus(vector, vector_slot); 3120 KeyedLoadICNexus nexus(vector, vector_slot);
3124 KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus); 3121 KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus);
3125 ic.UpdateState(receiver, key); 3122 ic.UpdateState(receiver, key);
3126 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, ic.Load(receiver, key)); 3123 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, ic.Load(receiver, key));
3127 } 3124 }
3128 3125
3129 return *result; 3126 return *result;
3130 } 3127 }
3131 } // namespace internal 3128 } // namespace internal
3132 } // namespace v8 3129 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698