| 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/compiler/typer.h" | 5 #include "src/compiler/typer.h" |
| 6 | 6 |
| 7 #include <iomanip> | 7 #include <iomanip> |
| 8 | 8 |
| 9 #include "src/base/flags.h" | 9 #include "src/base/flags.h" |
| 10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
| (...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 DCHECK_EQ(IrOpcode::kLoop, NodeProperties::GetControlInput(node)->opcode()); | 628 DCHECK_EQ(IrOpcode::kLoop, NodeProperties::GetControlInput(node)->opcode()); |
| 629 DCHECK_EQ(2, NodeProperties::GetControlInput(node)->InputCount()); | 629 DCHECK_EQ(2, NodeProperties::GetControlInput(node)->InputCount()); |
| 630 | 630 |
| 631 Type* initial_type = Operand(node, 0); | 631 Type* initial_type = Operand(node, 0); |
| 632 Type* increment_type = Operand(node, 2); | 632 Type* increment_type = Operand(node, 2); |
| 633 | 633 |
| 634 // We only handle integer induction variables (otherwise ranges | 634 // We only handle integer induction variables (otherwise ranges |
| 635 // do not apply and we cannot do anything). | 635 // do not apply and we cannot do anything). |
| 636 if (!initial_type->Is(typer_->cache_.kInteger) || | 636 if (!initial_type->Is(typer_->cache_.kInteger) || |
| 637 !increment_type->Is(typer_->cache_.kInteger)) { | 637 !increment_type->Is(typer_->cache_.kInteger)) { |
| 638 // Fallback to normal phi typing. | 638 // Fallback to normal phi typing, but ensure monotonicity. |
| 639 Type* type = Operand(node, 0); | 639 // (Unfortunately, without baking in the previous type, monotonicity might |
| 640 for (int i = 1; i < arity; ++i) { | 640 // be violated because we might not yet have retyped the incrementing |
| 641 // operation even though the increment's type might been already reflected |
| 642 // in the induction variable phi.) |
| 643 Type* type = NodeProperties::IsTyped(node) ? NodeProperties::GetType(node) |
| 644 : Type::None(); |
| 645 for (int i = 0; i < arity; ++i) { |
| 641 type = Type::Union(type, Operand(node, i), zone()); | 646 type = Type::Union(type, Operand(node, i), zone()); |
| 642 } | 647 } |
| 643 return type; | 648 return type; |
| 644 } | 649 } |
| 645 // If we do not have enough type information for the initial value or | 650 // If we do not have enough type information for the initial value or |
| 646 // the increment, just return the initial value's type. | 651 // the increment, just return the initial value's type. |
| 647 if (!initial_type->IsInhabited() || !increment_type->IsInhabited()) { | 652 if (!initial_type->IsInhabited() || !increment_type->IsInhabited()) { |
| 648 return initial_type; | 653 return initial_type; |
| 649 } | 654 } |
| 650 | 655 |
| (...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1703 Type* Typer::Visitor::TypeConstant(Handle<Object> value) { | 1708 Type* Typer::Visitor::TypeConstant(Handle<Object> value) { |
| 1704 if (Type::IsInteger(*value)) { | 1709 if (Type::IsInteger(*value)) { |
| 1705 return Type::Range(value->Number(), value->Number(), zone()); | 1710 return Type::Range(value->Number(), value->Number(), zone()); |
| 1706 } | 1711 } |
| 1707 return Type::Constant(value, zone()); | 1712 return Type::Constant(value, zone()); |
| 1708 } | 1713 } |
| 1709 | 1714 |
| 1710 } // namespace compiler | 1715 } // namespace compiler |
| 1711 } // namespace internal | 1716 } // namespace internal |
| 1712 } // namespace v8 | 1717 } // namespace v8 |
| OLD | NEW |