Index: runtime/vm/jit_optimizer.cc |
diff --git a/runtime/vm/jit_optimizer.cc b/runtime/vm/jit_optimizer.cc |
index f85d9c46fb3b212ad580ed0ee36a5428469b0e57..c510ff2b50794a66dfcf72f7f00df8be32debb6b 100644 |
--- a/runtime/vm/jit_optimizer.cc |
+++ b/runtime/vm/jit_optimizer.cc |
@@ -1543,6 +1543,17 @@ void JitOptimizer::VisitInstanceCall(InstanceCallInstr* instr) { |
const ICData& unary_checks = |
ICData::ZoneHandle(Z, instr->ic_data()->AsUnaryClassChecks()); |
+ const bool is_dense = CheckClassInstr::IsDenseCidRange(unary_checks); |
+ const intptr_t number_of_checks = unary_checks.NumberOfChecks(); |
+ if (op_kind == Token::kEQ && |
+ number_of_checks > FLAG_max_equality_polymorphic_checks && !is_dense && |
+ flow_graph()->InstanceCallNeedsClassCheck( |
+ instr, RawFunction::kRegularFunction)) { |
+ // Too many checks, it will be megamorphic which needs unary checks. |
+ instr->set_ic_data(&unary_checks); |
+ return; |
+ } |
+ |
if ((op_kind == Token::kASSIGN_INDEX) && TryReplaceWithIndexedOp(instr)) { |
return; |
} |