OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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/flow_graph.h" | 5 #include "vm/flow_graph.h" |
6 | 6 |
7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
8 #include "vm/cha.h" | 8 #include "vm/cha.h" |
9 #include "vm/flow_graph_builder.h" | 9 #include "vm/flow_graph_builder.h" |
10 #include "vm/flow_graph_compiler.h" | 10 #include "vm/flow_graph_compiler.h" |
(...skipping 2038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2049 } | 2049 } |
2050 } | 2050 } |
2051 } | 2051 } |
2052 } | 2052 } |
2053 TryMergeTruncDivMod(&div_mod_merge); | 2053 TryMergeTruncDivMod(&div_mod_merge); |
2054 TryMergeMathUnary(&sin_cos_merge); | 2054 TryMergeMathUnary(&sin_cos_merge); |
2055 } | 2055 } |
2056 } | 2056 } |
2057 | 2057 |
2058 | 2058 |
| 2059 // Returns true if use is dominated by the given instruction. |
| 2060 // Note: uses that occur at instruction itself are not dominated by it. |
| 2061 static bool IsDominatedUse(Instruction* dom, Value* use) { |
| 2062 BlockEntryInstr* dom_block = dom->GetBlock(); |
| 2063 |
| 2064 Instruction* instr = use->instruction(); |
| 2065 |
| 2066 PhiInstr* phi = instr->AsPhi(); |
| 2067 if (phi != NULL) { |
| 2068 return dom_block->Dominates(phi->block()->PredecessorAt(use->use_index())); |
| 2069 } |
| 2070 |
| 2071 BlockEntryInstr* use_block = instr->GetBlock(); |
| 2072 if (use_block == dom_block) { |
| 2073 // Fast path for the case of block entry. |
| 2074 if (dom_block == dom) return true; |
| 2075 |
| 2076 for (Instruction* curr = dom->next(); curr != NULL; curr = curr->next()) { |
| 2077 if (curr == instr) return true; |
| 2078 } |
| 2079 |
| 2080 return false; |
| 2081 } |
| 2082 |
| 2083 return dom_block->Dominates(use_block); |
| 2084 } |
| 2085 |
| 2086 |
| 2087 void FlowGraph::RenameDominatedUses(Definition* def, |
| 2088 Instruction* dom, |
| 2089 Definition* other) { |
| 2090 for (Value::Iterator it(def->input_use_list()); !it.Done(); it.Advance()) { |
| 2091 Value* use = it.Current(); |
| 2092 if (IsDominatedUse(dom, use)) { |
| 2093 use->BindTo(other); |
| 2094 } |
| 2095 } |
| 2096 } |
| 2097 |
| 2098 |
2059 static bool IsPositiveOrZeroSmiConst(Definition* d) { | 2099 static bool IsPositiveOrZeroSmiConst(Definition* d) { |
2060 ConstantInstr* const_instr = d->AsConstant(); | 2100 ConstantInstr* const_instr = d->AsConstant(); |
2061 if ((const_instr != NULL) && (const_instr->value().IsSmi())) { | 2101 if ((const_instr != NULL) && (const_instr->value().IsSmi())) { |
2062 return Smi::Cast(const_instr->value()).Value() >= 0; | 2102 return Smi::Cast(const_instr->value()).Value() >= 0; |
2063 } | 2103 } |
2064 return false; | 2104 return false; |
2065 } | 2105 } |
2066 | 2106 |
2067 | 2107 |
2068 static BinarySmiOpInstr* AsSmiShiftLeftInstruction(Definition* d) { | 2108 static BinarySmiOpInstr* AsSmiShiftLeftInstruction(Definition* d) { |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2246 Representation rep, | 2286 Representation rep, |
2247 intptr_t cid) { | 2287 intptr_t cid) { |
2248 ExtractNthOutputInstr* extract = | 2288 ExtractNthOutputInstr* extract = |
2249 new (Z) ExtractNthOutputInstr(new (Z) Value(instr), index, rep, cid); | 2289 new (Z) ExtractNthOutputInstr(new (Z) Value(instr), index, rep, cid); |
2250 instr->ReplaceUsesWith(extract); | 2290 instr->ReplaceUsesWith(extract); |
2251 InsertAfter(instr, extract, NULL, FlowGraph::kValue); | 2291 InsertAfter(instr, extract, NULL, FlowGraph::kValue); |
2252 } | 2292 } |
2253 | 2293 |
2254 | 2294 |
2255 } // namespace dart | 2295 } // namespace dart |
OLD | NEW |