| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 #library('tracer'); | 5 #library('tracer'); |
| 6 | 6 |
| 7 #import('dart:io'); | 7 #import('dart:io'); |
| 8 #import('ssa.dart'); | 8 #import('ssa.dart'); |
| 9 #import('../leg.dart'); | 9 #import('../leg.dart'); |
| 10 | 10 |
| 11 final bool GENERATE_SSA_TRACE = false; | 11 final bool GENERATE_SSA_TRACE = false; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 } | 65 } |
| 66 } | 66 } |
| 67 | 67 |
| 68 void addInstructions(HInstructionStringifier stringifier, | 68 void addInstructions(HInstructionStringifier stringifier, |
| 69 HInstructionList list) { | 69 HInstructionList list) { |
| 70 for (HInstruction instruction = list.first; | 70 for (HInstruction instruction = list.first; |
| 71 instruction !== null; | 71 instruction !== null; |
| 72 instruction = instruction.next) { | 72 instruction = instruction.next) { |
| 73 int bci = 0; | 73 int bci = 0; |
| 74 int uses = instruction.usedBy.length; | 74 int uses = instruction.usedBy.length; |
| 75 String changes = instruction.hasSideEffects() ? '!' : ' '; | |
| 76 String depends = instruction.dependsOnSomething() ? '?' : ''; | |
| 77 addIndent(); | 75 addIndent(); |
| 78 String temporaryId = stringifier.temporaryId(instruction); | 76 String temporaryId = stringifier.temporaryId(instruction); |
| 79 String instructionString = stringifier.visit(instruction); | 77 String instructionString = stringifier.visit(instruction); |
| 80 add("$bci $uses $temporaryId $instructionString $changes $depends <|@\n"); | 78 add("$bci $uses $temporaryId $instructionString <|@\n"); |
| 81 } | 79 } |
| 82 } | 80 } |
| 83 | 81 |
| 84 void visitBasicBlock(HBasicBlock block) { | 82 void visitBasicBlock(HBasicBlock block) { |
| 85 HInstructionStringifier stringifier = new HInstructionStringifier(block); | 83 HInstructionStringifier stringifier = new HInstructionStringifier(block); |
| 86 assert(block.id !== null); | 84 assert(block.id !== null); |
| 87 tag("block", () { | 85 tag("block", () { |
| 88 printProperty("name", "B${block.id}"); | 86 printProperty("name", "B${block.id}"); |
| 89 printProperty("from_bci", -1); | 87 printProperty("from_bci", -1); |
| 90 printProperty("to_bci", -1); | 88 printProperty("to_bci", -1); |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 case HType.INDEXABLE_PRIMITIVE: type = "string_or_array"; break; | 444 case HType.INDEXABLE_PRIMITIVE: type = "string_or_array"; break; |
| 447 case HType.UNKNOWN: type = 'unknown'; break; | 445 case HType.UNKNOWN: type = 'unknown'; break; |
| 448 default: | 446 default: |
| 449 // TODO(floitsch): Need a compiler object. | 447 // TODO(floitsch): Need a compiler object. |
| 450 compiler.internalError('Unexpected type guard.', | 448 compiler.internalError('Unexpected type guard.', |
| 451 instruction: node.guardedType); | 449 instruction: node.guardedType); |
| 452 break; | 450 break; |
| 453 } | 451 } |
| 454 StringBuffer envBuffer = new StringBuffer(); | 452 StringBuffer envBuffer = new StringBuffer(); |
| 455 List<HInstruction> inputs = node.inputs; | 453 List<HInstruction> inputs = node.inputs; |
| 456 for (int i = 0; i < inputs.length; i++) { | 454 // The last input is the guarded expression. |
| 457 if (inputs[i] !== node.guarded) { | 455 for (int i = 0; i < inputs.length - 1; i++) { |
| 458 envBuffer.add(" ${temporaryId(inputs[i])}"); | 456 envBuffer.add(" ${temporaryId(inputs[i])}"); |
| 459 } | |
| 460 } | 457 } |
| 461 String on = node.isOn ? "on" : "off"; | 458 String on = node.isOn ? "on" : "off"; |
| 462 String id = temporaryId(node.guarded); | 459 String id = temporaryId(node.guarded); |
| 463 return "TypeGuard($on): $id is $type env: $envBuffer"; | 460 return "TypeGuard($on): $id is $type env: $envBuffer"; |
| 464 } | 461 } |
| 465 | 462 |
| 466 String visitIs(HIs node) { | 463 String visitIs(HIs node) { |
| 467 String type = node.typeExpression.toString(); | 464 String type = node.typeExpression.toString(); |
| 468 return "TypeTest: ${temporaryId(node.expression)} is $type"; | 465 return "TypeTest: ${temporaryId(node.expression)} is $type"; |
| 469 } | 466 } |
| 470 | 467 |
| 471 String visitTypeConversion(HTypeConversion node) { | 468 String visitTypeConversion(HTypeConversion node) { |
| 472 String type = node.propagatedType.toString(); | 469 String type = node.propagatedType.toString(); |
| 473 return "TypeConversion: ${temporaryId(node.inputs[0])} to $type"; | 470 return "TypeConversion: ${temporaryId(node.inputs[0])} to $type"; |
| 474 } | 471 } |
| 475 } | 472 } |
| OLD | NEW |