OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/compiler/operation-typer.h" | 5 #include "src/compiler/operation-typer.h" |
6 | 6 |
| 7 #include "src/compiler/common-operator.h" |
7 #include "src/factory.h" | 8 #include "src/factory.h" |
8 #include "src/isolate.h" | 9 #include "src/isolate.h" |
9 #include "src/type-cache.h" | 10 #include "src/type-cache.h" |
10 #include "src/types.h" | 11 #include "src/types.h" |
11 | 12 |
12 #include "src/objects-inl.h" | 13 #include "src/objects-inl.h" |
13 | 14 |
14 namespace v8 { | 15 namespace v8 { |
15 namespace internal { | 16 namespace internal { |
16 namespace compiler { | 17 namespace compiler { |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 if ((outcome & kComparisonFalse) != 0 || | 450 if ((outcome & kComparisonFalse) != 0 || |
450 (outcome & kComparisonUndefined) != 0) { | 451 (outcome & kComparisonUndefined) != 0) { |
451 return (outcome & kComparisonTrue) != 0 ? Type::Boolean() | 452 return (outcome & kComparisonTrue) != 0 ? Type::Boolean() |
452 : singleton_false(); | 453 : singleton_false(); |
453 } | 454 } |
454 // Type should be non empty, so we know it should be true. | 455 // Type should be non empty, so we know it should be true. |
455 DCHECK((outcome & kComparisonTrue) != 0); | 456 DCHECK((outcome & kComparisonTrue) != 0); |
456 return singleton_true(); | 457 return singleton_true(); |
457 } | 458 } |
458 | 459 |
| 460 Type* OperationTyper::TypeSigma(const Operator* sigma_op, Type* input) { |
| 461 return Type::Intersect(input, SigmaTypeOf(sigma_op), zone()); |
| 462 } |
| 463 |
459 Type* OperationTyper::TypeJSAdd(Type* lhs, Type* rhs) { | 464 Type* OperationTyper::TypeJSAdd(Type* lhs, Type* rhs) { |
460 lhs = ToPrimitive(lhs); | 465 lhs = ToPrimitive(lhs); |
461 rhs = ToPrimitive(rhs); | 466 rhs = ToPrimitive(rhs); |
462 | 467 |
463 if (!lhs->IsInhabited() || !rhs->IsInhabited()) { | 468 if (!lhs->IsInhabited() || !rhs->IsInhabited()) { |
464 return Type::None(); | 469 return Type::None(); |
465 } | 470 } |
466 | 471 |
467 if (lhs->Maybe(Type::String()) || rhs->Maybe(Type::String())) { | 472 if (lhs->Maybe(Type::String()) || rhs->Maybe(Type::String())) { |
468 if (lhs->Is(Type::String()) || rhs->Is(Type::String())) { | 473 if (lhs->Is(Type::String()) || rhs->Is(Type::String())) { |
469 return Type::String(); | 474 return Type::String(); |
470 } else { | 475 } else { |
471 return Type::NumberOrString(); | 476 return Type::NumberOrString(); |
472 } | 477 } |
473 } | 478 } |
474 lhs = ToNumber(lhs); | 479 lhs = ToNumber(lhs); |
475 rhs = ToNumber(rhs); | 480 rhs = ToNumber(rhs); |
476 return NumberAdd(lhs, rhs); | 481 return NumberAdd(lhs, rhs); |
477 } | 482 } |
478 | 483 |
479 Type* OperationTyper::TypeJSSubtract(Type* lhs, Type* rhs) { | 484 Type* OperationTyper::TypeJSSubtract(Type* lhs, Type* rhs) { |
480 return NumberSubtract(ToNumber(lhs), ToNumber(rhs)); | 485 return NumberSubtract(ToNumber(lhs), ToNumber(rhs)); |
481 } | 486 } |
482 | 487 |
483 } // namespace compiler | 488 } // namespace compiler |
484 } // namespace internal | 489 } // namespace internal |
485 } // namespace v8 | 490 } // namespace v8 |
OLD | NEW |