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

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

Issue 1092353002: [strong] Disallow implicit conversions for binary arithmetic operations (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: cl feedback Created 5 years, 8 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/v8.h" 5 #include "src/v8.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 2550 matching lines...) Expand 10 before | Expand all | Expand 10 after
2561 } 2561 }
2562 2562
2563 2563
2564 MaybeHandle<Object> BinaryOpIC::Transition( 2564 MaybeHandle<Object> BinaryOpIC::Transition(
2565 Handle<AllocationSite> allocation_site, Handle<Object> left, 2565 Handle<AllocationSite> allocation_site, Handle<Object> left,
2566 Handle<Object> right) { 2566 Handle<Object> right) {
2567 BinaryOpICState state(isolate(), target()->extra_ic_state()); 2567 BinaryOpICState state(isolate(), target()->extra_ic_state());
2568 2568
2569 // Compute the actual result using the builtin for the binary operation. 2569 // Compute the actual result using the builtin for the binary operation.
2570 Object* builtin = isolate()->js_builtins_object()->javascript_builtin( 2570 Object* builtin = isolate()->js_builtins_object()->javascript_builtin(
2571 TokenToJSBuiltin(state.op())); 2571 TokenToJSBuiltin(state.op(), state.language_mode()));
2572 Handle<JSFunction> function = handle(JSFunction::cast(builtin), isolate()); 2572 Handle<JSFunction> function = handle(JSFunction::cast(builtin), isolate());
2573 Handle<Object> result; 2573 Handle<Object> result;
2574 ASSIGN_RETURN_ON_EXCEPTION( 2574 ASSIGN_RETURN_ON_EXCEPTION(
2575 isolate(), result, Execution::Call(isolate(), function, left, 1, &right), 2575 isolate(), result, Execution::Call(isolate(), function, left, 1, &right),
2576 Object); 2576 Object);
2577 2577
2578 // Do not try to update the target if the code was marked for lazy 2578 // Do not try to update the target if the code was marked for lazy
2579 // deoptimization. (Since we do not relocate addresses in these 2579 // deoptimization. (Since we do not relocate addresses in these
2580 // code objects, an attempt to access the target could fail.) 2580 // code objects, an attempt to access the target could fail.)
2581 if (AddressIsDeoptimizedCode()) { 2581 if (AddressIsDeoptimizedCode()) {
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
2798 } 2798 }
2799 2799
2800 2800
2801 RUNTIME_FUNCTION(Unreachable) { 2801 RUNTIME_FUNCTION(Unreachable) {
2802 UNREACHABLE(); 2802 UNREACHABLE();
2803 CHECK(false); 2803 CHECK(false);
2804 return isolate->heap()->undefined_value(); 2804 return isolate->heap()->undefined_value();
2805 } 2805 }
2806 2806
2807 2807
2808 Builtins::JavaScript BinaryOpIC::TokenToJSBuiltin(Token::Value op) { 2808 Builtins::JavaScript BinaryOpIC::TokenToJSBuiltin(Token::Value op,
2809 switch (op) { 2809 LanguageMode language_mode) {
2810 default: 2810 if (is_strong(language_mode)) {
2811 UNREACHABLE(); 2811 switch (op) {
2812 case Token::ADD: 2812 default:
2813 return Builtins::ADD; 2813 UNREACHABLE();
2814 break; 2814 case Token::ADD:
2815 case Token::SUB: 2815 return Builtins::ADD;
2816 return Builtins::SUB; 2816 case Token::SUB:
2817 break; 2817 return Builtins::SUB_STRONG;
2818 case Token::MUL: 2818 case Token::MUL:
2819 return Builtins::MUL; 2819 return Builtins::MUL_STRONG;
2820 break; 2820 case Token::DIV:
2821 case Token::DIV: 2821 return Builtins::DIV_STRONG;
2822 return Builtins::DIV; 2822 case Token::MOD:
2823 break; 2823 return Builtins::MOD_STRONG;
2824 case Token::MOD: 2824 case Token::BIT_OR:
2825 return Builtins::MOD; 2825 return Builtins::BIT_OR;
2826 break; 2826 case Token::BIT_AND:
2827 case Token::BIT_OR: 2827 return Builtins::BIT_AND;
2828 return Builtins::BIT_OR; 2828 case Token::BIT_XOR:
2829 break; 2829 return Builtins::BIT_XOR;
2830 case Token::BIT_AND: 2830 case Token::SAR:
2831 return Builtins::BIT_AND; 2831 return Builtins::SAR;
2832 break; 2832 case Token::SHR:
2833 case Token::BIT_XOR: 2833 return Builtins::SHR;
2834 return Builtins::BIT_XOR; 2834 case Token::SHL:
2835 break; 2835 return Builtins::SHL;
2836 case Token::SAR: 2836 }
2837 return Builtins::SAR; 2837 } else {
2838 break; 2838 switch (op) {
2839 case Token::SHR: 2839 default:
2840 return Builtins::SHR; 2840 UNREACHABLE();
2841 break; 2841 case Token::ADD:
2842 case Token::SHL: 2842 return Builtins::ADD;
2843 return Builtins::SHL; 2843 case Token::SUB:
2844 break; 2844 return Builtins::SUB;
2845 case Token::MUL:
2846 return Builtins::MUL;
2847 case Token::DIV:
2848 return Builtins::DIV;
2849 case Token::MOD:
2850 return Builtins::MOD;
2851 case Token::BIT_OR:
2852 return Builtins::BIT_OR;
2853 case Token::BIT_AND:
2854 return Builtins::BIT_AND;
2855 case Token::BIT_XOR:
2856 return Builtins::BIT_XOR;
2857 case Token::SAR:
2858 return Builtins::SAR;
2859 case Token::SHR:
2860 return Builtins::SHR;
2861 case Token::SHL:
2862 return Builtins::SHL;
2863 }
2845 } 2864 }
2846 } 2865 }
2847 2866
2848 2867
2849 Handle<Object> ToBooleanIC::ToBoolean(Handle<Object> object) { 2868 Handle<Object> ToBooleanIC::ToBoolean(Handle<Object> object) {
2850 ToBooleanStub stub(isolate(), target()->extra_ic_state()); 2869 ToBooleanStub stub(isolate(), target()->extra_ic_state());
2851 bool to_boolean_value = stub.UpdateStatus(object); 2870 bool to_boolean_value = stub.UpdateStatus(object);
2852 Handle<Code> code = stub.GetCode(); 2871 Handle<Code> code = stub.GetCode();
2853 set_target(*code); 2872 set_target(*code);
2854 return handle(Smi::FromInt(to_boolean_value ? 1 : 0), isolate()); 2873 return handle(Smi::FromInt(to_boolean_value ? 1 : 0), isolate());
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
3045 static const Address IC_utilities[] = { 3064 static const Address IC_utilities[] = {
3046 #define ADDR(name) FUNCTION_ADDR(name), 3065 #define ADDR(name) FUNCTION_ADDR(name),
3047 IC_UTIL_LIST(ADDR) NULL 3066 IC_UTIL_LIST(ADDR) NULL
3048 #undef ADDR 3067 #undef ADDR
3049 }; 3068 };
3050 3069
3051 3070
3052 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; } 3071 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; }
3053 } 3072 }
3054 } // namespace v8::internal 3073 } // namespace v8::internal
OLDNEW
« src/compiler/js-operator.h ('K') | « src/ic/ic.h ('k') | src/ic/ic-state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698