| 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/il_printer.h" | 5 #include "vm/il_printer.h" |
| 6 | 6 |
| 7 #include "vm/intermediate_language.h" | 7 #include "vm/intermediate_language.h" |
| 8 #include "vm/os.h" | 8 #include "vm/os.h" |
| 9 | 9 |
| 10 namespace dart { | 10 namespace dart { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 for (intptr_t i = 0; i < block_order_.length(); ++i) { | 37 for (intptr_t i = 0; i < block_order_.length(); ++i) { |
| 38 // Print the block entry. | 38 // Print the block entry. |
| 39 PrintInstruction(block_order_[i]); | 39 PrintInstruction(block_order_[i]); |
| 40 Instruction* current = block_order_[i]->StraightLineSuccessor(); | 40 Instruction* current = block_order_[i]->StraightLineSuccessor(); |
| 41 // And all the successors until an exit, branch, or a block entry. | 41 // And all the successors until an exit, branch, or a block entry. |
| 42 while ((current != NULL) && !current->IsBlockEntry()) { | 42 while ((current != NULL) && !current->IsBlockEntry()) { |
| 43 OS::Print("\n"); | 43 OS::Print("\n"); |
| 44 PrintInstruction(current); | 44 PrintInstruction(current); |
| 45 current = current->StraightLineSuccessor(); | 45 current = current->StraightLineSuccessor(); |
| 46 } | 46 } |
| 47 BlockEntryInstr* successor = |
| 48 (current == NULL) ? NULL : current->AsBlockEntry(); |
| 49 if (successor != NULL) { |
| 50 OS::Print(" goto %d", successor->block_id()); |
| 51 } |
| 47 OS::Print("\n"); | 52 OS::Print("\n"); |
| 48 } | 53 } |
| 49 } | 54 } |
| 50 | 55 |
| 51 | 56 |
| 52 void FlowGraphPrinter::PrintInstruction(Instruction* instr) { | 57 void FlowGraphPrinter::PrintInstruction(Instruction* instr) { |
| 53 char str[120]; | 58 char str[120]; |
| 54 BufferFormatter f(str, sizeof(str)); | 59 BufferFormatter f(str, sizeof(str)); |
| 55 instr->PrintTo(&f); | 60 instr->PrintTo(&f); |
| 56 OS::Print("%s", str); | 61 OS::Print("%s", str); |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 } | 405 } |
| 401 if (is_negated()) { | 406 if (is_negated()) { |
| 402 f->Print(" (negated)"); | 407 f->Print(" (negated)"); |
| 403 } | 408 } |
| 404 f->Print(" goto (%d, %d)", | 409 f->Print(" goto (%d, %d)", |
| 405 true_successor()->block_id(), | 410 true_successor()->block_id(), |
| 406 false_successor()->block_id()); | 411 false_successor()->block_id()); |
| 407 } | 412 } |
| 408 | 413 |
| 409 | 414 |
| 410 void GotoInstr::PrintTo(BufferFormatter* f) const { | |
| 411 f->Print(" goto %d", successor_->block_id()); | |
| 412 } | |
| 413 | |
| 414 | |
| 415 void ParallelMoveInstr::PrintTo(BufferFormatter* f) const { | 415 void ParallelMoveInstr::PrintTo(BufferFormatter* f) const { |
| 416 UNIMPLEMENTED(); | 416 UNIMPLEMENTED(); |
| 417 } | 417 } |
| 418 | 418 |
| 419 | 419 |
| 420 void FlowGraphVisualizer::Print(const char* format, ...) { | 420 void FlowGraphVisualizer::Print(const char* format, ...) { |
| 421 char str[120]; | 421 char str[120]; |
| 422 BufferFormatter f(str, sizeof(str)); | 422 BufferFormatter f(str, sizeof(str)); |
| 423 f.Print("%*s", 2 * indent_, ""); | 423 f.Print("%*s", 2 * indent_, ""); |
| 424 va_list args; | 424 va_list args; |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 Print("0 0 "); // Required fields "bci" and "use". Unused. | 524 Print("0 0 "); // Required fields "bci" and "use". Unused. |
| 525 Instruction* current = block_order_[i]; | 525 Instruction* current = block_order_[i]; |
| 526 PrintInstruction(current); | 526 PrintInstruction(current); |
| 527 current = current->StraightLineSuccessor(); | 527 current = current->StraightLineSuccessor(); |
| 528 // And all the successors until an exit, branch, or a block entry. | 528 // And all the successors until an exit, branch, or a block entry. |
| 529 while ((current != NULL) && !current->IsBlockEntry()) { | 529 while ((current != NULL) && !current->IsBlockEntry()) { |
| 530 Print("0 0 "); | 530 Print("0 0 "); |
| 531 PrintInstruction(current); | 531 PrintInstruction(current); |
| 532 current = current->StraightLineSuccessor(); | 532 current = current->StraightLineSuccessor(); |
| 533 } | 533 } |
| 534 BlockEntryInstr* successor = |
| 535 (current == NULL) ? NULL : current->AsBlockEntry(); |
| 536 if (successor != NULL) { |
| 537 Print("0 0 _ Goto B%d <|@\n", successor->block_id()); |
| 538 } |
| 534 END("HIR"); | 539 END("HIR"); |
| 535 } | 540 } |
| 536 END("block"); | 541 END("block"); |
| 537 } | 542 } |
| 538 END("cfg"); | 543 END("cfg"); |
| 539 } | 544 } |
| 540 #undef BEGIN | 545 #undef BEGIN |
| 541 #undef END | 546 #undef END |
| 542 } | 547 } |
| 543 | 548 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 void BranchInstr::PrintToVisualizer(BufferFormatter* f) const { | 637 void BranchInstr::PrintToVisualizer(BufferFormatter* f) const { |
| 633 f->Print("_ %s ", DebugName()); | 638 f->Print("_ %s ", DebugName()); |
| 634 f->Print("if "); | 639 f->Print("if "); |
| 635 value()->PrintTo(f); | 640 value()->PrintTo(f); |
| 636 f->Print(" goto (B%d, B%d)", | 641 f->Print(" goto (B%d, B%d)", |
| 637 true_successor()->block_id(), | 642 true_successor()->block_id(), |
| 638 false_successor()->block_id()); | 643 false_successor()->block_id()); |
| 639 } | 644 } |
| 640 | 645 |
| 641 | 646 |
| 642 void GotoInstr::PrintToVisualizer(BufferFormatter* f) const { | |
| 643 f->Print("_ Goto (B%d)", successor_->block_id()); | |
| 644 } | |
| 645 | |
| 646 | |
| 647 void ParallelMoveInstr::PrintToVisualizer(BufferFormatter* f) const { | 647 void ParallelMoveInstr::PrintToVisualizer(BufferFormatter* f) const { |
| 648 UNIMPLEMENTED(); | 648 UNIMPLEMENTED(); |
| 649 } | 649 } |
| 650 | 650 |
| 651 | 651 |
| 652 | 652 |
| 653 } // namespace dart | 653 } // namespace dart |
| OLD | NEW |