| 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 #include "vm/parser.h" | 9 #include "vm/parser.h" |
| 10 | 10 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 if (current->next() != NULL) { | 52 if (current->next() != NULL) { |
| 53 ASSERT(current->next()->IsBlockEntry()); | 53 ASSERT(current->next()->IsBlockEntry()); |
| 54 OS::Print(" goto %"Pd"", current->next()->AsBlockEntry()->block_id()); | 54 OS::Print(" goto %"Pd"", current->next()->AsBlockEntry()->block_id()); |
| 55 } | 55 } |
| 56 OS::Print("\n"); | 56 OS::Print("\n"); |
| 57 } | 57 } |
| 58 } | 58 } |
| 59 | 59 |
| 60 | 60 |
| 61 void FlowGraphPrinter::PrintInstruction(Instruction* instr) { | 61 void FlowGraphPrinter::PrintInstruction(Instruction* instr) { |
| 62 PrintOneInstruction(instr, print_locations_); |
| 63 } |
| 64 |
| 65 |
| 66 void FlowGraphPrinter::PrintOneInstruction(Instruction* instr, |
| 67 bool print_locations) { |
| 62 char str[1000]; | 68 char str[1000]; |
| 63 BufferFormatter f(str, sizeof(str)); | 69 BufferFormatter f(str, sizeof(str)); |
| 64 instr->PrintTo(&f); | 70 instr->PrintTo(&f); |
| 65 if (FLAG_print_environments && (instr->env() != NULL)) { | 71 if (FLAG_print_environments && (instr->env() != NULL)) { |
| 66 instr->env()->PrintTo(&f); | 72 instr->env()->PrintTo(&f); |
| 67 } | 73 } |
| 68 if (print_locations_ && (instr->locs() != NULL)) { | 74 if (print_locations && (instr->locs() != NULL)) { |
| 69 instr->locs()->PrintTo(&f); | 75 instr->locs()->PrintTo(&f); |
| 70 } | 76 } |
| 71 if (instr->lifetime_position() != -1) { | 77 if (instr->lifetime_position() != -1) { |
| 72 OS::Print("%3"Pd": ", instr->lifetime_position()); | 78 OS::Print("%3"Pd": ", instr->lifetime_position()); |
| 73 } | 79 } |
| 74 OS::Print("%s", str); | 80 OS::Print("%s", str); |
| 75 } | 81 } |
| 76 | 82 |
| 77 | 83 |
| 78 void FlowGraphPrinter::PrintTypeCheck(const ParsedFunction& parsed_function, | 84 void FlowGraphPrinter::PrintTypeCheck(const ParsedFunction& parsed_function, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 f->Print("%s", String::Handle(cls.Name()).ToCString()); | 124 f->Print("%s", String::Handle(cls.Name()).ToCString()); |
| 119 } | 125 } |
| 120 } | 126 } |
| 121 f->Print("]"); | 127 f->Print("]"); |
| 122 } | 128 } |
| 123 | 129 |
| 124 | 130 |
| 125 void Definition::PrintTo(BufferFormatter* f) const { | 131 void Definition::PrintTo(BufferFormatter* f) const { |
| 126 // Do not access 'deopt_id()' as it asserts that the computation can | 132 // Do not access 'deopt_id()' as it asserts that the computation can |
| 127 // deoptimize. | 133 // deoptimize. |
| 128 f->Print("%s:%"Pd"(", DebugName(), deopt_id()); | 134 if (HasSSATemp()) { |
| 135 f->Print("v%"Pd" <- ", ssa_temp_index()); |
| 136 } |
| 137 f->Print("%s:%"Pd"(", DebugName(), deopt_id_); |
| 129 PrintOperandsTo(f); | 138 PrintOperandsTo(f); |
| 130 f->Print(")"); | 139 f->Print(")"); |
| 131 } | 140 } |
| 132 | 141 |
| 133 | 142 |
| 134 void Definition::PrintOperandsTo(BufferFormatter* f) const { | 143 void Definition::PrintOperandsTo(BufferFormatter* f) const { |
| 135 for (int i = 0; i < InputCount(); ++i) { | 144 for (int i = 0; i < InputCount(); ++i) { |
| 136 if (i > 0) f->Print(", "); | 145 if (i > 0) f->Print(", "); |
| 137 if (InputAt(i) != NULL) InputAt(i)->PrintTo(f); | 146 if (InputAt(i) != NULL) InputAt(i)->PrintTo(f); |
| 138 } | 147 } |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 } | 473 } |
| 465 if (def.has_propagated_cid()) { | 474 if (def.has_propagated_cid()) { |
| 466 const Class& cls = Class::Handle( | 475 const Class& cls = Class::Handle( |
| 467 Isolate::Current()->class_table()->At(def.propagated_cid())); | 476 Isolate::Current()->class_table()->At(def.propagated_cid())); |
| 468 f->Print(" {PCid: %s}", String::Handle(cls.Name()).ToCString()); | 477 f->Print(" {PCid: %s}", String::Handle(cls.Name()).ToCString()); |
| 469 } | 478 } |
| 470 } | 479 } |
| 471 | 480 |
| 472 | 481 |
| 473 void PhiInstr::PrintTo(BufferFormatter* f) const { | 482 void PhiInstr::PrintTo(BufferFormatter* f) const { |
| 474 f->Print(" v%"Pd" <- phi(", ssa_temp_index()); | 483 f->Print(" v%"Pd" <- phi(", ssa_temp_index()); |
| 475 for (intptr_t i = 0; i < inputs_.length(); ++i) { | 484 for (intptr_t i = 0; i < inputs_.length(); ++i) { |
| 476 if (inputs_[i] != NULL) inputs_[i]->PrintTo(f); | 485 if (inputs_[i] != NULL) inputs_[i]->PrintTo(f); |
| 477 if (i < inputs_.length() - 1) f->Print(", "); | 486 if (i < inputs_.length() - 1) f->Print(", "); |
| 478 } | 487 } |
| 479 f->Print(")"); | 488 f->Print(")"); |
| 480 PrintPropagatedType(f, *this); | 489 PrintPropagatedType(f, *this); |
| 481 } | 490 } |
| 482 | 491 |
| 483 | 492 |
| 484 void ParameterInstr::PrintTo(BufferFormatter* f) const { | 493 void ParameterInstr::PrintTo(BufferFormatter* f) const { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 503 } | 512 } |
| 504 | 513 |
| 505 | 514 |
| 506 void PushArgumentInstr::PrintTo(BufferFormatter* f) const { | 515 void PushArgumentInstr::PrintTo(BufferFormatter* f) const { |
| 507 f->Print(" %s ", DebugName()); | 516 f->Print(" %s ", DebugName()); |
| 508 value()->PrintTo(f); | 517 value()->PrintTo(f); |
| 509 } | 518 } |
| 510 | 519 |
| 511 | 520 |
| 512 void ReturnInstr::PrintTo(BufferFormatter* f) const { | 521 void ReturnInstr::PrintTo(BufferFormatter* f) const { |
| 513 f->Print(" %s:%"Pd" ", DebugName(), deopt_id()); | 522 f->Print(" %s ", DebugName()); |
| 514 value()->PrintTo(f); | 523 value()->PrintTo(f); |
| 515 } | 524 } |
| 516 | 525 |
| 517 | 526 |
| 518 void ThrowInstr::PrintTo(BufferFormatter* f) const { | 527 void ThrowInstr::PrintTo(BufferFormatter* f) const { |
| 519 f->Print(" %s" , DebugName()); | 528 f->Print(" %s" , DebugName()); |
| 520 } | 529 } |
| 521 | 530 |
| 522 | 531 |
| 523 void ReThrowInstr::PrintTo(BufferFormatter* f) const { | 532 void ReThrowInstr::PrintTo(BufferFormatter* f) const { |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 } | 742 } |
| 734 | 743 |
| 735 | 744 |
| 736 void PushArgumentInstr::PrintToVisualizer(BufferFormatter* f) const { | 745 void PushArgumentInstr::PrintToVisualizer(BufferFormatter* f) const { |
| 737 f->Print("_ %s ", DebugName()); | 746 f->Print("_ %s ", DebugName()); |
| 738 value()->PrintTo(f); | 747 value()->PrintTo(f); |
| 739 } | 748 } |
| 740 | 749 |
| 741 | 750 |
| 742 void ReturnInstr::PrintToVisualizer(BufferFormatter* f) const { | 751 void ReturnInstr::PrintToVisualizer(BufferFormatter* f) const { |
| 743 f->Print("_ %s:%"Pd" ", DebugName(), deopt_id()); | 752 f->Print("_ %s ", DebugName()); |
| 744 value()->PrintTo(f); | 753 value()->PrintTo(f); |
| 745 } | 754 } |
| 746 | 755 |
| 747 | 756 |
| 748 void ThrowInstr::PrintToVisualizer(BufferFormatter* f) const { | 757 void ThrowInstr::PrintToVisualizer(BufferFormatter* f) const { |
| 749 f->Print("_ %s ", DebugName()); | 758 f->Print("_ %s ", DebugName()); |
| 750 } | 759 } |
| 751 | 760 |
| 752 | 761 |
| 753 void ReThrowInstr::PrintToVisualizer(BufferFormatter* f) const { | 762 void ReThrowInstr::PrintToVisualizer(BufferFormatter* f) const { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 783 if ((locations_ != NULL) && !locations_[i].IsInvalid()) { | 792 if ((locations_ != NULL) && !locations_[i].IsInvalid()) { |
| 784 f->Print(" ["); | 793 f->Print(" ["); |
| 785 locations_[i].PrintTo(f); | 794 locations_[i].PrintTo(f); |
| 786 f->Print("]"); | 795 f->Print("]"); |
| 787 } | 796 } |
| 788 } | 797 } |
| 789 f->Print(" }"); | 798 f->Print(" }"); |
| 790 } | 799 } |
| 791 | 800 |
| 792 } // namespace dart | 801 } // namespace dart |
| OLD | NEW |