| 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/flow_graph_range_analysis.h" | 7 #include "vm/flow_graph_range_analysis.h" |
| 8 #include "vm/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
| 9 #include "vm/os.h" | 9 #include "vm/os.h" |
| 10 #include "vm/parser.h" | 10 #include "vm/parser.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 return found; | 74 return found; |
| 75 } | 75 } |
| 76 | 76 |
| 77 | 77 |
| 78 bool FlowGraphPrinter::ShouldPrint(const Function& function) { | 78 bool FlowGraphPrinter::ShouldPrint(const Function& function) { |
| 79 return PassesFilter(FLAG_print_flow_graph_filter, function); | 79 return PassesFilter(FLAG_print_flow_graph_filter, function); |
| 80 } | 80 } |
| 81 | 81 |
| 82 | 82 |
| 83 void FlowGraphPrinter::PrintGraph(const char* phase, FlowGraph* flow_graph) { | 83 void FlowGraphPrinter::PrintGraph(const char* phase, FlowGraph* flow_graph) { |
| 84 OS::Print("*** BEGIN CFG\n%s\n", phase); | 84 LogBlock lb(Isolate::Current()); |
| 85 ISL_Print("*** BEGIN CFG\n%s\n", phase); |
| 85 FlowGraphPrinter printer(*flow_graph); | 86 FlowGraphPrinter printer(*flow_graph); |
| 86 printer.PrintBlocks(); | 87 printer.PrintBlocks(); |
| 87 OS::Print("*** END CFG\n"); | 88 ISL_Print("*** END CFG\n"); |
| 88 fflush(stdout); | 89 fflush(stdout); |
| 89 } | 90 } |
| 90 | 91 |
| 91 | 92 |
| 92 void FlowGraphPrinter::PrintBlock(BlockEntryInstr* block, | 93 void FlowGraphPrinter::PrintBlock(BlockEntryInstr* block, |
| 93 bool print_locations) { | 94 bool print_locations) { |
| 94 // Print the block entry. | 95 // Print the block entry. |
| 95 PrintOneInstruction(block, print_locations); | 96 PrintOneInstruction(block, print_locations); |
| 96 OS::Print("\n"); | 97 ISL_Print("\n"); |
| 97 // And all the successors in the block. | 98 // And all the successors in the block. |
| 98 for (ForwardInstructionIterator it(block); !it.Done(); it.Advance()) { | 99 for (ForwardInstructionIterator it(block); !it.Done(); it.Advance()) { |
| 99 Instruction* current = it.Current(); | 100 Instruction* current = it.Current(); |
| 100 PrintOneInstruction(current, print_locations); | 101 PrintOneInstruction(current, print_locations); |
| 101 OS::Print("\n"); | 102 ISL_Print("\n"); |
| 102 } | 103 } |
| 103 } | 104 } |
| 104 | 105 |
| 105 | 106 |
| 106 void FlowGraphPrinter::PrintBlocks() { | 107 void FlowGraphPrinter::PrintBlocks() { |
| 107 if (!function_.IsNull()) { | 108 if (!function_.IsNull()) { |
| 108 OS::Print("==== %s\n", function_.ToFullyQualifiedCString()); | 109 ISL_Print("==== %s\n", function_.ToFullyQualifiedCString()); |
| 109 } | 110 } |
| 110 | 111 |
| 111 for (intptr_t i = 0; i < block_order_.length(); ++i) { | 112 for (intptr_t i = 0; i < block_order_.length(); ++i) { |
| 112 PrintBlock(block_order_[i], print_locations_); | 113 PrintBlock(block_order_[i], print_locations_); |
| 113 } | 114 } |
| 114 } | 115 } |
| 115 | 116 |
| 116 | 117 |
| 117 void FlowGraphPrinter::PrintInstruction(Instruction* instr) { | 118 void FlowGraphPrinter::PrintInstruction(Instruction* instr) { |
| 118 PrintOneInstruction(instr, print_locations_); | 119 PrintOneInstruction(instr, print_locations_); |
| 119 } | 120 } |
| 120 | 121 |
| 121 | 122 |
| 122 void FlowGraphPrinter::PrintOneInstruction(Instruction* instr, | 123 void FlowGraphPrinter::PrintOneInstruction(Instruction* instr, |
| 123 bool print_locations) { | 124 bool print_locations) { |
| 124 char str[4000]; | 125 char str[4000]; |
| 125 BufferFormatter f(str, sizeof(str)); | 126 BufferFormatter f(str, sizeof(str)); |
| 126 instr->PrintTo(&f); | 127 instr->PrintTo(&f); |
| 127 if (FLAG_print_environments && (instr->env() != NULL)) { | 128 if (FLAG_print_environments && (instr->env() != NULL)) { |
| 128 instr->env()->PrintTo(&f); | 129 instr->env()->PrintTo(&f); |
| 129 } | 130 } |
| 130 if (print_locations && (instr->HasLocs())) { | 131 if (print_locations && (instr->HasLocs())) { |
| 131 instr->locs()->PrintTo(&f); | 132 instr->locs()->PrintTo(&f); |
| 132 } | 133 } |
| 133 if (instr->lifetime_position() != -1) { | 134 if (instr->lifetime_position() != -1) { |
| 134 OS::Print("%3" Pd ": ", instr->lifetime_position()); | 135 ISL_Print("%3" Pd ": ", instr->lifetime_position()); |
| 135 } | 136 } |
| 136 if (!instr->IsBlockEntry()) OS::Print(" "); | 137 if (!instr->IsBlockEntry()) ISL_Print(" "); |
| 137 OS::Print("%s", str); | 138 ISL_Print("%s", str); |
| 138 } | 139 } |
| 139 | 140 |
| 140 | 141 |
| 141 void FlowGraphPrinter::PrintTypeCheck(const ParsedFunction& parsed_function, | 142 void FlowGraphPrinter::PrintTypeCheck(const ParsedFunction& parsed_function, |
| 142 intptr_t token_pos, | 143 intptr_t token_pos, |
| 143 Value* value, | 144 Value* value, |
| 144 const AbstractType& dst_type, | 145 const AbstractType& dst_type, |
| 145 const String& dst_name, | 146 const String& dst_name, |
| 146 bool eliminated) { | 147 bool eliminated) { |
| 147 const char* compile_type_name = "unknown"; | 148 const char* compile_type_name = "unknown"; |
| 148 if (value != NULL && value->reaching_type_ != NULL) { | 149 if (value != NULL && value->reaching_type_ != NULL) { |
| 149 compile_type_name = value->reaching_type_->ToCString(); | 150 compile_type_name = value->reaching_type_->ToCString(); |
| 150 } | 151 } |
| 151 OS::Print("%s type check: compile type %s is %s specific than " | 152 ISL_Print("%s type check: compile type %s is %s specific than " |
| 152 "type '%s' of '%s'.\n", | 153 "type '%s' of '%s'.\n", |
| 153 eliminated ? "Eliminated" : "Generated", | 154 eliminated ? "Eliminated" : "Generated", |
| 154 compile_type_name, | 155 compile_type_name, |
| 155 eliminated ? "more" : "not more", | 156 eliminated ? "more" : "not more", |
| 156 String::Handle(dst_type.Name()).ToCString(), | 157 String::Handle(dst_type.Name()).ToCString(), |
| 157 dst_name.ToCString()); | 158 dst_name.ToCString()); |
| 158 } | 159 } |
| 159 | 160 |
| 160 | 161 |
| 161 void CompileType::PrintTo(BufferFormatter* f) const { | 162 void CompileType::PrintTo(BufferFormatter* f) const { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 f->Print(" cnt:%" Pd " trgt:'%s'", count, target.ToQualifiedCString()); | 216 f->Print(" cnt:%" Pd " trgt:'%s'", count, target.ToQualifiedCString()); |
| 216 } | 217 } |
| 217 f->Print("]"); | 218 f->Print("]"); |
| 218 } | 219 } |
| 219 | 220 |
| 220 | 221 |
| 221 void FlowGraphPrinter::PrintICData(const ICData& ic_data) { | 222 void FlowGraphPrinter::PrintICData(const ICData& ic_data) { |
| 222 char buffer[1024]; | 223 char buffer[1024]; |
| 223 BufferFormatter f(buffer, sizeof(buffer)); | 224 BufferFormatter f(buffer, sizeof(buffer)); |
| 224 PrintICDataHelper(&f, ic_data); | 225 PrintICDataHelper(&f, ic_data); |
| 225 OS::Print("%s ", buffer); | 226 ISL_Print("%s ", buffer); |
| 226 const Array& a = Array::Handle(ic_data.arguments_descriptor()); | 227 const Array& a = Array::Handle(ic_data.arguments_descriptor()); |
| 227 OS::Print(" arg-desc %" Pd "\n", a.Length()); | 228 ISL_Print(" arg-desc %" Pd "\n", a.Length()); |
| 228 } | 229 } |
| 229 | 230 |
| 230 | 231 |
| 231 static void PrintUse(BufferFormatter* f, const Definition& definition) { | 232 static void PrintUse(BufferFormatter* f, const Definition& definition) { |
| 232 if (definition.HasSSATemp()) { | 233 if (definition.HasSSATemp()) { |
| 233 if (definition.HasPairRepresentation()) { | 234 if (definition.HasPairRepresentation()) { |
| 234 f->Print("v%" Pd ", v%" Pd "", definition.ssa_temp_index(), | 235 f->Print("v%" Pd ", v%" Pd "", definition.ssa_temp_index(), |
| 235 definition.ssa_temp_index() + 1); | 236 definition.ssa_temp_index() + 1); |
| 236 } else { | 237 } else { |
| 237 f->Print("v%" Pd "", definition.ssa_temp_index()); | 238 f->Print("v%" Pd "", definition.ssa_temp_index()); |
| (...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1206 } | 1207 } |
| 1207 | 1208 |
| 1208 const char* Environment::ToCString() const { | 1209 const char* Environment::ToCString() const { |
| 1209 char buffer[1024]; | 1210 char buffer[1024]; |
| 1210 BufferFormatter bf(buffer, 1024); | 1211 BufferFormatter bf(buffer, 1024); |
| 1211 PrintTo(&bf); | 1212 PrintTo(&bf); |
| 1212 return Isolate::Current()->current_zone()->MakeCopyOfString(buffer); | 1213 return Isolate::Current()->current_zone()->MakeCopyOfString(buffer); |
| 1213 } | 1214 } |
| 1214 | 1215 |
| 1215 } // namespace dart | 1216 } // namespace dart |
| OLD | NEW |