| Index: runtime/vm/intermediate_language.cc
|
| ===================================================================
|
| --- runtime/vm/intermediate_language.cc (revision 13738)
|
| +++ runtime/vm/intermediate_language.cc (working copy)
|
| @@ -86,6 +86,15 @@
|
| }
|
|
|
|
|
| +bool AssertAssignableInstr::AttributesEqual(Instruction* other) const {
|
| + AssertAssignableInstr* other_assert = other->AsAssertAssignable();
|
| + ASSERT(other_assert != NULL);
|
| + // This predicate has to be commutative for DominatorBasedCSE to work.
|
| + // TODO(fschneider): Eliminate more asserts with subtype relation.
|
| + return dst_type().raw() == other_assert->dst_type().raw();
|
| +}
|
| +
|
| +
|
| bool StrictCompareInstr::AttributesEqual(Instruction* other) const {
|
| StrictCompareInstr* other_op = other->AsStrictCompare();
|
| ASSERT(other_op != NULL);
|
| @@ -1404,6 +1413,31 @@
|
| }
|
|
|
|
|
| +Definition* AssertAssignableInstr::Canonicalize() {
|
| + // (1) Replace the assert with its input if the input has a known compatible
|
| + // class-id. The class-ids handled here are those that are known to be
|
| + // results of IL instructions.
|
| + intptr_t cid = value()->ResultCid();
|
| + bool is_redundant = false;
|
| + if (dst_type().IsIntType()) {
|
| + is_redundant = (cid == kSmiCid) || (cid == kMintCid);
|
| + } else if (dst_type().IsDoubleType()) {
|
| + is_redundant = (cid == kDoubleCid);
|
| + } else if (dst_type().IsBoolType()) {
|
| + is_redundant = (cid == kBoolCid);
|
| + }
|
| + if (is_redundant) return value()->definition();
|
| +
|
| + // (2) Replace the assert with its input if the input is the result of a
|
| + // compatible assert itself.
|
| + AssertAssignableInstr* check = value()->definition()->AsAssertAssignable();
|
| + if ((check != NULL) && (check->dst_type().raw() == dst_type().raw())) {
|
| + // TODO(fschneider): Eliminate more asserts with subtype relation.
|
| + return check;
|
| + }
|
| + return this;
|
| +}
|
| +
|
| Definition* StrictCompareInstr::Canonicalize() {
|
| if (!right()->BindsToConstant()) return this;
|
| const Object& right_constant = right()->BoundConstant();
|
|
|