| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/il_printer.h" | 5 #include "vm/il_printer.h" |
| 6 | 6 |
| 7 #include "vm/intermediate_language.h" | 7 #include "vm/intermediate_language.h" |
| 8 #include "vm/os.h" | 8 #include "vm/os.h" |
| 9 #include "vm/parser.h" | 9 #include "vm/parser.h" |
| 10 | 10 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 | 125 |
| 126 | 126 |
| 127 const char* CompileType::ToCString() const { | 127 const char* CompileType::ToCString() const { |
| 128 char buffer[1024]; | 128 char buffer[1024]; |
| 129 BufferFormatter f(buffer, sizeof(buffer)); | 129 BufferFormatter f(buffer, sizeof(buffer)); |
| 130 PrintTo(&f); | 130 PrintTo(&f); |
| 131 return Isolate::Current()->current_zone()->MakeCopyOfString(buffer); | 131 return Isolate::Current()->current_zone()->MakeCopyOfString(buffer); |
| 132 } | 132 } |
| 133 | 133 |
| 134 | 134 |
| 135 static void PrintICData(BufferFormatter* f, const ICData& ic_data) { | 135 static void PrintICDataHelper(BufferFormatter* f, const ICData& ic_data) { |
| 136 f->Print(" IC[%" Pd ": ", ic_data.NumberOfChecks()); | 136 f->Print(" IC[%" Pd ": ", ic_data.NumberOfChecks()); |
| 137 Function& target = Function::Handle(); | 137 Function& target = Function::Handle(); |
| 138 for (intptr_t i = 0; i < ic_data.NumberOfChecks(); i++) { | 138 for (intptr_t i = 0; i < ic_data.NumberOfChecks(); i++) { |
| 139 GrowableArray<intptr_t> class_ids; | 139 GrowableArray<intptr_t> class_ids; |
| 140 ic_data.GetCheckAt(i, &class_ids, &target); | 140 ic_data.GetCheckAt(i, &class_ids, &target); |
| 141 const intptr_t count = ic_data.GetCountAt(i); | 141 const intptr_t count = ic_data.GetCountAt(i); |
| 142 if (i > 0) { | 142 if (i > 0) { |
| 143 f->Print(" | "); | 143 f->Print(" | "); |
| 144 } | 144 } |
| 145 for (intptr_t k = 0; k < class_ids.length(); k++) { | 145 for (intptr_t k = 0; k < class_ids.length(); k++) { |
| 146 if (k > 0) { | 146 if (k > 0) { |
| 147 f->Print(", "); | 147 f->Print(", "); |
| 148 } | 148 } |
| 149 const Class& cls = | 149 const Class& cls = |
| 150 Class::Handle(Isolate::Current()->class_table()->At(class_ids[k])); | 150 Class::Handle(Isolate::Current()->class_table()->At(class_ids[k])); |
| 151 f->Print("%s", String::Handle(cls.Name()).ToCString()); | 151 f->Print("%s", String::Handle(cls.Name()).ToCString()); |
| 152 } | 152 } |
| 153 if (count > 0) { | 153 if (count > 0) { |
| 154 f->Print(" #%" Pd, count); | 154 f->Print(" #%" Pd, count); |
| 155 } | 155 } |
| 156 f->Print(" <%p>", static_cast<void*>(target.raw())); | 156 f->Print(" <%p>", static_cast<void*>(target.raw())); |
| 157 } | 157 } |
| 158 f->Print("]"); | 158 f->Print("]"); |
| 159 } | 159 } |
| 160 | 160 |
| 161 | 161 |
| 162 void FlowGraphPrinter::PrintICData(const ICData& ic_data) { |
| 163 char buffer[1024]; |
| 164 BufferFormatter f(buffer, sizeof(buffer)); |
| 165 PrintICDataHelper(&f, ic_data); |
| 166 OS::Print("%s\n", buffer); |
| 167 } |
| 168 |
| 169 |
| 162 static void PrintUse(BufferFormatter* f, const Definition& definition) { | 170 static void PrintUse(BufferFormatter* f, const Definition& definition) { |
| 163 if (definition.is_used()) { | 171 if (definition.is_used()) { |
| 164 if (definition.HasSSATemp()) { | 172 if (definition.HasSSATemp()) { |
| 165 f->Print("v%" Pd, definition.ssa_temp_index()); | 173 f->Print("v%" Pd, definition.ssa_temp_index()); |
| 166 } else if (definition.temp_index() != -1) { | 174 } else if (definition.temp_index() != -1) { |
| 167 f->Print("t%" Pd, definition.temp_index()); | 175 f->Print("t%" Pd, definition.temp_index()); |
| 168 } | 176 } |
| 169 } | 177 } |
| 170 } | 178 } |
| 171 | 179 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 } | 355 } |
| 348 | 356 |
| 349 | 357 |
| 350 void InstanceCallInstr::PrintOperandsTo(BufferFormatter* f) const { | 358 void InstanceCallInstr::PrintOperandsTo(BufferFormatter* f) const { |
| 351 f->Print("%s", function_name().ToCString()); | 359 f->Print("%s", function_name().ToCString()); |
| 352 for (intptr_t i = 0; i < ArgumentCount(); ++i) { | 360 for (intptr_t i = 0; i < ArgumentCount(); ++i) { |
| 353 f->Print(", "); | 361 f->Print(", "); |
| 354 PushArgumentAt(i)->value()->PrintTo(f); | 362 PushArgumentAt(i)->value()->PrintTo(f); |
| 355 } | 363 } |
| 356 if (HasICData()) { | 364 if (HasICData()) { |
| 357 PrintICData(f, *ic_data()); | 365 PrintICDataHelper(f, *ic_data()); |
| 358 } | 366 } |
| 359 } | 367 } |
| 360 | 368 |
| 361 | 369 |
| 362 void PolymorphicInstanceCallInstr::PrintOperandsTo(BufferFormatter* f) const { | 370 void PolymorphicInstanceCallInstr::PrintOperandsTo(BufferFormatter* f) const { |
| 363 f->Print("%s", instance_call()->function_name().ToCString()); | 371 f->Print("%s", instance_call()->function_name().ToCString()); |
| 364 for (intptr_t i = 0; i < ArgumentCount(); ++i) { | 372 for (intptr_t i = 0; i < ArgumentCount(); ++i) { |
| 365 f->Print(", "); | 373 f->Print(", "); |
| 366 PushArgumentAt(i)->value()->PrintTo(f); | 374 PushArgumentAt(i)->value()->PrintTo(f); |
| 367 } | 375 } |
| 368 PrintICData(f, ic_data()); | 376 PrintICDataHelper(f, ic_data()); |
| 369 } | 377 } |
| 370 | 378 |
| 371 | 379 |
| 372 void StrictCompareInstr::PrintOperandsTo(BufferFormatter* f) const { | 380 void StrictCompareInstr::PrintOperandsTo(BufferFormatter* f) const { |
| 373 f->Print("%s, ", Token::Str(kind())); | 381 f->Print("%s, ", Token::Str(kind())); |
| 374 left()->PrintTo(f); | 382 left()->PrintTo(f); |
| 375 f->Print(", "); | 383 f->Print(", "); |
| 376 right()->PrintTo(f); | 384 right()->PrintTo(f); |
| 377 if (needs_number_check()) { | 385 if (needs_number_check()) { |
| 378 f->Print(", with number check"); | 386 f->Print(", with number check"); |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 845 | 853 |
| 846 | 854 |
| 847 void UnaryDoubleOpInstr::PrintOperandsTo(BufferFormatter* f) const { | 855 void UnaryDoubleOpInstr::PrintOperandsTo(BufferFormatter* f) const { |
| 848 f->Print("%s, ", Token::Str(op_kind())); | 856 f->Print("%s, ", Token::Str(op_kind())); |
| 849 value()->PrintTo(f); | 857 value()->PrintTo(f); |
| 850 } | 858 } |
| 851 | 859 |
| 852 | 860 |
| 853 void CheckClassInstr::PrintOperandsTo(BufferFormatter* f) const { | 861 void CheckClassInstr::PrintOperandsTo(BufferFormatter* f) const { |
| 854 value()->PrintTo(f); | 862 value()->PrintTo(f); |
| 855 PrintICData(f, unary_checks()); | 863 PrintICDataHelper(f, unary_checks()); |
| 856 if (IsNullCheck()) { | 864 if (IsNullCheck()) { |
| 857 f->Print(" nullcheck"); | 865 f->Print(" nullcheck"); |
| 858 } | 866 } |
| 859 } | 867 } |
| 860 | 868 |
| 861 | 869 |
| 862 void InvokeMathCFunctionInstr::PrintOperandsTo(BufferFormatter* f) const { | 870 void InvokeMathCFunctionInstr::PrintOperandsTo(BufferFormatter* f) const { |
| 863 f->Print("%s, ", MethodRecognizer::KindToCString(recognized_kind_)); | 871 f->Print("%s, ", MethodRecognizer::KindToCString(recognized_kind_)); |
| 864 Definition::PrintOperandsTo(f); | 872 Definition::PrintOperandsTo(f); |
| 865 } | 873 } |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1030 f->Print(" ["); | 1038 f->Print(" ["); |
| 1031 locations_[i].PrintTo(f); | 1039 locations_[i].PrintTo(f); |
| 1032 f->Print("]"); | 1040 f->Print("]"); |
| 1033 } | 1041 } |
| 1034 } | 1042 } |
| 1035 f->Print(" }"); | 1043 f->Print(" }"); |
| 1036 if (outer_ != NULL) outer_->PrintTo(f); | 1044 if (outer_ != NULL) outer_->PrintTo(f); |
| 1037 } | 1045 } |
| 1038 | 1046 |
| 1039 } // namespace dart | 1047 } // namespace dart |
| OLD | NEW |