Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: vm/il_printer.cc

Issue 10692107: Add forward iterator to iterate instructions inside a basic block. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « vm/flow_graph_builder.cc ('k') | vm/intermediate_language.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 21 matching lines...) Expand all
32 32
33 33
34 void FlowGraphPrinter::PrintBlocks() { 34 void FlowGraphPrinter::PrintBlocks() {
35 if (!function_.IsNull()) { 35 if (!function_.IsNull()) {
36 OS::Print("==== %s\n", function_.ToFullyQualifiedCString()); 36 OS::Print("==== %s\n", function_.ToFullyQualifiedCString());
37 } 37 }
38 38
39 for (intptr_t i = 0; i < block_order_.length(); ++i) { 39 for (intptr_t i = 0; i < block_order_.length(); ++i) {
40 // Print the block entry. 40 // Print the block entry.
41 PrintInstruction(block_order_[i]); 41 PrintInstruction(block_order_[i]);
42 Instruction* current = block_order_[i]->successor();
43 // And all the successors until an exit, branch, or a block entry. 42 // And all the successors until an exit, branch, or a block entry.
44 while ((current != NULL) && !current->IsBlockEntry()) { 43 Instruction* current = block_order_[i];
44 for (ForwardInstructionIterator it(current->AsBlockEntry());
45 !it.Done();
46 it.Advance()) {
47 current = it.Current();
45 OS::Print("\n"); 48 OS::Print("\n");
46 PrintInstruction(current); 49 PrintInstruction(current);
47 current = current->successor();
48 } 50 }
49 BlockEntryInstr* successor = 51 if (current->successor() != NULL) {
50 (current == NULL) ? NULL : current->AsBlockEntry(); 52 ASSERT(current->successor()->IsBlockEntry());
51 if (successor != NULL) { 53 OS::Print(" goto %d", current->successor()->AsBlockEntry()->block_id());
52 OS::Print(" goto %d", successor->block_id());
53 } 54 }
54 OS::Print("\n"); 55 OS::Print("\n");
55 } 56 }
56 } 57 }
57 58
58 59
59 void FlowGraphPrinter::PrintInstruction(Instruction* instr) { 60 void FlowGraphPrinter::PrintInstruction(Instruction* instr) {
60 char str[1000]; 61 char str[1000];
61 BufferFormatter f(str, sizeof(str)); 62 BufferFormatter f(str, sizeof(str));
62 instr->PrintTo(&f); 63 instr->PrintTo(&f);
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 } 522 }
522 END("locals"); 523 END("locals");
523 } 524 }
524 END("states"); 525 END("states");
525 } 526 }
526 527
527 { 528 {
528 BEGIN("HIR"); 529 BEGIN("HIR");
529 // Print the block entry. 530 // Print the block entry.
530 Print("0 0 "); // Required fields "bci" and "use". Unused. 531 Print("0 0 "); // Required fields "bci" and "use". Unused.
532 PrintInstruction(block_order_[i]);
533 // And all the successors until an exit, branch, or a block entry.
531 Instruction* current = block_order_[i]; 534 Instruction* current = block_order_[i];
532 PrintInstruction(current); 535 for (ForwardInstructionIterator it(current->AsBlockEntry());
533 current = current->successor(); 536 !it.Done();
534 // And all the successors until an exit, branch, or a block entry. 537 it.Advance()) {
535 while ((current != NULL) && !current->IsBlockEntry()) { 538 current = it.Current();
536 Print("0 0 "); 539 Print("0 0 ");
537 PrintInstruction(current); 540 PrintInstruction(current);
538 current = current->successor();
539 } 541 }
540 BlockEntryInstr* successor = 542 if (current->successor() != NULL) {
541 (current == NULL) ? NULL : current->AsBlockEntry(); 543 ASSERT(current->successor()->IsBlockEntry());
542 if (successor != NULL) { 544 Print("0 0 _ Goto B%d <|@\n",
543 Print("0 0 _ Goto B%d <|@\n", successor->block_id()); 545 current->successor()->AsBlockEntry()->block_id());
544 } 546 }
545 END("HIR"); 547 END("HIR");
546 } 548 }
547 END("block"); 549 END("block");
548 } 550 }
549 END("cfg"); 551 END("cfg");
550 } 552 }
551 #undef BEGIN 553 #undef BEGIN
552 #undef END 554 #undef END
553 } 555 }
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 void Environment::PrintTo(BufferFormatter* f) const { 666 void Environment::PrintTo(BufferFormatter* f) const {
665 f->Print(" env={ "); 667 f->Print(" env={ ");
666 for (intptr_t i = 0; i < values_.length(); ++i) { 668 for (intptr_t i = 0; i < values_.length(); ++i) {
667 if (i > 0) f->Print(", "); 669 if (i > 0) f->Print(", ");
668 values_[i]->PrintTo(f); 670 values_[i]->PrintTo(f);
669 } 671 }
670 f->Print(" }"); 672 f->Print(" }");
671 } 673 }
672 674
673 } // namespace dart 675 } // namespace dart
OLDNEW
« no previous file with comments | « vm/flow_graph_builder.cc ('k') | vm/intermediate_language.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698