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

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: rebase :( 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 LanguageMode language_mode) {
2809 switch (op) { 2810 switch (op) {
2810 default: 2811 default:
2811 UNREACHABLE(); 2812 UNREACHABLE();
2812 case Token::ADD: 2813 case Token::ADD:
2813 return Builtins::ADD; 2814 return Builtins::ADD;
2814 break; 2815 break;
2815 case Token::SUB: 2816 case Token::SUB:
2816 return Builtins::SUB; 2817 return is_strong(language_mode) ? Builtins::SUB_STRONG : Builtins::SUB;
rossberg 2015/04/23 13:29:37 Nit: considering that you'll have to add the same
conradw 2015/04/23 14:51:54 Done.
2817 break; 2818 break;
2818 case Token::MUL: 2819 case Token::MUL:
2819 return Builtins::MUL; 2820 return is_strong(language_mode) ? Builtins::MUL_STRONG : Builtins::MUL;
2820 break; 2821 break;
2821 case Token::DIV: 2822 case Token::DIV:
2822 return Builtins::DIV; 2823 return is_strong(language_mode) ? Builtins::DIV_STRONG : Builtins::DIV;
2823 break; 2824 break;
2824 case Token::MOD: 2825 case Token::MOD:
2825 return Builtins::MOD; 2826 return is_strong(language_mode) ? Builtins::MOD_STRONG : Builtins::MOD;
2826 break; 2827 break;
2827 case Token::BIT_OR: 2828 case Token::BIT_OR:
2828 return Builtins::BIT_OR; 2829 return Builtins::BIT_OR;
2829 break; 2830 break;
2830 case Token::BIT_AND: 2831 case Token::BIT_AND:
2831 return Builtins::BIT_AND; 2832 return Builtins::BIT_AND;
2832 break; 2833 break;
2833 case Token::BIT_XOR: 2834 case Token::BIT_XOR:
2834 return Builtins::BIT_XOR; 2835 return Builtins::BIT_XOR;
2835 break; 2836 break;
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
3045 static const Address IC_utilities[] = { 3046 static const Address IC_utilities[] = {
3046 #define ADDR(name) FUNCTION_ADDR(name), 3047 #define ADDR(name) FUNCTION_ADDR(name),
3047 IC_UTIL_LIST(ADDR) NULL 3048 IC_UTIL_LIST(ADDR) NULL
3048 #undef ADDR 3049 #undef ADDR
3049 }; 3050 };
3050 3051
3051 3052
3052 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; } 3053 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; }
3053 } 3054 }
3054 } // namespace v8::internal 3055 } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698