| 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 | |
| 234 static void PrintICDataHelper(BufferFormatter* f, | 198 static void PrintICDataHelper(BufferFormatter* f, |
| 235 const ICData& ic_data, | 199 const ICData& ic_data, |
| 236 intptr_t num_checks_to_print) { | 200 intptr_t num_checks_to_print) { |
| 237 f->Print(" IC["); | 201 f->Print(" IC["); |
| 238 f->Print("%" Pd ": ", ic_data.NumberOfChecks()); | 202 f->Print("%" Pd ": ", ic_data.NumberOfChecks()); |
| 239 Function& target = Function::Handle(); | 203 Function& target = Function::Handle(); |
| 240 if ((num_checks_to_print == FlowGraphPrinter::kPrintAll) || | 204 if ((num_checks_to_print == FlowGraphPrinter::kPrintAll) || |
| 241 (num_checks_to_print > ic_data.NumberOfChecks())) { | 205 (num_checks_to_print > ic_data.NumberOfChecks())) { |
| 242 num_checks_to_print = ic_data.NumberOfChecks(); | 206 num_checks_to_print = ic_data.NumberOfChecks(); |
| 243 } | 207 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 intptr_t num_checks_to_print) { | 249 intptr_t num_checks_to_print) { |
| 286 char buffer[1024]; | 250 char buffer[1024]; |
| 287 BufferFormatter f(buffer, sizeof(buffer)); | 251 BufferFormatter f(buffer, sizeof(buffer)); |
| 288 PrintICDataHelper(&f, ic_data, num_checks_to_print); | 252 PrintICDataHelper(&f, ic_data, num_checks_to_print); |
| 289 THR_Print("%s ", buffer); | 253 THR_Print("%s ", buffer); |
| 290 const Array& a = Array::Handle(ic_data.arguments_descriptor()); | 254 const Array& a = Array::Handle(ic_data.arguments_descriptor()); |
| 291 THR_Print(" arg-desc %" Pd "\n", a.Length()); | 255 THR_Print(" arg-desc %" Pd "\n", a.Length()); |
| 292 } | 256 } |
| 293 | 257 |
| 294 | 258 |
| 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 | |
| 305 static void PrintUse(BufferFormatter* f, const Definition& definition) { | 259 static void PrintUse(BufferFormatter* f, const Definition& definition) { |
| 306 if (definition.HasSSATemp()) { | 260 if (definition.HasSSATemp()) { |
| 307 if (definition.HasPairRepresentation()) { | 261 if (definition.HasPairRepresentation()) { |
| 308 f->Print("(v%" Pd ", v%" Pd ")", definition.ssa_temp_index(), | 262 f->Print("(v%" Pd ", v%" Pd ")", definition.ssa_temp_index(), |
| 309 definition.ssa_temp_index() + 1); | 263 definition.ssa_temp_index() + 1); |
| 310 } else { | 264 } else { |
| 311 f->Print("v%" Pd "", definition.ssa_temp_index()); | 265 f->Print("v%" Pd "", definition.ssa_temp_index()); |
| 312 } | 266 } |
| 313 } else if (definition.HasTemp()) { | 267 } else if (definition.HasTemp()) { |
| 314 f->Print("t%" Pd "", definition.temp_index()); | 268 f->Print("t%" Pd "", definition.temp_index()); |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 } | 460 } |
| 507 } | 461 } |
| 508 | 462 |
| 509 | 463 |
| 510 void PolymorphicInstanceCallInstr::PrintOperandsTo(BufferFormatter* f) const { | 464 void PolymorphicInstanceCallInstr::PrintOperandsTo(BufferFormatter* f) const { |
| 511 f->Print(" %s", instance_call()->function_name().ToCString()); | 465 f->Print(" %s", instance_call()->function_name().ToCString()); |
| 512 for (intptr_t i = 0; i < ArgumentCount(); ++i) { | 466 for (intptr_t i = 0; i < ArgumentCount(); ++i) { |
| 513 f->Print(", "); | 467 f->Print(", "); |
| 514 PushArgumentAt(i)->value()->PrintTo(f); | 468 PushArgumentAt(i)->value()->PrintTo(f); |
| 515 } | 469 } |
| 516 PrintTargetsHelper(f, targets_, FlowGraphPrinter::kPrintAll); | 470 if (FLAG_display_sorted_ic_data) { |
| 471 PrintICDataSortedHelper(f, ic_data()); |
| 472 } else { |
| 473 PrintICDataHelper(f, ic_data(), FlowGraphPrinter::kPrintAll); |
| 474 } |
| 517 if (with_checks()) { | 475 if (with_checks()) { |
| 518 f->Print(" WITH-CHECKS"); | 476 f->Print(" WITH-CHECKS"); |
| 519 } | 477 } |
| 520 if (complete()) { | 478 if (complete()) { |
| 521 f->Print(" COMPLETE"); | 479 f->Print(" COMPLETE"); |
| 522 } | 480 } |
| 523 } | 481 } |
| 524 | 482 |
| 525 | 483 |
| 526 void StrictCompareInstr::PrintOperandsTo(BufferFormatter* f) const { | 484 void StrictCompareInstr::PrintOperandsTo(BufferFormatter* f) const { |
| (...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1358 } | 1316 } |
| 1359 | 1317 |
| 1360 | 1318 |
| 1361 bool FlowGraphPrinter::ShouldPrint(const Function& function) { | 1319 bool FlowGraphPrinter::ShouldPrint(const Function& function) { |
| 1362 return false; | 1320 return false; |
| 1363 } | 1321 } |
| 1364 | 1322 |
| 1365 #endif // !PRODUCT | 1323 #endif // !PRODUCT |
| 1366 | 1324 |
| 1367 } // namespace dart | 1325 } // namespace dart |
| OLD | NEW |