| 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 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 if ((use != NULL) && (use->is_receiver() == PhiInstr::kReceiver)) { | 413 if ((use != NULL) && (use->is_receiver() == PhiInstr::kReceiver)) { |
| 414 use->set_is_receiver(PhiInstr::kNotReceiver); | 414 use->set_is_receiver(PhiInstr::kNotReceiver); |
| 415 unmark.Add(use); | 415 unmark.Add(use); |
| 416 } | 416 } |
| 417 } | 417 } |
| 418 } | 418 } |
| 419 } | 419 } |
| 420 | 420 |
| 421 | 421 |
| 422 bool FlowGraph::IsReceiver(Definition* def) const { | 422 bool FlowGraph::IsReceiver(Definition* def) const { |
| 423 def = def->OriginalDefinition(); // Could be redefined. |
| 423 if (def->IsParameter()) return (def->AsParameter()->index() == 0); | 424 if (def->IsParameter()) return (def->AsParameter()->index() == 0); |
| 424 if (!def->IsPhi() || graph_entry()->catch_entries().is_empty()) return false; | 425 if (!def->IsPhi() || graph_entry()->catch_entries().is_empty()) return false; |
| 425 PhiInstr* phi = def->AsPhi(); | 426 PhiInstr* phi = def->AsPhi(); |
| 426 if (phi->is_receiver() != PhiInstr::kUnknownReceiver) { | 427 if (phi->is_receiver() != PhiInstr::kUnknownReceiver) { |
| 427 return (phi->is_receiver() == PhiInstr::kReceiver); | 428 return (phi->is_receiver() == PhiInstr::kReceiver); |
| 428 } | 429 } |
| 429 // Not known if this phi is the receiver yet. Compute it now. | 430 // Not known if this phi is the receiver yet. Compute it now. |
| 430 ComputeIsReceiver(phi); | 431 ComputeIsReceiver(phi); |
| 431 return (phi->is_receiver() == PhiInstr::kReceiver); | 432 return (phi->is_receiver() == PhiInstr::kReceiver); |
| 432 } | 433 } |
| (...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1285 } | 1286 } |
| 1286 } | 1287 } |
| 1287 | 1288 |
| 1288 for (BlockIterator it(postorder_iterator()); !it.Done(); it.Advance()) { | 1289 for (BlockIterator it(postorder_iterator()); !it.Done(); it.Advance()) { |
| 1289 JoinEntryInstr* join = it.Current()->AsJoinEntry(); | 1290 JoinEntryInstr* join = it.Current()->AsJoinEntry(); |
| 1290 if (join != NULL) join->RemoveDeadPhis(constant_dead()); | 1291 if (join != NULL) join->RemoveDeadPhis(constant_dead()); |
| 1291 } | 1292 } |
| 1292 } | 1293 } |
| 1293 | 1294 |
| 1294 | 1295 |
| 1295 RedefinitionInstr* FlowGraph::EnsureRedefinition(BlockEntryInstr* block, | 1296 RedefinitionInstr* FlowGraph::EnsureRedefinition(Instruction* prev, |
| 1296 Definition* original, | 1297 Definition* original, |
| 1297 CompileType compile_type) { | 1298 CompileType compile_type) { |
| 1298 RedefinitionInstr* first = block->next()->AsRedefinition(); | 1299 RedefinitionInstr* first = prev->next()->AsRedefinition(); |
| 1299 if (first != NULL && (first->type() != NULL)) { | 1300 if (first != NULL && (first->constrained_type() != NULL)) { |
| 1300 if ((first->value()->definition() == original) && | 1301 if ((first->value()->definition() == original) && |
| 1301 first->type()->IsEqualTo(&compile_type)) { | 1302 first->constrained_type()->IsEqualTo(&compile_type)) { |
| 1302 // Already redefined. Do nothing. | 1303 // Already redefined. Do nothing. |
| 1303 return NULL; | 1304 return NULL; |
| 1304 } | 1305 } |
| 1305 } | 1306 } |
| 1306 RedefinitionInstr* redef = new RedefinitionInstr(new Value(original)); | 1307 RedefinitionInstr* redef = new RedefinitionInstr(new Value(original)); |
| 1307 redef->set_type(new CompileType(compile_type)); | 1308 redef->set_constrained_type(new CompileType(compile_type)); |
| 1308 InsertAfter(block, redef, NULL, FlowGraph::kValue); | 1309 InsertAfter(prev, redef, NULL, FlowGraph::kValue); |
| 1309 RenameDominatedUses(original, redef, redef); | 1310 RenameDominatedUses(original, redef, redef); |
| 1310 return redef; | 1311 return redef; |
| 1311 } | 1312 } |
| 1312 | 1313 |
| 1313 | 1314 |
| 1314 void FlowGraph::RemoveRedefinitions() { | 1315 void FlowGraph::RemoveRedefinitions() { |
| 1315 // Remove redefinition instructions inserted to inhibit hoisting. | 1316 // Remove redefinition instructions inserted to inhibit hoisting. |
| 1316 for (BlockIterator block_it = reverse_postorder_iterator(); !block_it.Done(); | 1317 for (BlockIterator block_it = reverse_postorder_iterator(); !block_it.Done(); |
| 1317 block_it.Advance()) { | 1318 block_it.Advance()) { |
| 1318 for (ForwardInstructionIterator instr_it(block_it.Current()); | 1319 for (ForwardInstructionIterator instr_it(block_it.Current()); |
| (...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2298 Representation rep, | 2299 Representation rep, |
| 2299 intptr_t cid) { | 2300 intptr_t cid) { |
| 2300 ExtractNthOutputInstr* extract = | 2301 ExtractNthOutputInstr* extract = |
| 2301 new (Z) ExtractNthOutputInstr(new (Z) Value(instr), index, rep, cid); | 2302 new (Z) ExtractNthOutputInstr(new (Z) Value(instr), index, rep, cid); |
| 2302 instr->ReplaceUsesWith(extract); | 2303 instr->ReplaceUsesWith(extract); |
| 2303 InsertAfter(instr, extract, NULL, FlowGraph::kValue); | 2304 InsertAfter(instr, extract, NULL, FlowGraph::kValue); |
| 2304 } | 2305 } |
| 2305 | 2306 |
| 2306 | 2307 |
| 2307 } // namespace dart | 2308 } // namespace dart |
| OLD | NEW |