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 | 9 |
10 namespace dart { | 10 namespace dart { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 75 |
76 | 76 |
77 void FlowGraphPrinter::PrintComputation(Computation* comp) { | 77 void FlowGraphPrinter::PrintComputation(Computation* comp) { |
78 char str[1000]; | 78 char str[1000]; |
79 BufferFormatter f(str, sizeof(str)); | 79 BufferFormatter f(str, sizeof(str)); |
80 comp->PrintTo(&f); | 80 comp->PrintTo(&f); |
81 OS::Print("%s", str); | 81 OS::Print("%s", str); |
82 } | 82 } |
83 | 83 |
84 | 84 |
| 85 static void PrintICData(BufferFormatter* f, const ICData& ic_data) { |
| 86 f->Print(" IC[%d: ", ic_data.NumberOfChecks()); |
| 87 Function& target = Function::Handle(); |
| 88 for (intptr_t i = 0; i < ic_data.NumberOfChecks(); i++) { |
| 89 GrowableArray<intptr_t> class_ids; |
| 90 ic_data.GetCheckAt(i, &class_ids, &target); |
| 91 if (i > 0) { |
| 92 f->Print(" | "); |
| 93 } |
| 94 for (intptr_t k = 0; k < class_ids.length(); k++) { |
| 95 if (k > 0) { |
| 96 f->Print(", "); |
| 97 } |
| 98 const Class& cls = |
| 99 Class::Handle(Isolate::Current()->class_table()->At(class_ids[k])); |
| 100 f->Print("%s", String::Handle(cls.Name()).ToCString()); |
| 101 } |
| 102 } |
| 103 f->Print("]"); |
| 104 } |
| 105 |
| 106 |
85 void Computation::PrintTo(BufferFormatter* f) const { | 107 void Computation::PrintTo(BufferFormatter* f) const { |
86 f->Print("%s(", DebugName()); | 108 f->Print("%s:%d(", DebugName(), cid()); |
87 PrintOperandsTo(f); | 109 PrintOperandsTo(f); |
88 f->Print(")"); | 110 f->Print(")"); |
| 111 if (HasICData()) { |
| 112 PrintICData(f, *ic_data()); |
| 113 } |
89 } | 114 } |
90 | 115 |
91 | 116 |
92 void Computation::PrintOperandsTo(BufferFormatter* f) const { | 117 void Computation::PrintOperandsTo(BufferFormatter* f) const { |
93 for (int i = 0; i < InputCount(); ++i) { | 118 for (int i = 0; i < InputCount(); ++i) { |
94 if (i > 0) f->Print(", "); | 119 if (i > 0) f->Print(", "); |
95 if (InputAt(i) != NULL) InputAt(i)->PrintTo(f); | 120 if (InputAt(i) != NULL) InputAt(i)->PrintTo(f); |
96 } | 121 } |
97 } | 122 } |
98 | 123 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 f->Print(", "); | 164 f->Print(", "); |
140 ArgumentAt(i)->PrintTo(f); | 165 ArgumentAt(i)->PrintTo(f); |
141 } | 166 } |
142 } | 167 } |
143 | 168 |
144 | 169 |
145 void PolymorphicInstanceCallComp::PrintTo(BufferFormatter* f) const { | 170 void PolymorphicInstanceCallComp::PrintTo(BufferFormatter* f) const { |
146 f->Print("%s(", DebugName()); | 171 f->Print("%s(", DebugName()); |
147 instance_call()->PrintOperandsTo(f); | 172 instance_call()->PrintOperandsTo(f); |
148 f->Print(") "); | 173 f->Print(") "); |
149 intptr_t len = HasICData() ? ic_data()->NumberOfChecks() : 0; | 174 if (HasICData()) { |
150 f->Print("[%d: ", len); | 175 PrintICData(f, *ic_data()); |
151 for (intptr_t i = 0; i < len; i++) { | |
152 intptr_t class_id = ic_data()->GetReceiverClassIdAt(i); | |
153 const Class& cls = | |
154 Class::Handle(Isolate::Current()->class_table()->At(class_id)); | |
155 if (i > 0) { | |
156 f->Print(", "); | |
157 } | |
158 f->Print("%s", cls.ToCString()); | |
159 } | 176 } |
160 f->Print("]"); | |
161 } | 177 } |
162 | 178 |
163 void StrictCompareComp::PrintOperandsTo(BufferFormatter* f) const { | 179 void StrictCompareComp::PrintOperandsTo(BufferFormatter* f) const { |
164 f->Print("%s, ", Token::Str(kind())); | 180 f->Print("%s, ", Token::Str(kind())); |
165 left()->PrintTo(f); | 181 left()->PrintTo(f); |
166 f->Print(", "); | 182 f->Print(", "); |
167 right()->PrintTo(f); | 183 right()->PrintTo(f); |
168 } | 184 } |
169 | 185 |
170 | 186 |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
696 if (i > 0) f->Print(", "); | 712 if (i > 0) f->Print(", "); |
697 values_[i]->PrintTo(f); | 713 values_[i]->PrintTo(f); |
698 if ((i < locations_.length()) && !locations_[i].IsInvalid()) { | 714 if ((i < locations_.length()) && !locations_[i].IsInvalid()) { |
699 f->Print(" [%s]", locations_[i].Name()); | 715 f->Print(" [%s]", locations_[i].Name()); |
700 } | 716 } |
701 } | 717 } |
702 f->Print(" }"); | 718 f->Print(" }"); |
703 } | 719 } |
704 | 720 |
705 } // namespace dart | 721 } // namespace dart |
OLD | NEW |