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

Side by Side Diff: runtime/vm/il_printer.cc

Issue 10915141: Repair flow graph printing after graph refactoring. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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 | « runtime/vm/flow_graph.cc ('k') | runtime/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 #include "vm/parser.h" 9 #include "vm/parser.h"
10 10
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 instr->PrintTo(&f); 70 instr->PrintTo(&f);
71 if (FLAG_print_environments && (instr->env() != NULL)) { 71 if (FLAG_print_environments && (instr->env() != NULL)) {
72 instr->env()->PrintTo(&f); 72 instr->env()->PrintTo(&f);
73 } 73 }
74 if (print_locations && (instr->locs() != NULL)) { 74 if (print_locations && (instr->locs() != NULL)) {
75 instr->locs()->PrintTo(&f); 75 instr->locs()->PrintTo(&f);
76 } 76 }
77 if (instr->lifetime_position() != -1) { 77 if (instr->lifetime_position() != -1) {
78 OS::Print("%3"Pd": ", instr->lifetime_position()); 78 OS::Print("%3"Pd": ", instr->lifetime_position());
79 } 79 }
80 if (!instr->IsBlockEntry()) OS::Print(" ");
80 OS::Print("%s", str); 81 OS::Print("%s", str);
81 } 82 }
82 83
83 84
84 void FlowGraphPrinter::PrintTypeCheck(const ParsedFunction& parsed_function, 85 void FlowGraphPrinter::PrintTypeCheck(const ParsedFunction& parsed_function,
85 intptr_t token_pos, 86 intptr_t token_pos,
86 Value* value, 87 Value* value,
87 const AbstractType& dst_type, 88 const AbstractType& dst_type,
88 const String& dst_name, 89 const String& dst_name,
89 bool eliminated) { 90 bool eliminated) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 } 122 }
122 const Class& cls = 123 const Class& cls =
123 Class::Handle(Isolate::Current()->class_table()->At(class_ids[k])); 124 Class::Handle(Isolate::Current()->class_table()->At(class_ids[k]));
124 f->Print("%s", String::Handle(cls.Name()).ToCString()); 125 f->Print("%s", String::Handle(cls.Name()).ToCString());
125 } 126 }
126 } 127 }
127 f->Print("]"); 128 f->Print("]");
128 } 129 }
129 130
130 131
132 static void PrintPropagatedType(BufferFormatter* f, const Definition& def) {
133 if (def.HasPropagatedType()) {
134 String& name = String::Handle();
135 name = AbstractType::Handle(def.PropagatedType()).Name();
136 f->Print(" {PT: %s}", name.ToCString());
137 }
138 if (def.has_propagated_cid()) {
139 const Class& cls = Class::Handle(
140 Isolate::Current()->class_table()->At(def.propagated_cid()));
141 f->Print(" {PCid: %s}", String::Handle(cls.Name()).ToCString());
142 }
143 }
144
145
146 static void PrintUse(BufferFormatter* f, const Definition& definition) {
147 if (definition.is_used()) {
148 if (definition.HasSSATemp()) {
149 f->Print("v%"Pd, definition.ssa_temp_index());
150 } else if (definition.temp_index() != -1) {
151 f->Print("t%"Pd, definition.temp_index());
152 }
153 }
154 }
155
156
131 void Definition::PrintTo(BufferFormatter* f) const { 157 void Definition::PrintTo(BufferFormatter* f) const {
132 // Do not access 'deopt_id()' as it asserts that the computation can 158 PrintUse(f, *this);
133 // deoptimize. 159 if (is_used()) {
134 if (HasSSATemp()) { 160 if (HasSSATemp() || (temp_index() != -1)) f->Print(" <- ");
135 f->Print("v%"Pd" <- ", ssa_temp_index());
136 } 161 }
137 f->Print("%s:%"Pd"(", DebugName(), deopt_id_); 162 f->Print("%s:%"Pd"(", DebugName(), GetDeoptId());
138 PrintOperandsTo(f); 163 PrintOperandsTo(f);
139 f->Print(")"); 164 f->Print(")");
165 PrintPropagatedType(f, *this);
140 } 166 }
141 167
142 168
143 void Definition::PrintOperandsTo(BufferFormatter* f) const { 169 void Definition::PrintOperandsTo(BufferFormatter* f) const {
144 for (int i = 0; i < InputCount(); ++i) { 170 for (int i = 0; i < InputCount(); ++i) {
145 if (i > 0) f->Print(", "); 171 if (i > 0) f->Print(", ");
146 if (InputAt(i) != NULL) InputAt(i)->PrintTo(f); 172 if (InputAt(i) != NULL) InputAt(i)->PrintTo(f);
147 } 173 }
148 } 174 }
149 175
150 176
151 void Definition::PrintToVisualizer(BufferFormatter* f) const { 177 void Definition::PrintToVisualizer(BufferFormatter* f) const {
152 PrintTo(f); 178 PrintTo(f);
153 } 179 }
154 180
155 181
156 void Value::PrintTo(BufferFormatter* f) const { 182 void Value::PrintTo(BufferFormatter* f) const {
157 if (definition()->HasSSATemp()) { 183 PrintUse(f, *definition());
158 f->Print("v%"Pd"", definition()->ssa_temp_index());
159 } else {
160 f->Print("t%"Pd"", definition()->temp_index());
161 }
162 } 184 }
163 185
164 186
165 void ConstantInstr::PrintOperandsTo(BufferFormatter* f) const { 187 void ConstantInstr::PrintOperandsTo(BufferFormatter* f) const {
166 f->Print("#%s", value().ToCString()); 188 f->Print("#%s", value().ToCString());
167 } 189 }
168 190
169 191
170 void AssertAssignableInstr::PrintOperandsTo(BufferFormatter* f) const { 192 void AssertAssignableInstr::PrintOperandsTo(BufferFormatter* f) const {
171 value()->PrintTo(f); 193 value()->PrintTo(f);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 for (intptr_t i = 0; i < ArgumentCount(); ++i) { 231 for (intptr_t i = 0; i < ArgumentCount(); ++i) {
210 f->Print(", "); 232 f->Print(", ");
211 ArgumentAt(i)->value()->PrintTo(f); 233 ArgumentAt(i)->value()->PrintTo(f);
212 } 234 }
213 if (HasICData()) { 235 if (HasICData()) {
214 PrintICData(f, *ic_data()); 236 PrintICData(f, *ic_data());
215 } 237 }
216 } 238 }
217 239
218 240
219 void PolymorphicInstanceCallInstr::PrintTo(BufferFormatter* f) const { 241 void PolymorphicInstanceCallInstr::PrintOperandsTo(BufferFormatter* f) const {
220 f->Print("%s(", DebugName());
221 instance_call()->PrintOperandsTo(f); 242 instance_call()->PrintOperandsTo(f);
222 f->Print(") ");
223 PrintICData(f, ic_data()); 243 PrintICData(f, ic_data());
224 } 244 }
225 245
226 246
227 void StrictCompareInstr::PrintOperandsTo(BufferFormatter* f) const { 247 void StrictCompareInstr::PrintOperandsTo(BufferFormatter* f) const {
228 f->Print("%s, ", Token::Str(kind())); 248 f->Print("%s, ", Token::Str(kind()));
229 left()->PrintTo(f); 249 left()->PrintTo(f);
230 f->Print(", "); 250 f->Print(", ");
231 right()->PrintTo(f); 251 right()->PrintTo(f);
232 } 252 }
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 } 446 }
427 447
428 448
429 void CheckClassInstr::PrintOperandsTo(BufferFormatter* f) const { 449 void CheckClassInstr::PrintOperandsTo(BufferFormatter* f) const {
430 value()->PrintTo(f); 450 value()->PrintTo(f);
431 PrintICData(f, unary_checks()); 451 PrintICData(f, unary_checks());
432 } 452 }
433 453
434 454
435 void GraphEntryInstr::PrintTo(BufferFormatter* f) const { 455 void GraphEntryInstr::PrintTo(BufferFormatter* f) const {
436 f->Print("%2"Pd": [graph]", block_id()); 456 f->Print("B%"Pd"[graph]", block_id());
437 if (start_env_ != NULL) { 457 if ((constant_null() != NULL) || (start_env() != NULL)) {
438 f->Print("\n{\n"); 458 f->Print(" {");
439 const GrowableArray<Value*>& values = start_env_->values(); 459 if (constant_null() != NULL) {
440 for (intptr_t i = 0; i < values.length(); i++) { 460 f->Print("\n ");
441 Definition* def = values[i]->definition(); 461 constant_null()->PrintTo(f);
442 f->Print(" ");
443 def->PrintTo(f);
444 f->Print("\n");
445 } 462 }
446 f->Print("} "); 463 if (start_env() != NULL) {
447 start_env_->PrintTo(f); 464 for (intptr_t i = 0; i < start_env()->values().length(); ++i) {
465 Definition* def = start_env()->values()[i]->definition();
466 if (def->IsParameter()) {
467 f->Print("\n ");
468 def->PrintTo(f);
469 }
470 }
471 }
472 f->Print("\n}");
448 } 473 }
449 } 474 }
450 475
451 476
452 void JoinEntryInstr::PrintTo(BufferFormatter* f) const { 477 void JoinEntryInstr::PrintTo(BufferFormatter* f) const {
453 f->Print("%2"Pd": [join]", block_id()); 478 f->Print("B%"Pd"[join]", block_id());
454 if (phis_ != NULL) { 479 if (phis_ != NULL) {
480 f->Print(" {");
455 for (intptr_t i = 0; i < phis_->length(); ++i) { 481 for (intptr_t i = 0; i < phis_->length(); ++i) {
456 if ((*phis_)[i] == NULL) continue; 482 if ((*phis_)[i] == NULL) continue;
457 f->Print("\n"); 483 f->Print("\n ");
458 (*phis_)[i]->PrintTo(f); 484 (*phis_)[i]->PrintTo(f);
459 } 485 }
486 f->Print("\n}");
460 } 487 }
461 if (HasParallelMove()) { 488 if (HasParallelMove()) {
462 f->Print("\n"); 489 f->Print(" ");
463 parallel_move()->PrintTo(f); 490 parallel_move()->PrintTo(f);
464 } 491 }
465 } 492 }
466 493
467 494
468 static void PrintPropagatedType(BufferFormatter* f, const Definition& def) {
469 if (def.HasPropagatedType()) {
470 String& name = String::Handle();
471 name = AbstractType::Handle(def.PropagatedType()).Name();
472 f->Print(" {PT: %s}", name.ToCString());
473 }
474 if (def.has_propagated_cid()) {
475 const Class& cls = Class::Handle(
476 Isolate::Current()->class_table()->At(def.propagated_cid()));
477 f->Print(" {PCid: %s}", String::Handle(cls.Name()).ToCString());
478 }
479 }
480
481
482 void PhiInstr::PrintTo(BufferFormatter* f) const { 495 void PhiInstr::PrintTo(BufferFormatter* f) const {
483 f->Print(" v%"Pd" <- phi(", ssa_temp_index()); 496 f->Print("v%"Pd" <- phi(", ssa_temp_index());
484 for (intptr_t i = 0; i < inputs_.length(); ++i) { 497 for (intptr_t i = 0; i < inputs_.length(); ++i) {
485 if (inputs_[i] != NULL) inputs_[i]->PrintTo(f); 498 if (inputs_[i] != NULL) inputs_[i]->PrintTo(f);
486 if (i < inputs_.length() - 1) f->Print(", "); 499 if (i < inputs_.length() - 1) f->Print(", ");
487 } 500 }
488 f->Print(")"); 501 f->Print(")");
489 PrintPropagatedType(f, *this); 502 PrintPropagatedType(f, *this);
490 } 503 }
491 504
492 505
493 void ParameterInstr::PrintTo(BufferFormatter* f) const { 506 void ParameterInstr::PrintOperandsTo(BufferFormatter* f) const {
494 f->Print(" v%"Pd" <- parameter(%"Pd")", 507 f->Print("%"Pd, index());
495 HasSSATemp() ? ssa_temp_index() : temp_index(),
496 index());
497 PrintPropagatedType(f, *this);
498 } 508 }
499 509
500 510
501 void TargetEntryInstr::PrintTo(BufferFormatter* f) const { 511 void TargetEntryInstr::PrintTo(BufferFormatter* f) const {
502 f->Print("%2"Pd": [target", block_id()); 512 f->Print("B%"Pd"[target", block_id());
503 if (IsCatchEntry()) { 513 if (IsCatchEntry()) {
504 f->Print(" catch %"Pd"]", catch_try_index()); 514 f->Print(" catch %"Pd"]", catch_try_index());
505 } else { 515 } else {
506 f->Print("]"); 516 f->Print("]");
507 } 517 }
508 if (HasParallelMove()) { 518 if (HasParallelMove()) {
509 f->Print("\n"); 519 f->Print(" ");
510 parallel_move()->PrintTo(f); 520 parallel_move()->PrintTo(f);
511 } 521 }
512 } 522 }
513 523
514 524
515 void PushArgumentInstr::PrintTo(BufferFormatter* f) const { 525 void PushArgumentInstr::PrintOperandsTo(BufferFormatter* f) const {
516 f->Print(" %s ", DebugName());
517 value()->PrintTo(f); 526 value()->PrintTo(f);
518 } 527 }
519 528
520 529
521 void ReturnInstr::PrintTo(BufferFormatter* f) const { 530 void ReturnInstr::PrintTo(BufferFormatter* f) const {
522 f->Print(" %s ", DebugName()); 531 f->Print("%s ", DebugName());
523 value()->PrintTo(f); 532 value()->PrintTo(f);
524 } 533 }
525 534
526 535
527 void ThrowInstr::PrintTo(BufferFormatter* f) const { 536 void ThrowInstr::PrintTo(BufferFormatter* f) const {
528 f->Print(" %s" , DebugName()); 537 f->Print("%s" , DebugName());
529 } 538 }
530 539
531 540
532 void ReThrowInstr::PrintTo(BufferFormatter* f) const { 541 void ReThrowInstr::PrintTo(BufferFormatter* f) const {
533 f->Print(" %s ", DebugName()); 542 f->Print("%s ", DebugName());
534 } 543 }
535 544
536 545
537 void GotoInstr::PrintTo(BufferFormatter* f) const { 546 void GotoInstr::PrintTo(BufferFormatter* f) const {
538 if (HasParallelMove()) { 547 if (HasParallelMove()) {
539 parallel_move()->PrintTo(f); 548 parallel_move()->PrintTo(f);
540 } else { 549 f->Print(" ");
541 f->Print(" ");
542 } 550 }
543 f->Print(" goto:%"Pd" %"Pd"", GetDeoptId(), successor()->block_id()); 551 f->Print("goto:%"Pd" %"Pd"", GetDeoptId(), successor()->block_id());
544 } 552 }
545 553
546 554
547 void BranchInstr::PrintTo(BufferFormatter* f) const { 555 void BranchInstr::PrintTo(BufferFormatter* f) const {
548 f->Print(" %s ", DebugName()); 556 f->Print("%s ", DebugName());
549 f->Print("if "); 557 f->Print("if ");
550 comparison()->PrintTo(f); 558 comparison()->PrintTo(f);
551 559
552 f->Print(" goto (%"Pd", %"Pd")", 560 f->Print(" goto (%"Pd", %"Pd")",
553 true_successor()->block_id(), 561 true_successor()->block_id(),
554 false_successor()->block_id()); 562 false_successor()->block_id());
555 } 563 }
556 564
557 565
558 void ParallelMoveInstr::PrintTo(BufferFormatter* f) const { 566 void ParallelMoveInstr::PrintTo(BufferFormatter* f) const {
559 f->Print(" %s ", DebugName()); 567 f->Print("%s ", DebugName());
560 for (intptr_t i = 0; i < moves_.length(); i++) { 568 for (intptr_t i = 0; i < moves_.length(); i++) {
561 if (i != 0) f->Print(", "); 569 if (i != 0) f->Print(", ");
562 moves_[i]->dest().PrintTo(f); 570 moves_[i]->dest().PrintTo(f);
563 f->Print(" <- "); 571 f->Print(" <- ");
564 moves_[i]->src().PrintTo(f); 572 moves_[i]->src().PrintTo(f);
565 } 573 }
566 } 574 }
567 575
568 576
569 void FlowGraphVisualizer::Print(const char* format, ...) { 577 void FlowGraphVisualizer::Print(const char* format, ...) {
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 if ((locations_ != NULL) && !locations_[i].IsInvalid()) { 800 if ((locations_ != NULL) && !locations_[i].IsInvalid()) {
793 f->Print(" ["); 801 f->Print(" [");
794 locations_[i].PrintTo(f); 802 locations_[i].PrintTo(f);
795 f->Print("]"); 803 f->Print("]");
796 } 804 }
797 } 805 }
798 f->Print(" }"); 806 f->Print(" }");
799 } 807 }
800 808
801 } // namespace dart 809 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph.cc ('k') | runtime/vm/intermediate_language.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698