| 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 } | |
| 52 OS::Print("\n"); | 47 OS::Print("\n"); |
| 53 } | 48 } |
| 54 } | 49 } |
| 55 | 50 |
| 56 | 51 |
| 57 void FlowGraphPrinter::PrintInstruction(Instruction* instr) { | 52 void FlowGraphPrinter::PrintInstruction(Instruction* instr) { |
| 58 char str[120]; | 53 char str[120]; |
| 59 BufferFormatter f(str, sizeof(str)); | 54 BufferFormatter f(str, sizeof(str)); |
| 60 instr->PrintTo(&f); | 55 instr->PrintTo(&f); |
| 61 OS::Print("%s", str); | 56 OS::Print("%s", str); |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 } | 400 } |
| 406 if (is_negated()) { | 401 if (is_negated()) { |
| 407 f->Print(" (negated)"); | 402 f->Print(" (negated)"); |
| 408 } | 403 } |
| 409 f->Print(" goto (%d, %d)", | 404 f->Print(" goto (%d, %d)", |
| 410 true_successor()->block_id(), | 405 true_successor()->block_id(), |
| 411 false_successor()->block_id()); | 406 false_successor()->block_id()); |
| 412 } | 407 } |
| 413 | 408 |
| 414 | 409 |
| 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 } | |
| 539 END("HIR"); | 534 END("HIR"); |
| 540 } | 535 } |
| 541 END("block"); | 536 END("block"); |
| 542 } | 537 } |
| 543 END("cfg"); | 538 END("cfg"); |
| 544 } | 539 } |
| 545 #undef BEGIN | 540 #undef BEGIN |
| 546 #undef END | 541 #undef END |
| 547 } | 542 } |
| 548 | 543 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 void BranchInstr::PrintToVisualizer(BufferFormatter* f) const { | 632 void BranchInstr::PrintToVisualizer(BufferFormatter* f) const { |
| 638 f->Print("_ %s ", DebugName()); | 633 f->Print("_ %s ", DebugName()); |
| 639 f->Print("if "); | 634 f->Print("if "); |
| 640 value()->PrintTo(f); | 635 value()->PrintTo(f); |
| 641 f->Print(" goto (B%d, B%d)", | 636 f->Print(" goto (B%d, B%d)", |
| 642 true_successor()->block_id(), | 637 true_successor()->block_id(), |
| 643 false_successor()->block_id()); | 638 false_successor()->block_id()); |
| 644 } | 639 } |
| 645 | 640 |
| 646 | 641 |
| 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 |