Chromium Code Reviews| Index: vm/intermediate_language.cc |
| =================================================================== |
| --- vm/intermediate_language.cc (revision 10497) |
| +++ vm/intermediate_language.cc (working copy) |
| @@ -302,6 +302,23 @@ |
| } |
| +void Definition::ReplaceUsesWith(Definition* other) { |
| + UseVal* head = use_list(); |
| + if (head == NULL) return; |
| + |
| + UseVal* current = head; |
| + while (current->next_use() != NULL) { |
| + current->definition_ = other; |
| + current = current->next_use(); |
| + } |
| + current->definition_ = other; |
| + |
| + current->next_use_ = other->use_list(); |
| + other->use_list()->previous_use_ = current; |
| + other->set_use_list(head); |
| +} |
| + |
| + |
| RawAbstractType* BindInstr::CompileType() const { |
| if (HasPropagatedType()) { |
| return PropagatedType(); |
| @@ -627,12 +644,16 @@ |
| RawAbstractType* EqualityCompareComp::CompileType() const { |
| - return Type::BoolInterface(); |
| + return receiver_class_id() != kObjectCid |
| + ? Type::BoolInterface() |
| + : Type::DynamicType(); |
| } |
| RawAbstractType* RelationalOpComp::CompileType() const { |
| - return Type::BoolInterface(); |
| + return operands_class_id() != kObjectCid |
| + ? Type::BoolInterface() |
| + : Type::DynamicType(); |
| } |
| @@ -993,6 +1014,32 @@ |
| } |
| +Definition* StrictCompareComp::TryReplace(BindInstr* instr) { |
| + UseVal* left_use = left()->AsUse(); |
| + UseVal* right_use = right()->AsUse(); |
| + 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_use->definition()->AsBind()->computation()->AsConstant(); |
|
Kevin Millikin (Google)
2012/08/13 12:43:34
right->computation()->AsConstant()
Florian Schneider
2012/08/13 12:58:07
Done.
|
| + // 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) && |
|
Kevin Millikin (Google)
2012/08/13 12:43:34
(left_type.raw() == Type::BoolInterface()) &&
(kin
Florian Schneider
2012/08/13 12:58:07
Thanks. Done.
|
| + (right_constant->value().raw() == Bool::True())) { |
| + // Remove the constant from the graph. |
| + right->RemoveFromGraph(); |
| + // Return left subexpression as the replacement for this instruction. |
| + return left; |
| + } |
| + return NULL; |
| +} |
| + |
| + |
| LocationSummary* StrictCompareComp::MakeLocationSummary() const { |
| return LocationSummary::Make(2, |
| Location::SameAsFirstInput(), |