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

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

Issue 2974233002: VM: Re-format to use at most one newline between functions (Closed)
Patch Set: Rebase and merge Created 3 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
« no previous file with comments | « runtime/vm/il_printer.h ('k') | runtime/vm/instructions_arm.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/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 14 matching lines...) Expand all
25 25
26 DECLARE_FLAG(bool, trace_inlining_intervals); 26 DECLARE_FLAG(bool, trace_inlining_intervals);
27 27
28 void BufferFormatter::Print(const char* format, ...) { 28 void BufferFormatter::Print(const char* format, ...) {
29 va_list args; 29 va_list args;
30 va_start(args, format); 30 va_start(args, format);
31 VPrint(format, args); 31 VPrint(format, args);
32 va_end(args); 32 va_end(args);
33 } 33 }
34 34
35
36 void BufferFormatter::VPrint(const char* format, va_list args) { 35 void BufferFormatter::VPrint(const char* format, va_list args) {
37 intptr_t available = size_ - position_; 36 intptr_t available = size_ - position_;
38 if (available <= 0) return; 37 if (available <= 0) return;
39 intptr_t written = OS::VSNPrint(buffer_ + position_, available, format, args); 38 intptr_t written = OS::VSNPrint(buffer_ + position_, available, format, args);
40 if (written >= 0) { 39 if (written >= 0) {
41 position_ += (available <= written) ? available : written; 40 position_ += (available <= written) ? available : written;
42 } 41 }
43 } 42 }
44 43
45
46 // Checks whether function's name matches the given filter, which is 44 // Checks whether function's name matches the given filter, which is
47 // a comma-separated list of strings. 45 // a comma-separated list of strings.
48 bool FlowGraphPrinter::PassesFilter(const char* filter, 46 bool FlowGraphPrinter::PassesFilter(const char* filter,
49 const Function& function) { 47 const Function& function) {
50 if (filter == NULL) { 48 if (filter == NULL) {
51 return true; 49 return true;
52 } 50 }
53 51
54 char* save_ptr; // Needed for strtok_r. 52 char* save_ptr; // Needed for strtok_r.
55 const char* function_name = function.ToFullyQualifiedCString(); 53 const char* function_name = function.ToFullyQualifiedCString();
(...skipping 20 matching lines...) Expand all
76 } 74 }
77 } 75 }
78 } 76 }
79 token = strtok_r(NULL, ",", &save_ptr); 77 token = strtok_r(NULL, ",", &save_ptr);
80 } 78 }
81 delete[] filter_buffer; 79 delete[] filter_buffer;
82 80
83 return found; 81 return found;
84 } 82 }
85 83
86
87 bool FlowGraphPrinter::ShouldPrint(const Function& function) { 84 bool FlowGraphPrinter::ShouldPrint(const Function& function) {
88 return PassesFilter(FLAG_print_flow_graph_filter, function); 85 return PassesFilter(FLAG_print_flow_graph_filter, function);
89 } 86 }
90 87
91
92 void FlowGraphPrinter::PrintGraph(const char* phase, FlowGraph* flow_graph) { 88 void FlowGraphPrinter::PrintGraph(const char* phase, FlowGraph* flow_graph) {
93 LogBlock lb; 89 LogBlock lb;
94 THR_Print("*** BEGIN CFG\n%s\n", phase); 90 THR_Print("*** BEGIN CFG\n%s\n", phase);
95 FlowGraphPrinter printer(*flow_graph); 91 FlowGraphPrinter printer(*flow_graph);
96 printer.PrintBlocks(); 92 printer.PrintBlocks();
97 THR_Print("*** END CFG\n"); 93 THR_Print("*** END CFG\n");
98 fflush(stdout); 94 fflush(stdout);
99 } 95 }
100 96
101
102 void FlowGraphPrinter::PrintBlock(BlockEntryInstr* block, 97 void FlowGraphPrinter::PrintBlock(BlockEntryInstr* block,
103 bool print_locations) { 98 bool print_locations) {
104 // Print the block entry. 99 // Print the block entry.
105 PrintOneInstruction(block, print_locations); 100 PrintOneInstruction(block, print_locations);
106 THR_Print("\n"); 101 THR_Print("\n");
107 // And all the successors in the block. 102 // And all the successors in the block.
108 for (ForwardInstructionIterator it(block); !it.Done(); it.Advance()) { 103 for (ForwardInstructionIterator it(block); !it.Done(); it.Advance()) {
109 Instruction* current = it.Current(); 104 Instruction* current = it.Current();
110 PrintOneInstruction(current, print_locations); 105 PrintOneInstruction(current, print_locations);
111 THR_Print("\n"); 106 THR_Print("\n");
112 } 107 }
113 } 108 }
114 109
115
116 void FlowGraphPrinter::PrintBlocks() { 110 void FlowGraphPrinter::PrintBlocks() {
117 if (!function_.IsNull()) { 111 if (!function_.IsNull()) {
118 THR_Print("==== %s\n", function_.ToFullyQualifiedCString()); 112 THR_Print("==== %s\n", function_.ToFullyQualifiedCString());
119 } 113 }
120 114
121 for (intptr_t i = 0; i < block_order_.length(); ++i) { 115 for (intptr_t i = 0; i < block_order_.length(); ++i) {
122 PrintBlock(block_order_[i], print_locations_); 116 PrintBlock(block_order_[i], print_locations_);
123 } 117 }
124 } 118 }
125 119
126
127 void FlowGraphPrinter::PrintInstruction(Instruction* instr) { 120 void FlowGraphPrinter::PrintInstruction(Instruction* instr) {
128 PrintOneInstruction(instr, print_locations_); 121 PrintOneInstruction(instr, print_locations_);
129 } 122 }
130 123
131
132 void FlowGraphPrinter::PrintOneInstruction(Instruction* instr, 124 void FlowGraphPrinter::PrintOneInstruction(Instruction* instr,
133 bool print_locations) { 125 bool print_locations) {
134 char str[4000]; 126 char str[4000];
135 BufferFormatter f(str, sizeof(str)); 127 BufferFormatter f(str, sizeof(str));
136 instr->PrintTo(&f); 128 instr->PrintTo(&f);
137 if (FLAG_print_environments && (instr->env() != NULL)) { 129 if (FLAG_print_environments && (instr->env() != NULL)) {
138 instr->env()->PrintTo(&f); 130 instr->env()->PrintTo(&f);
139 } 131 }
140 if (print_locations && (instr->HasLocs())) { 132 if (print_locations && (instr->HasLocs())) {
141 instr->locs()->PrintTo(&f); 133 instr->locs()->PrintTo(&f);
142 } 134 }
143 if (instr->lifetime_position() != -1) { 135 if (instr->lifetime_position() != -1) {
144 THR_Print("%3" Pd ": ", instr->lifetime_position()); 136 THR_Print("%3" Pd ": ", instr->lifetime_position());
145 } 137 }
146 if (!instr->IsBlockEntry()) THR_Print(" "); 138 if (!instr->IsBlockEntry()) THR_Print(" ");
147 THR_Print("%s", str); 139 THR_Print("%s", str);
148 if (FLAG_trace_inlining_intervals) { 140 if (FLAG_trace_inlining_intervals) {
149 THR_Print(" iid: %" Pd "", instr->inlining_id()); 141 THR_Print(" iid: %" Pd "", instr->inlining_id());
150 } 142 }
151 } 143 }
152 144
153
154 void FlowGraphPrinter::PrintTypeCheck(const ParsedFunction& parsed_function, 145 void FlowGraphPrinter::PrintTypeCheck(const ParsedFunction& parsed_function,
155 TokenPosition token_pos, 146 TokenPosition token_pos,
156 Value* value, 147 Value* value,
157 const AbstractType& dst_type, 148 const AbstractType& dst_type,
158 const String& dst_name, 149 const String& dst_name,
159 bool eliminated) { 150 bool eliminated) {
160 const char* compile_type_name = "unknown"; 151 const char* compile_type_name = "unknown";
161 if (value != NULL && value->reaching_type_ != NULL) { 152 if (value != NULL && value->reaching_type_ != NULL) {
162 compile_type_name = value->reaching_type_->ToCString(); 153 compile_type_name = value->reaching_type_->ToCString();
163 } 154 }
164 THR_Print( 155 THR_Print(
165 "%s type check: compile type %s is %s specific than " 156 "%s type check: compile type %s is %s specific than "
166 "type '%s' of '%s'.\n", 157 "type '%s' of '%s'.\n",
167 eliminated ? "Eliminated" : "Generated", compile_type_name, 158 eliminated ? "Eliminated" : "Generated", compile_type_name,
168 eliminated ? "more" : "not more", 159 eliminated ? "more" : "not more",
169 String::Handle(dst_type.Name()).ToCString(), dst_name.ToCString()); 160 String::Handle(dst_type.Name()).ToCString(), dst_name.ToCString());
170 } 161 }
171 162
172
173 void CompileType::PrintTo(BufferFormatter* f) const { 163 void CompileType::PrintTo(BufferFormatter* f) const {
174 const char* type_name = "?"; 164 const char* type_name = "?";
175 if ((cid_ != kIllegalCid) && (cid_ != kDynamicCid)) { 165 if ((cid_ != kIllegalCid) && (cid_ != kDynamicCid)) {
176 const Class& cls = 166 const Class& cls =
177 Class::Handle(Isolate::Current()->class_table()->At(cid_)); 167 Class::Handle(Isolate::Current()->class_table()->At(cid_));
178 type_name = String::Handle(cls.ScrubbedName()).ToCString(); 168 type_name = String::Handle(cls.ScrubbedName()).ToCString();
179 } else if (type_ != NULL && 169 } else if (type_ != NULL &&
180 !type_->Equals(Type::Handle(Type::DynamicType()))) { 170 !type_->Equals(Type::Handle(Type::DynamicType()))) {
181 type_name = type_->ToCString(); 171 type_name = type_->ToCString();
182 } else if (!is_nullable()) { 172 } else if (!is_nullable()) {
183 type_name = "!null"; 173 type_name = "!null";
184 } 174 }
185 175
186 f->Print("T{%s%s}", type_name, is_nullable_ ? "?" : ""); 176 f->Print("T{%s%s}", type_name, is_nullable_ ? "?" : "");
187 } 177 }
188 178
189
190 const char* CompileType::ToCString() const { 179 const char* CompileType::ToCString() const {
191 char buffer[1024]; 180 char buffer[1024];
192 BufferFormatter f(buffer, sizeof(buffer)); 181 BufferFormatter f(buffer, sizeof(buffer));
193 PrintTo(&f); 182 PrintTo(&f);
194 return Thread::Current()->zone()->MakeCopyOfString(buffer); 183 return Thread::Current()->zone()->MakeCopyOfString(buffer);
195 } 184 }
196 185
197
198 static void PrintTargetsHelper(BufferFormatter* f, 186 static void PrintTargetsHelper(BufferFormatter* f,
199 const CallTargets& targets, 187 const CallTargets& targets,
200 intptr_t num_checks_to_print) { 188 intptr_t num_checks_to_print) {
201 f->Print(" IC["); 189 f->Print(" IC[");
202 f->Print("%" Pd ": ", targets.length()); 190 f->Print("%" Pd ": ", targets.length());
203 Function& target = Function::Handle(); 191 Function& target = Function::Handle();
204 if ((num_checks_to_print == FlowGraphPrinter::kPrintAll) || 192 if ((num_checks_to_print == FlowGraphPrinter::kPrintAll) ||
205 (num_checks_to_print > targets.length())) { 193 (num_checks_to_print > targets.length())) {
206 num_checks_to_print = targets.length(); 194 num_checks_to_print = targets.length();
207 } 195 }
(...skipping 16 matching lines...) Expand all
224 String::Handle(cls.Name()).ToCString()); 212 String::Handle(cls.Name()).ToCString());
225 f->Print(" cnt:%" Pd " trgt:'%s'", count, target.ToQualifiedCString()); 213 f->Print(" cnt:%" Pd " trgt:'%s'", count, target.ToQualifiedCString());
226 } 214 }
227 } 215 }
228 if (num_checks_to_print < targets.length()) { 216 if (num_checks_to_print < targets.length()) {
229 f->Print("..."); 217 f->Print("...");
230 } 218 }
231 f->Print("]"); 219 f->Print("]");
232 } 220 }
233 221
234
235 static void PrintCidsHelper(BufferFormatter* f, 222 static void PrintCidsHelper(BufferFormatter* f,
236 const Cids& targets, 223 const Cids& targets,
237 intptr_t num_checks_to_print) { 224 intptr_t num_checks_to_print) {
238 f->Print(" Cids["); 225 f->Print(" Cids[");
239 f->Print("%" Pd ": ", targets.length()); 226 f->Print("%" Pd ": ", targets.length());
240 if ((num_checks_to_print == FlowGraphPrinter::kPrintAll) || 227 if ((num_checks_to_print == FlowGraphPrinter::kPrintAll) ||
241 (num_checks_to_print > targets.length())) { 228 (num_checks_to_print > targets.length())) {
242 num_checks_to_print = targets.length(); 229 num_checks_to_print = targets.length();
243 } 230 }
244 for (intptr_t i = 0; i < num_checks_to_print; i++) { 231 for (intptr_t i = 0; i < num_checks_to_print; i++) {
245 const CidRange& range = targets[i]; 232 const CidRange& range = targets[i];
246 if (i > 0) { 233 if (i > 0) {
247 f->Print(" | "); 234 f->Print(" | ");
248 } 235 }
249 const Class& cls = 236 const Class& cls =
250 Class::Handle(Isolate::Current()->class_table()->At(range.cid_start)); 237 Class::Handle(Isolate::Current()->class_table()->At(range.cid_start));
251 f->Print("%s etc. ", String::Handle(cls.Name()).ToCString()); 238 f->Print("%s etc. ", String::Handle(cls.Name()).ToCString());
252 if (range.IsSingleCid()) { 239 if (range.IsSingleCid()) {
253 f->Print(" cid %" Pd, range.cid_start); 240 f->Print(" cid %" Pd, range.cid_start);
254 } else { 241 } else {
255 f->Print(" cid %" Pd "-%" Pd, range.cid_start, range.cid_end); 242 f->Print(" cid %" Pd "-%" Pd, range.cid_start, range.cid_end);
256 } 243 }
257 } 244 }
258 if (num_checks_to_print < targets.length()) { 245 if (num_checks_to_print < targets.length()) {
259 f->Print("..."); 246 f->Print("...");
260 } 247 }
261 f->Print("]"); 248 f->Print("]");
262 } 249 }
263 250
264
265 static void PrintICDataHelper(BufferFormatter* f, 251 static void PrintICDataHelper(BufferFormatter* f,
266 const ICData& ic_data, 252 const ICData& ic_data,
267 intptr_t num_checks_to_print) { 253 intptr_t num_checks_to_print) {
268 f->Print(" IC["); 254 f->Print(" IC[");
269 f->Print("%" Pd ": ", ic_data.NumberOfChecks()); 255 f->Print("%" Pd ": ", ic_data.NumberOfChecks());
270 Function& target = Function::Handle(); 256 Function& target = Function::Handle();
271 if ((num_checks_to_print == FlowGraphPrinter::kPrintAll) || 257 if ((num_checks_to_print == FlowGraphPrinter::kPrintAll) ||
272 (num_checks_to_print > ic_data.NumberOfChecks())) { 258 (num_checks_to_print > ic_data.NumberOfChecks())) {
273 num_checks_to_print = ic_data.NumberOfChecks(); 259 num_checks_to_print = ic_data.NumberOfChecks();
274 } 260 }
(...skipping 13 matching lines...) Expand all
288 f->Print("%s", String::Handle(cls.Name()).ToCString()); 274 f->Print("%s", String::Handle(cls.Name()).ToCString());
289 } 275 }
290 f->Print(" cnt:%" Pd " trgt:'%s'", count, target.ToQualifiedCString()); 276 f->Print(" cnt:%" Pd " trgt:'%s'", count, target.ToQualifiedCString());
291 } 277 }
292 if (num_checks_to_print < ic_data.NumberOfChecks()) { 278 if (num_checks_to_print < ic_data.NumberOfChecks()) {
293 f->Print("..."); 279 f->Print("...");
294 } 280 }
295 f->Print("]"); 281 f->Print("]");
296 } 282 }
297 283
298
299 static void PrintICDataSortedHelper(BufferFormatter* f, 284 static void PrintICDataSortedHelper(BufferFormatter* f,
300 const ICData& ic_data_orig) { 285 const ICData& ic_data_orig) {
301 const ICData& ic_data = 286 const ICData& ic_data =
302 ICData::Handle(ic_data_orig.AsUnaryClassChecksSortedByCount()); 287 ICData::Handle(ic_data_orig.AsUnaryClassChecksSortedByCount());
303 f->Print(" IC[n:%" Pd "; ", ic_data.NumberOfChecks()); 288 f->Print(" IC[n:%" Pd "; ", ic_data.NumberOfChecks());
304 for (intptr_t i = 0; i < ic_data.NumberOfChecks(); i++) { 289 for (intptr_t i = 0; i < ic_data.NumberOfChecks(); i++) {
305 const intptr_t count = ic_data.GetCountAt(i); 290 const intptr_t count = ic_data.GetCountAt(i);
306 const intptr_t cid = ic_data.GetReceiverClassIdAt(i); 291 const intptr_t cid = ic_data.GetReceiverClassIdAt(i);
307 const Class& cls = 292 const Class& cls =
308 Class::Handle(Isolate::Current()->class_table()->At(cid)); 293 Class::Handle(Isolate::Current()->class_table()->At(cid));
309 f->Print("%s : %" Pd ", ", String::Handle(cls.Name()).ToCString(), count); 294 f->Print("%s : %" Pd ", ", String::Handle(cls.Name()).ToCString(), count);
310 } 295 }
311 f->Print("]"); 296 f->Print("]");
312 } 297 }
313 298
314
315 void FlowGraphPrinter::PrintICData(const ICData& ic_data, 299 void FlowGraphPrinter::PrintICData(const ICData& ic_data,
316 intptr_t num_checks_to_print) { 300 intptr_t num_checks_to_print) {
317 char buffer[1024]; 301 char buffer[1024];
318 BufferFormatter f(buffer, sizeof(buffer)); 302 BufferFormatter f(buffer, sizeof(buffer));
319 PrintICDataHelper(&f, ic_data, num_checks_to_print); 303 PrintICDataHelper(&f, ic_data, num_checks_to_print);
320 THR_Print("%s ", buffer); 304 THR_Print("%s ", buffer);
321 const Array& a = Array::Handle(ic_data.arguments_descriptor()); 305 const Array& a = Array::Handle(ic_data.arguments_descriptor());
322 THR_Print(" arg-desc %" Pd "\n", a.Length()); 306 THR_Print(" arg-desc %" Pd "\n", a.Length());
323 } 307 }
324 308
325
326 void FlowGraphPrinter::PrintCidRangeData(const CallTargets& targets, 309 void FlowGraphPrinter::PrintCidRangeData(const CallTargets& targets,
327 intptr_t num_checks_to_print) { 310 intptr_t num_checks_to_print) {
328 char buffer[1024]; 311 char buffer[1024];
329 BufferFormatter f(buffer, sizeof(buffer)); 312 BufferFormatter f(buffer, sizeof(buffer));
330 PrintTargetsHelper(&f, targets, num_checks_to_print); 313 PrintTargetsHelper(&f, targets, num_checks_to_print);
331 THR_Print("%s ", buffer); 314 THR_Print("%s ", buffer);
332 // TODO(erikcorry): Print args descriptor. 315 // TODO(erikcorry): Print args descriptor.
333 } 316 }
334 317
335
336 static void PrintUse(BufferFormatter* f, const Definition& definition) { 318 static void PrintUse(BufferFormatter* f, const Definition& definition) {
337 if (definition.HasSSATemp()) { 319 if (definition.HasSSATemp()) {
338 if (definition.HasPairRepresentation()) { 320 if (definition.HasPairRepresentation()) {
339 f->Print("(v%" Pd ", v%" Pd ")", definition.ssa_temp_index(), 321 f->Print("(v%" Pd ", v%" Pd ")", definition.ssa_temp_index(),
340 definition.ssa_temp_index() + 1); 322 definition.ssa_temp_index() + 1);
341 } else { 323 } else {
342 f->Print("v%" Pd "", definition.ssa_temp_index()); 324 f->Print("v%" Pd "", definition.ssa_temp_index());
343 } 325 }
344 } else if (definition.HasTemp()) { 326 } else if (definition.HasTemp()) {
345 f->Print("t%" Pd "", definition.temp_index()); 327 f->Print("t%" Pd "", definition.temp_index());
346 } 328 }
347 } 329 }
348 330
349
350 const char* Instruction::ToCString() const { 331 const char* Instruction::ToCString() const {
351 char buffer[1024]; 332 char buffer[1024];
352 BufferFormatter f(buffer, sizeof(buffer)); 333 BufferFormatter f(buffer, sizeof(buffer));
353 PrintTo(&f); 334 PrintTo(&f);
354 return Thread::Current()->zone()->MakeCopyOfString(buffer); 335 return Thread::Current()->zone()->MakeCopyOfString(buffer);
355 } 336 }
356 337
357
358 void Instruction::PrintTo(BufferFormatter* f) const { 338 void Instruction::PrintTo(BufferFormatter* f) const {
359 if (GetDeoptId() != Thread::kNoDeoptId) { 339 if (GetDeoptId() != Thread::kNoDeoptId) {
360 f->Print("%s:%" Pd "(", DebugName(), GetDeoptId()); 340 f->Print("%s:%" Pd "(", DebugName(), GetDeoptId());
361 } else { 341 } else {
362 f->Print("%s(", DebugName()); 342 f->Print("%s(", DebugName());
363 } 343 }
364 PrintOperandsTo(f); 344 PrintOperandsTo(f);
365 f->Print(")"); 345 f->Print(")");
366 } 346 }
367 347
368
369 void Instruction::PrintOperandsTo(BufferFormatter* f) const { 348 void Instruction::PrintOperandsTo(BufferFormatter* f) const {
370 for (int i = 0; i < InputCount(); ++i) { 349 for (int i = 0; i < InputCount(); ++i) {
371 if (i > 0) f->Print(", "); 350 if (i > 0) f->Print(", ");
372 if (InputAt(i) != NULL) InputAt(i)->PrintTo(f); 351 if (InputAt(i) != NULL) InputAt(i)->PrintTo(f);
373 } 352 }
374 } 353 }
375 354
376
377 void Definition::PrintTo(BufferFormatter* f) const { 355 void Definition::PrintTo(BufferFormatter* f) const {
378 PrintUse(f, *this); 356 PrintUse(f, *this);
379 if (HasSSATemp() || HasTemp()) f->Print(" <- "); 357 if (HasSSATemp() || HasTemp()) f->Print(" <- ");
380 if (GetDeoptId() != Thread::kNoDeoptId) { 358 if (GetDeoptId() != Thread::kNoDeoptId) {
381 f->Print("%s:%" Pd "(", DebugName(), GetDeoptId()); 359 f->Print("%s:%" Pd "(", DebugName(), GetDeoptId());
382 } else { 360 } else {
383 f->Print("%s(", DebugName()); 361 f->Print("%s(", DebugName());
384 } 362 }
385 PrintOperandsTo(f); 363 PrintOperandsTo(f);
386 f->Print(")"); 364 f->Print(")");
387 if (range_ != NULL) { 365 if (range_ != NULL) {
388 f->Print(" "); 366 f->Print(" ");
389 range_->PrintTo(f); 367 range_->PrintTo(f);
390 } 368 }
391 369
392 if (type_ != NULL && 370 if (type_ != NULL &&
393 ((type_->ToNullableCid() != kDynamicCid) || !type_->is_nullable())) { 371 ((type_->ToNullableCid() != kDynamicCid) || !type_->is_nullable())) {
394 f->Print(" "); 372 f->Print(" ");
395 type_->PrintTo(f); 373 type_->PrintTo(f);
396 } 374 }
397 } 375 }
398 376
399
400 void Definition::PrintOperandsTo(BufferFormatter* f) const { 377 void Definition::PrintOperandsTo(BufferFormatter* f) const {
401 for (int i = 0; i < InputCount(); ++i) { 378 for (int i = 0; i < InputCount(); ++i) {
402 if (i > 0) f->Print(", "); 379 if (i > 0) f->Print(", ");
403 if (InputAt(i) != NULL) { 380 if (InputAt(i) != NULL) {
404 InputAt(i)->PrintTo(f); 381 InputAt(i)->PrintTo(f);
405 } 382 }
406 } 383 }
407 } 384 }
408 385
409
410 void Value::PrintTo(BufferFormatter* f) const { 386 void Value::PrintTo(BufferFormatter* f) const {
411 PrintUse(f, *definition()); 387 PrintUse(f, *definition());
412 388
413 if ((reaching_type_ != NULL) && (reaching_type_ != definition()->type_)) { 389 if ((reaching_type_ != NULL) && (reaching_type_ != definition()->type_)) {
414 f->Print(" "); 390 f->Print(" ");
415 reaching_type_->PrintTo(f); 391 reaching_type_->PrintTo(f);
416 } 392 }
417 } 393 }
418 394
419
420 void ConstantInstr::PrintOperandsTo(BufferFormatter* f) const { 395 void ConstantInstr::PrintOperandsTo(BufferFormatter* f) const {
421 const char* cstr = value().ToCString(); 396 const char* cstr = value().ToCString();
422 const char* new_line = strchr(cstr, '\n'); 397 const char* new_line = strchr(cstr, '\n');
423 if (new_line == NULL) { 398 if (new_line == NULL) {
424 f->Print("#%s", cstr); 399 f->Print("#%s", cstr);
425 } else { 400 } else {
426 const intptr_t pos = new_line - cstr; 401 const intptr_t pos = new_line - cstr;
427 char* buffer = Thread::Current()->zone()->Alloc<char>(pos + 1); 402 char* buffer = Thread::Current()->zone()->Alloc<char>(pos + 1);
428 strncpy(buffer, cstr, pos); 403 strncpy(buffer, cstr, pos);
429 buffer[pos] = '\0'; 404 buffer[pos] = '\0';
430 f->Print("#%s\\n...", buffer); 405 f->Print("#%s\\n...", buffer);
431 } 406 }
432 } 407 }
433 408
434
435 void ConstraintInstr::PrintOperandsTo(BufferFormatter* f) const { 409 void ConstraintInstr::PrintOperandsTo(BufferFormatter* f) const {
436 value()->PrintTo(f); 410 value()->PrintTo(f);
437 f->Print(" ^ "); 411 f->Print(" ^ ");
438 constraint()->PrintTo(f); 412 constraint()->PrintTo(f);
439 } 413 }
440 414
441
442 void Range::PrintTo(BufferFormatter* f) const { 415 void Range::PrintTo(BufferFormatter* f) const {
443 f->Print("["); 416 f->Print("[");
444 min_.PrintTo(f); 417 min_.PrintTo(f);
445 f->Print(", "); 418 f->Print(", ");
446 max_.PrintTo(f); 419 max_.PrintTo(f);
447 f->Print("]"); 420 f->Print("]");
448 } 421 }
449 422
450
451 const char* Range::ToCString(const Range* range) { 423 const char* Range::ToCString(const Range* range) {
452 if (range == NULL) return "[_|_, _|_]"; 424 if (range == NULL) return "[_|_, _|_]";
453 425
454 char buffer[256]; 426 char buffer[256];
455 BufferFormatter f(buffer, sizeof(buffer)); 427 BufferFormatter f(buffer, sizeof(buffer));
456 range->PrintTo(&f); 428 range->PrintTo(&f);
457 return Thread::Current()->zone()->MakeCopyOfString(buffer); 429 return Thread::Current()->zone()->MakeCopyOfString(buffer);
458 } 430 }
459 431
460
461 void RangeBoundary::PrintTo(BufferFormatter* f) const { 432 void RangeBoundary::PrintTo(BufferFormatter* f) const {
462 switch (kind_) { 433 switch (kind_) {
463 case kSymbol: 434 case kSymbol:
464 f->Print("v%" Pd "", 435 f->Print("v%" Pd "",
465 reinterpret_cast<Definition*>(value_)->ssa_temp_index()); 436 reinterpret_cast<Definition*>(value_)->ssa_temp_index());
466 if (offset_ != 0) f->Print("%+" Pd64 "", offset_); 437 if (offset_ != 0) f->Print("%+" Pd64 "", offset_);
467 break; 438 break;
468 case kNegativeInfinity: 439 case kNegativeInfinity:
469 f->Print("-inf"); 440 f->Print("-inf");
470 break; 441 break;
471 case kPositiveInfinity: 442 case kPositiveInfinity:
472 f->Print("+inf"); 443 f->Print("+inf");
473 break; 444 break;
474 case kConstant: 445 case kConstant:
475 f->Print("%" Pd64 "", value_); 446 f->Print("%" Pd64 "", value_);
476 break; 447 break;
477 case kUnknown: 448 case kUnknown:
478 f->Print("_|_"); 449 f->Print("_|_");
479 break; 450 break;
480 } 451 }
481 } 452 }
482 453
483
484 const char* RangeBoundary::ToCString() const { 454 const char* RangeBoundary::ToCString() const {
485 char buffer[256]; 455 char buffer[256];
486 BufferFormatter f(buffer, sizeof(buffer)); 456 BufferFormatter f(buffer, sizeof(buffer));
487 PrintTo(&f); 457 PrintTo(&f);
488 return Thread::Current()->zone()->MakeCopyOfString(buffer); 458 return Thread::Current()->zone()->MakeCopyOfString(buffer);
489 } 459 }
490 460
491
492 void DropTempsInstr::PrintOperandsTo(BufferFormatter* f) const { 461 void DropTempsInstr::PrintOperandsTo(BufferFormatter* f) const {
493 f->Print("%" Pd "", num_temps()); 462 f->Print("%" Pd "", num_temps());
494 if (value() != NULL) { 463 if (value() != NULL) {
495 f->Print(", "); 464 f->Print(", ");
496 value()->PrintTo(f); 465 value()->PrintTo(f);
497 } 466 }
498 } 467 }
499 468
500
501 void AssertAssignableInstr::PrintOperandsTo(BufferFormatter* f) const { 469 void AssertAssignableInstr::PrintOperandsTo(BufferFormatter* f) const {
502 value()->PrintTo(f); 470 value()->PrintTo(f);
503 f->Print(", %s, '%s',", dst_type().ToCString(), dst_name().ToCString()); 471 f->Print(", %s, '%s',", dst_type().ToCString(), dst_name().ToCString());
504 f->Print(" instantiator_type_args("); 472 f->Print(" instantiator_type_args(");
505 instantiator_type_arguments()->PrintTo(f); 473 instantiator_type_arguments()->PrintTo(f);
506 f->Print("), function_type_args("); 474 f->Print("), function_type_args(");
507 function_type_arguments()->PrintTo(f); 475 function_type_arguments()->PrintTo(f);
508 f->Print(")"); 476 f->Print(")");
509 } 477 }
510 478
511
512 void AssertBooleanInstr::PrintOperandsTo(BufferFormatter* f) const { 479 void AssertBooleanInstr::PrintOperandsTo(BufferFormatter* f) const {
513 value()->PrintTo(f); 480 value()->PrintTo(f);
514 } 481 }
515 482
516
517 void ClosureCallInstr::PrintOperandsTo(BufferFormatter* f) const { 483 void ClosureCallInstr::PrintOperandsTo(BufferFormatter* f) const {
518 f->Print(" function="); 484 f->Print(" function=");
519 InputAt(0)->PrintTo(f); 485 InputAt(0)->PrintTo(f);
520 f->Print("<%" Pd ">", type_args_len()); 486 f->Print("<%" Pd ">", type_args_len());
521 for (intptr_t i = 0; i < ArgumentCount(); ++i) { 487 for (intptr_t i = 0; i < ArgumentCount(); ++i) {
522 f->Print(", "); 488 f->Print(", ");
523 PushArgumentAt(i)->value()->PrintTo(f); 489 PushArgumentAt(i)->value()->PrintTo(f);
524 } 490 }
525 } 491 }
526 492
527
528 void InstanceCallInstr::PrintOperandsTo(BufferFormatter* f) const { 493 void InstanceCallInstr::PrintOperandsTo(BufferFormatter* f) const {
529 f->Print(" %s<%" Pd ">", function_name().ToCString(), type_args_len()); 494 f->Print(" %s<%" Pd ">", function_name().ToCString(), type_args_len());
530 for (intptr_t i = 0; i < ArgumentCount(); ++i) { 495 for (intptr_t i = 0; i < ArgumentCount(); ++i) {
531 f->Print(", "); 496 f->Print(", ");
532 PushArgumentAt(i)->value()->PrintTo(f); 497 PushArgumentAt(i)->value()->PrintTo(f);
533 } 498 }
534 if (HasICData()) { 499 if (HasICData()) {
535 if (FLAG_display_sorted_ic_data) { 500 if (FLAG_display_sorted_ic_data) {
536 PrintICDataSortedHelper(f, *ic_data()); 501 PrintICDataSortedHelper(f, *ic_data());
537 } else { 502 } else {
538 PrintICDataHelper(f, *ic_data(), FlowGraphPrinter::kPrintAll); 503 PrintICDataHelper(f, *ic_data(), FlowGraphPrinter::kPrintAll);
539 } 504 }
540 } 505 }
541 } 506 }
542 507
543
544 void PolymorphicInstanceCallInstr::PrintOperandsTo(BufferFormatter* f) const { 508 void PolymorphicInstanceCallInstr::PrintOperandsTo(BufferFormatter* f) const {
545 f->Print(" %s<%" Pd ">", instance_call()->function_name().ToCString(), 509 f->Print(" %s<%" Pd ">", instance_call()->function_name().ToCString(),
546 instance_call()->type_args_len()); 510 instance_call()->type_args_len());
547 for (intptr_t i = 0; i < ArgumentCount(); ++i) { 511 for (intptr_t i = 0; i < ArgumentCount(); ++i) {
548 f->Print(", "); 512 f->Print(", ");
549 PushArgumentAt(i)->value()->PrintTo(f); 513 PushArgumentAt(i)->value()->PrintTo(f);
550 } 514 }
551 PrintTargetsHelper(f, targets_, FlowGraphPrinter::kPrintAll); 515 PrintTargetsHelper(f, targets_, FlowGraphPrinter::kPrintAll);
552 if (complete()) { 516 if (complete()) {
553 f->Print(" COMPLETE"); 517 f->Print(" COMPLETE");
554 } 518 }
555 } 519 }
556 520
557
558 void StrictCompareInstr::PrintOperandsTo(BufferFormatter* f) const { 521 void StrictCompareInstr::PrintOperandsTo(BufferFormatter* f) const {
559 f->Print("%s, ", Token::Str(kind())); 522 f->Print("%s, ", Token::Str(kind()));
560 left()->PrintTo(f); 523 left()->PrintTo(f);
561 f->Print(", "); 524 f->Print(", ");
562 right()->PrintTo(f); 525 right()->PrintTo(f);
563 if (needs_number_check()) { 526 if (needs_number_check()) {
564 f->Print(", with number check"); 527 f->Print(", with number check");
565 } 528 }
566 } 529 }
567 530
568
569 void TestCidsInstr::PrintOperandsTo(BufferFormatter* f) const { 531 void TestCidsInstr::PrintOperandsTo(BufferFormatter* f) const {
570 left()->PrintTo(f); 532 left()->PrintTo(f);
571 f->Print(" %s [", Token::Str(kind())); 533 f->Print(" %s [", Token::Str(kind()));
572 intptr_t length = cid_results().length(); 534 intptr_t length = cid_results().length();
573 for (intptr_t i = 0; i < length; i += 2) { 535 for (intptr_t i = 0; i < length; i += 2) {
574 f->Print("0x%" Px ":%s ", cid_results()[i], 536 f->Print("0x%" Px ":%s ", cid_results()[i],
575 cid_results()[i + 1] == 0 ? "false" : "true"); 537 cid_results()[i + 1] == 0 ? "false" : "true");
576 } 538 }
577 f->Print("] "); 539 f->Print("] ");
578 if (CanDeoptimize()) { 540 if (CanDeoptimize()) {
579 ASSERT(deopt_id() != Thread::kNoDeoptId); 541 ASSERT(deopt_id() != Thread::kNoDeoptId);
580 f->Print("else deoptimize "); 542 f->Print("else deoptimize ");
581 } else { 543 } else {
582 ASSERT(deopt_id() == Thread::kNoDeoptId); 544 ASSERT(deopt_id() == Thread::kNoDeoptId);
583 f->Print("else %s ", cid_results()[length - 1] != 0 ? "false" : "true"); 545 f->Print("else %s ", cid_results()[length - 1] != 0 ? "false" : "true");
584 } 546 }
585 } 547 }
586 548
587
588 void EqualityCompareInstr::PrintOperandsTo(BufferFormatter* f) const { 549 void EqualityCompareInstr::PrintOperandsTo(BufferFormatter* f) const {
589 left()->PrintTo(f); 550 left()->PrintTo(f);
590 f->Print(" %s ", Token::Str(kind())); 551 f->Print(" %s ", Token::Str(kind()));
591 right()->PrintTo(f); 552 right()->PrintTo(f);
592 } 553 }
593 554
594
595 void StaticCallInstr::PrintOperandsTo(BufferFormatter* f) const { 555 void StaticCallInstr::PrintOperandsTo(BufferFormatter* f) const {
596 f->Print(" %s<%" Pd "> ", String::Handle(function().name()).ToCString(), 556 f->Print(" %s<%" Pd "> ", String::Handle(function().name()).ToCString(),
597 type_args_len()); 557 type_args_len());
598 for (intptr_t i = 0; i < ArgumentCount(); ++i) { 558 for (intptr_t i = 0; i < ArgumentCount(); ++i) {
599 if (i > 0) f->Print(", "); 559 if (i > 0) f->Print(", ");
600 PushArgumentAt(i)->value()->PrintTo(f); 560 PushArgumentAt(i)->value()->PrintTo(f);
601 } 561 }
602 } 562 }
603 563
604
605 void LoadLocalInstr::PrintOperandsTo(BufferFormatter* f) const { 564 void LoadLocalInstr::PrintOperandsTo(BufferFormatter* f) const {
606 f->Print("%s @%d", local().name().ToCString(), local().index()); 565 f->Print("%s @%d", local().name().ToCString(), local().index());
607 } 566 }
608 567
609
610 void StoreLocalInstr::PrintOperandsTo(BufferFormatter* f) const { 568 void StoreLocalInstr::PrintOperandsTo(BufferFormatter* f) const {
611 f->Print("%s @%d, ", local().name().ToCString(), local().index()); 569 f->Print("%s @%d, ", local().name().ToCString(), local().index());
612 value()->PrintTo(f); 570 value()->PrintTo(f);
613 } 571 }
614 572
615
616 void NativeCallInstr::PrintOperandsTo(BufferFormatter* f) const { 573 void NativeCallInstr::PrintOperandsTo(BufferFormatter* f) const {
617 f->Print("%s", native_name().ToCString()); 574 f->Print("%s", native_name().ToCString());
618 } 575 }
619 576
620
621 void GuardFieldInstr::PrintOperandsTo(BufferFormatter* f) const { 577 void GuardFieldInstr::PrintOperandsTo(BufferFormatter* f) const {
622 f->Print("%s %s, ", String::Handle(field().name()).ToCString(), 578 f->Print("%s %s, ", String::Handle(field().name()).ToCString(),
623 field().GuardedPropertiesAsCString()); 579 field().GuardedPropertiesAsCString());
624 value()->PrintTo(f); 580 value()->PrintTo(f);
625 } 581 }
626 582
627
628 void StoreInstanceFieldInstr::PrintOperandsTo(BufferFormatter* f) const { 583 void StoreInstanceFieldInstr::PrintOperandsTo(BufferFormatter* f) const {
629 if (field().IsNull()) { 584 if (field().IsNull()) {
630 f->Print("{%" Pd "}, ", offset_in_bytes()); 585 f->Print("{%" Pd "}, ", offset_in_bytes());
631 } else { 586 } else {
632 f->Print("%s {%" Pd "}, ", String::Handle(field().name()).ToCString(), 587 f->Print("%s {%" Pd "}, ", String::Handle(field().name()).ToCString(),
633 field().Offset()); 588 field().Offset());
634 } 589 }
635 instance()->PrintTo(f); 590 instance()->PrintTo(f);
636 f->Print(", "); 591 f->Print(", ");
637 value()->PrintTo(f); 592 value()->PrintTo(f);
638 } 593 }
639 594
640
641 void IfThenElseInstr::PrintOperandsTo(BufferFormatter* f) const { 595 void IfThenElseInstr::PrintOperandsTo(BufferFormatter* f) const {
642 comparison()->PrintOperandsTo(f); 596 comparison()->PrintOperandsTo(f);
643 f->Print(" ? %" Pd " : %" Pd, if_true_, if_false_); 597 f->Print(" ? %" Pd " : %" Pd, if_true_, if_false_);
644 } 598 }
645 599
646
647 void LoadStaticFieldInstr::PrintOperandsTo(BufferFormatter* f) const { 600 void LoadStaticFieldInstr::PrintOperandsTo(BufferFormatter* f) const {
648 field_value()->PrintTo(f); 601 field_value()->PrintTo(f);
649 } 602 }
650 603
651
652 void StoreStaticFieldInstr::PrintOperandsTo(BufferFormatter* f) const { 604 void StoreStaticFieldInstr::PrintOperandsTo(BufferFormatter* f) const {
653 f->Print("%s, ", String::Handle(field().name()).ToCString()); 605 f->Print("%s, ", String::Handle(field().name()).ToCString());
654 value()->PrintTo(f); 606 value()->PrintTo(f);
655 } 607 }
656 608
657
658 void InstanceOfInstr::PrintOperandsTo(BufferFormatter* f) const { 609 void InstanceOfInstr::PrintOperandsTo(BufferFormatter* f) const {
659 value()->PrintTo(f); 610 value()->PrintTo(f);
660 f->Print(" IS %s,", String::Handle(type().Name()).ToCString()); 611 f->Print(" IS %s,", String::Handle(type().Name()).ToCString());
661 f->Print(" instantiator_type_args("); 612 f->Print(" instantiator_type_args(");
662 instantiator_type_arguments()->PrintTo(f); 613 instantiator_type_arguments()->PrintTo(f);
663 f->Print("), function_type_args("); 614 f->Print("), function_type_args(");
664 function_type_arguments()->PrintTo(f); 615 function_type_arguments()->PrintTo(f);
665 f->Print(")"); 616 f->Print(")");
666 } 617 }
667 618
668
669 void RelationalOpInstr::PrintOperandsTo(BufferFormatter* f) const { 619 void RelationalOpInstr::PrintOperandsTo(BufferFormatter* f) const {
670 f->Print("%s, ", Token::Str(kind())); 620 f->Print("%s, ", Token::Str(kind()));
671 left()->PrintTo(f); 621 left()->PrintTo(f);
672 f->Print(", "); 622 f->Print(", ");
673 right()->PrintTo(f); 623 right()->PrintTo(f);
674 } 624 }
675 625
676
677 void AllocateObjectInstr::PrintOperandsTo(BufferFormatter* f) const { 626 void AllocateObjectInstr::PrintOperandsTo(BufferFormatter* f) const {
678 f->Print("%s", String::Handle(cls().ScrubbedName()).ToCString()); 627 f->Print("%s", String::Handle(cls().ScrubbedName()).ToCString());
679 for (intptr_t i = 0; i < ArgumentCount(); i++) { 628 for (intptr_t i = 0; i < ArgumentCount(); i++) {
680 f->Print(", "); 629 f->Print(", ");
681 PushArgumentAt(i)->value()->PrintTo(f); 630 PushArgumentAt(i)->value()->PrintTo(f);
682 } 631 }
683 632
684 if (Identity().IsNotAliased()) { 633 if (Identity().IsNotAliased()) {
685 f->Print(" <not-aliased>"); 634 f->Print(" <not-aliased>");
686 } 635 }
687 } 636 }
688 637
689
690 void MaterializeObjectInstr::PrintOperandsTo(BufferFormatter* f) const { 638 void MaterializeObjectInstr::PrintOperandsTo(BufferFormatter* f) const {
691 f->Print("%s", String::Handle(cls_.ScrubbedName()).ToCString()); 639 f->Print("%s", String::Handle(cls_.ScrubbedName()).ToCString());
692 for (intptr_t i = 0; i < InputCount(); i++) { 640 for (intptr_t i = 0; i < InputCount(); i++) {
693 f->Print(", "); 641 f->Print(", ");
694 f->Print("%s: ", slots_[i]->ToCString()); 642 f->Print("%s: ", slots_[i]->ToCString());
695 InputAt(i)->PrintTo(f); 643 InputAt(i)->PrintTo(f);
696 } 644 }
697 } 645 }
698 646
699
700 void LoadFieldInstr::PrintOperandsTo(BufferFormatter* f) const { 647 void LoadFieldInstr::PrintOperandsTo(BufferFormatter* f) const {
701 instance()->PrintTo(f); 648 instance()->PrintTo(f);
702 f->Print(", %" Pd, offset_in_bytes()); 649 f->Print(", %" Pd, offset_in_bytes());
703 650
704 if (field() != NULL) { 651 if (field() != NULL) {
705 f->Print(" {%s}", String::Handle(field()->name()).ToCString()); 652 f->Print(" {%s}", String::Handle(field()->name()).ToCString());
706 const char* expected = "?"; 653 const char* expected = "?";
707 if (field()->guarded_cid() != kIllegalCid) { 654 if (field()->guarded_cid() != kIllegalCid) {
708 const Class& cls = Class::Handle( 655 const Class& cls = Class::Handle(
709 Isolate::Current()->class_table()->At(field()->guarded_cid())); 656 Isolate::Current()->class_table()->At(field()->guarded_cid()));
710 expected = String::Handle(cls.Name()).ToCString(); 657 expected = String::Handle(cls.Name()).ToCString();
711 } 658 }
712 659
713 f->Print(" [%s %s]", field()->is_nullable() ? "nullable" : "non-nullable", 660 f->Print(" [%s %s]", field()->is_nullable() ? "nullable" : "non-nullable",
714 expected); 661 expected);
715 } 662 }
716 663
717 f->Print(", immutable=%d", immutable_); 664 f->Print(", immutable=%d", immutable_);
718 } 665 }
719 666
720
721 void InstantiateTypeInstr::PrintOperandsTo(BufferFormatter* f) const { 667 void InstantiateTypeInstr::PrintOperandsTo(BufferFormatter* f) const {
722 const String& type_name = String::Handle(type().Name()); 668 const String& type_name = String::Handle(type().Name());
723 f->Print("%s,", type_name.ToCString()); 669 f->Print("%s,", type_name.ToCString());
724 f->Print(" instantiator_type_args("); 670 f->Print(" instantiator_type_args(");
725 instantiator_type_arguments()->PrintTo(f); 671 instantiator_type_arguments()->PrintTo(f);
726 f->Print("), function_type_args("); 672 f->Print("), function_type_args(");
727 function_type_arguments()->PrintTo(f); 673 function_type_arguments()->PrintTo(f);
728 f->Print(")"); 674 f->Print(")");
729 } 675 }
730 676
731
732 void InstantiateTypeArgumentsInstr::PrintOperandsTo(BufferFormatter* f) const { 677 void InstantiateTypeArgumentsInstr::PrintOperandsTo(BufferFormatter* f) const {
733 const String& type_args = String::Handle(type_arguments().Name()); 678 const String& type_args = String::Handle(type_arguments().Name());
734 f->Print("%s,", type_args.ToCString()); 679 f->Print("%s,", type_args.ToCString());
735 f->Print(" instantiator_type_args("); 680 f->Print(" instantiator_type_args(");
736 instantiator_type_arguments()->PrintTo(f); 681 instantiator_type_arguments()->PrintTo(f);
737 f->Print("), function_type_args("); 682 f->Print("), function_type_args(");
738 function_type_arguments()->PrintTo(f); 683 function_type_arguments()->PrintTo(f);
739 f->Print(")"); 684 f->Print(")");
740 } 685 }
741 686
742
743 void AllocateContextInstr::PrintOperandsTo(BufferFormatter* f) const { 687 void AllocateContextInstr::PrintOperandsTo(BufferFormatter* f) const {
744 f->Print("%" Pd "", num_context_variables()); 688 f->Print("%" Pd "", num_context_variables());
745 } 689 }
746 690
747
748 void AllocateUninitializedContextInstr::PrintOperandsTo( 691 void AllocateUninitializedContextInstr::PrintOperandsTo(
749 BufferFormatter* f) const { 692 BufferFormatter* f) const {
750 f->Print("%" Pd "", num_context_variables()); 693 f->Print("%" Pd "", num_context_variables());
751 694
752 if (Identity().IsNotAliased()) { 695 if (Identity().IsNotAliased()) {
753 f->Print(" <not-aliased>"); 696 f->Print(" <not-aliased>");
754 } 697 }
755 } 698 }
756 699
757
758 void MathUnaryInstr::PrintOperandsTo(BufferFormatter* f) const { 700 void MathUnaryInstr::PrintOperandsTo(BufferFormatter* f) const {
759 f->Print("'%s', ", MathUnaryInstr::KindToCString(kind())); 701 f->Print("'%s', ", MathUnaryInstr::KindToCString(kind()));
760 value()->PrintTo(f); 702 value()->PrintTo(f);
761 } 703 }
762 704
763
764 void TruncDivModInstr::PrintOperandsTo(BufferFormatter* f) const { 705 void TruncDivModInstr::PrintOperandsTo(BufferFormatter* f) const {
765 Definition::PrintOperandsTo(f); 706 Definition::PrintOperandsTo(f);
766 } 707 }
767 708
768
769 void ExtractNthOutputInstr::PrintOperandsTo(BufferFormatter* f) const { 709 void ExtractNthOutputInstr::PrintOperandsTo(BufferFormatter* f) const {
770 f->Print("Extract %" Pd " from ", index()); 710 f->Print("Extract %" Pd " from ", index());
771 Definition::PrintOperandsTo(f); 711 Definition::PrintOperandsTo(f);
772 } 712 }
773 713
774
775 void UnaryIntegerOpInstr::PrintOperandsTo(BufferFormatter* f) const { 714 void UnaryIntegerOpInstr::PrintOperandsTo(BufferFormatter* f) const {
776 f->Print("%s, ", Token::Str(op_kind())); 715 f->Print("%s, ", Token::Str(op_kind()));
777 value()->PrintTo(f); 716 value()->PrintTo(f);
778 } 717 }
779 718
780
781 void CheckedSmiOpInstr::PrintOperandsTo(BufferFormatter* f) const { 719 void CheckedSmiOpInstr::PrintOperandsTo(BufferFormatter* f) const {
782 f->Print("%s", Token::Str(op_kind())); 720 f->Print("%s", Token::Str(op_kind()));
783 f->Print(", "); 721 f->Print(", ");
784 left()->PrintTo(f); 722 left()->PrintTo(f);
785 f->Print(", "); 723 f->Print(", ");
786 right()->PrintTo(f); 724 right()->PrintTo(f);
787 } 725 }
788 726
789
790 void CheckedSmiComparisonInstr::PrintOperandsTo(BufferFormatter* f) const { 727 void CheckedSmiComparisonInstr::PrintOperandsTo(BufferFormatter* f) const {
791 f->Print("%s", Token::Str(kind())); 728 f->Print("%s", Token::Str(kind()));
792 f->Print(", "); 729 f->Print(", ");
793 left()->PrintTo(f); 730 left()->PrintTo(f);
794 f->Print(", "); 731 f->Print(", ");
795 right()->PrintTo(f); 732 right()->PrintTo(f);
796 } 733 }
797 734
798
799 void BinaryIntegerOpInstr::PrintOperandsTo(BufferFormatter* f) const { 735 void BinaryIntegerOpInstr::PrintOperandsTo(BufferFormatter* f) const {
800 f->Print("%s", Token::Str(op_kind())); 736 f->Print("%s", Token::Str(op_kind()));
801 if (is_truncating()) { 737 if (is_truncating()) {
802 f->Print(" [tr]"); 738 f->Print(" [tr]");
803 } else if (!can_overflow()) { 739 } else if (!can_overflow()) {
804 f->Print(" [-o]"); 740 f->Print(" [-o]");
805 } 741 }
806 f->Print(", "); 742 f->Print(", ");
807 left()->PrintTo(f); 743 left()->PrintTo(f);
808 f->Print(", "); 744 f->Print(", ");
809 right()->PrintTo(f); 745 right()->PrintTo(f);
810 } 746 }
811 747
812
813 void BinaryDoubleOpInstr::PrintOperandsTo(BufferFormatter* f) const { 748 void BinaryDoubleOpInstr::PrintOperandsTo(BufferFormatter* f) const {
814 f->Print("%s, ", Token::Str(op_kind())); 749 f->Print("%s, ", Token::Str(op_kind()));
815 left()->PrintTo(f); 750 left()->PrintTo(f);
816 f->Print(", "); 751 f->Print(", ");
817 right()->PrintTo(f); 752 right()->PrintTo(f);
818 } 753 }
819 754
820
821 void DoubleTestOpInstr::PrintOperandsTo(BufferFormatter* f) const { 755 void DoubleTestOpInstr::PrintOperandsTo(BufferFormatter* f) const {
822 switch (op_kind()) { 756 switch (op_kind()) {
823 case MethodRecognizer::kDouble_getIsNaN: 757 case MethodRecognizer::kDouble_getIsNaN:
824 f->Print("IsNaN "); 758 f->Print("IsNaN ");
825 break; 759 break;
826 case MethodRecognizer::kDouble_getIsInfinite: 760 case MethodRecognizer::kDouble_getIsInfinite:
827 f->Print("IsInfinite "); 761 f->Print("IsInfinite ");
828 break; 762 break;
829 default: 763 default:
830 UNREACHABLE(); 764 UNREACHABLE();
831 } 765 }
832 value()->PrintTo(f); 766 value()->PrintTo(f);
833 } 767 }
834 768
835
836 void BinaryFloat32x4OpInstr::PrintOperandsTo(BufferFormatter* f) const { 769 void BinaryFloat32x4OpInstr::PrintOperandsTo(BufferFormatter* f) const {
837 f->Print("%s, ", Token::Str(op_kind())); 770 f->Print("%s, ", Token::Str(op_kind()));
838 left()->PrintTo(f); 771 left()->PrintTo(f);
839 f->Print(", "); 772 f->Print(", ");
840 right()->PrintTo(f); 773 right()->PrintTo(f);
841 } 774 }
842 775
843
844 void BinaryFloat64x2OpInstr::PrintOperandsTo(BufferFormatter* f) const { 776 void BinaryFloat64x2OpInstr::PrintOperandsTo(BufferFormatter* f) const {
845 f->Print("%s, ", Token::Str(op_kind())); 777 f->Print("%s, ", Token::Str(op_kind()));
846 left()->PrintTo(f); 778 left()->PrintTo(f);
847 f->Print(", "); 779 f->Print(", ");
848 right()->PrintTo(f); 780 right()->PrintTo(f);
849 } 781 }
850 782
851
852 void Simd32x4ShuffleInstr::PrintOperandsTo(BufferFormatter* f) const { 783 void Simd32x4ShuffleInstr::PrintOperandsTo(BufferFormatter* f) const {
853 // TODO(johnmccutchan): Add proper string enumeration of shuffle. 784 // TODO(johnmccutchan): Add proper string enumeration of shuffle.
854 f->Print("%s, ", MethodRecognizer::KindToCString(op_kind())); 785 f->Print("%s, ", MethodRecognizer::KindToCString(op_kind()));
855 value()->PrintTo(f); 786 value()->PrintTo(f);
856 } 787 }
857 788
858
859 void Simd32x4ShuffleMixInstr::PrintOperandsTo(BufferFormatter* f) const { 789 void Simd32x4ShuffleMixInstr::PrintOperandsTo(BufferFormatter* f) const {
860 f->Print("%s, ", MethodRecognizer::KindToCString(op_kind())); 790 f->Print("%s, ", MethodRecognizer::KindToCString(op_kind()));
861 xy()->PrintTo(f); 791 xy()->PrintTo(f);
862 f->Print(", "); 792 f->Print(", ");
863 zw()->PrintTo(f); 793 zw()->PrintTo(f);
864 } 794 }
865 795
866
867 void Simd32x4GetSignMaskInstr::PrintOperandsTo(BufferFormatter* f) const { 796 void Simd32x4GetSignMaskInstr::PrintOperandsTo(BufferFormatter* f) const {
868 if (op_kind() == MethodRecognizer::kFloat32x4GetSignMask) { 797 if (op_kind() == MethodRecognizer::kFloat32x4GetSignMask) {
869 f->Print("Float32x4.getSignMask "); 798 f->Print("Float32x4.getSignMask ");
870 } else { 799 } else {
871 ASSERT(op_kind() == MethodRecognizer::kInt32x4GetSignMask); 800 ASSERT(op_kind() == MethodRecognizer::kInt32x4GetSignMask);
872 f->Print("Int32x4.getSignMask "); 801 f->Print("Int32x4.getSignMask ");
873 } 802 }
874 value()->PrintTo(f); 803 value()->PrintTo(f);
875 } 804 }
876 805
877
878 void Float32x4SplatInstr::PrintOperandsTo(BufferFormatter* f) const { 806 void Float32x4SplatInstr::PrintOperandsTo(BufferFormatter* f) const {
879 f->Print("SPLAT "); 807 f->Print("SPLAT ");
880 value()->PrintTo(f); 808 value()->PrintTo(f);
881 } 809 }
882 810
883
884 void Float32x4ConstructorInstr::PrintOperandsTo(BufferFormatter* f) const { 811 void Float32x4ConstructorInstr::PrintOperandsTo(BufferFormatter* f) const {
885 f->Print("Float32x4("); 812 f->Print("Float32x4(");
886 value0()->PrintTo(f); 813 value0()->PrintTo(f);
887 f->Print(", "); 814 f->Print(", ");
888 value1()->PrintTo(f); 815 value1()->PrintTo(f);
889 f->Print(", "); 816 f->Print(", ");
890 value2()->PrintTo(f); 817 value2()->PrintTo(f);
891 f->Print(", "); 818 f->Print(", ");
892 value3()->PrintTo(f); 819 value3()->PrintTo(f);
893 f->Print(")"); 820 f->Print(")");
894 } 821 }
895 822
896
897 void Float32x4ComparisonInstr::PrintOperandsTo(BufferFormatter* f) const { 823 void Float32x4ComparisonInstr::PrintOperandsTo(BufferFormatter* f) const {
898 f->Print("Float32x4 Comparison %s, ", 824 f->Print("Float32x4 Comparison %s, ",
899 MethodRecognizer::KindToCString(op_kind())); 825 MethodRecognizer::KindToCString(op_kind()));
900 left()->PrintTo(f); 826 left()->PrintTo(f);
901 f->Print(", "); 827 f->Print(", ");
902 right()->PrintTo(f); 828 right()->PrintTo(f);
903 } 829 }
904 830
905
906 void Float32x4MinMaxInstr::PrintOperandsTo(BufferFormatter* f) const { 831 void Float32x4MinMaxInstr::PrintOperandsTo(BufferFormatter* f) const {
907 f->Print("%s, ", MethodRecognizer::KindToCString(op_kind())); 832 f->Print("%s, ", MethodRecognizer::KindToCString(op_kind()));
908 left()->PrintTo(f); 833 left()->PrintTo(f);
909 f->Print(", "); 834 f->Print(", ");
910 right()->PrintTo(f); 835 right()->PrintTo(f);
911 } 836 }
912 837
913
914 void Float32x4SqrtInstr::PrintOperandsTo(BufferFormatter* f) const { 838 void Float32x4SqrtInstr::PrintOperandsTo(BufferFormatter* f) const {
915 f->Print("%s, ", MethodRecognizer::KindToCString(op_kind())); 839 f->Print("%s, ", MethodRecognizer::KindToCString(op_kind()));
916 left()->PrintTo(f); 840 left()->PrintTo(f);
917 } 841 }
918 842
919
920 void Float32x4ScaleInstr::PrintOperandsTo(BufferFormatter* f) const { 843 void Float32x4ScaleInstr::PrintOperandsTo(BufferFormatter* f) const {
921 f->Print("%s, ", MethodRecognizer::KindToCString(op_kind())); 844 f->Print("%s, ", MethodRecognizer::KindToCString(op_kind()));
922 left()->PrintTo(f); 845 left()->PrintTo(f);
923 f->Print(", "); 846 f->Print(", ");
924 right()->PrintTo(f); 847 right()->PrintTo(f);
925 } 848 }
926 849
927
928 void Float32x4ZeroArgInstr::PrintOperandsTo(BufferFormatter* f) const { 850 void Float32x4ZeroArgInstr::PrintOperandsTo(BufferFormatter* f) const {
929 f->Print("%s, ", MethodRecognizer::KindToCString(op_kind())); 851 f->Print("%s, ", MethodRecognizer::KindToCString(op_kind()));
930 left()->PrintTo(f); 852 left()->PrintTo(f);
931 } 853 }
932 854
933
934 void Float32x4ClampInstr::PrintOperandsTo(BufferFormatter* f) const { 855 void Float32x4ClampInstr::PrintOperandsTo(BufferFormatter* f) const {
935 f->Print("Float32x4.clamp, "); 856 f->Print("Float32x4.clamp, ");
936 left()->PrintTo(f); 857 left()->PrintTo(f);
937 } 858 }
938 859
939
940 void Float32x4WithInstr::PrintOperandsTo(BufferFormatter* f) const { 860 void Float32x4WithInstr::PrintOperandsTo(BufferFormatter* f) const {
941 f->Print("%s, ", MethodRecognizer::KindToCString(op_kind())); 861 f->Print("%s, ", MethodRecognizer::KindToCString(op_kind()));
942 left()->PrintTo(f); 862 left()->PrintTo(f);
943 f->Print(", "); 863 f->Print(", ");
944 replacement()->PrintTo(f); 864 replacement()->PrintTo(f);
945 } 865 }
946 866
947
948 void Float32x4ToInt32x4Instr::PrintOperandsTo(BufferFormatter* f) const { 867 void Float32x4ToInt32x4Instr::PrintOperandsTo(BufferFormatter* f) const {
949 f->Print("Float32x4.toInt32x4 "); 868 f->Print("Float32x4.toInt32x4 ");
950 left()->PrintTo(f); 869 left()->PrintTo(f);
951 } 870 }
952 871
953
954 void Simd64x2ShuffleInstr::PrintOperandsTo(BufferFormatter* f) const { 872 void Simd64x2ShuffleInstr::PrintOperandsTo(BufferFormatter* f) const {
955 // TODO(johnmccutchan): Add proper string enumeration of shuffle. 873 // TODO(johnmccutchan): Add proper string enumeration of shuffle.
956 f->Print("%s, ", MethodRecognizer::KindToCString(op_kind())); 874 f->Print("%s, ", MethodRecognizer::KindToCString(op_kind()));
957 value()->PrintTo(f); 875 value()->PrintTo(f);
958 } 876 }
959 877
960
961 void Float64x2SplatInstr::PrintOperandsTo(BufferFormatter* f) const { 878 void Float64x2SplatInstr::PrintOperandsTo(BufferFormatter* f) const {
962 f->Print("Float64x2.splat "); 879 f->Print("Float64x2.splat ");
963 value()->PrintTo(f); 880 value()->PrintTo(f);
964 } 881 }
965 882
966
967 void Float64x2ConstructorInstr::PrintOperandsTo(BufferFormatter* f) const { 883 void Float64x2ConstructorInstr::PrintOperandsTo(BufferFormatter* f) const {
968 f->Print("Float64x2("); 884 f->Print("Float64x2(");
969 value0()->PrintTo(f); 885 value0()->PrintTo(f);
970 f->Print(", "); 886 f->Print(", ");
971 value1()->PrintTo(f); 887 value1()->PrintTo(f);
972 f->Print(")"); 888 f->Print(")");
973 } 889 }
974 890
975
976 void Float32x4ToFloat64x2Instr::PrintOperandsTo(BufferFormatter* f) const { 891 void Float32x4ToFloat64x2Instr::PrintOperandsTo(BufferFormatter* f) const {
977 f->Print("Float64x2.fromFloat32x4 "); 892 f->Print("Float64x2.fromFloat32x4 ");
978 left()->PrintTo(f); 893 left()->PrintTo(f);
979 } 894 }
980 895
981
982 void Float64x2ToFloat32x4Instr::PrintOperandsTo(BufferFormatter* f) const { 896 void Float64x2ToFloat32x4Instr::PrintOperandsTo(BufferFormatter* f) const {
983 f->Print("Float32x4.fromFloat64x2 "); 897 f->Print("Float32x4.fromFloat64x2 ");
984 left()->PrintTo(f); 898 left()->PrintTo(f);
985 } 899 }
986 900
987
988 void Float64x2ZeroArgInstr::PrintOperandsTo(BufferFormatter* f) const { 901 void Float64x2ZeroArgInstr::PrintOperandsTo(BufferFormatter* f) const {
989 f->Print("%s, ", MethodRecognizer::KindToCString(op_kind())); 902 f->Print("%s, ", MethodRecognizer::KindToCString(op_kind()));
990 left()->PrintTo(f); 903 left()->PrintTo(f);
991 } 904 }
992 905
993
994 void Float64x2OneArgInstr::PrintOperandsTo(BufferFormatter* f) const { 906 void Float64x2OneArgInstr::PrintOperandsTo(BufferFormatter* f) const {
995 f->Print("%s(", MethodRecognizer::KindToCString(op_kind())); 907 f->Print("%s(", MethodRecognizer::KindToCString(op_kind()));
996 left()->PrintTo(f); 908 left()->PrintTo(f);
997 f->Print(", "); 909 f->Print(", ");
998 right()->PrintTo(f); 910 right()->PrintTo(f);
999 f->Print(")"); 911 f->Print(")");
1000 } 912 }
1001 913
1002
1003 void Int32x4ConstructorInstr::PrintOperandsTo(BufferFormatter* f) const { 914 void Int32x4ConstructorInstr::PrintOperandsTo(BufferFormatter* f) const {
1004 f->Print("Int32x4("); 915 f->Print("Int32x4(");
1005 value0()->PrintTo(f); 916 value0()->PrintTo(f);
1006 f->Print(", "); 917 f->Print(", ");
1007 value1()->PrintTo(f); 918 value1()->PrintTo(f);
1008 f->Print(", "); 919 f->Print(", ");
1009 value2()->PrintTo(f); 920 value2()->PrintTo(f);
1010 f->Print(", "); 921 f->Print(", ");
1011 value3()->PrintTo(f); 922 value3()->PrintTo(f);
1012 f->Print(")"); 923 f->Print(")");
1013 } 924 }
1014 925
1015
1016 void Int32x4BoolConstructorInstr::PrintOperandsTo(BufferFormatter* f) const { 926 void Int32x4BoolConstructorInstr::PrintOperandsTo(BufferFormatter* f) const {
1017 f->Print("Int32x4.bool("); 927 f->Print("Int32x4.bool(");
1018 value0()->PrintTo(f); 928 value0()->PrintTo(f);
1019 f->Print(", "); 929 f->Print(", ");
1020 value1()->PrintTo(f); 930 value1()->PrintTo(f);
1021 f->Print(", "); 931 f->Print(", ");
1022 value2()->PrintTo(f); 932 value2()->PrintTo(f);
1023 f->Print(", "); 933 f->Print(", ");
1024 value3()->PrintTo(f); 934 value3()->PrintTo(f);
1025 f->Print(")"); 935 f->Print(")");
1026 } 936 }
1027 937
1028
1029 void Int32x4GetFlagInstr::PrintOperandsTo(BufferFormatter* f) const { 938 void Int32x4GetFlagInstr::PrintOperandsTo(BufferFormatter* f) const {
1030 f->Print("Int32x4.%s ", MethodRecognizer::KindToCString(op_kind())); 939 f->Print("Int32x4.%s ", MethodRecognizer::KindToCString(op_kind()));
1031 value()->PrintTo(f); 940 value()->PrintTo(f);
1032 } 941 }
1033 942
1034
1035 void Int32x4SetFlagInstr::PrintOperandsTo(BufferFormatter* f) const { 943 void Int32x4SetFlagInstr::PrintOperandsTo(BufferFormatter* f) const {
1036 f->Print("Int32x4.%s ", MethodRecognizer::KindToCString(op_kind())); 944 f->Print("Int32x4.%s ", MethodRecognizer::KindToCString(op_kind()));
1037 value()->PrintTo(f); 945 value()->PrintTo(f);
1038 f->Print(", "); 946 f->Print(", ");
1039 flagValue()->PrintTo(f); 947 flagValue()->PrintTo(f);
1040 } 948 }
1041 949
1042
1043 void Int32x4SelectInstr::PrintOperandsTo(BufferFormatter* f) const { 950 void Int32x4SelectInstr::PrintOperandsTo(BufferFormatter* f) const {
1044 f->Print("Int32x4.select "); 951 f->Print("Int32x4.select ");
1045 mask()->PrintTo(f); 952 mask()->PrintTo(f);
1046 f->Print(", "); 953 f->Print(", ");
1047 trueValue()->PrintTo(f); 954 trueValue()->PrintTo(f);
1048 f->Print(", "); 955 f->Print(", ");
1049 falseValue()->PrintTo(f); 956 falseValue()->PrintTo(f);
1050 } 957 }
1051 958
1052
1053 void Int32x4ToFloat32x4Instr::PrintOperandsTo(BufferFormatter* f) const { 959 void Int32x4ToFloat32x4Instr::PrintOperandsTo(BufferFormatter* f) const {
1054 f->Print("Int32x4.toFloat32x4 "); 960 f->Print("Int32x4.toFloat32x4 ");
1055 left()->PrintTo(f); 961 left()->PrintTo(f);
1056 } 962 }
1057 963
1058
1059 void BinaryInt32x4OpInstr::PrintOperandsTo(BufferFormatter* f) const { 964 void BinaryInt32x4OpInstr::PrintOperandsTo(BufferFormatter* f) const {
1060 f->Print("%s, ", Token::Str(op_kind())); 965 f->Print("%s, ", Token::Str(op_kind()));
1061 left()->PrintTo(f); 966 left()->PrintTo(f);
1062 f->Print(", "); 967 f->Print(", ");
1063 right()->PrintTo(f); 968 right()->PrintTo(f);
1064 } 969 }
1065 970
1066
1067 void UnaryDoubleOpInstr::PrintOperandsTo(BufferFormatter* f) const { 971 void UnaryDoubleOpInstr::PrintOperandsTo(BufferFormatter* f) const {
1068 f->Print("%s, ", Token::Str(op_kind())); 972 f->Print("%s, ", Token::Str(op_kind()));
1069 value()->PrintTo(f); 973 value()->PrintTo(f);
1070 } 974 }
1071 975
1072
1073 void CheckClassIdInstr::PrintOperandsTo(BufferFormatter* f) const { 976 void CheckClassIdInstr::PrintOperandsTo(BufferFormatter* f) const {
1074 value()->PrintTo(f); 977 value()->PrintTo(f);
1075 978
1076 const Class& cls = 979 const Class& cls =
1077 Class::Handle(Isolate::Current()->class_table()->At(cids().cid_start)); 980 Class::Handle(Isolate::Current()->class_table()->At(cids().cid_start));
1078 const String& name = String::Handle(cls.ScrubbedName()); 981 const String& name = String::Handle(cls.ScrubbedName());
1079 if (cids().IsSingleCid()) { 982 if (cids().IsSingleCid()) {
1080 f->Print(", %s", name.ToCString()); 983 f->Print(", %s", name.ToCString());
1081 } else { 984 } else {
1082 const Class& cls2 = 985 const Class& cls2 =
1083 Class::Handle(Isolate::Current()->class_table()->At(cids().cid_end)); 986 Class::Handle(Isolate::Current()->class_table()->At(cids().cid_end));
1084 const String& name2 = String::Handle(cls2.ScrubbedName()); 987 const String& name2 = String::Handle(cls2.ScrubbedName());
1085 f->Print(", cid %" Pd "-%" Pd " %s-%s", cids().cid_start, cids().cid_end, 988 f->Print(", cid %" Pd "-%" Pd " %s-%s", cids().cid_start, cids().cid_end,
1086 name.ToCString(), name2.ToCString()); 989 name.ToCString(), name2.ToCString());
1087 } 990 }
1088 } 991 }
1089 992
1090
1091 void CheckClassInstr::PrintOperandsTo(BufferFormatter* f) const { 993 void CheckClassInstr::PrintOperandsTo(BufferFormatter* f) const {
1092 value()->PrintTo(f); 994 value()->PrintTo(f);
1093 PrintCidsHelper(f, cids_, FlowGraphPrinter::kPrintAll); 995 PrintCidsHelper(f, cids_, FlowGraphPrinter::kPrintAll);
1094 if (IsNullCheck()) { 996 if (IsNullCheck()) {
1095 f->Print(" nullcheck"); 997 f->Print(" nullcheck");
1096 } 998 }
1097 } 999 }
1098 1000
1099
1100 void InvokeMathCFunctionInstr::PrintOperandsTo(BufferFormatter* f) const { 1001 void InvokeMathCFunctionInstr::PrintOperandsTo(BufferFormatter* f) const {
1101 f->Print("%s, ", MethodRecognizer::KindToCString(recognized_kind_)); 1002 f->Print("%s, ", MethodRecognizer::KindToCString(recognized_kind_));
1102 Definition::PrintOperandsTo(f); 1003 Definition::PrintOperandsTo(f);
1103 } 1004 }
1104 1005
1105
1106 void GraphEntryInstr::PrintTo(BufferFormatter* f) const { 1006 void GraphEntryInstr::PrintTo(BufferFormatter* f) const {
1107 const GrowableArray<Definition*>& defns = initial_definitions_; 1007 const GrowableArray<Definition*>& defns = initial_definitions_;
1108 f->Print("B%" Pd "[graph]:%" Pd, block_id(), GetDeoptId()); 1008 f->Print("B%" Pd "[graph]:%" Pd, block_id(), GetDeoptId());
1109 if (defns.length() > 0) { 1009 if (defns.length() > 0) {
1110 f->Print(" {"); 1010 f->Print(" {");
1111 for (intptr_t i = 0; i < defns.length(); ++i) { 1011 for (intptr_t i = 0; i < defns.length(); ++i) {
1112 Definition* def = defns[i]; 1012 Definition* def = defns[i];
1113 f->Print("\n "); 1013 f->Print("\n ");
1114 def->PrintTo(f); 1014 def->PrintTo(f);
1115 } 1015 }
1116 f->Print("\n}"); 1016 f->Print("\n}");
1117 } 1017 }
1118 } 1018 }
1119 1019
1120
1121 void JoinEntryInstr::PrintTo(BufferFormatter* f) const { 1020 void JoinEntryInstr::PrintTo(BufferFormatter* f) const {
1122 if (try_index() != CatchClauseNode::kInvalidTryIndex) { 1021 if (try_index() != CatchClauseNode::kInvalidTryIndex) {
1123 f->Print("B%" Pd "[join try_idx %" Pd "]:%" Pd " pred(", block_id(), 1022 f->Print("B%" Pd "[join try_idx %" Pd "]:%" Pd " pred(", block_id(),
1124 try_index(), GetDeoptId()); 1023 try_index(), GetDeoptId());
1125 } else { 1024 } else {
1126 f->Print("B%" Pd "[join]:%" Pd " pred(", block_id(), GetDeoptId()); 1025 f->Print("B%" Pd "[join]:%" Pd " pred(", block_id(), GetDeoptId());
1127 } 1026 }
1128 for (intptr_t i = 0; i < predecessors_.length(); ++i) { 1027 for (intptr_t i = 0; i < predecessors_.length(); ++i) {
1129 if (i > 0) f->Print(", "); 1028 if (i > 0) f->Print(", ");
1130 f->Print("B%" Pd, predecessors_[i]->block_id()); 1029 f->Print("B%" Pd, predecessors_[i]->block_id());
1131 } 1030 }
1132 f->Print(")"); 1031 f->Print(")");
1133 if (phis_ != NULL) { 1032 if (phis_ != NULL) {
1134 f->Print(" {"); 1033 f->Print(" {");
1135 for (intptr_t i = 0; i < phis_->length(); ++i) { 1034 for (intptr_t i = 0; i < phis_->length(); ++i) {
1136 if ((*phis_)[i] == NULL) continue; 1035 if ((*phis_)[i] == NULL) continue;
1137 f->Print("\n "); 1036 f->Print("\n ");
1138 (*phis_)[i]->PrintTo(f); 1037 (*phis_)[i]->PrintTo(f);
1139 } 1038 }
1140 f->Print("\n}"); 1039 f->Print("\n}");
1141 } 1040 }
1142 if (HasParallelMove()) { 1041 if (HasParallelMove()) {
1143 f->Print(" "); 1042 f->Print(" ");
1144 parallel_move()->PrintTo(f); 1043 parallel_move()->PrintTo(f);
1145 } 1044 }
1146 } 1045 }
1147 1046
1148
1149 void IndirectEntryInstr::PrintTo(BufferFormatter* f) const { 1047 void IndirectEntryInstr::PrintTo(BufferFormatter* f) const {
1150 ASSERT(try_index() == CatchClauseNode::kInvalidTryIndex); 1048 ASSERT(try_index() == CatchClauseNode::kInvalidTryIndex);
1151 f->Print("B%" Pd "[join indirect]:%" Pd " pred(", block_id(), GetDeoptId()); 1049 f->Print("B%" Pd "[join indirect]:%" Pd " pred(", block_id(), GetDeoptId());
1152 for (intptr_t i = 0; i < predecessors_.length(); ++i) { 1050 for (intptr_t i = 0; i < predecessors_.length(); ++i) {
1153 if (i > 0) f->Print(", "); 1051 if (i > 0) f->Print(", ");
1154 f->Print("B%" Pd, predecessors_[i]->block_id()); 1052 f->Print("B%" Pd, predecessors_[i]->block_id());
1155 } 1053 }
1156 f->Print(")"); 1054 f->Print(")");
1157 if (phis_ != NULL) { 1055 if (phis_ != NULL) {
1158 f->Print(" {"); 1056 f->Print(" {");
1159 for (intptr_t i = 0; i < phis_->length(); ++i) { 1057 for (intptr_t i = 0; i < phis_->length(); ++i) {
1160 if ((*phis_)[i] == NULL) continue; 1058 if ((*phis_)[i] == NULL) continue;
1161 f->Print("\n "); 1059 f->Print("\n ");
1162 (*phis_)[i]->PrintTo(f); 1060 (*phis_)[i]->PrintTo(f);
1163 } 1061 }
1164 f->Print("\n}"); 1062 f->Print("\n}");
1165 } 1063 }
1166 if (HasParallelMove()) { 1064 if (HasParallelMove()) {
1167 f->Print(" "); 1065 f->Print(" ");
1168 parallel_move()->PrintTo(f); 1066 parallel_move()->PrintTo(f);
1169 } 1067 }
1170 } 1068 }
1171 1069
1172
1173 static const char* RepresentationToCString(Representation rep) { 1070 static const char* RepresentationToCString(Representation rep) {
1174 switch (rep) { 1071 switch (rep) {
1175 case kTagged: 1072 case kTagged:
1176 return "tagged"; 1073 return "tagged";
1177 case kUntagged: 1074 case kUntagged:
1178 return "untagged"; 1075 return "untagged";
1179 case kUnboxedDouble: 1076 case kUnboxedDouble:
1180 return "double"; 1077 return "double";
1181 case kUnboxedInt32: 1078 case kUnboxedInt32:
1182 return "int32"; 1079 return "int32";
(...skipping 10 matching lines...) Expand all
1193 case kPairOfTagged: 1090 case kPairOfTagged:
1194 return "tagged-pair"; 1091 return "tagged-pair";
1195 case kNoRepresentation: 1092 case kNoRepresentation:
1196 return "none"; 1093 return "none";
1197 case kNumRepresentations: 1094 case kNumRepresentations:
1198 UNREACHABLE(); 1095 UNREACHABLE();
1199 } 1096 }
1200 return "?"; 1097 return "?";
1201 } 1098 }
1202 1099
1203
1204 void PhiInstr::PrintTo(BufferFormatter* f) const { 1100 void PhiInstr::PrintTo(BufferFormatter* f) const {
1205 if (HasPairRepresentation()) { 1101 if (HasPairRepresentation()) {
1206 f->Print("(v%" Pd ", v%" Pd ") <- phi(", ssa_temp_index(), 1102 f->Print("(v%" Pd ", v%" Pd ") <- phi(", ssa_temp_index(),
1207 ssa_temp_index() + 1); 1103 ssa_temp_index() + 1);
1208 } else { 1104 } else {
1209 f->Print("v%" Pd " <- phi(", ssa_temp_index()); 1105 f->Print("v%" Pd " <- phi(", ssa_temp_index());
1210 } 1106 }
1211 for (intptr_t i = 0; i < inputs_.length(); ++i) { 1107 for (intptr_t i = 0; i < inputs_.length(); ++i) {
1212 if (inputs_[i] != NULL) inputs_[i]->PrintTo(f); 1108 if (inputs_[i] != NULL) inputs_[i]->PrintTo(f);
1213 if (i < inputs_.length() - 1) f->Print(", "); 1109 if (i < inputs_.length() - 1) f->Print(", ");
(...skipping 12 matching lines...) Expand all
1226 if (representation() != kNoRepresentation && representation() != kTagged) { 1122 if (representation() != kNoRepresentation && representation() != kTagged) {
1227 f->Print(" %s", RepresentationToCString(representation())); 1123 f->Print(" %s", RepresentationToCString(representation()));
1228 } 1124 }
1229 1125
1230 if (type_ != NULL) { 1126 if (type_ != NULL) {
1231 f->Print(" "); 1127 f->Print(" ");
1232 type_->PrintTo(f); 1128 type_->PrintTo(f);
1233 } 1129 }
1234 } 1130 }
1235 1131
1236
1237 void UnboxIntegerInstr::PrintOperandsTo(BufferFormatter* f) const { 1132 void UnboxIntegerInstr::PrintOperandsTo(BufferFormatter* f) const {
1238 if (is_truncating()) { 1133 if (is_truncating()) {
1239 f->Print("[tr], "); 1134 f->Print("[tr], ");
1240 } 1135 }
1241 Definition::PrintOperandsTo(f); 1136 Definition::PrintOperandsTo(f);
1242 } 1137 }
1243 1138
1244
1245 void UnboxedIntConverterInstr::PrintOperandsTo(BufferFormatter* f) const { 1139 void UnboxedIntConverterInstr::PrintOperandsTo(BufferFormatter* f) const {
1246 f->Print("%s->%s%s, ", RepresentationToCString(from()), 1140 f->Print("%s->%s%s, ", RepresentationToCString(from()),
1247 RepresentationToCString(to()), is_truncating() ? "[tr]" : ""); 1141 RepresentationToCString(to()), is_truncating() ? "[tr]" : "");
1248 Definition::PrintOperandsTo(f); 1142 Definition::PrintOperandsTo(f);
1249 } 1143 }
1250 1144
1251
1252 void ParameterInstr::PrintOperandsTo(BufferFormatter* f) const { 1145 void ParameterInstr::PrintOperandsTo(BufferFormatter* f) const {
1253 f->Print("%" Pd, index()); 1146 f->Print("%" Pd, index());
1254 } 1147 }
1255 1148
1256
1257 void CheckStackOverflowInstr::PrintOperandsTo(BufferFormatter* f) const { 1149 void CheckStackOverflowInstr::PrintOperandsTo(BufferFormatter* f) const {
1258 if (in_loop()) f->Print("depth %" Pd, loop_depth()); 1150 if (in_loop()) f->Print("depth %" Pd, loop_depth());
1259 } 1151 }
1260 1152
1261
1262 void TargetEntryInstr::PrintTo(BufferFormatter* f) const { 1153 void TargetEntryInstr::PrintTo(BufferFormatter* f) const {
1263 if (try_index() != CatchClauseNode::kInvalidTryIndex) { 1154 if (try_index() != CatchClauseNode::kInvalidTryIndex) {
1264 f->Print("B%" Pd "[target try_idx %" Pd "]:%" Pd, block_id(), try_index(), 1155 f->Print("B%" Pd "[target try_idx %" Pd "]:%" Pd, block_id(), try_index(),
1265 GetDeoptId()); 1156 GetDeoptId());
1266 } else { 1157 } else {
1267 f->Print("B%" Pd "[target]:%" Pd, block_id(), GetDeoptId()); 1158 f->Print("B%" Pd "[target]:%" Pd, block_id(), GetDeoptId());
1268 } 1159 }
1269 if (HasParallelMove()) { 1160 if (HasParallelMove()) {
1270 f->Print(" "); 1161 f->Print(" ");
1271 parallel_move()->PrintTo(f); 1162 parallel_move()->PrintTo(f);
1272 } 1163 }
1273 } 1164 }
1274 1165
1275
1276 void CatchBlockEntryInstr::PrintTo(BufferFormatter* f) const { 1166 void CatchBlockEntryInstr::PrintTo(BufferFormatter* f) const {
1277 f->Print("B%" Pd "[target catch try_idx %" Pd " catch_try_idx %" Pd "]", 1167 f->Print("B%" Pd "[target catch try_idx %" Pd " catch_try_idx %" Pd "]",
1278 block_id(), try_index(), catch_try_index()); 1168 block_id(), try_index(), catch_try_index());
1279 if (HasParallelMove()) { 1169 if (HasParallelMove()) {
1280 f->Print("\n"); 1170 f->Print("\n");
1281 parallel_move()->PrintTo(f); 1171 parallel_move()->PrintTo(f);
1282 } 1172 }
1283 1173
1284 const GrowableArray<Definition*>& defns = initial_definitions_; 1174 const GrowableArray<Definition*>& defns = initial_definitions_;
1285 if (defns.length() > 0) { 1175 if (defns.length() > 0) {
1286 f->Print(" {"); 1176 f->Print(" {");
1287 for (intptr_t i = 0; i < defns.length(); ++i) { 1177 for (intptr_t i = 0; i < defns.length(); ++i) {
1288 Definition* def = defns[i]; 1178 Definition* def = defns[i];
1289 f->Print("\n "); 1179 f->Print("\n ");
1290 def->PrintTo(f); 1180 def->PrintTo(f);
1291 } 1181 }
1292 f->Print("\n}"); 1182 f->Print("\n}");
1293 } 1183 }
1294 } 1184 }
1295 1185
1296
1297 void PushArgumentInstr::PrintOperandsTo(BufferFormatter* f) const { 1186 void PushArgumentInstr::PrintOperandsTo(BufferFormatter* f) const {
1298 value()->PrintTo(f); 1187 value()->PrintTo(f);
1299 } 1188 }
1300 1189
1301
1302 void GotoInstr::PrintTo(BufferFormatter* f) const { 1190 void GotoInstr::PrintTo(BufferFormatter* f) const {
1303 if (HasParallelMove()) { 1191 if (HasParallelMove()) {
1304 parallel_move()->PrintTo(f); 1192 parallel_move()->PrintTo(f);
1305 f->Print(" "); 1193 f->Print(" ");
1306 } 1194 }
1307 if (GetDeoptId() != Thread::kNoDeoptId) { 1195 if (GetDeoptId() != Thread::kNoDeoptId) {
1308 f->Print("goto:%" Pd " B%" Pd "", GetDeoptId(), successor()->block_id()); 1196 f->Print("goto:%" Pd " B%" Pd "", GetDeoptId(), successor()->block_id());
1309 } else { 1197 } else {
1310 f->Print("goto: B%" Pd "", successor()->block_id()); 1198 f->Print("goto: B%" Pd "", successor()->block_id());
1311 } 1199 }
1312 } 1200 }
1313 1201
1314
1315 void IndirectGotoInstr::PrintTo(BufferFormatter* f) const { 1202 void IndirectGotoInstr::PrintTo(BufferFormatter* f) const {
1316 if (GetDeoptId() != Thread::kNoDeoptId) { 1203 if (GetDeoptId() != Thread::kNoDeoptId) {
1317 f->Print("igoto:%" Pd "(", GetDeoptId()); 1204 f->Print("igoto:%" Pd "(", GetDeoptId());
1318 } else { 1205 } else {
1319 f->Print("igoto:("); 1206 f->Print("igoto:(");
1320 } 1207 }
1321 InputAt(0)->PrintTo(f); 1208 InputAt(0)->PrintTo(f);
1322 f->Print(")"); 1209 f->Print(")");
1323 } 1210 }
1324 1211
1325
1326 void BranchInstr::PrintTo(BufferFormatter* f) const { 1212 void BranchInstr::PrintTo(BufferFormatter* f) const {
1327 f->Print("%s ", DebugName()); 1213 f->Print("%s ", DebugName());
1328 f->Print("if "); 1214 f->Print("if ");
1329 comparison()->PrintTo(f); 1215 comparison()->PrintTo(f);
1330 1216
1331 f->Print(" goto (%" Pd ", %" Pd ")", true_successor()->block_id(), 1217 f->Print(" goto (%" Pd ", %" Pd ")", true_successor()->block_id(),
1332 false_successor()->block_id()); 1218 false_successor()->block_id());
1333 } 1219 }
1334 1220
1335
1336 void ParallelMoveInstr::PrintTo(BufferFormatter* f) const { 1221 void ParallelMoveInstr::PrintTo(BufferFormatter* f) const {
1337 f->Print("%s ", DebugName()); 1222 f->Print("%s ", DebugName());
1338 for (intptr_t i = 0; i < moves_.length(); i++) { 1223 for (intptr_t i = 0; i < moves_.length(); i++) {
1339 if (i != 0) f->Print(", "); 1224 if (i != 0) f->Print(", ");
1340 moves_[i]->dest().PrintTo(f); 1225 moves_[i]->dest().PrintTo(f);
1341 f->Print(" <- "); 1226 f->Print(" <- ");
1342 moves_[i]->src().PrintTo(f); 1227 moves_[i]->src().PrintTo(f);
1343 } 1228 }
1344 } 1229 }
1345 1230
1346
1347 void Environment::PrintTo(BufferFormatter* f) const { 1231 void Environment::PrintTo(BufferFormatter* f) const {
1348 f->Print(" env={ "); 1232 f->Print(" env={ ");
1349 int arg_count = 0; 1233 int arg_count = 0;
1350 for (intptr_t i = 0; i < values_.length(); ++i) { 1234 for (intptr_t i = 0; i < values_.length(); ++i) {
1351 if (i > 0) f->Print(", "); 1235 if (i > 0) f->Print(", ");
1352 if (values_[i]->definition()->IsPushArgument()) { 1236 if (values_[i]->definition()->IsPushArgument()) {
1353 f->Print("a%d", arg_count++); 1237 f->Print("a%d", arg_count++);
1354 } else { 1238 } else {
1355 values_[i]->PrintTo(f); 1239 values_[i]->PrintTo(f);
1356 } 1240 }
1357 if ((locations_ != NULL) && !locations_[i].IsInvalid()) { 1241 if ((locations_ != NULL) && !locations_[i].IsInvalid()) {
1358 f->Print(" ["); 1242 f->Print(" [");
1359 locations_[i].PrintTo(f); 1243 locations_[i].PrintTo(f);
1360 f->Print("]"); 1244 f->Print("]");
1361 } 1245 }
1362 } 1246 }
1363 f->Print(" }"); 1247 f->Print(" }");
1364 if (outer_ != NULL) outer_->PrintTo(f); 1248 if (outer_ != NULL) outer_->PrintTo(f);
1365 } 1249 }
1366 1250
1367 const char* Environment::ToCString() const { 1251 const char* Environment::ToCString() const {
1368 char buffer[1024]; 1252 char buffer[1024];
1369 BufferFormatter bf(buffer, 1024); 1253 BufferFormatter bf(buffer, 1024);
1370 PrintTo(&bf); 1254 PrintTo(&bf);
1371 return Thread::Current()->zone()->MakeCopyOfString(buffer); 1255 return Thread::Current()->zone()->MakeCopyOfString(buffer);
1372 } 1256 }
1373 1257
1374
1375 #else // PRODUCT 1258 #else // PRODUCT
1376 1259
1377
1378 const char* Instruction::ToCString() const { 1260 const char* Instruction::ToCString() const {
1379 return DebugName(); 1261 return DebugName();
1380 } 1262 }
1381 1263
1382
1383 void FlowGraphPrinter::PrintOneInstruction(Instruction* instr, 1264 void FlowGraphPrinter::PrintOneInstruction(Instruction* instr,
1384 bool print_locations) { 1265 bool print_locations) {
1385 UNREACHABLE(); 1266 UNREACHABLE();
1386 } 1267 }
1387 1268
1388
1389 void FlowGraphPrinter::PrintTypeCheck(const ParsedFunction& parsed_function, 1269 void FlowGraphPrinter::PrintTypeCheck(const ParsedFunction& parsed_function,
1390 TokenPosition token_pos, 1270 TokenPosition token_pos,
1391 Value* value, 1271 Value* value,
1392 const AbstractType& dst_type, 1272 const AbstractType& dst_type,
1393 const String& dst_name, 1273 const String& dst_name,
1394 bool eliminated) { 1274 bool eliminated) {
1395 UNREACHABLE(); 1275 UNREACHABLE();
1396 } 1276 }
1397 1277
1398
1399 void FlowGraphPrinter::PrintBlock(BlockEntryInstr* block, 1278 void FlowGraphPrinter::PrintBlock(BlockEntryInstr* block,
1400 bool print_locations) { 1279 bool print_locations) {
1401 UNREACHABLE(); 1280 UNREACHABLE();
1402 } 1281 }
1403 1282
1404
1405 void FlowGraphPrinter::PrintGraph(const char* phase, FlowGraph* flow_graph) { 1283 void FlowGraphPrinter::PrintGraph(const char* phase, FlowGraph* flow_graph) {
1406 UNREACHABLE(); 1284 UNREACHABLE();
1407 } 1285 }
1408 1286
1409
1410 void FlowGraphPrinter::PrintICData(const ICData& ic_data, 1287 void FlowGraphPrinter::PrintICData(const ICData& ic_data,
1411 intptr_t num_checks_to_print) { 1288 intptr_t num_checks_to_print) {
1412 UNREACHABLE(); 1289 UNREACHABLE();
1413 } 1290 }
1414 1291
1415
1416 bool FlowGraphPrinter::ShouldPrint(const Function& function) { 1292 bool FlowGraphPrinter::ShouldPrint(const Function& function) {
1417 return false; 1293 return false;
1418 } 1294 }
1419 1295
1420 #endif // !PRODUCT 1296 #endif // !PRODUCT
1421 1297
1422 } // namespace dart 1298 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/il_printer.h ('k') | runtime/vm/instructions_arm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698