| OLD | NEW | 
|---|
| 1 // Copyright (c) 2016, the Dart project authors.  Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors.  Please see the AUTHORS file | 
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a | 
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "vm/redundancy_elimination.h" | 5 #include "vm/redundancy_elimination.h" | 
| 6 | 6 | 
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" | 
| 8 #include "vm/flow_graph.h" | 8 #include "vm/flow_graph.h" | 
| 9 #include "vm/hash_map.h" | 9 #include "vm/hash_map.h" | 
| 10 #include "vm/il_printer.h" | 10 #include "vm/il_printer.h" | 
| (...skipping 2076 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2087       // as replaced and store a pointer to the replacement. | 2087       // as replaced and store a pointer to the replacement. | 
| 2088       Definition* replacement = (*pred_out_values)[place_id]->Replacement(); | 2088       Definition* replacement = (*pred_out_values)[place_id]->Replacement(); | 
| 2089       Value* input = new(Z) Value(replacement); | 2089       Value* input = new(Z) Value(replacement); | 
| 2090       phi->SetInputAt(i, input); | 2090       phi->SetInputAt(i, input); | 
| 2091       replacement->AddInputUse(input); | 2091       replacement->AddInputUse(input); | 
| 2092     } | 2092     } | 
| 2093 | 2093 | 
| 2094     graph_->AllocateSSAIndexes(phi); | 2094     graph_->AllocateSSAIndexes(phi); | 
| 2095     phis_.Add(phi);  // Postpone phi insertion until after load forwarding. | 2095     phis_.Add(phi);  // Postpone phi insertion until after load forwarding. | 
| 2096 | 2096 | 
| 2097     if (FLAG_trace_load_optimization) { | 2097     if (FLAG_support_il_printer && FLAG_trace_load_optimization) { | 
| 2098       THR_Print("created pending phi %s for %s at B%" Pd "\n", | 2098       THR_Print("created pending phi %s for %s at B%" Pd "\n", | 
| 2099                 phi->ToCString(), | 2099                 phi->ToCString(), | 
| 2100                 aliased_set_->places()[place_id]->ToCString(), | 2100                 aliased_set_->places()[place_id]->ToCString(), | 
| 2101                 block->block_id()); | 2101                 block->block_id()); | 
| 2102     } | 2102     } | 
| 2103   } | 2103   } | 
| 2104 | 2104 | 
| 2105   // Iterate over basic blocks and replace exposed loads with incoming | 2105   // Iterate over basic blocks and replace exposed loads with incoming | 
| 2106   // values. | 2106   // values. | 
| 2107   void ForwardLoads() { | 2107   void ForwardLoads() { | 
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2315       // a dominates b or b dominates a. | 2315       // a dominates b or b dominates a. | 
| 2316       if (!a->IsPhi()) { | 2316       if (!a->IsPhi()) { | 
| 2317         if (Dominates(a, b)) { | 2317         if (Dominates(a, b)) { | 
| 2318           Definition* t = a; | 2318           Definition* t = a; | 
| 2319           a = b; | 2319           a = b; | 
| 2320           b = t; | 2320           b = t; | 
| 2321         } | 2321         } | 
| 2322         ASSERT(Dominates(b, a)); | 2322         ASSERT(Dominates(b, a)); | 
| 2323       } | 2323       } | 
| 2324 | 2324 | 
| 2325       if (FLAG_trace_load_optimization) { | 2325       if (FLAG_support_il_printer && FLAG_trace_load_optimization) { | 
| 2326         THR_Print("Replacing %s with congruent %s\n", | 2326         THR_Print("Replacing %s with congruent %s\n", | 
| 2327                   a->ToCString(), | 2327                   a->ToCString(), | 
| 2328                   b->ToCString()); | 2328                   b->ToCString()); | 
| 2329       } | 2329       } | 
| 2330 | 2330 | 
| 2331       a->ReplaceUsesWith(b); | 2331       a->ReplaceUsesWith(b); | 
| 2332       if (a->IsPhi()) { | 2332       if (a->IsPhi()) { | 
| 2333         // We might be replacing a phi introduced by the load forwarding | 2333         // We might be replacing a phi introduced by the load forwarding | 
| 2334         // that is not inserted in the graph yet. | 2334         // that is not inserted in the graph yet. | 
| 2335         ASSERT(b->IsPhi()); | 2335         ASSERT(b->IsPhi()); | 
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2749 // Right now we are attempting to sink allocation only into | 2749 // Right now we are attempting to sink allocation only into | 
| 2750 // deoptimization exit. So candidate should only be used in StoreInstanceField | 2750 // deoptimization exit. So candidate should only be used in StoreInstanceField | 
| 2751 // instructions that write into fields of the allocated object. | 2751 // instructions that write into fields of the allocated object. | 
| 2752 // We do not support materialization of the object that has type arguments. | 2752 // We do not support materialization of the object that has type arguments. | 
| 2753 static bool IsAllocationSinkingCandidate(Definition* alloc, | 2753 static bool IsAllocationSinkingCandidate(Definition* alloc, | 
| 2754                                          SafeUseCheck check_type) { | 2754                                          SafeUseCheck check_type) { | 
| 2755   for (Value* use = alloc->input_use_list(); | 2755   for (Value* use = alloc->input_use_list(); | 
| 2756        use != NULL; | 2756        use != NULL; | 
| 2757        use = use->next_use()) { | 2757        use = use->next_use()) { | 
| 2758     if (!IsSafeUse(use, check_type)) { | 2758     if (!IsSafeUse(use, check_type)) { | 
| 2759       if (FLAG_trace_optimization) { | 2759       if (FLAG_support_il_printer && FLAG_trace_optimization) { | 
| 2760         THR_Print("use of %s at %s is unsafe for allocation sinking\n", | 2760         THR_Print("use of %s at %s is unsafe for allocation sinking\n", | 
| 2761                   alloc->ToCString(), | 2761                   alloc->ToCString(), | 
| 2762                   use->instruction()->ToCString()); | 2762                   use->instruction()->ToCString()); | 
| 2763       } | 2763       } | 
| 2764       return false; | 2764       return false; | 
| 2765     } | 2765     } | 
| 2766   } | 2766   } | 
| 2767 | 2767 | 
| 2768   return true; | 2768   return true; | 
| 2769 } | 2769 } | 
| (...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3462         join->phis_ = NULL; | 3462         join->phis_ = NULL; | 
| 3463       } else { | 3463       } else { | 
| 3464         join->phis_->TruncateTo(to_index); | 3464         join->phis_->TruncateTo(to_index); | 
| 3465       } | 3465       } | 
| 3466     } | 3466     } | 
| 3467   } | 3467   } | 
| 3468 } | 3468 } | 
| 3469 | 3469 | 
| 3470 | 3470 | 
| 3471 }  // namespace dart | 3471 }  // namespace dart | 
| OLD | NEW | 
|---|