Chromium Code Reviews| Index: runtime/vm/intermediate_language.cc |
| =================================================================== |
| --- runtime/vm/intermediate_language.cc (revision 28802) |
| +++ runtime/vm/intermediate_language.cc (working copy) |
| @@ -1629,7 +1629,35 @@ |
| } |
| +static bool MayBeBoxableNumber(intptr_t cid) { |
| + return (cid == kDynamicCid) || |
| + (cid == kMintCid) || |
| + (cid == kBigintCid) || |
| + (cid == kDoubleCid); |
| +} |
| + |
| + |
| +static bool MaybeNumber(CompileType* type) { |
| + ASSERT(Type::Handle(Type::Number()).IsMoreSpecificThan( |
| + Type::Handle(Type::Number()), NULL)); |
| + return type->ToAbstractType()->IsDynamicType() |
| + || type->IsMoreSpecificThan(Type::Handle(Type::Number())); |
| +} |
| + |
| + |
| Definition* StrictCompareInstr::Canonicalize(FlowGraph* flow_graph) { |
| + // Use propagated cid and type information to eliminate number checks. |
| + // If one of the inputs is not a boxable number (Mint, Double, Bigint), or |
| + // is not a subtype of num, no need for number checks. |
| + if (needs_number_check()) { |
| + if (!MayBeBoxableNumber(left()->Type()->ToCid()) || |
| + !MayBeBoxableNumber(right()->Type()->ToCid())) { |
| + set_needs_number_check(false); |
| + } else if (!MaybeNumber(left()->Type()) || !MaybeNumber(right()->Type())) { |
|
srdjan
2013/10/17 17:06:45
Wouldn't it be enough to just check for MayBeNumbe
Florian Schneider
2013/10/18 10:55:27
It would work, but the check on the AbstractType d
|
| + set_needs_number_check(false); |
| + } |
| + } |
| + |
| bool negated = false; |
| Definition* replacement = CanonicalizeStrictCompare(this, &negated); |
| if (negated && replacement->IsComparison()) { |