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

Side by Side Diff: src/ic/ic-state.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 5 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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/ic/ic.h" 7 #include "src/ic/ic.h"
8 #include "src/ic/ic-state.h" 8 #include "src/ic/ic-state.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 46
47 BinaryOpICState::BinaryOpICState(Isolate* isolate, ExtraICState extra_ic_state) 47 BinaryOpICState::BinaryOpICState(Isolate* isolate, ExtraICState extra_ic_state)
48 : fixed_right_arg_( 48 : fixed_right_arg_(
49 HasFixedRightArgField::decode(extra_ic_state) 49 HasFixedRightArgField::decode(extra_ic_state)
50 ? Just(1 << FixedRightArgValueField::decode(extra_ic_state)) 50 ? Just(1 << FixedRightArgValueField::decode(extra_ic_state))
51 : Nothing<int>()), 51 : Nothing<int>()),
52 isolate_(isolate) { 52 isolate_(isolate) {
53 op_ = 53 op_ =
54 static_cast<Token::Value>(FIRST_TOKEN + OpField::decode(extra_ic_state)); 54 static_cast<Token::Value>(FIRST_TOKEN + OpField::decode(extra_ic_state));
55 strong_ = StrongField::decode(extra_ic_state);
55 left_kind_ = LeftKindField::decode(extra_ic_state); 56 left_kind_ = LeftKindField::decode(extra_ic_state);
56 right_kind_ = fixed_right_arg_.IsJust() 57 right_kind_ = fixed_right_arg_.IsJust()
57 ? (Smi::IsValid(fixed_right_arg_.FromJust()) ? SMI : INT32) 58 ? (Smi::IsValid(fixed_right_arg_.FromJust()) ? SMI : INT32)
58 : RightKindField::decode(extra_ic_state); 59 : RightKindField::decode(extra_ic_state);
59 result_kind_ = ResultKindField::decode(extra_ic_state); 60 result_kind_ = ResultKindField::decode(extra_ic_state);
60 DCHECK_LE(FIRST_TOKEN, op_); 61 DCHECK_LE(FIRST_TOKEN, op_);
61 DCHECK_LE(op_, LAST_TOKEN); 62 DCHECK_LE(op_, LAST_TOKEN);
62 } 63 }
63 64
64 65
65 ExtraICState BinaryOpICState::GetExtraICState() const { 66 ExtraICState BinaryOpICState::GetExtraICState() const {
66 ExtraICState extra_ic_state = 67 ExtraICState extra_ic_state =
67 OpField::encode(op_ - FIRST_TOKEN) | LeftKindField::encode(left_kind_) | 68 OpField::encode(op_ - FIRST_TOKEN) | LeftKindField::encode(left_kind_) |
68 ResultKindField::encode(result_kind_) | 69 ResultKindField::encode(result_kind_) |
70 StrongField::encode(strong_) |
69 HasFixedRightArgField::encode(fixed_right_arg_.IsJust()); 71 HasFixedRightArgField::encode(fixed_right_arg_.IsJust());
70 if (fixed_right_arg_.IsJust()) { 72 if (fixed_right_arg_.IsJust()) {
71 extra_ic_state = FixedRightArgValueField::update( 73 extra_ic_state = FixedRightArgValueField::update(
72 extra_ic_state, WhichPowerOf2(fixed_right_arg_.FromJust())); 74 extra_ic_state, WhichPowerOf2(fixed_right_arg_.FromJust()));
73 } else { 75 } else {
74 extra_ic_state = RightKindField::update(extra_ic_state, right_kind_); 76 extra_ic_state = RightKindField::update(extra_ic_state, right_kind_);
75 } 77 }
76 return extra_ic_state; 78 return extra_ic_state;
77 } 79 }
78 80
79 81
80 // static 82 // static
81 void BinaryOpICState::GenerateAheadOfTime( 83 void BinaryOpICState::GenerateAheadOfTime(
82 Isolate* isolate, void (*Generate)(Isolate*, const BinaryOpICState&)) { 84 Isolate* isolate, void (*Generate)(Isolate*, const BinaryOpICState&)) {
83 // TODO(olivf) We should investigate why adding stubs to the snapshot is so 85 // TODO(olivf) We should investigate why adding stubs to the snapshot is so
84 // expensive at runtime. When solved we should be able to add most binops to 86 // expensive at runtime. When solved we should be able to add most binops to
85 // the snapshot instead of hand-picking them. 87 // the snapshot instead of hand-picking them.
86 // Generated list of commonly used stubs 88 // Generated list of commonly used stubs
87 #define GENERATE(op, left_kind, right_kind, result_kind) \ 89 #define GENERATE(op, left_kind, right_kind, result_kind) \
88 do { \ 90 do { \
89 BinaryOpICState state(isolate, op); \ 91 BinaryOpICState state(isolate, op, LanguageMode::SLOPPY); \
90 state.left_kind_ = left_kind; \ 92 state.left_kind_ = left_kind; \
91 state.fixed_right_arg_ = Nothing<int>(); \ 93 state.fixed_right_arg_ = Nothing<int>(); \
92 state.right_kind_ = right_kind; \ 94 state.right_kind_ = right_kind; \
93 state.result_kind_ = result_kind; \ 95 state.result_kind_ = result_kind; \
94 Generate(isolate, state); \ 96 Generate(isolate, state); \
95 } while (false) 97 } while (false)
96 GENERATE(Token::ADD, INT32, INT32, INT32); 98 GENERATE(Token::ADD, INT32, INT32, INT32);
97 GENERATE(Token::ADD, INT32, INT32, NUMBER); 99 GENERATE(Token::ADD, INT32, INT32, NUMBER);
98 GENERATE(Token::ADD, INT32, NUMBER, NUMBER); 100 GENERATE(Token::ADD, INT32, NUMBER, NUMBER);
99 GENERATE(Token::ADD, INT32, SMI, INT32); 101 GENERATE(Token::ADD, INT32, SMI, INT32);
100 GENERATE(Token::ADD, NUMBER, INT32, NUMBER); 102 GENERATE(Token::ADD, NUMBER, INT32, NUMBER);
101 GENERATE(Token::ADD, NUMBER, NUMBER, NUMBER); 103 GENERATE(Token::ADD, NUMBER, NUMBER, NUMBER);
102 GENERATE(Token::ADD, NUMBER, SMI, NUMBER); 104 GENERATE(Token::ADD, NUMBER, SMI, NUMBER);
103 GENERATE(Token::ADD, SMI, INT32, INT32); 105 GENERATE(Token::ADD, SMI, INT32, INT32);
104 GENERATE(Token::ADD, SMI, INT32, NUMBER); 106 GENERATE(Token::ADD, SMI, INT32, NUMBER);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 GENERATE(Token::SUB, INT32, SMI, INT32); 183 GENERATE(Token::SUB, INT32, SMI, INT32);
182 GENERATE(Token::SUB, NUMBER, INT32, NUMBER); 184 GENERATE(Token::SUB, NUMBER, INT32, NUMBER);
183 GENERATE(Token::SUB, NUMBER, NUMBER, NUMBER); 185 GENERATE(Token::SUB, NUMBER, NUMBER, NUMBER);
184 GENERATE(Token::SUB, NUMBER, SMI, NUMBER); 186 GENERATE(Token::SUB, NUMBER, SMI, NUMBER);
185 GENERATE(Token::SUB, SMI, INT32, INT32); 187 GENERATE(Token::SUB, SMI, INT32, INT32);
186 GENERATE(Token::SUB, SMI, NUMBER, NUMBER); 188 GENERATE(Token::SUB, SMI, NUMBER, NUMBER);
187 GENERATE(Token::SUB, SMI, SMI, SMI); 189 GENERATE(Token::SUB, SMI, SMI, SMI);
188 #undef GENERATE 190 #undef GENERATE
189 #define GENERATE(op, left_kind, fixed_right_arg_value, result_kind) \ 191 #define GENERATE(op, left_kind, fixed_right_arg_value, result_kind) \
190 do { \ 192 do { \
191 BinaryOpICState state(isolate, op); \ 193 BinaryOpICState state(isolate, op, LanguageMode::SLOPPY); \
192 state.left_kind_ = left_kind; \ 194 state.left_kind_ = left_kind; \
193 state.fixed_right_arg_ = Just(fixed_right_arg_value); \ 195 state.fixed_right_arg_ = Just(fixed_right_arg_value); \
194 state.right_kind_ = SMI; \ 196 state.right_kind_ = SMI; \
195 state.result_kind_ = result_kind; \ 197 state.result_kind_ = result_kind; \
196 Generate(isolate, state); \ 198 Generate(isolate, state); \
197 } while (false) 199 } while (false)
198 GENERATE(Token::MOD, SMI, 2, SMI); 200 GENERATE(Token::MOD, SMI, 2, SMI);
199 GENERATE(Token::MOD, SMI, 4, SMI); 201 GENERATE(Token::MOD, SMI, 4, SMI);
200 GENERATE(Token::MOD, SMI, 8, SMI); 202 GENERATE(Token::MOD, SMI, 8, SMI);
201 GENERATE(Token::MOD, SMI, 16, SMI); 203 GENERATE(Token::MOD, SMI, 16, SMI);
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 case UNIQUE_NAME: 506 case UNIQUE_NAME:
505 case OBJECT: 507 case OBJECT:
506 case GENERIC: 508 case GENERIC:
507 return GENERIC; 509 return GENERIC;
508 } 510 }
509 UNREACHABLE(); 511 UNREACHABLE();
510 return GENERIC; // Make the compiler happy. 512 return GENERIC; // Make the compiler happy.
511 } 513 }
512 } 514 }
513 } // namespace v8::internal 515 } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698