Chromium Code Reviews| Index: runtime/vm/intermediate_language.cc |
| =================================================================== |
| --- runtime/vm/intermediate_language.cc (revision 10581) |
| +++ runtime/vm/intermediate_language.cc (working copy) |
| @@ -649,17 +649,27 @@ |
| } |
| +// Only known == targets return a Boolean. |
| RawAbstractType* EqualityCompareComp::CompileType() const { |
| - return receiver_class_id() != kObjectCid |
| - ? Type::BoolInterface() |
| - : Type::DynamicType(); |
| + if ((receiver_class_id() == kSmiCid) || |
| + (receiver_class_id() == kDoubleCid) || |
| + (receiver_class_id() == kNumberCid)) { |
| + return Type::BoolInterface(); |
| + } |
| + if (HasICData() && ic_data()->AllTargetsHaveSameOwner(kInstanceCid)) { |
| + return Type::BoolInterface(); |
| + } |
| + return Type::DynamicType(); |
| } |
| RawAbstractType* RelationalOpComp::CompileType() const { |
| - return operands_class_id() != kObjectCid |
| - ? Type::BoolInterface() |
| - : Type::DynamicType(); |
| + if ((operands_class_id() == kSmiCid) || |
| + (operands_class_id() == kDoubleCid) || |
| + (operands_class_id() == kNumberCid)) { |
| + return Type::BoolInterface(); |
| + } |
| + return Type::DynamicType(); |
| } |
| @@ -1035,20 +1045,18 @@ |
| Definition* StrictCompareComp::TryReplace(BindInstr* instr) { |
| UseVal* left_use = left()->AsUse(); |
| UseVal* right_use = right()->AsUse(); |
| - if (right_use == NULL || left_use == NULL) return NULL; |
| + if ((right_use == NULL) || (left_use == NULL)) return NULL; |
| Definition* left = left_use->definition(); |
| BindInstr* right = right_use->definition()->AsBind(); |
| if (right == NULL) return NULL; |
| ConstantVal* right_constant = right->computation()->AsConstant(); |
| if (right_constant == NULL) return NULL; |
| // TODO(fschneider): Handle other cases: e === false and e !== true/false. |
| - const AbstractType& left_type = |
| - AbstractType::Handle(left->HasPropagatedType() |
| - ? left->PropagatedType() |
| - : left->CompileType()); |
| - if ((left_type.raw() == Type::BoolInterface()) && |
| - (kind() == Token::kEQ_STRICT) && |
| - (right_constant->value().raw() == Bool::True())) { |
| + // Handles e === true. |
| + const AbstractType& left_type = AbstractType::Handle(left->CompileType()); |
| + if ((kind() == Token::kEQ_STRICT) && |
| + (right_constant->value().raw() == Bool::True()) && |
| + left_type.IsSubtypeOf(Type::Handle(Type::BoolInterface()), NULL)) { |
|
regis
2012/08/13 23:06:19
You should be using Value::CompileTypeIsMoreSpecif
srdjan
2012/08/15 13:54:24
Done.
|
| // Remove the constant from the graph. |
| right->RemoveFromGraph(); |
| // Return left subexpression as the replacement for this instruction. |