Index: runtime/vm/aot_optimizer.cc |
diff --git a/runtime/vm/aot_optimizer.cc b/runtime/vm/aot_optimizer.cc |
index 168471ceeb93252db7dae73defb027ad0ff5ddd1..00131579c16799ad18408bc5371c31cd49c62e3e 100644 |
--- a/runtime/vm/aot_optimizer.cc |
+++ b/runtime/vm/aot_optimizer.cc |
@@ -291,6 +291,18 @@ bool AotOptimizer::TryCreateICData(InstanceCallInstr* call) { |
call->set_ic_data(&ic_data); |
if (has_unique_no_such_method_) { |
call->set_has_unique_selector(true); |
+ // Add redefinition of the receiver to prevent code motion across |
+ // this call. |
+ RedefinitionInstr* redefinition = |
+ new (Z) RedefinitionInstr(new (Z) Value(call->ArgumentAt(0))); |
+ redefinition->set_ssa_temp_index(flow_graph_->alloc_ssa_temp_index()); |
+ redefinition->InsertAfter(call); |
+ // Replace all uses of the receiver dominated by this call. |
+ FlowGraph::RenameDominatedUses(call->ArgumentAt(0), redefinition, |
+ redefinition); |
+ if (!redefinition->HasUses()) { |
+ redefinition->RemoveFromGraph(); |
+ } |
} |
return true; |
} |