| 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 | 9 |
| 10 namespace dart { | 10 namespace dart { |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 } | 323 } |
| 324 | 324 |
| 325 | 325 |
| 326 void GraphEntryInstr::PrintTo(BufferFormatter* f) const { | 326 void GraphEntryInstr::PrintTo(BufferFormatter* f) const { |
| 327 f->Print("%2d: [graph]", block_id()); | 327 f->Print("%2d: [graph]", block_id()); |
| 328 } | 328 } |
| 329 | 329 |
| 330 | 330 |
| 331 void JoinEntryInstr::PrintTo(BufferFormatter* f) const { | 331 void JoinEntryInstr::PrintTo(BufferFormatter* f) const { |
| 332 f->Print("%2d: [join]", block_id()); | 332 f->Print("%2d: [join]", block_id()); |
| 333 if (phis_ != NULL) { |
| 334 for (intptr_t i = 0; i < phis_->length(); ++i) { |
| 335 if ((*phis_)[i] == NULL) continue; |
| 336 f->Print("\n"); |
| 337 (*phis_)[i]->PrintTo(f); |
| 338 } |
| 339 } |
| 340 } |
| 341 |
| 342 |
| 343 void PhiInstr::PrintTo(BufferFormatter* f) const { |
| 344 f->Print(" phi("); |
| 345 for (intptr_t i = 0; i < inputs_.length(); ++i) { |
| 346 if (inputs_[i] != NULL) inputs_[i]->PrintTo(f); |
| 347 if (i < inputs_.length() - 1) f->Print(","); |
| 348 } |
| 349 f->Print(")"); |
| 333 } | 350 } |
| 334 | 351 |
| 335 | 352 |
| 336 void TargetEntryInstr::PrintTo(BufferFormatter* f) const { | 353 void TargetEntryInstr::PrintTo(BufferFormatter* f) const { |
| 337 f->Print("%2d: [target", block_id()); | 354 f->Print("%2d: [target", block_id()); |
| 338 if (HasTryIndex()) { | 355 if (HasTryIndex()) { |
| 339 f->Print(" catch %d]", try_index()); | 356 f->Print(" catch %d]", try_index()); |
| 340 } else { | 357 } else { |
| 341 f->Print("]"); | 358 f->Print("]"); |
| 342 } | 359 } |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 Print("%s \"B%d\"\n", "dominator", entry->dominator()->block_id()); | 476 Print("%s \"B%d\"\n", "dominator", entry->dominator()->block_id()); |
| 460 } | 477 } |
| 461 | 478 |
| 462 // TODO(fschneider): Mark blocks with loop nesting level. | 479 // TODO(fschneider): Mark blocks with loop nesting level. |
| 463 Print("%s %d\n", "loop_depth", 0); | 480 Print("%s %d\n", "loop_depth", 0); |
| 464 | 481 |
| 465 { | 482 { |
| 466 BEGIN("states"); // Required section. | 483 BEGIN("states"); // Required section. |
| 467 { | 484 { |
| 468 BEGIN("locals"); // Required section. | 485 BEGIN("locals"); // Required section. |
| 469 // TODO(fschneider): Insert phi-instructions here. | 486 JoinEntryInstr* join = entry->AsJoinEntry(); |
| 470 intptr_t num_phis = 0; | 487 intptr_t num_phis = (join != NULL && join->phi_count()) |
| 488 ? join->phis()->length() |
| 489 : 0; |
| 471 Print("%s %d\n", "size", num_phis); | 490 Print("%s %d\n", "size", num_phis); |
| 491 for (intptr_t j = 0; j < num_phis; ++j) { |
| 492 PhiInstr* phi = (*join->phis())[j]; |
| 493 if (phi != NULL) { |
| 494 Print("%d ", j); // Print variable index. |
| 495 char buffer[120]; |
| 496 BufferFormatter formatter(buffer, sizeof(buffer)); |
| 497 phi->PrintToVisualizer(&formatter); |
| 498 Print("%s\n", buffer); |
| 499 } |
| 500 } |
| 472 END("locals"); | 501 END("locals"); |
| 473 } | 502 } |
| 474 END("states"); | 503 END("states"); |
| 475 } | 504 } |
| 476 | 505 |
| 477 { | 506 { |
| 478 BEGIN("HIR"); | 507 BEGIN("HIR"); |
| 479 // Print the block entry. | 508 // Print the block entry. |
| 480 Print("0 0 "); // Required fields "bci" and "use". Unused. | 509 Print("0 0 "); // Required fields "bci" and "use". Unused. |
| 481 Instruction* current = block_order_[i]; | 510 Instruction* current = block_order_[i]; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 509 void GraphEntryInstr::PrintToVisualizer(BufferFormatter* f) const { | 538 void GraphEntryInstr::PrintToVisualizer(BufferFormatter* f) const { |
| 510 f->Print("_ [graph]"); | 539 f->Print("_ [graph]"); |
| 511 } | 540 } |
| 512 | 541 |
| 513 | 542 |
| 514 void JoinEntryInstr::PrintToVisualizer(BufferFormatter* f) const { | 543 void JoinEntryInstr::PrintToVisualizer(BufferFormatter* f) const { |
| 515 f->Print("_ [join]"); | 544 f->Print("_ [join]"); |
| 516 } | 545 } |
| 517 | 546 |
| 518 | 547 |
| 548 void PhiInstr::PrintToVisualizer(BufferFormatter* f) const { |
| 549 // TODO(fschneider): Print operands when SSA renaming is implemented. |
| 550 f->Print("v ["); |
| 551 for (intptr_t i = 0; i < InputCount(); ++i) { |
| 552 f->Print(" v "); |
| 553 } |
| 554 f->Print("]"); |
| 555 } |
| 556 |
| 557 |
| 519 void TargetEntryInstr::PrintToVisualizer(BufferFormatter* f) const { | 558 void TargetEntryInstr::PrintToVisualizer(BufferFormatter* f) const { |
| 520 f->Print("_ [target"); | 559 f->Print("_ [target"); |
| 521 if (HasTryIndex()) { | 560 if (HasTryIndex()) { |
| 522 f->Print(" catch %d]", try_index()); | 561 f->Print(" catch %d]", try_index()); |
| 523 } else { | 562 } else { |
| 524 f->Print("]"); | 563 f->Print("]"); |
| 525 } | 564 } |
| 526 } | 565 } |
| 527 | 566 |
| 528 | 567 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 f->Print("_ %s ", DebugName()); | 601 f->Print("_ %s ", DebugName()); |
| 563 f->Print("if "); | 602 f->Print("if "); |
| 564 value()->PrintTo(f); | 603 value()->PrintTo(f); |
| 565 f->Print(" goto (B%d, B%d)", | 604 f->Print(" goto (B%d, B%d)", |
| 566 true_successor()->block_id(), | 605 true_successor()->block_id(), |
| 567 false_successor()->block_id()); | 606 false_successor()->block_id()); |
| 568 } | 607 } |
| 569 | 608 |
| 570 | 609 |
| 571 } // namespace dart | 610 } // namespace dart |
| OLD | NEW |