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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 } while (false) | 182 } while (false) |
183 GENERATE(Token::MOD, SMI, 2, SMI); | 183 GENERATE(Token::MOD, SMI, 2, SMI); |
184 GENERATE(Token::MOD, SMI, 4, SMI); | 184 GENERATE(Token::MOD, SMI, 4, SMI); |
185 GENERATE(Token::MOD, SMI, 8, SMI); | 185 GENERATE(Token::MOD, SMI, 8, SMI); |
186 GENERATE(Token::MOD, SMI, 16, SMI); | 186 GENERATE(Token::MOD, SMI, 16, SMI); |
187 GENERATE(Token::MOD, SMI, 32, SMI); | 187 GENERATE(Token::MOD, SMI, 32, SMI); |
188 GENERATE(Token::MOD, SMI, 2048, SMI); | 188 GENERATE(Token::MOD, SMI, 2048, SMI); |
189 #undef GENERATE | 189 #undef GENERATE |
190 } | 190 } |
191 | 191 |
192 | 192 AstType* BinaryOpICState::GetResultType() const { |
193 Type* BinaryOpICState::GetResultType() const { | |
194 Kind result_kind = result_kind_; | 193 Kind result_kind = result_kind_; |
195 if (HasSideEffects()) { | 194 if (HasSideEffects()) { |
196 result_kind = NONE; | 195 result_kind = NONE; |
197 } else if (result_kind == GENERIC && op_ == Token::ADD) { | 196 } else if (result_kind == GENERIC && op_ == Token::ADD) { |
198 return Type::NumberOrString(); | 197 return AstType::NumberOrString(); |
199 } else if (result_kind == NUMBER && op_ == Token::SHR) { | 198 } else if (result_kind == NUMBER && op_ == Token::SHR) { |
200 return Type::Unsigned32(); | 199 return AstType::Unsigned32(); |
201 } | 200 } |
202 DCHECK_NE(GENERIC, result_kind); | 201 DCHECK_NE(GENERIC, result_kind); |
203 return KindToType(result_kind); | 202 return KindToType(result_kind); |
204 } | 203 } |
205 | 204 |
206 | 205 |
207 std::ostream& operator<<(std::ostream& os, const BinaryOpICState& s) { | 206 std::ostream& operator<<(std::ostream& os, const BinaryOpICState& s) { |
208 os << "(" << Token::Name(s.op_); | 207 os << "(" << Token::Name(s.op_); |
209 if (s.CouldCreateAllocationMementos()) os << "_CreateAllocationMementos"; | 208 if (s.CouldCreateAllocationMementos()) os << "_CreateAllocationMementos"; |
210 os << ":" << BinaryOpICState::KindToString(s.left_kind_) << "*"; | 209 os << ":" << BinaryOpICState::KindToString(s.left_kind_) << "*"; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 return "String"; | 310 return "String"; |
312 case GENERIC: | 311 case GENERIC: |
313 return "Generic"; | 312 return "Generic"; |
314 } | 313 } |
315 UNREACHABLE(); | 314 UNREACHABLE(); |
316 return NULL; | 315 return NULL; |
317 } | 316 } |
318 | 317 |
319 | 318 |
320 // static | 319 // static |
321 Type* BinaryOpICState::KindToType(Kind kind) { | 320 AstType* BinaryOpICState::KindToType(Kind kind) { |
322 switch (kind) { | 321 switch (kind) { |
323 case NONE: | 322 case NONE: |
324 return Type::None(); | 323 return AstType::None(); |
325 case SMI: | 324 case SMI: |
326 return Type::SignedSmall(); | 325 return AstType::SignedSmall(); |
327 case INT32: | 326 case INT32: |
328 return Type::Signed32(); | 327 return AstType::Signed32(); |
329 case NUMBER: | 328 case NUMBER: |
330 return Type::Number(); | 329 return AstType::Number(); |
331 case STRING: | 330 case STRING: |
332 return Type::String(); | 331 return AstType::String(); |
333 case GENERIC: | 332 case GENERIC: |
334 return Type::Any(); | 333 return AstType::Any(); |
335 } | 334 } |
336 UNREACHABLE(); | 335 UNREACHABLE(); |
337 return NULL; | 336 return NULL; |
338 } | 337 } |
339 | 338 |
340 | 339 |
341 const char* CompareICState::GetStateName(State state) { | 340 const char* CompareICState::GetStateName(State state) { |
342 switch (state) { | 341 switch (state) { |
343 case UNINITIALIZED: | 342 case UNINITIALIZED: |
344 return "UNINITIALIZED"; | 343 return "UNINITIALIZED"; |
(...skipping 13 matching lines...) Expand all Loading... |
358 return "RECEIVER"; | 357 return "RECEIVER"; |
359 case KNOWN_RECEIVER: | 358 case KNOWN_RECEIVER: |
360 return "KNOWN_RECEIVER"; | 359 return "KNOWN_RECEIVER"; |
361 case GENERIC: | 360 case GENERIC: |
362 return "GENERIC"; | 361 return "GENERIC"; |
363 } | 362 } |
364 UNREACHABLE(); | 363 UNREACHABLE(); |
365 return NULL; | 364 return NULL; |
366 } | 365 } |
367 | 366 |
368 | 367 AstType* CompareICState::StateToType(Zone* zone, State state, Handle<Map> map) { |
369 Type* CompareICState::StateToType(Zone* zone, State state, Handle<Map> map) { | |
370 switch (state) { | 368 switch (state) { |
371 case UNINITIALIZED: | 369 case UNINITIALIZED: |
372 return Type::None(); | 370 return AstType::None(); |
373 case BOOLEAN: | 371 case BOOLEAN: |
374 return Type::Boolean(); | 372 return AstType::Boolean(); |
375 case SMI: | 373 case SMI: |
376 return Type::SignedSmall(); | 374 return AstType::SignedSmall(); |
377 case NUMBER: | 375 case NUMBER: |
378 return Type::Number(); | 376 return AstType::Number(); |
379 case STRING: | 377 case STRING: |
380 return Type::String(); | 378 return AstType::String(); |
381 case INTERNALIZED_STRING: | 379 case INTERNALIZED_STRING: |
382 return Type::InternalizedString(); | 380 return AstType::InternalizedString(); |
383 case UNIQUE_NAME: | 381 case UNIQUE_NAME: |
384 return Type::UniqueName(); | 382 return AstType::UniqueName(); |
385 case RECEIVER: | 383 case RECEIVER: |
386 return Type::Receiver(); | 384 return AstType::Receiver(); |
387 case KNOWN_RECEIVER: | 385 case KNOWN_RECEIVER: |
388 return map.is_null() ? Type::Receiver() : Type::Class(map, zone); | 386 return map.is_null() ? AstType::Receiver() : AstType::Class(map, zone); |
389 case GENERIC: | 387 case GENERIC: |
390 return Type::Any(); | 388 return AstType::Any(); |
391 } | 389 } |
392 UNREACHABLE(); | 390 UNREACHABLE(); |
393 return NULL; | 391 return NULL; |
394 } | 392 } |
395 | 393 |
396 | 394 |
397 CompareICState::State CompareICState::NewInputState(State old_state, | 395 CompareICState::State CompareICState::NewInputState(State old_state, |
398 Handle<Object> value) { | 396 Handle<Object> value) { |
399 switch (old_state) { | 397 switch (old_state) { |
400 case UNINITIALIZED: | 398 case UNINITIALIZED: |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 case RECEIVER: | 505 case RECEIVER: |
508 case GENERIC: | 506 case GENERIC: |
509 return GENERIC; | 507 return GENERIC; |
510 } | 508 } |
511 UNREACHABLE(); | 509 UNREACHABLE(); |
512 return GENERIC; // Make the compiler happy. | 510 return GENERIC; // Make the compiler happy. |
513 } | 511 } |
514 | 512 |
515 } // namespace internal | 513 } // namespace internal |
516 } // namespace v8 | 514 } // namespace v8 |
OLD | NEW |