Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1150)

Unified Diff: runtime/vm/intermediate_language.cc

Issue 11186023: Enable more redundancy elimination for checked mode asserts. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698