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

Unified Diff: vm/intermediate_language.cc

Issue 10830275: Optimize expressions of the form (expr === true) when expr has boolean type. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: ready for review Created 8 years, 4 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 | « 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: 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(),
« no previous file with comments | « vm/intermediate_language.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698