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

Unified Diff: runtime/vm/flow_graph_optimizer.cc

Issue 57703004: Constant fold strict comparison based on incoming types: different (exact) types means that the res… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 1 month 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/lib/integers.dart ('k') | runtime/vm/flow_graph_type_propagator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph_optimizer.cc
===================================================================
--- runtime/vm/flow_graph_optimizer.cc (revision 29815)
+++ runtime/vm/flow_graph_optimizer.cc (working copy)
@@ -6307,14 +6307,27 @@
: instr->left()->Type()->IsNull();
if (instr->kind() == Token::kNE_STRICT) result = !result;
SetValue(instr, Bool::Get(result));
- } else {
- SetValue(instr, non_constant_);
+ return;
Kevin Millikin (Google) 2013/11/07 11:29:37 If you want the early return, this should be: if
}
- } else if (IsConstant(left) && IsConstant(right)) {
+ }
+ if (IsConstant(left) && IsConstant(right)) {
bool result = (left.raw() == right.raw());
if (instr->kind() == Token::kNE_STRICT) result = !result;
SetValue(instr, Bool::Get(result));
+ return;
}
+ const intptr_t left_cid = instr->left()->Type()->ToCid();
+ const intptr_t right_cid = instr->right()->Type()->ToCid();
+ if ((left_cid != kDynamicCid) && (right_cid != kDynamicCid)) {
+ // If exact classes (cids) are known and they differ, the result
+ // of strict compare can be computed.
+ if (left_cid != right_cid) {
+ const bool result = (instr->kind() == Token::kEQ_STRICT) ? false : true;
+ SetValue(instr, Bool::Get(result));
+ return;
+ }
+ }
+ SetValue(instr, non_constant_);
Kevin Millikin (Google) 2013/11/07 11:29:37 Abbreviate non-constant by X, constant by C, unkno
}
« no previous file with comments | « runtime/lib/integers.dart ('k') | runtime/vm/flow_graph_type_propagator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698