| 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 { |
| 11 | 11 |
| 12 DEFINE_FLAG(bool, print_environments, false, "Print SSA environments."); |
| 13 |
| 12 | 14 |
| 13 void BufferFormatter::Print(const char* format, ...) { | 15 void BufferFormatter::Print(const char* format, ...) { |
| 14 va_list args; | 16 va_list args; |
| 15 va_start(args, format); | 17 va_start(args, format); |
| 16 VPrint(format, args); | 18 VPrint(format, args); |
| 17 va_end(args); | 19 va_end(args); |
| 18 } | 20 } |
| 19 | 21 |
| 20 | 22 |
| 21 void BufferFormatter::VPrint(const char* format, va_list args) { | 23 void BufferFormatter::VPrint(const char* format, va_list args) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 51 } | 53 } |
| 52 OS::Print("\n"); | 54 OS::Print("\n"); |
| 53 } | 55 } |
| 54 } | 56 } |
| 55 | 57 |
| 56 | 58 |
| 57 void FlowGraphPrinter::PrintInstruction(Instruction* instr) { | 59 void FlowGraphPrinter::PrintInstruction(Instruction* instr) { |
| 58 char str[120]; | 60 char str[120]; |
| 59 BufferFormatter f(str, sizeof(str)); | 61 BufferFormatter f(str, sizeof(str)); |
| 60 instr->PrintTo(&f); | 62 instr->PrintTo(&f); |
| 63 if (FLAG_print_environments && (instr->env() != NULL)) { |
| 64 instr->env()->PrintTo(&f); |
| 65 } |
| 61 OS::Print("%s", str); | 66 OS::Print("%s", str); |
| 62 } | 67 } |
| 63 | 68 |
| 64 | 69 |
| 65 void FlowGraphPrinter::PrintComputation(Computation* comp) { | 70 void FlowGraphPrinter::PrintComputation(Computation* comp) { |
| 66 char str[120]; | 71 char str[120]; |
| 67 BufferFormatter f(str, sizeof(str)); | 72 BufferFormatter f(str, sizeof(str)); |
| 68 comp->PrintTo(&f); | 73 comp->PrintTo(&f); |
| 69 OS::Print("%s", str); | 74 OS::Print("%s", str); |
| 70 } | 75 } |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 f.VPrint(format, args); | 431 f.VPrint(format, args); |
| 427 va_end(args); | 432 va_end(args); |
| 428 (*Dart::flow_graph_writer())(str, strlen(str)); | 433 (*Dart::flow_graph_writer())(str, strlen(str)); |
| 429 } | 434 } |
| 430 | 435 |
| 431 | 436 |
| 432 void FlowGraphVisualizer::PrintInstruction(Instruction* instr) { | 437 void FlowGraphVisualizer::PrintInstruction(Instruction* instr) { |
| 433 char str[120]; | 438 char str[120]; |
| 434 BufferFormatter f(str, sizeof(str)); | 439 BufferFormatter f(str, sizeof(str)); |
| 435 instr->PrintToVisualizer(&f); | 440 instr->PrintToVisualizer(&f); |
| 441 if (FLAG_print_environments && (instr->env() != NULL)) { |
| 442 instr->env()->PrintTo(&f); |
| 443 } |
| 436 f.Print(" <|@\n"); | 444 f.Print(" <|@\n"); |
| 437 (*Dart::flow_graph_writer())(str, strlen(str)); | 445 (*Dart::flow_graph_writer())(str, strlen(str)); |
| 438 } | 446 } |
| 439 | 447 |
| 440 | 448 |
| 441 void FlowGraphVisualizer::PrintFunction() { | 449 void FlowGraphVisualizer::PrintFunction() { |
| 442 #define BEGIN(name) \ | 450 #define BEGIN(name) \ |
| 443 Print("begin_%s\n", name); \ | 451 Print("begin_%s\n", name); \ |
| 444 indent_++; | 452 indent_++; |
| 445 #define END(name) \ | 453 #define END(name) \ |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 true_successor()->block_id(), | 650 true_successor()->block_id(), |
| 643 false_successor()->block_id()); | 651 false_successor()->block_id()); |
| 644 } | 652 } |
| 645 | 653 |
| 646 | 654 |
| 647 void ParallelMoveInstr::PrintToVisualizer(BufferFormatter* f) const { | 655 void ParallelMoveInstr::PrintToVisualizer(BufferFormatter* f) const { |
| 648 UNIMPLEMENTED(); | 656 UNIMPLEMENTED(); |
| 649 } | 657 } |
| 650 | 658 |
| 651 | 659 |
| 660 void Environment::PrintTo(BufferFormatter* f) const { |
| 661 f->Print(" env={ "); |
| 662 for (intptr_t i = 0; i < values_.length(); ++i) { |
| 663 if (i > 0) f->Print(", "); |
| 664 values_[i]->PrintTo(f); |
| 665 } |
| 666 f->Print(" }"); |
| 667 } |
| 652 | 668 |
| 653 } // namespace dart | 669 } // namespace dart |
| OLD | NEW |