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

Unified Diff: runtime/vm/intermediate_language.cc

Issue 10826285: Optimize equality for case when all targets are Object.equals. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: 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 | « runtime/vm/intermediate_language.h ('k') | runtime/vm/intermediate_language_ia32.cc » ('j') | 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 10581)
+++ runtime/vm/intermediate_language.cc (working copy)
@@ -649,17 +649,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();
}
@@ -1035,20 +1045,18 @@
Definition* StrictCompareComp::TryReplace(BindInstr* instr) {
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_type.IsSubtypeOf(Type::Handle(Type::BoolInterface()), NULL)) {
regis 2012/08/13 23:06:19 You should be using Value::CompileTypeIsMoreSpecif
srdjan 2012/08/15 13:54:24 Done.
// Remove the constant from the graph.
right->RemoveFromGraph();
// Return left subexpression as the replacement for this instruction.
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | runtime/vm/intermediate_language_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698