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