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

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 10611)
+++ runtime/vm/intermediate_language.cc (working copy)
@@ -648,17 +648,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();
}
@@ -1032,22 +1042,22 @@
Definition* StrictCompareComp::TryReplace(BindInstr* instr) {
+ return NULL;
Florian Schneider 2012/08/15 11:29:57 Accidental edit? I don't see why this should be di
srdjan 2012/08/15 13:54:25 Yes, accidental edit, but correct. See other email
Florian Schneider 2012/08/15 14:15:56 I'm not convinced: This optimization relies only o
srdjan 2012/08/15 15:36:06 If the left expression's CompileType says that it
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_use->CompileTypeIsMoreSpecificThan(
Florian Schneider 2012/08/15 14:15:56 Not sure if this works with null: Which other type
srdjan 2012/08/15 15:36:06 The only type more specific than bool interface is
+ Type::Handle(Type::BoolInterface()))) {
// 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