| 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 { |
| 11 | 11 |
| 12 | 12 |
| 13 void FlowGraphPrinter::VisitBlocks() { | 13 void BufferFormatter::Print(const char* format, ...) { |
| 14 intptr_t available = size_ - position_; |
| 15 if (available <= 0) return; |
| 16 va_list args; |
| 17 va_start(args, format); |
| 18 intptr_t written = |
| 19 OS::VSNPrint(buffer_ + position_, available, format, args); |
| 20 if (written >= 0) { |
| 21 position_ += (available <= written) ? available : written; |
| 22 } |
| 23 va_end(args); |
| 24 } |
| 25 |
| 26 |
| 27 void FlowGraphPrinter::PrintBlocks() { |
| 14 OS::Print("==== %s\n", function_.ToFullyQualifiedCString()); | 28 OS::Print("==== %s\n", function_.ToFullyQualifiedCString()); |
| 15 | 29 |
| 16 for (intptr_t i = 0; i < block_order_.length(); ++i) { | 30 for (intptr_t i = 0; i < block_order_.length(); ++i) { |
| 17 // Print the block entry. | 31 // Print the block entry. |
| 18 Instruction* current = block_order_[i]->Accept(this); | 32 Print(block_order_[i]); |
| 33 Instruction* current = block_order_[i]->StraightLineSuccessor(); |
| 19 // And all the successors until an exit, branch, or a block entry. | 34 // And all the successors until an exit, branch, or a block entry. |
| 20 while ((current != NULL) && !current->IsBlockEntry()) { | 35 while ((current != NULL) && !current->IsBlockEntry()) { |
| 21 OS::Print("\n"); | 36 OS::Print("\n"); |
| 22 current = current->Accept(this); | 37 Print(current); |
| 38 current = current->StraightLineSuccessor(); |
| 23 } | 39 } |
| 24 BlockEntryInstr* successor = | 40 BlockEntryInstr* successor = |
| 25 (current == NULL) ? NULL : current->AsBlockEntry(); | 41 (current == NULL) ? NULL : current->AsBlockEntry(); |
| 26 if (successor != NULL) { | 42 if (successor != NULL) { |
| 27 // For readability label blocks with their reverse postorder index, | 43 OS::Print(" goto %d", successor->block_id()); |
| 28 // not their postorder block number, so the first block is 0 (not | |
| 29 // n-1). | |
| 30 OS::Print(" goto %d", reverse_index(successor->postorder_number())); | |
| 31 } | 44 } |
| 32 OS::Print("\n"); | 45 OS::Print("\n"); |
| 33 } | 46 } |
| 34 } | 47 } |
| 35 | 48 |
| 36 | 49 |
| 37 void FlowGraphPrinter::VisitUse(UseVal* val) { | 50 void FlowGraphPrinter::Print(Instruction* instr) { |
| 38 OS::Print("t%d", val->definition()->temp_index()); | 51 char str[80]; |
| 39 } | 52 BufferFormatter f(str, sizeof(str)); |
| 40 | 53 instr->PrintTo(&f); |
| 41 | 54 OS::Print("%s", str); |
| 42 void FlowGraphPrinter::VisitConstant(ConstantVal* val) { | 55 } |
| 43 OS::Print("#%s", val->value().ToCString()); | 56 |
| 44 } | 57 |
| 45 | 58 void Computation::PrintTo(BufferFormatter* f) const { |
| 46 | 59 f->Print("%s(", DebugName()); |
| 47 void FlowGraphPrinter::VisitAssertAssignable(AssertAssignableComp* comp) { | 60 PrintOperandsTo(f); |
| 48 OS::Print("AssertAssignable("); | 61 f->Print(")"); |
| 49 comp->value()->Accept(this); | 62 } |
| 50 OS::Print(", %s, '%s'", | 63 |
| 51 String::Handle(comp->dst_type().Name()).ToCString(), | 64 |
| 52 comp->dst_name().ToCString()); | 65 void Computation::PrintOperandsTo(BufferFormatter* f) const { |
| 53 if (comp->instantiator_type_arguments() != NULL) { | 66 for (int i = 0; i < InputCount(); ++i) { |
| 54 OS::Print(" (instantiator:"); | 67 if (i > 0) f->Print(", "); |
| 55 comp->instantiator_type_arguments()->Accept(this); | 68 if (InputAt(i) != NULL) InputAt(i)->PrintTo(f); |
| 56 } | 69 } |
| 57 OS::Print(")"); | 70 } |
| 58 } | 71 |
| 59 | 72 |
| 60 | 73 void UseVal::PrintTo(BufferFormatter* f) const { |
| 61 void FlowGraphPrinter::VisitAssertBoolean(AssertBooleanComp* comp) { | 74 f->Print("t%d", definition()->temp_index()); |
| 62 OS::Print("AssertBoolean("); | 75 } |
| 63 comp->value()->Accept(this); | 76 |
| 64 OS::Print(")"); | 77 |
| 65 } | 78 void ConstantVal::PrintTo(BufferFormatter* f) const { |
| 66 | 79 f->Print("#%s", value().ToCString()); |
| 67 | 80 } |
| 68 void FlowGraphPrinter::VisitCurrentContext(CurrentContextComp* comp) { | 81 |
| 69 OS::Print("CurrentContext"); | 82 |
| 70 } | 83 void AssertAssignableComp::PrintOperandsTo(BufferFormatter* f) const { |
| 71 | 84 value()->PrintTo(f); |
| 72 | 85 f->Print(", %s, '%s'", |
| 73 void FlowGraphPrinter::VisitClosureCall(ClosureCallComp* comp) { | 86 String::Handle(dst_type().Name()).ToCString(), |
| 74 OS::Print("ClosureCall("); | 87 dst_name().ToCString()); |
| 75 comp->context()->Accept(this); | 88 if (instantiator_type_arguments() != NULL) { |
| 76 for (intptr_t i = 0; i < comp->ArgumentCount(); ++i) { | 89 f->Print(" (instantiator:"); |
| 77 OS::Print(", "); | 90 instantiator_type_arguments()->PrintTo(f); |
| 78 comp->ArgumentAt(i)->Accept(this); | 91 f->Print(")"); |
| 79 } | 92 } |
| 80 OS::Print(")"); | 93 } |
| 81 } | 94 |
| 82 | 95 |
| 83 | 96 void ClosureCallComp::PrintOperandsTo(BufferFormatter* f) const { |
| 84 void FlowGraphPrinter::VisitInstanceCall(InstanceCallComp* comp) { | 97 context()->PrintTo(f); |
| 85 OS::Print("InstanceCall(%s", comp->function_name().ToCString()); | 98 for (intptr_t i = 0; i < ArgumentCount(); ++i) { |
| 86 for (intptr_t i = 0; i < comp->ArgumentCount(); ++i) { | 99 f->Print(", "); |
| 87 OS::Print(", "); | 100 ArgumentAt(i)->PrintTo(f); |
| 88 comp->ArgumentAt(i)->Accept(this); | 101 } |
| 89 } | 102 } |
| 90 OS::Print(")"); | 103 |
| 91 } | 104 |
| 92 | 105 void InstanceCallComp::PrintOperandsTo(BufferFormatter* f) const { |
| 93 | 106 f->Print("%s", function_name().ToCString()); |
| 94 void FlowGraphPrinter::VisitStrictCompare(StrictCompareComp* comp) { | 107 for (intptr_t i = 0; i < ArgumentCount(); ++i) { |
| 95 OS::Print("StrictCompare(%s, ", Token::Str(comp->kind())); | 108 f->Print(", "); |
| 96 comp->left()->Accept(this); | 109 ArgumentAt(i)->PrintTo(f); |
| 97 OS::Print(", "); | 110 } |
| 98 comp->right()->Accept(this); | 111 } |
| 99 OS::Print(")"); | 112 |
| 100 } | 113 |
| 101 | 114 void StrictCompareComp::PrintOperandsTo(BufferFormatter* f) const { |
| 102 | 115 f->Print("%s, ", Token::Str(kind())); |
| 103 void FlowGraphPrinter::VisitEqualityCompare(EqualityCompareComp* comp) { | 116 left()->PrintTo(f); |
| 104 comp->left()->Accept(this); | 117 f->Print(", "); |
| 105 OS::Print(" == "); | 118 right()->PrintTo(f); |
| 106 comp->right()->Accept(this); | 119 } |
| 107 } | 120 |
| 108 | 121 |
| 109 | 122 void EqualityCompareComp::PrintOperandsTo(BufferFormatter* f) const { |
| 110 void FlowGraphPrinter::VisitStaticCall(StaticCallComp* comp) { | 123 left()->PrintTo(f); |
| 111 OS::Print("StaticCall(%s", | 124 f->Print(" == "); |
| 112 String::Handle(comp->function().name()).ToCString()); | 125 right()->PrintTo(f); |
| 113 for (intptr_t i = 0; i < comp->ArgumentCount(); ++i) { | 126 } |
| 114 OS::Print(", "); | 127 |
| 115 comp->ArgumentAt(i)->Accept(this); | 128 |
| 116 } | 129 void StaticCallComp::PrintOperandsTo(BufferFormatter* f) const { |
| 117 OS::Print(")"); | 130 f->Print("%s", String::Handle(function().name()).ToCString()); |
| 118 } | 131 for (intptr_t i = 0; i < ArgumentCount(); ++i) { |
| 119 | 132 f->Print(", "); |
| 120 | 133 ArgumentAt(i)->PrintTo(f); |
| 121 void FlowGraphPrinter::VisitLoadLocal(LoadLocalComp* comp) { | 134 } |
| 122 OS::Print("LoadLocal(%s lvl:%d)", | 135 } |
| 123 comp->local().name().ToCString(), comp->context_level()); | 136 |
| 124 } | 137 |
| 125 | 138 void LoadLocalComp::PrintOperandsTo(BufferFormatter* f) const { |
| 126 | 139 f->Print("%s lvl:%d", local().name().ToCString(), context_level()); |
| 127 void FlowGraphPrinter::VisitStoreLocal(StoreLocalComp* comp) { | 140 } |
| 128 OS::Print("StoreLocal(%s, ", comp->local().name().ToCString()); | 141 |
| 129 comp->value()->Accept(this); | 142 |
| 130 OS::Print(", lvl: %d)", comp->context_level()); | 143 void StoreLocalComp::PrintOperandsTo(BufferFormatter* f) const { |
| 131 } | 144 f->Print("%s, ", local().name().ToCString()); |
| 132 | 145 value()->PrintTo(f); |
| 133 | 146 f->Print(", lvl: %d", context_level()); |
| 134 void FlowGraphPrinter::VisitNativeCall(NativeCallComp* comp) { | 147 } |
| 135 OS::Print("NativeCall(%s)", comp->native_name().ToCString()); | 148 |
| 136 } | 149 |
| 137 | 150 void NativeCallComp::PrintOperandsTo(BufferFormatter* f) const { |
| 138 | 151 f->Print("%s", native_name().ToCString()); |
| 139 void FlowGraphPrinter::VisitLoadInstanceField(LoadInstanceFieldComp* comp) { | 152 } |
| 140 OS::Print("LoadInstanceField(%s, ", | 153 |
| 141 String::Handle(comp->field().name()).ToCString()); | 154 |
| 142 comp->instance()->Accept(this); | 155 void LoadInstanceFieldComp::PrintOperandsTo(BufferFormatter* f) const { |
| 143 OS::Print(")"); | 156 f->Print("%s, ", String::Handle(field().name()).ToCString()); |
| 144 } | 157 instance()->PrintTo(f); |
| 145 | 158 } |
| 146 | 159 |
| 147 void FlowGraphPrinter::VisitStoreInstanceField(StoreInstanceFieldComp* comp) { | 160 |
| 148 OS::Print("StoreInstanceField(%s, ", | 161 void StoreInstanceFieldComp::PrintOperandsTo(BufferFormatter* f) const { |
| 149 String::Handle(comp->field().name()).ToCString()); | 162 f->Print("%s, ", String::Handle(field().name()).ToCString()); |
| 150 comp->instance()->Accept(this); | 163 instance()->PrintTo(f); |
| 151 OS::Print(", "); | 164 f->Print(", "); |
| 152 comp->value()->Accept(this); | 165 value()->PrintTo(f); |
| 153 OS::Print(")"); | 166 } |
| 154 } | 167 |
| 155 | 168 |
| 156 | 169 void LoadStaticFieldComp::PrintOperandsTo(BufferFormatter* f) const { |
| 157 void FlowGraphPrinter::VisitLoadStaticField(LoadStaticFieldComp* comp) { | 170 f->Print("%s", String::Handle(field().name()).ToCString()); |
| 158 OS::Print("LoadStaticField(%s)", | 171 } |
| 159 String::Handle(comp->field().name()).ToCString()); | 172 |
| 160 } | 173 |
| 161 | 174 void StoreStaticFieldComp::PrintOperandsTo(BufferFormatter* f) const { |
| 162 | 175 f->Print("%s, ", String::Handle(field().name()).ToCString()); |
| 163 void FlowGraphPrinter::VisitStoreStaticField(StoreStaticFieldComp* comp) { | 176 value()->PrintTo(f); |
| 164 OS::Print("StoreStaticField(%s, ", | 177 } |
| 165 String::Handle(comp->field().name()).ToCString()); | 178 |
| 166 comp->value()->Accept(this); | 179 |
| 167 OS::Print(")"); | 180 void InstanceOfComp::PrintOperandsTo(BufferFormatter* f) const { |
| 168 } | 181 value()->PrintTo(f); |
| 169 | 182 f->Print(" %s %s", |
| 170 | 183 negate_result() ? "ISNOT" : "IS", |
| 171 void FlowGraphPrinter::VisitStoreIndexed(StoreIndexedComp* comp) { | 184 String::Handle(type().Name()).ToCString()); |
| 172 OS::Print("StoreIndexed("); | 185 if (type_arguments() != NULL) { |
| 173 comp->array()->Accept(this); | 186 f->Print(" (type-arg:"); |
| 174 OS::Print(", "); | 187 type_arguments()->PrintTo(f); |
| 175 comp->index()->Accept(this); | 188 } |
| 176 OS::Print(", "); | 189 } |
| 177 comp->value()->Accept(this); | 190 |
| 178 OS::Print(")"); | 191 |
| 179 } | 192 void AllocateObjectComp::PrintOperandsTo(BufferFormatter* f) const { |
| 180 | 193 f->Print("%s", Class::Handle(constructor().owner()).ToCString()); |
| 181 | 194 for (intptr_t i = 0; i < arguments().length(); i++) { |
| 182 void FlowGraphPrinter::VisitInstanceSetter(InstanceSetterComp* comp) { | 195 f->Print(", "); |
| 183 OS::Print("InstanceSetter("); | 196 arguments()[i]->PrintTo(f); |
| 184 comp->receiver()->Accept(this); | 197 } |
| 185 OS::Print(", "); | 198 } |
| 186 comp->value()->Accept(this); | 199 |
| 187 OS::Print(")"); | 200 |
| 188 } | 201 void AllocateObjectWithBoundsCheckComp::PrintOperandsTo( |
| 189 | 202 BufferFormatter* f) const { |
| 190 | 203 f->Print("%s", Class::Handle(constructor().owner()).ToCString()); |
| 191 void FlowGraphPrinter::VisitStaticSetter(StaticSetterComp* comp) { | 204 for (intptr_t i = 0; i < arguments().length(); i++) { |
| 192 OS::Print("StaticSetter("); | 205 f->Print(", "); |
| 193 comp->value()->Accept(this); | 206 arguments()[i]->PrintTo(f); |
| 194 OS::Print(")"); | 207 } |
| 195 } | 208 } |
| 196 | 209 |
| 197 | 210 |
| 198 void FlowGraphPrinter::VisitBooleanNegate(BooleanNegateComp* comp) { | 211 void CreateArrayComp::PrintOperandsTo(BufferFormatter* f) const { |
| 199 OS::Print("! "); | 212 for (int i = 0; i < ElementCount(); ++i) { |
| 200 comp->value()->Accept(this); | 213 if (i != 0) f->Print(", "); |
| 201 } | 214 ElementAt(i)->PrintTo(f); |
| 202 | 215 } |
| 203 | 216 if (ElementCount() > 0) f->Print(", "); |
| 204 void FlowGraphPrinter::VisitInstanceOf(InstanceOfComp* comp) { | 217 element_type()->PrintTo(f); |
| 205 comp->value()->Accept(this); | 218 } |
| 206 OS::Print(" %s %s", | 219 |
| 207 comp->negate_result() ? "ISNOT" : "IS", | 220 |
| 208 String::Handle(comp->type().Name()).ToCString()); | 221 void CreateClosureComp::PrintOperandsTo(BufferFormatter* f) const { |
| 209 if (comp->type_arguments() != NULL) { | 222 f->Print("%s", function().ToCString()); |
| 210 OS::Print(" (type-arg:"); | 223 if (type_arguments() != NULL) { |
| 211 comp->type_arguments()->Accept(this); | 224 f->Print(", "); |
| 212 } | 225 type_arguments()->PrintTo(f); |
| 213 OS::Print(")"); | 226 } |
| 214 } | 227 } |
| 215 | 228 |
| 216 | 229 |
| 217 void FlowGraphPrinter::VisitAllocateObject(AllocateObjectComp* comp) { | 230 void NativeLoadFieldComp::PrintOperandsTo(BufferFormatter* f) const { |
| 218 OS::Print("AllocateObject(%s", | 231 value()->PrintTo(f); |
| 219 Class::Handle(comp->constructor().owner()).ToCString()); | 232 f->Print(", %d", offset_in_bytes()); |
| 220 for (intptr_t i = 0; i < comp->arguments().length(); i++) { | 233 } |
| 221 OS::Print(", "); | 234 |
| 222 comp->arguments()[i]->Accept(this); | 235 |
| 223 } | 236 void NativeStoreFieldComp::PrintOperandsTo(BufferFormatter* f) const { |
| 224 OS::Print(")"); | 237 dest()->PrintTo(f); |
| 225 } | 238 f->Print(", %d, ", offset_in_bytes()); |
| 226 | 239 value()->PrintTo(f); |
| 227 | 240 } |
| 228 void FlowGraphPrinter::VisitAllocateObjectWithBoundsCheck( | 241 |
| 229 AllocateObjectWithBoundsCheckComp* comp) { | 242 |
| 230 OS::Print("AllocateObjectWithBoundsCheck(%s", | 243 void InstantiateTypeArgumentsComp::PrintOperandsTo(BufferFormatter* f) const { |
| 231 Class::Handle(comp->constructor().owner()).ToCString()); | 244 const String& type_args = String::Handle(type_arguments().Name()); |
| 232 for (intptr_t i = 0; i < comp->arguments().length(); i++) { | 245 f->Print("%s, ", type_args.ToCString()); |
| 233 OS::Print(", "); | 246 instantiator()->PrintTo(f); |
| 234 comp->arguments()[i]->Accept(this); | 247 } |
| 235 } | 248 |
| 236 OS::Print(")"); | 249 |
| 237 } | 250 void ExtractConstructorTypeArgumentsComp::PrintOperandsTo( |
| 238 | 251 BufferFormatter* f) const { |
| 239 | 252 const String& type_args = String::Handle(type_arguments().Name()); |
| 240 void FlowGraphPrinter::VisitCreateArray(CreateArrayComp* comp) { | 253 f->Print("%s, ", type_args.ToCString()); |
| 241 OS::Print("CreateArray("); | 254 instantiator()->PrintTo(f); |
| 242 for (int i = 0; i < comp->ElementCount(); ++i) { | 255 } |
| 243 if (i != 0) OS::Print(", "); | 256 |
| 244 comp->ElementAt(i)->Accept(this); | 257 |
| 245 } | 258 void AllocateContextComp::PrintOperandsTo(BufferFormatter* f) const { |
| 246 if (comp->ElementCount() > 0) OS::Print(", "); | 259 f->Print("%d", num_context_variables()); |
| 247 comp->element_type()->Accept(this); | 260 } |
| 248 OS::Print(")"); | 261 |
| 249 } | 262 |
| 250 | 263 void CatchEntryComp::PrintOperandsTo(BufferFormatter* f) const { |
| 251 | 264 f->Print("%s, %s", |
| 252 void FlowGraphPrinter::VisitCreateClosure(CreateClosureComp* comp) { | 265 exception_var().name().ToCString(), |
| 253 OS::Print("CreateClosure(%s", comp->function().ToCString()); | 266 stacktrace_var().name().ToCString()); |
| 254 if (comp->type_arguments() != NULL) { | 267 } |
| 255 OS::Print(", "); | 268 |
| 256 comp->type_arguments()->Accept(this); | 269 |
| 257 } | 270 void GraphEntryInstr::PrintTo(BufferFormatter* f) const { |
| 258 OS::Print(")"); | 271 f->Print("%2d: [graph]", block_id()); |
| 259 } | 272 } |
| 260 | 273 |
| 261 | 274 |
| 262 void FlowGraphPrinter::VisitNativeLoadField(NativeLoadFieldComp* comp) { | 275 void JoinEntryInstr::PrintTo(BufferFormatter* f) const { |
| 263 OS::Print("NativeLoadField("); | 276 f->Print("%2d: [join]", block_id()); |
| 264 comp->value()->Accept(this); | 277 } |
| 265 OS::Print(", %d)", comp->offset_in_bytes()); | 278 |
| 266 } | 279 |
| 267 | 280 void TargetEntryInstr::PrintTo(BufferFormatter* f) const { |
| 268 | 281 f->Print("%2d: [target", block_id()); |
| 269 void FlowGraphPrinter::VisitNativeStoreField(NativeStoreFieldComp* comp) { | 282 if (HasTryIndex()) { |
| 270 OS::Print("NativeStoreField("); | 283 f->Print(" catch %d]", try_index()); |
| 271 comp->dest()->Accept(this); | |
| 272 OS::Print(", %d, ", comp->offset_in_bytes()); | |
| 273 comp->value()->Accept(this); | |
| 274 OS::Print(")"); | |
| 275 } | |
| 276 | |
| 277 | |
| 278 void FlowGraphPrinter::VisitInstantiateTypeArguments( | |
| 279 InstantiateTypeArgumentsComp* comp) { | |
| 280 const String& type_args = String::Handle(comp->type_arguments().Name()); | |
| 281 OS::Print("InstantiateTypeArguments(%s, ", type_args.ToCString()); | |
| 282 comp->instantiator()->Accept(this); | |
| 283 OS::Print(")"); | |
| 284 } | |
| 285 | |
| 286 | |
| 287 void FlowGraphPrinter::VisitExtractConstructorTypeArguments( | |
| 288 ExtractConstructorTypeArgumentsComp* comp) { | |
| 289 const String& type_args = String::Handle(comp->type_arguments().Name()); | |
| 290 OS::Print("ExtractConstructorTypeArguments(%s, ", type_args.ToCString()); | |
| 291 comp->instantiator()->Accept(this); | |
| 292 OS::Print(")"); | |
| 293 } | |
| 294 | |
| 295 | |
| 296 void FlowGraphPrinter::VisitExtractConstructorInstantiator( | |
| 297 ExtractConstructorInstantiatorComp* comp) { | |
| 298 OS::Print("ExtractConstructorInstantiator("); | |
| 299 comp->instantiator()->Accept(this); | |
| 300 OS::Print(")"); | |
| 301 } | |
| 302 | |
| 303 | |
| 304 void FlowGraphPrinter::VisitAllocateContext(AllocateContextComp* comp) { | |
| 305 OS::Print("AllocateContext(%d)", comp->num_context_variables()); | |
| 306 } | |
| 307 | |
| 308 | |
| 309 void FlowGraphPrinter::VisitChainContext(ChainContextComp* comp) { | |
| 310 OS::Print("ChainContext("); | |
| 311 comp->context_value()->Accept(this); | |
| 312 OS::Print(")"); | |
| 313 } | |
| 314 | |
| 315 | |
| 316 void FlowGraphPrinter::VisitCloneContext(CloneContextComp* comp) { | |
| 317 OS::Print("CloneContext("); | |
| 318 comp->context_value()->Accept(this); | |
| 319 OS::Print(")"); | |
| 320 } | |
| 321 | |
| 322 | |
| 323 void FlowGraphPrinter::VisitCatchEntry(CatchEntryComp* comp) { | |
| 324 OS::Print("CatchEntry(%s, %s)", | |
| 325 comp->exception_var().name().ToCString(), | |
| 326 comp->stacktrace_var().name().ToCString()); | |
| 327 } | |
| 328 | |
| 329 | |
| 330 void FlowGraphPrinter::VisitStoreContext(StoreContextComp* comp) { | |
| 331 OS::Print("StoreContext("); | |
| 332 comp->value()->Accept(this); | |
| 333 OS::Print(")"); | |
| 334 } | |
| 335 | |
| 336 | |
| 337 void FlowGraphPrinter::VisitGraphEntry(GraphEntryInstr* instr) { | |
| 338 OS::Print("%2d: [graph]", reverse_index(instr->postorder_number())); | |
| 339 } | |
| 340 | |
| 341 | |
| 342 void FlowGraphPrinter::VisitJoinEntry(JoinEntryInstr* instr) { | |
| 343 OS::Print("%2d: [join]", reverse_index(instr->postorder_number())); | |
| 344 } | |
| 345 | |
| 346 | |
| 347 void FlowGraphPrinter::VisitTargetEntry(TargetEntryInstr* instr) { | |
| 348 OS::Print("%2d: [target", reverse_index(instr->postorder_number())); | |
| 349 if (instr->HasTryIndex()) { | |
| 350 OS::Print(" catch %d]", instr->try_index()); | |
| 351 } else { | 284 } else { |
| 352 OS::Print("]"); | 285 f->Print("]"); |
| 353 } | 286 } |
| 354 } | 287 } |
| 355 | 288 |
| 356 | 289 |
| 357 void FlowGraphPrinter::VisitDo(DoInstr* instr) { | 290 void DoInstr::PrintTo(BufferFormatter* f) const { |
| 358 OS::Print(" "); | 291 f->Print(" "); |
| 359 instr->computation()->Accept(this); | 292 computation()->PrintTo(f); |
| 360 } | 293 } |
| 361 | 294 |
| 362 | 295 |
| 363 void FlowGraphPrinter::VisitBind(BindInstr* instr) { | 296 void BindInstr::PrintTo(BufferFormatter* f) const { |
| 364 OS::Print(" t%d <- ", instr->temp_index()); | 297 f->Print(" t%d <- ", temp_index()); |
| 365 instr->computation()->Accept(this); | 298 computation()->PrintTo(f); |
| 366 } | 299 } |
| 367 | 300 |
| 368 | 301 |
| 369 void FlowGraphPrinter::VisitReturn(ReturnInstr* instr) { | 302 void ReturnInstr::PrintTo(BufferFormatter* f) const { |
| 370 OS::Print(" return "); | 303 f->Print(" %s ", DebugName()); |
| 371 instr->value()->Accept(this); | 304 value()->PrintTo(f); |
| 372 } | 305 } |
| 373 | 306 |
| 374 | 307 |
| 375 void FlowGraphPrinter::VisitThrow(ThrowInstr* instr) { | 308 void ThrowInstr::PrintTo(BufferFormatter* f) const { |
| 376 OS::Print(" throw "); | 309 f->Print(" %s ", DebugName()); |
| 377 instr->exception()->Accept(this); | 310 exception()->PrintTo(f); |
| 378 } | 311 } |
| 379 | 312 |
| 380 | 313 |
| 381 void FlowGraphPrinter::VisitReThrow(ReThrowInstr* instr) { | 314 void ReThrowInstr::PrintTo(BufferFormatter* f) const { |
| 382 OS::Print(" rethrow ("); | 315 f->Print(" %s ", DebugName()); |
| 383 instr->exception()->Accept(this); | 316 exception()->PrintTo(f); |
| 384 OS::Print(", "); | 317 f->Print(", "); |
| 385 instr->stack_trace()->Accept(this); | 318 stack_trace()->PrintTo(f); |
| 386 OS::Print(")"); | 319 } |
| 387 } | 320 |
| 388 | 321 |
| 389 | 322 void BranchInstr::PrintTo(BufferFormatter* f) const { |
| 390 void FlowGraphPrinter::VisitBranch(BranchInstr* instr) { | 323 f->Print(" %s ", DebugName()); |
| 391 OS::Print(" if "); | 324 f->Print("if "); |
| 392 instr->value()->Accept(this); | 325 value()->PrintTo(f); |
| 393 OS::Print(" goto (%d, %d)", | 326 f->Print(" goto (%d, %d)", |
| 394 reverse_index(instr->true_successor()->postorder_number()), | 327 true_successor()->block_id(), |
| 395 reverse_index(instr->false_successor()->postorder_number())); | 328 false_successor()->block_id()); |
| 396 } | 329 } |
| 397 | 330 |
| 398 | 331 |
| 399 } // namespace dart | 332 } // namespace dart |
| OLD | NEW |