| OLD | NEW |
| 1 // Copyright (c) 2011, 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 #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() ? '?' : ''; |
| 75 addIndent(); | 77 addIndent(); |
| 76 String temporaryId = stringifier.temporaryId(instruction); | 78 String temporaryId = stringifier.temporaryId(instruction); |
| 77 String instructionString = stringifier.visit(instruction); | 79 String instructionString = stringifier.visit(instruction); |
| 78 add("$bci $uses $temporaryId $instructionString <|@\n"); | 80 add("$bci $uses $temporaryId $instructionString $changes $depends <|@\n"); |
| 79 } | 81 } |
| 80 } | 82 } |
| 81 | 83 |
| 82 void visitBasicBlock(HBasicBlock block) { | 84 void visitBasicBlock(HBasicBlock block) { |
| 83 HInstructionStringifier stringifier = new HInstructionStringifier(block); | 85 HInstructionStringifier stringifier = new HInstructionStringifier(block); |
| 84 assert(block.id !== null); | 86 assert(block.id !== null); |
| 85 tag("block", () { | 87 tag("block", () { |
| 86 printProperty("name", "B${block.id}"); | 88 printProperty("name", "B${block.id}"); |
| 87 printProperty("from_bci", -1); | 89 printProperty("from_bci", -1); |
| 88 printProperty("to_bci", -1); | 90 printProperty("to_bci", -1); |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 type = "string"; | 459 type = "string"; |
| 458 } else if (guardedType == HType.INDEXABLE_PRIMITIVE) { | 460 } else if (guardedType == HType.INDEXABLE_PRIMITIVE) { |
| 459 type = "string_or_array"; | 461 type = "string_or_array"; |
| 460 } else if (guardedType == HType.UNKNOWN) { | 462 } else if (guardedType == HType.UNKNOWN) { |
| 461 type = 'unknown'; | 463 type = 'unknown'; |
| 462 } else { | 464 } else { |
| 463 throw new CompilerCancelledException('Unexpected type guard: $type'); | 465 throw new CompilerCancelledException('Unexpected type guard: $type'); |
| 464 } | 466 } |
| 465 StringBuffer envBuffer = new StringBuffer(); | 467 StringBuffer envBuffer = new StringBuffer(); |
| 466 List<HInstruction> inputs = node.inputs; | 468 List<HInstruction> inputs = node.inputs; |
| 467 // The last input is the guarded expression. | 469 for (int i = 0; i < inputs.length; i++) { |
| 468 for (int i = 0; i < inputs.length - 1; i++) { | 470 if (inputs[i] !== node.guarded) { |
| 469 envBuffer.add(" ${temporaryId(inputs[i])}"); | 471 envBuffer.add(" ${temporaryId(inputs[i])}"); |
| 472 } |
| 470 } | 473 } |
| 471 String on = node.isOn ? "on" : "off"; | 474 String on = node.isOn ? "on" : "off"; |
| 472 String id = temporaryId(node.guarded); | 475 String id = temporaryId(node.guarded); |
| 473 return "TypeGuard($on): $id is $type env: $envBuffer"; | 476 return "TypeGuard($on): $id is $type env: $envBuffer"; |
| 474 } | 477 } |
| 475 | 478 |
| 476 String visitIs(HIs node) { | 479 String visitIs(HIs node) { |
| 477 String type = node.typeExpression.toString(); | 480 String type = node.typeExpression.toString(); |
| 478 return "TypeTest: ${temporaryId(node.expression)} is $type"; | 481 return "TypeTest: ${temporaryId(node.expression)} is $type"; |
| 479 } | 482 } |
| 480 | 483 |
| 481 String visitTypeConversion(HTypeConversion node) { | 484 String visitTypeConversion(HTypeConversion node) { |
| 482 String type = node.propagatedType.toString(); | 485 String type = node.propagatedType.toString(); |
| 483 return "TypeConversion: ${temporaryId(node.inputs[0])} to $type"; | 486 return "TypeConversion: ${temporaryId(node.inputs[0])} to $type"; |
| 484 } | 487 } |
| 485 } | 488 } |
| OLD | NEW |