Chromium Code Reviews| Index: runtime/vm/intermediate_language.cc |
| =================================================================== |
| --- runtime/vm/intermediate_language.cc (revision 10611) |
| +++ runtime/vm/intermediate_language.cc (working copy) |
| @@ -648,17 +648,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(); |
| } |
| @@ -1032,22 +1042,22 @@ |
| Definition* StrictCompareComp::TryReplace(BindInstr* instr) { |
| + return NULL; |
|
Florian Schneider
2012/08/15 11:29:57
Accidental edit? I don't see why this should be di
srdjan
2012/08/15 13:54:25
Yes, accidental edit, but correct. See other email
Florian Schneider
2012/08/15 14:15:56
I'm not convinced: This optimization relies only o
srdjan
2012/08/15 15:36:06
If the left expression's CompileType says that it
|
| 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_use->CompileTypeIsMoreSpecificThan( |
|
Florian Schneider
2012/08/15 14:15:56
Not sure if this works with null: Which other type
srdjan
2012/08/15 15:36:06
The only type more specific than bool interface is
|
| + Type::Handle(Type::BoolInterface()))) { |
| // Remove the constant from the graph. |
| right->RemoveFromGraph(); |
| // Return left subexpression as the replacement for this instruction. |