OLD | NEW |
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/ic/ic-state.h" | 5 #include "src/ic/ic-state.h" |
6 | 6 |
7 #include "src/ic/ic.h" | 7 #include "src/ic/ic.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 GENERATE(Token::MOD, SMI, 2, SMI); | 184 GENERATE(Token::MOD, SMI, 2, SMI); |
185 GENERATE(Token::MOD, SMI, 4, SMI); | 185 GENERATE(Token::MOD, SMI, 4, SMI); |
186 GENERATE(Token::MOD, SMI, 8, SMI); | 186 GENERATE(Token::MOD, SMI, 8, SMI); |
187 GENERATE(Token::MOD, SMI, 16, SMI); | 187 GENERATE(Token::MOD, SMI, 16, SMI); |
188 GENERATE(Token::MOD, SMI, 32, SMI); | 188 GENERATE(Token::MOD, SMI, 32, SMI); |
189 GENERATE(Token::MOD, SMI, 2048, SMI); | 189 GENERATE(Token::MOD, SMI, 2048, SMI); |
190 #undef GENERATE | 190 #undef GENERATE |
191 } | 191 } |
192 | 192 |
193 | 193 |
194 Type* BinaryOpICState::GetResultType(Zone* zone) const { | 194 Type* BinaryOpICState::GetResultType() const { |
195 Kind result_kind = result_kind_; | 195 Kind result_kind = result_kind_; |
196 if (HasSideEffects()) { | 196 if (HasSideEffects()) { |
197 result_kind = NONE; | 197 result_kind = NONE; |
198 } else if (result_kind == GENERIC && op_ == Token::ADD) { | 198 } else if (result_kind == GENERIC && op_ == Token::ADD) { |
199 return Type::Union(Type::Number(zone), Type::String(zone), zone); | 199 return Type::NumberOrString(); |
200 } else if (result_kind == NUMBER && op_ == Token::SHR) { | 200 } else if (result_kind == NUMBER && op_ == Token::SHR) { |
201 return Type::Unsigned32(zone); | 201 return Type::Unsigned32(); |
202 } | 202 } |
203 DCHECK_NE(GENERIC, result_kind); | 203 DCHECK_NE(GENERIC, result_kind); |
204 return KindToType(result_kind, zone); | 204 return KindToType(result_kind); |
205 } | 205 } |
206 | 206 |
207 | 207 |
208 std::ostream& operator<<(std::ostream& os, const BinaryOpICState& s) { | 208 std::ostream& operator<<(std::ostream& os, const BinaryOpICState& s) { |
209 os << "(" << Token::Name(s.op_); | 209 os << "(" << Token::Name(s.op_); |
210 if (s.CouldCreateAllocationMementos()) os << "_CreateAllocationMementos"; | 210 if (s.CouldCreateAllocationMementos()) os << "_CreateAllocationMementos"; |
211 if (is_strong(s.strength())) os << "_Strong"; | 211 if (is_strong(s.strength())) os << "_Strong"; |
212 os << ":" << BinaryOpICState::KindToString(s.left_kind_) << "*"; | 212 os << ":" << BinaryOpICState::KindToString(s.left_kind_) << "*"; |
213 if (s.fixed_right_arg_.IsJust()) { | 213 if (s.fixed_right_arg_.IsJust()) { |
214 os << s.fixed_right_arg_.FromJust(); | 214 os << s.fixed_right_arg_.FromJust(); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 return "String"; | 313 return "String"; |
314 case GENERIC: | 314 case GENERIC: |
315 return "Generic"; | 315 return "Generic"; |
316 } | 316 } |
317 UNREACHABLE(); | 317 UNREACHABLE(); |
318 return NULL; | 318 return NULL; |
319 } | 319 } |
320 | 320 |
321 | 321 |
322 // static | 322 // static |
323 Type* BinaryOpICState::KindToType(Kind kind, Zone* zone) { | 323 Type* BinaryOpICState::KindToType(Kind kind) { |
324 switch (kind) { | 324 switch (kind) { |
325 case NONE: | 325 case NONE: |
326 return Type::None(zone); | 326 return Type::None(); |
327 case SMI: | 327 case SMI: |
328 return Type::SignedSmall(zone); | 328 return Type::SignedSmall(); |
329 case INT32: | 329 case INT32: |
330 return Type::Signed32(zone); | 330 return Type::Signed32(); |
331 case NUMBER: | 331 case NUMBER: |
332 return Type::Number(zone); | 332 return Type::Number(); |
333 case STRING: | 333 case STRING: |
334 return Type::String(zone); | 334 return Type::String(); |
335 case GENERIC: | 335 case GENERIC: |
336 return Type::Any(zone); | 336 return Type::Any(); |
337 } | 337 } |
338 UNREACHABLE(); | 338 UNREACHABLE(); |
339 return NULL; | 339 return NULL; |
340 } | 340 } |
341 | 341 |
342 | 342 |
343 const char* CompareICState::GetStateName(State state) { | 343 const char* CompareICState::GetStateName(State state) { |
344 switch (state) { | 344 switch (state) { |
345 case UNINITIALIZED: | 345 case UNINITIALIZED: |
346 return "UNINITIALIZED"; | 346 return "UNINITIALIZED"; |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 case OBJECT: | 501 case OBJECT: |
502 case GENERIC: | 502 case GENERIC: |
503 return GENERIC; | 503 return GENERIC; |
504 } | 504 } |
505 UNREACHABLE(); | 505 UNREACHABLE(); |
506 return GENERIC; // Make the compiler happy. | 506 return GENERIC; // Make the compiler happy. |
507 } | 507 } |
508 | 508 |
509 } // namespace internal | 509 } // namespace internal |
510 } // namespace v8 | 510 } // namespace v8 |
OLD | NEW |