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