| 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/flow_graph_builder.h" | 8 #include "vm/flow_graph_builder.h" |
| 9 #include "vm/intermediate_language.h" | 9 #include "vm/intermediate_language.h" |
| 10 #include "vm/longjump.h" | 10 #include "vm/longjump.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 } | 68 } |
| 69 | 69 |
| 70 | 70 |
| 71 void FlowGraph::InsertAfter(Instruction* prev, | 71 void FlowGraph::InsertAfter(Instruction* prev, |
| 72 Instruction* instr, | 72 Instruction* instr, |
| 73 Environment* env, | 73 Environment* env, |
| 74 Definition::UseKind use_kind) { | 74 Definition::UseKind use_kind) { |
| 75 for (intptr_t i = instr->InputCount() - 1; i >= 0; --i) { | 75 for (intptr_t i = instr->InputCount() - 1; i >= 0; --i) { |
| 76 Value* input = instr->InputAt(i); | 76 Value* input = instr->InputAt(i); |
| 77 input->definition()->AddInputUse(input); | 77 input->definition()->AddInputUse(input); |
| 78 input->set_instruction(instr); | |
| 79 input->set_use_index(i); | |
| 80 } | 78 } |
| 81 ASSERT(instr->env() == NULL); | 79 ASSERT(instr->env() == NULL); |
| 82 if (env != NULL) env->DeepCopyTo(instr); | 80 if (env != NULL) env->DeepCopyTo(instr); |
| 83 if (use_kind == Definition::kValue) { | 81 if (use_kind == Definition::kValue) { |
| 84 ASSERT(instr->IsDefinition()); | 82 ASSERT(instr->IsDefinition()); |
| 85 instr->AsDefinition()->set_ssa_temp_index(alloc_ssa_temp_index()); | 83 instr->AsDefinition()->set_ssa_temp_index(alloc_ssa_temp_index()); |
| 86 } | 84 } |
| 87 instr->InsertAfter(prev); | 85 instr->InsertAfter(prev); |
| 88 } | 86 } |
| 89 | 87 |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 Definition* input_defn = v->definition(); | 499 Definition* input_defn = v->definition(); |
| 502 if (input_defn->IsLoadLocal() || input_defn->IsStoreLocal()) { | 500 if (input_defn->IsLoadLocal() || input_defn->IsStoreLocal()) { |
| 503 // Remove the load/store from the graph. | 501 // Remove the load/store from the graph. |
| 504 input_defn->UnuseAllInputs(); | 502 input_defn->UnuseAllInputs(); |
| 505 input_defn->RemoveFromGraph(); | 503 input_defn->RemoveFromGraph(); |
| 506 // Assert we are not referencing nulls in the initial environment. | 504 // Assert we are not referencing nulls in the initial environment. |
| 507 ASSERT(reaching_defn->ssa_temp_index() != -1); | 505 ASSERT(reaching_defn->ssa_temp_index() != -1); |
| 508 v->set_definition(reaching_defn); | 506 v->set_definition(reaching_defn); |
| 509 input_defn = reaching_defn; | 507 input_defn = reaching_defn; |
| 510 } | 508 } |
| 511 v->set_instruction(current); | |
| 512 v->set_use_index(i); | |
| 513 input_defn->AddInputUse(v); | 509 input_defn->AddInputUse(v); |
| 514 } | 510 } |
| 515 | 511 |
| 516 // Drop pushed arguments for calls. | 512 // Drop pushed arguments for calls. |
| 517 for (intptr_t j = 0; j < current->ArgumentCount(); j++) { | 513 for (intptr_t j = 0; j < current->ArgumentCount(); j++) { |
| 518 env->RemoveLast(); | 514 env->RemoveLast(); |
| 519 } | 515 } |
| 520 | 516 |
| 521 // 2b. Handle LoadLocal and StoreLocal. | 517 // 2b. Handle LoadLocal and StoreLocal. |
| 522 // For each LoadLocal: Remove it from the graph. | 518 // For each LoadLocal: Remove it from the graph. |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 block_entry->last_instruction()->SuccessorAt(0)->AsJoinEntry(); | 580 block_entry->last_instruction()->SuccessorAt(0)->AsJoinEntry(); |
| 585 intptr_t pred_index = successor->IndexOfPredecessor(block_entry); | 581 intptr_t pred_index = successor->IndexOfPredecessor(block_entry); |
| 586 ASSERT(pred_index >= 0); | 582 ASSERT(pred_index >= 0); |
| 587 if (successor->phis() != NULL) { | 583 if (successor->phis() != NULL) { |
| 588 for (intptr_t i = 0; i < successor->phis()->length(); ++i) { | 584 for (intptr_t i = 0; i < successor->phis()->length(); ++i) { |
| 589 PhiInstr* phi = (*successor->phis())[i]; | 585 PhiInstr* phi = (*successor->phis())[i]; |
| 590 if (phi != NULL) { | 586 if (phi != NULL) { |
| 591 // Rename input operand. | 587 // Rename input operand. |
| 592 Value* use = new Value((*env)[i]); | 588 Value* use = new Value((*env)[i]); |
| 593 phi->SetInputAt(pred_index, use); | 589 phi->SetInputAt(pred_index, use); |
| 594 use->set_instruction(phi); | |
| 595 use->set_use_index(pred_index); | |
| 596 use->definition()->AddInputUse(use); | 590 use->definition()->AddInputUse(use); |
| 597 } | 591 } |
| 598 } | 592 } |
| 599 } | 593 } |
| 600 } | 594 } |
| 601 } | 595 } |
| 602 | 596 |
| 603 | 597 |
| 604 void FlowGraph::MarkLivePhis(GrowableArray<PhiInstr*>* live_phis) { | 598 void FlowGraph::MarkLivePhis(GrowableArray<PhiInstr*>* live_phis) { |
| 605 while (!live_phis->is_empty()) { | 599 while (!live_phis->is_empty()) { |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 !it.Done(); | 694 !it.Done(); |
| 701 it.Advance()) { | 695 it.Advance()) { |
| 702 ++size; | 696 ++size; |
| 703 } | 697 } |
| 704 } | 698 } |
| 705 return size; | 699 return size; |
| 706 } | 700 } |
| 707 | 701 |
| 708 | 702 |
| 709 } // namespace dart | 703 } // namespace dart |
| OLD | NEW |