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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 | 188 |
189 | 189 |
190 const char* CompileType::ToCString() const { | 190 const char* CompileType::ToCString() const { |
191 char buffer[1024]; | 191 char buffer[1024]; |
192 BufferFormatter f(buffer, sizeof(buffer)); | 192 BufferFormatter f(buffer, sizeof(buffer)); |
193 PrintTo(&f); | 193 PrintTo(&f); |
194 return Thread::Current()->zone()->MakeCopyOfString(buffer); | 194 return Thread::Current()->zone()->MakeCopyOfString(buffer); |
195 } | 195 } |
196 | 196 |
197 | 197 |
| 198 static void PrintTargetsHelper(BufferFormatter* f, |
| 199 const CallTargets& targets, |
| 200 intptr_t num_checks_to_print) { |
| 201 f->Print(" IC["); |
| 202 f->Print("%" Pd ": ", targets.length()); |
| 203 Function& target = Function::Handle(); |
| 204 if ((num_checks_to_print == FlowGraphPrinter::kPrintAll) || |
| 205 (num_checks_to_print > targets.length())) { |
| 206 num_checks_to_print = targets.length(); |
| 207 } |
| 208 for (intptr_t i = 0; i < num_checks_to_print; i++) { |
| 209 const CidRangeTarget& range = targets[i]; |
| 210 const intptr_t count = range.count; |
| 211 target ^= range.target->raw(); |
| 212 if (i > 0) { |
| 213 f->Print(" | "); |
| 214 } |
| 215 if (range.cid_start == range.cid_end) { |
| 216 const Class& cls = |
| 217 Class::Handle(Isolate::Current()->class_table()->At(range.cid_start)); |
| 218 f->Print("%s", String::Handle(cls.Name()).ToCString()); |
| 219 f->Print(" cnt:%" Pd " trgt:'%s'", count, target.ToQualifiedCString()); |
| 220 } else { |
| 221 const Class& cls = Class::Handle(range.target->Owner()); |
| 222 f->Print("cid %" Pd "-%" Pd " %s", range.cid_start, range.cid_end, |
| 223 String::Handle(cls.Name()).ToCString()); |
| 224 f->Print(" cnt:%" Pd " trgt:'%s'", count, target.ToQualifiedCString()); |
| 225 } |
| 226 } |
| 227 if (num_checks_to_print < targets.length()) { |
| 228 f->Print("..."); |
| 229 } |
| 230 f->Print("]"); |
| 231 } |
| 232 |
| 233 |
198 static void PrintICDataHelper(BufferFormatter* f, | 234 static void PrintICDataHelper(BufferFormatter* f, |
199 const ICData& ic_data, | 235 const ICData& ic_data, |
200 intptr_t num_checks_to_print) { | 236 intptr_t num_checks_to_print) { |
201 f->Print(" IC["); | 237 f->Print(" IC["); |
202 f->Print("%" Pd ": ", ic_data.NumberOfChecks()); | 238 f->Print("%" Pd ": ", ic_data.NumberOfChecks()); |
203 Function& target = Function::Handle(); | 239 Function& target = Function::Handle(); |
204 if ((num_checks_to_print == FlowGraphPrinter::kPrintAll) || | 240 if ((num_checks_to_print == FlowGraphPrinter::kPrintAll) || |
205 (num_checks_to_print > ic_data.NumberOfChecks())) { | 241 (num_checks_to_print > ic_data.NumberOfChecks())) { |
206 num_checks_to_print = ic_data.NumberOfChecks(); | 242 num_checks_to_print = ic_data.NumberOfChecks(); |
207 } | 243 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 intptr_t num_checks_to_print) { | 285 intptr_t num_checks_to_print) { |
250 char buffer[1024]; | 286 char buffer[1024]; |
251 BufferFormatter f(buffer, sizeof(buffer)); | 287 BufferFormatter f(buffer, sizeof(buffer)); |
252 PrintICDataHelper(&f, ic_data, num_checks_to_print); | 288 PrintICDataHelper(&f, ic_data, num_checks_to_print); |
253 THR_Print("%s ", buffer); | 289 THR_Print("%s ", buffer); |
254 const Array& a = Array::Handle(ic_data.arguments_descriptor()); | 290 const Array& a = Array::Handle(ic_data.arguments_descriptor()); |
255 THR_Print(" arg-desc %" Pd "\n", a.Length()); | 291 THR_Print(" arg-desc %" Pd "\n", a.Length()); |
256 } | 292 } |
257 | 293 |
258 | 294 |
| 295 void FlowGraphPrinter::PrintCidRangeData(const CallTargets& targets, |
| 296 intptr_t num_checks_to_print) { |
| 297 char buffer[1024]; |
| 298 BufferFormatter f(buffer, sizeof(buffer)); |
| 299 PrintTargetsHelper(&f, targets, num_checks_to_print); |
| 300 THR_Print("%s ", buffer); |
| 301 // TODO(erikcorry): Print args descriptor. |
| 302 } |
| 303 |
| 304 |
259 static void PrintUse(BufferFormatter* f, const Definition& definition) { | 305 static void PrintUse(BufferFormatter* f, const Definition& definition) { |
260 if (definition.HasSSATemp()) { | 306 if (definition.HasSSATemp()) { |
261 if (definition.HasPairRepresentation()) { | 307 if (definition.HasPairRepresentation()) { |
262 f->Print("(v%" Pd ", v%" Pd ")", definition.ssa_temp_index(), | 308 f->Print("(v%" Pd ", v%" Pd ")", definition.ssa_temp_index(), |
263 definition.ssa_temp_index() + 1); | 309 definition.ssa_temp_index() + 1); |
264 } else { | 310 } else { |
265 f->Print("v%" Pd "", definition.ssa_temp_index()); | 311 f->Print("v%" Pd "", definition.ssa_temp_index()); |
266 } | 312 } |
267 } else if (definition.HasTemp()) { | 313 } else if (definition.HasTemp()) { |
268 f->Print("t%" Pd "", definition.temp_index()); | 314 f->Print("t%" Pd "", definition.temp_index()); |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 } | 506 } |
461 } | 507 } |
462 | 508 |
463 | 509 |
464 void PolymorphicInstanceCallInstr::PrintOperandsTo(BufferFormatter* f) const { | 510 void PolymorphicInstanceCallInstr::PrintOperandsTo(BufferFormatter* f) const { |
465 f->Print(" %s", instance_call()->function_name().ToCString()); | 511 f->Print(" %s", instance_call()->function_name().ToCString()); |
466 for (intptr_t i = 0; i < ArgumentCount(); ++i) { | 512 for (intptr_t i = 0; i < ArgumentCount(); ++i) { |
467 f->Print(", "); | 513 f->Print(", "); |
468 PushArgumentAt(i)->value()->PrintTo(f); | 514 PushArgumentAt(i)->value()->PrintTo(f); |
469 } | 515 } |
470 if (FLAG_display_sorted_ic_data) { | 516 PrintTargetsHelper(f, targets_, FlowGraphPrinter::kPrintAll); |
471 PrintICDataSortedHelper(f, ic_data()); | |
472 } else { | |
473 PrintICDataHelper(f, ic_data(), FlowGraphPrinter::kPrintAll); | |
474 } | |
475 if (with_checks()) { | 517 if (with_checks()) { |
476 f->Print(" WITH-CHECKS"); | 518 f->Print(" WITH-CHECKS"); |
477 } | 519 } |
478 if (complete()) { | 520 if (complete()) { |
479 f->Print(" COMPLETE"); | 521 f->Print(" COMPLETE"); |
480 } | 522 } |
481 } | 523 } |
482 | 524 |
483 | 525 |
484 void StrictCompareInstr::PrintOperandsTo(BufferFormatter* f) const { | 526 void StrictCompareInstr::PrintOperandsTo(BufferFormatter* f) const { |
(...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1316 } | 1358 } |
1317 | 1359 |
1318 | 1360 |
1319 bool FlowGraphPrinter::ShouldPrint(const Function& function) { | 1361 bool FlowGraphPrinter::ShouldPrint(const Function& function) { |
1320 return false; | 1362 return false; |
1321 } | 1363 } |
1322 | 1364 |
1323 #endif // !PRODUCT | 1365 #endif // !PRODUCT |
1324 | 1366 |
1325 } // namespace dart | 1367 } // namespace dart |
OLD | NEW |