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

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

Issue 12260008: Reapply r18377 it was reverted due to the unrelated bug it surfaced. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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
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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 OS::Print("%s", str); 81 OS::Print("%s", str);
82 } 82 }
83 83
84 84
85 void FlowGraphPrinter::PrintTypeCheck(const ParsedFunction& parsed_function, 85 void FlowGraphPrinter::PrintTypeCheck(const ParsedFunction& parsed_function,
86 intptr_t token_pos, 86 intptr_t token_pos,
87 Value* value, 87 Value* value,
88 const AbstractType& dst_type, 88 const AbstractType& dst_type,
89 const String& dst_name, 89 const String& dst_name,
90 bool eliminated) { 90 bool eliminated) {
91 const Script& script = Script::Handle(parsed_function.function().script());
92 const char* compile_type_name = "unknown"; 91 const char* compile_type_name = "unknown";
93 if (value != NULL) { 92 if (value != NULL) {
94 const AbstractType& type = AbstractType::Handle(value->CompileType()); 93 compile_type_name = value->Type()->ToCString();
95 if (!type.IsNull()) {
96 compile_type_name = String::Handle(type.Name()).ToCString();
97 }
98 } 94 }
99 Parser::PrintMessage(script, token_pos, "", 95 OS::Print("%s type check: compile type %s is %s specific than "
100 "%s type check: compile type '%s' is %s specific than " 96 "type '%s' of '%s'.\n",
101 "type '%s' of '%s'.",
102 eliminated ? "Eliminated" : "Generated", 97 eliminated ? "Eliminated" : "Generated",
103 compile_type_name, 98 compile_type_name,
104 eliminated ? "more" : "not more", 99 eliminated ? "more" : "not more",
105 String::Handle(dst_type.Name()).ToCString(), 100 String::Handle(dst_type.Name()).ToCString(),
106 dst_name.ToCString()); 101 dst_name.ToCString());
107 } 102 }
108 103
109 104
105 void CompileType::PrintTo(BufferFormatter* f) const {
106 f->Print("T{");
107 f->Print("%s, ", is_nullable_ ? "null" : "not-null");
108 if (cid_ != kIllegalCid) {
109 const Class& cls =
110 Class::Handle(Isolate::Current()->class_table()->At(cid_));
111 f->Print("%s, ", String::Handle(cls.Name()).ToCString());
112 } else {
113 f->Print("?, ");
114 }
115 f->Print("%s}", (type_ != NULL) ? String::Handle(type_->Name()).ToCString()
116 : "?");
117 }
118
119
120 const char* CompileType::ToCString() const {
121 char buffer[1024];
122 BufferFormatter f(buffer, sizeof(buffer));
123 PrintTo(&f);
124 return Isolate::Current()->current_zone()->MakeCopyOfString(buffer);
125 }
126
127
128
129
110 static void PrintICData(BufferFormatter* f, const ICData& ic_data) { 130 static void PrintICData(BufferFormatter* f, const ICData& ic_data) {
111 f->Print(" IC[%"Pd": ", ic_data.NumberOfChecks()); 131 f->Print(" IC[%"Pd": ", ic_data.NumberOfChecks());
112 Function& target = Function::Handle(); 132 Function& target = Function::Handle();
113 for (intptr_t i = 0; i < ic_data.NumberOfChecks(); i++) { 133 for (intptr_t i = 0; i < ic_data.NumberOfChecks(); i++) {
114 GrowableArray<intptr_t> class_ids; 134 GrowableArray<intptr_t> class_ids;
115 ic_data.GetCheckAt(i, &class_ids, &target); 135 ic_data.GetCheckAt(i, &class_ids, &target);
116 const intptr_t count = ic_data.GetCountAt(i); 136 const intptr_t count = ic_data.GetCountAt(i);
117 if (i > 0) { 137 if (i > 0) {
118 f->Print(" | "); 138 f->Print(" | ");
119 } 139 }
120 for (intptr_t k = 0; k < class_ids.length(); k++) { 140 for (intptr_t k = 0; k < class_ids.length(); k++) {
121 if (k > 0) { 141 if (k > 0) {
122 f->Print(", "); 142 f->Print(", ");
123 } 143 }
124 const Class& cls = 144 const Class& cls =
125 Class::Handle(Isolate::Current()->class_table()->At(class_ids[k])); 145 Class::Handle(Isolate::Current()->class_table()->At(class_ids[k]));
126 f->Print("%s", String::Handle(cls.Name()).ToCString()); 146 f->Print("%s", String::Handle(cls.Name()).ToCString());
127 } 147 }
128 if (count > 0) { 148 if (count > 0) {
129 f->Print(" #%"Pd, count); 149 f->Print(" #%"Pd, count);
130 } 150 }
131 f->Print(" <%p>", static_cast<void*>(target.raw())); 151 f->Print(" <%p>", static_cast<void*>(target.raw()));
132 } 152 }
133 f->Print("]"); 153 f->Print("]");
134 } 154 }
135 155
136 156
137 static void PrintPropagatedType(BufferFormatter* f, const Definition& def) {
138 if (def.HasPropagatedType()) {
139 String& name = String::Handle();
140 name = AbstractType::Handle(def.PropagatedType()).Name();
141 f->Print(" {PT: %s}", name.ToCString());
142 }
143 if (def.has_propagated_cid()) {
144 const Class& cls = Class::Handle(
145 Isolate::Current()->class_table()->At(def.propagated_cid()));
146 f->Print(" {PCid: %s}", String::Handle(cls.Name()).ToCString());
147 }
148 }
149
150
151 static void PrintUse(BufferFormatter* f, const Definition& definition) { 157 static void PrintUse(BufferFormatter* f, const Definition& definition) {
152 if (definition.is_used()) { 158 if (definition.is_used()) {
153 if (definition.HasSSATemp()) { 159 if (definition.HasSSATemp()) {
154 f->Print("v%"Pd, definition.ssa_temp_index()); 160 f->Print("v%"Pd, definition.ssa_temp_index());
155 } else if (definition.temp_index() != -1) { 161 } else if (definition.temp_index() != -1) {
156 f->Print("t%"Pd, definition.temp_index()); 162 f->Print("t%"Pd, definition.temp_index());
157 } 163 }
158 } 164 }
159 } 165 }
160 166
(...skipping 14 matching lines...) Expand all
175 181
176 182
177 void Definition::PrintTo(BufferFormatter* f) const { 183 void Definition::PrintTo(BufferFormatter* f) const {
178 PrintUse(f, *this); 184 PrintUse(f, *this);
179 if (is_used()) { 185 if (is_used()) {
180 if (HasSSATemp() || (temp_index() != -1)) f->Print(" <- "); 186 if (HasSSATemp() || (temp_index() != -1)) f->Print(" <- ");
181 } 187 }
182 f->Print("%s:%"Pd"(", DebugName(), GetDeoptId()); 188 f->Print("%s:%"Pd"(", DebugName(), GetDeoptId());
183 PrintOperandsTo(f); 189 PrintOperandsTo(f);
184 f->Print(")"); 190 f->Print(")");
185 PrintPropagatedType(f, *this);
186 if (range_ != NULL) { 191 if (range_ != NULL) {
187 f->Print(" "); 192 f->Print(" ");
188 range_->PrintTo(f); 193 range_->PrintTo(f);
189 } 194 }
195
196 if (type_ != NULL) {
197 f->Print(" ");
198 type_->PrintTo(f);
199 }
190 } 200 }
191 201
192 202
193 void Definition::PrintOperandsTo(BufferFormatter* f) const { 203 void Definition::PrintOperandsTo(BufferFormatter* f) const {
194 for (int i = 0; i < InputCount(); ++i) { 204 for (int i = 0; i < InputCount(); ++i) {
195 if (i > 0) f->Print(", "); 205 if (i > 0) f->Print(", ");
196 if (InputAt(i) != NULL) InputAt(i)->PrintTo(f); 206 if (InputAt(i) != NULL) InputAt(i)->PrintTo(f);
197 } 207 }
198 } 208 }
199 209
200 210
201 void Value::PrintTo(BufferFormatter* f) const { 211 void Value::PrintTo(BufferFormatter* f) const {
202 PrintUse(f, *definition()); 212 PrintUse(f, *definition());
213 if ((reaching_type_ != NULL) &&
214 (reaching_type_ != definition()->Type())) {
215 f->Print(" ");
216 reaching_type_->PrintTo(f);
217 }
203 } 218 }
204 219
205 220
206 void ConstantInstr::PrintOperandsTo(BufferFormatter* f) const { 221 void ConstantInstr::PrintOperandsTo(BufferFormatter* f) const {
207 const char* cstr = value().ToCString(); 222 const char* cstr = value().ToCString();
208 const char* new_line = strchr(cstr, '\n'); 223 const char* new_line = strchr(cstr, '\n');
209 if (new_line == NULL) { 224 if (new_line == NULL) {
210 f->Print("#%s", cstr); 225 f->Print("#%s", cstr);
211 } else { 226 } else {
212 const intptr_t pos = new_line - cstr; 227 const intptr_t pos = new_line - cstr;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 const char* RangeBoundary::ToCString() const { 284 const char* RangeBoundary::ToCString() const {
270 char buffer[256]; 285 char buffer[256];
271 BufferFormatter f(buffer, sizeof(buffer)); 286 BufferFormatter f(buffer, sizeof(buffer));
272 PrintTo(&f); 287 PrintTo(&f);
273 return Isolate::Current()->current_zone()->MakeCopyOfString(buffer); 288 return Isolate::Current()->current_zone()->MakeCopyOfString(buffer);
274 } 289 }
275 290
276 291
277 void AssertAssignableInstr::PrintOperandsTo(BufferFormatter* f) const { 292 void AssertAssignableInstr::PrintOperandsTo(BufferFormatter* f) const {
278 value()->PrintTo(f); 293 value()->PrintTo(f);
279 f->Print(", %s, '%s'%s", 294 f->Print(", %s, '%s'",
280 String::Handle(dst_type().Name()).ToCString(), 295 dst_type().ToCString(),
281 dst_name().ToCString(), 296 dst_name().ToCString());
282 is_eliminated() ? " eliminated" : "");
283 f->Print(" instantiator("); 297 f->Print(" instantiator(");
284 instantiator()->PrintTo(f); 298 instantiator()->PrintTo(f);
285 f->Print(")"); 299 f->Print(")");
286 f->Print(" instantiator_type_arguments("); 300 f->Print(" instantiator_type_arguments(");
287 instantiator_type_arguments()->PrintTo(f); 301 instantiator_type_arguments()->PrintTo(f);
288 f->Print(")"); 302 f->Print(")");
289 } 303 }
290 304
291 305
292 void AssertBooleanInstr::PrintOperandsTo(BufferFormatter* f) const { 306 void AssertBooleanInstr::PrintOperandsTo(BufferFormatter* f) const {
293 value()->PrintTo(f); 307 value()->PrintTo(f);
294 f->Print("%s", is_eliminated() ? " eliminated" : "");
295 } 308 }
296 309
297 310
298 void ArgumentDefinitionTestInstr::PrintOperandsTo(BufferFormatter* f) const { 311 void ArgumentDefinitionTestInstr::PrintOperandsTo(BufferFormatter* f) const {
299 saved_arguments_descriptor()->PrintTo(f); 312 saved_arguments_descriptor()->PrintTo(f);
300 f->Print(", ?%s @%"Pd"", 313 f->Print(", ?%s @%"Pd"",
301 formal_parameter_name().ToCString(), 314 formal_parameter_name().ToCString(),
302 formal_parameter_index()); 315 formal_parameter_index());
303 } 316 }
304 317
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 } 613 }
601 614
602 615
603 void PhiInstr::PrintTo(BufferFormatter* f) const { 616 void PhiInstr::PrintTo(BufferFormatter* f) const {
604 f->Print("v%"Pd" <- phi(", ssa_temp_index()); 617 f->Print("v%"Pd" <- phi(", ssa_temp_index());
605 for (intptr_t i = 0; i < inputs_.length(); ++i) { 618 for (intptr_t i = 0; i < inputs_.length(); ++i) {
606 if (inputs_[i] != NULL) inputs_[i]->PrintTo(f); 619 if (inputs_[i] != NULL) inputs_[i]->PrintTo(f);
607 if (i < inputs_.length() - 1) f->Print(", "); 620 if (i < inputs_.length() - 1) f->Print(", ");
608 } 621 }
609 f->Print(")"); 622 f->Print(")");
610 PrintPropagatedType(f, *this);
611 if (is_alive()) { 623 if (is_alive()) {
612 f->Print(" alive"); 624 f->Print(" alive");
613 } else { 625 } else {
614 f->Print(" dead"); 626 f->Print(" dead");
615 } 627 }
616 if (range_ != NULL) { 628 if (range_ != NULL) {
617 f->Print(" "); 629 f->Print(" ");
618 range_->PrintTo(f); 630 range_->PrintTo(f);
619 } 631 }
632 if (type_ != NULL) {
633 f->Print(" ");
634 type_->PrintTo(f);
635 }
620 } 636 }
621 637
622 638
623 void ParameterInstr::PrintOperandsTo(BufferFormatter* f) const { 639 void ParameterInstr::PrintOperandsTo(BufferFormatter* f) const {
624 f->Print("%"Pd, index()); 640 f->Print("%"Pd, index());
625 } 641 }
626 642
627 643
628 void TargetEntryInstr::PrintTo(BufferFormatter* f) const { 644 void TargetEntryInstr::PrintTo(BufferFormatter* f) const {
629 f->Print("B%"Pd"[target", block_id()); 645 f->Print("B%"Pd"[target", block_id());
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 f->Print(" ["); 705 f->Print(" [");
690 locations_[i].PrintTo(f); 706 locations_[i].PrintTo(f);
691 f->Print("]"); 707 f->Print("]");
692 } 708 }
693 } 709 }
694 f->Print(" }"); 710 f->Print(" }");
695 if (outer_ != NULL) outer_->PrintTo(f); 711 if (outer_ != NULL) outer_->PrintTo(f);
696 } 712 }
697 713
698 } // namespace dart 714 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698