Index: runtime/vm/intermediate_language.cc |
diff --git a/runtime/vm/intermediate_language.cc b/runtime/vm/intermediate_language.cc |
index 358f299bfb3c6bf820474cd6e7404bdea85089d2..1a01537f04a03fd829b74fbad01a2b263c4ceec9 100644 |
--- a/runtime/vm/intermediate_language.cc |
+++ b/runtime/vm/intermediate_language.cc |
@@ -2736,6 +2736,30 @@ Instruction* CheckClassIdInstr::Canonicalize(FlowGraph* flow_graph) { |
} |
+TestCidsInstr::TestCidsInstr(TokenPosition token_pos, |
+ Token::Kind kind, |
+ Value* value, |
+ const ZoneGrowableArray<intptr_t>& cid_results, |
+ intptr_t deopt_id) |
+ : TemplateComparison(token_pos, kind, deopt_id), |
+ cid_results_(cid_results), |
+ licm_hoisted_(false) { |
+ ASSERT((kind == Token::kIS) || (kind == Token::kISNOT)); |
+ SetInputAt(0, value); |
+ set_operation_cid(kObjectCid); |
+#ifdef DEBUG |
+ ASSERT(cid_results[0] == kSmiCid); |
+ if (deopt_id == Thread::kNoDeoptId) { |
+ // The entry for Smi can be special, but all other entries have |
+ // to match in the no-deopt case. |
+ for (intptr_t i = 4; i < cid_results.length(); i += 2) { |
+ ASSERT(cid_results[i + 1] == cid_results[3]); |
+ } |
+ } |
+#endif |
+} |
+ |
+ |
Definition* TestCidsInstr::Canonicalize(FlowGraph* flow_graph) { |
CompileType* in_type = left()->Type(); |
intptr_t cid = in_type->ToCid(); |
@@ -2751,7 +2775,12 @@ Definition* TestCidsInstr::Canonicalize(FlowGraph* flow_graph) { |
} |
} |
- // TODO(sra): Handle misses if the instruction is not deoptimizing. |
+ if (!CanDeoptimize()) { |
+ return (data[data.length() - 1] == true_result) |
+ ? flow_graph->GetConstant(Bool::False()) |
+ : flow_graph->GetConstant(Bool::True()); |
+ } |
+ |
// TODO(sra): Handle nullable input, possibly canonicalizing to a compare |
// against `null`. |
return this; |
@@ -3860,6 +3889,9 @@ bool TestCidsInstr::AttributesEqual(Instruction* other) const { |
if (!ComparisonInstr::AttributesEqual(other)) { |
return false; |
} |
+ if (CanDeoptimize() != other->CanDeoptimize()) { |
Vyacheslav Egorov (Google)
2017/05/30 10:54:20
I don't think CanDeoptimize() should be compared h
|
+ return false; |
+ } |
if (cid_results().length() != other_instr->cid_results().length()) { |
return false; |
} |