Chromium Code Reviews| Index: src/compiler/typer.cc |
| diff --git a/src/compiler/typer.cc b/src/compiler/typer.cc |
| index 594e4bd61369e5b0caa6830127ab211a698722ed..cbf23f7ff98d85acb227613826c12f7726488351 100644 |
| --- a/src/compiler/typer.cc |
| +++ b/src/compiler/typer.cc |
| @@ -197,6 +197,7 @@ class Typer::Visitor : public Reducer { |
| Bounds WrapContextBoundsForInput(Node* node); |
| Type* Weaken(Node* node, Type* current_type, Type* previous_type); |
| + Type* WeakenConstants(Type* type); |
| Zone* zone() { return typer_->zone(); } |
| Isolate* isolate() { return typer_->isolate(); } |
| @@ -555,11 +556,26 @@ Bounds Typer::Visitor::TypeSelect(Node* node) { |
| } |
| +Type* Typer::Visitor::WeakenConstants(Type* type) { |
| + Type* const integer = typer_->cache_.kInteger; |
| + if (!type->Maybe(integer)) return type; |
| + Type* myinteger = Type::Intersect(type, integer, zone()); |
|
Jarin
2015/09/14 08:06:29
Could you come up with a better name than myintege
|
| + if (myinteger->NumConstants() <= 1) return type; |
| + return Type::Union( |
| + type, Type::Range(myinteger->Min(), myinteger->Max(), typer_->zone()), |
| + typer_->zone()); |
| +} |
| + |
| + |
| Bounds Typer::Visitor::TypePhi(Node* node) { |
| int arity = node->op()->ValueInputCount(); |
| Bounds bounds = Operand(node, 0); |
| for (int i = 1; i < arity; ++i) { |
| bounds = Bounds::Either(bounds, Operand(node, i), zone()); |
| + // In order to avoid huge unions, we weaken multiple integer constants |
| + // to a single range. |
| + bounds.upper = WeakenConstants(bounds.upper); |
| + bounds.lower = WeakenConstants(bounds.lower); |
| } |
| return bounds; |
| } |