| 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 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 '../js_backend/js_backend.dart'; | 9 import '../js_backend/js_backend.dart'; |
| 10 import '../dart2jslib.dart'; | 10 import '../dart2jslib.dart'; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 printProperty("dominator", "B${block.dominator.id}"); | 107 printProperty("dominator", "B${block.dominator.id}"); |
| 108 } | 108 } |
| 109 tag("states", () { | 109 tag("states", () { |
| 110 tag("locals", () { | 110 tag("locals", () { |
| 111 printProperty("size", 0); | 111 printProperty("size", 0); |
| 112 printProperty("method", "None"); | 112 printProperty("method", "None"); |
| 113 block.forEachPhi((phi) { | 113 block.forEachPhi((phi) { |
| 114 String phiId = stringifier.temporaryId(phi); | 114 String phiId = stringifier.temporaryId(phi); |
| 115 StringBuffer inputIds = new StringBuffer(); | 115 StringBuffer inputIds = new StringBuffer(); |
| 116 for (int i = 0; i < phi.inputs.length; i++) { | 116 for (int i = 0; i < phi.inputs.length; i++) { |
| 117 inputIds.add(stringifier.temporaryId(phi.inputs[i])); | 117 inputIds.write(stringifier.temporaryId(phi.inputs[i])); |
| 118 inputIds.add(" "); | 118 inputIds.write(" "); |
| 119 } | 119 } |
| 120 println("${phi.id} $phiId [ $inputIds]"); | 120 println("${phi.id} $phiId [ $inputIds]"); |
| 121 }); | 121 }); |
| 122 }); | 122 }); |
| 123 }); | 123 }); |
| 124 tag("HIR", () { | 124 tag("HIR", () { |
| 125 addInstructions(stringifier, block.phis); | 125 addInstructions(stringifier, block.phis); |
| 126 addInstructions(stringifier, block); | 126 addInstructions(stringifier, block); |
| 127 }); | 127 }); |
| 128 }); | 128 }); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 prefix = 'x'; | 207 prefix = 'x'; |
| 208 } | 208 } |
| 209 } | 209 } |
| 210 return "$prefix${instruction.id}"; | 210 return "$prefix${instruction.id}"; |
| 211 } | 211 } |
| 212 | 212 |
| 213 String visitBailoutTarget(HBailoutTarget node) { | 213 String visitBailoutTarget(HBailoutTarget node) { |
| 214 StringBuffer envBuffer = new StringBuffer(); | 214 StringBuffer envBuffer = new StringBuffer(); |
| 215 List<HInstruction> inputs = node.inputs; | 215 List<HInstruction> inputs = node.inputs; |
| 216 for (int i = 0; i < inputs.length; i++) { | 216 for (int i = 0; i < inputs.length; i++) { |
| 217 envBuffer.add(" ${temporaryId(inputs[i])}"); | 217 envBuffer.write(" ${temporaryId(inputs[i])}"); |
| 218 } | 218 } |
| 219 String on = node.isEnabled ? "enabled" : "disabled"; | 219 String on = node.isEnabled ? "enabled" : "disabled"; |
| 220 return "BailoutTarget($on): id: ${node.state} env: $envBuffer"; | 220 return "BailoutTarget($on): id: ${node.state} env: $envBuffer"; |
| 221 } | 221 } |
| 222 | 222 |
| 223 String visitBoolify(HBoolify node) { | 223 String visitBoolify(HBoolify node) { |
| 224 return "Boolify: ${temporaryId(node.inputs[0])}"; | 224 return "Boolify: ${temporaryId(node.inputs[0])}"; |
| 225 } | 225 } |
| 226 | 226 |
| 227 String handleInvokeBinary(HInvokeBinary node, String op) { | 227 String handleInvokeBinary(HInvokeBinary node, String op) { |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 HBasicBlock thenBlock = currentBlock.successors[0]; | 308 HBasicBlock thenBlock = currentBlock.successors[0]; |
| 309 HBasicBlock elseBlock = currentBlock.successors[1]; | 309 HBasicBlock elseBlock = currentBlock.successors[1]; |
| 310 String conditionId = temporaryId(node.inputs[0]); | 310 String conditionId = temporaryId(node.inputs[0]); |
| 311 return "If ($conditionId): (B${thenBlock.id}) else (B${elseBlock.id})"; | 311 return "If ($conditionId): (B${thenBlock.id}) else (B${elseBlock.id})"; |
| 312 } | 312 } |
| 313 | 313 |
| 314 String visitGenericInvoke(String invokeType, String functionName, | 314 String visitGenericInvoke(String invokeType, String functionName, |
| 315 List<HInstruction> arguments) { | 315 List<HInstruction> arguments) { |
| 316 StringBuffer argumentsString = new StringBuffer(); | 316 StringBuffer argumentsString = new StringBuffer(); |
| 317 for (int i = 0; i < arguments.length; i++) { | 317 for (int i = 0; i < arguments.length; i++) { |
| 318 if (i != 0) argumentsString.add(", "); | 318 if (i != 0) argumentsString.write(", "); |
| 319 argumentsString.add(temporaryId(arguments[i])); | 319 argumentsString.write(temporaryId(arguments[i])); |
| 320 } | 320 } |
| 321 return "$invokeType: $functionName($argumentsString)"; | 321 return "$invokeType: $functionName($argumentsString)"; |
| 322 } | 322 } |
| 323 | 323 |
| 324 String visitIndex(HIndex node) { | 324 String visitIndex(HIndex node) { |
| 325 String receiver = temporaryId(node.receiver); | 325 String receiver = temporaryId(node.receiver); |
| 326 String index = temporaryId(node.index); | 326 String index = temporaryId(node.index); |
| 327 return "Index: $receiver[$index]"; | 327 return "Index: $receiver[$index]"; |
| 328 } | 328 } |
| 329 | 329 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 "${node.element.name.slowToString()}", | 389 "${node.element.name.slowToString()}", |
| 390 node.inputs); | 390 node.inputs); |
| 391 } | 391 } |
| 392 | 392 |
| 393 String visitLess(HLess node) => handleInvokeBinary(node, '<'); | 393 String visitLess(HLess node) => handleInvokeBinary(node, '<'); |
| 394 String visitLessEqual(HLessEqual node) => handleInvokeBinary(node, '<='); | 394 String visitLessEqual(HLessEqual node) => handleInvokeBinary(node, '<='); |
| 395 | 395 |
| 396 String visitLiteralList(HLiteralList node) { | 396 String visitLiteralList(HLiteralList node) { |
| 397 StringBuffer elementsString = new StringBuffer(); | 397 StringBuffer elementsString = new StringBuffer(); |
| 398 for (int i = 0; i < node.inputs.length; i++) { | 398 for (int i = 0; i < node.inputs.length; i++) { |
| 399 if (i != 0) elementsString.add(", "); | 399 if (i != 0) elementsString.write(", "); |
| 400 elementsString.add(temporaryId(node.inputs[i])); | 400 elementsString.write(temporaryId(node.inputs[i])); |
| 401 } | 401 } |
| 402 return "Literal list: [$elementsString]"; | 402 return "Literal list: [$elementsString]"; |
| 403 } | 403 } |
| 404 | 404 |
| 405 String visitLoopBranch(HLoopBranch branch) { | 405 String visitLoopBranch(HLoopBranch branch) { |
| 406 HBasicBlock bodyBlock = currentBlock.successors[0]; | 406 HBasicBlock bodyBlock = currentBlock.successors[0]; |
| 407 HBasicBlock exitBlock = currentBlock.successors[1]; | 407 HBasicBlock exitBlock = currentBlock.successors[1]; |
| 408 String conditionId = temporaryId(branch.inputs[0]); | 408 String conditionId = temporaryId(branch.inputs[0]); |
| 409 return "While ($conditionId): (B${bodyBlock.id}) then (B${exitBlock.id})"; | 409 return "While ($conditionId): (B${bodyBlock.id}) then (B${exitBlock.id})"; |
| 410 } | 410 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 421 String visitParameterValue(HParameterValue node) { | 421 String visitParameterValue(HParameterValue node) { |
| 422 return "p${node.sourceElement.name.slowToString()}"; | 422 return "p${node.sourceElement.name.slowToString()}"; |
| 423 } | 423 } |
| 424 | 424 |
| 425 String visitLocalValue(HLocalValue node) { | 425 String visitLocalValue(HLocalValue node) { |
| 426 return "l${node.sourceElement.name.slowToString()}"; | 426 return "l${node.sourceElement.name.slowToString()}"; |
| 427 } | 427 } |
| 428 | 428 |
| 429 String visitPhi(HPhi phi) { | 429 String visitPhi(HPhi phi) { |
| 430 StringBuffer buffer = new StringBuffer(); | 430 StringBuffer buffer = new StringBuffer(); |
| 431 buffer.add("Phi("); | 431 buffer.write("Phi("); |
| 432 for (int i = 0; i < phi.inputs.length; i++) { | 432 for (int i = 0; i < phi.inputs.length; i++) { |
| 433 if (i > 0) buffer.add(", "); | 433 if (i > 0) buffer.write(", "); |
| 434 buffer.add(temporaryId(phi.inputs[i])); | 434 buffer.write(temporaryId(phi.inputs[i])); |
| 435 } | 435 } |
| 436 buffer.add(")"); | 436 buffer.write(")"); |
| 437 return buffer.toString(); | 437 return buffer.toString(); |
| 438 } | 438 } |
| 439 | 439 |
| 440 String visitReturn(HReturn node) => "Return ${temporaryId(node.inputs[0])}"; | 440 String visitReturn(HReturn node) => "Return ${temporaryId(node.inputs[0])}"; |
| 441 | 441 |
| 442 String visitShiftLeft(HShiftLeft node) => handleInvokeBinary(node, '<<'); | 442 String visitShiftLeft(HShiftLeft node) => handleInvokeBinary(node, '<<'); |
| 443 | 443 |
| 444 String visitStatic(HStatic node) | 444 String visitStatic(HStatic node) |
| 445 => "Static ${node.element.name.slowToString()}"; | 445 => "Static ${node.element.name.slowToString()}"; |
| 446 | 446 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 458 String visitStringConcat(HStringConcat node) { | 458 String visitStringConcat(HStringConcat node) { |
| 459 var leftId = temporaryId(node.left); | 459 var leftId = temporaryId(node.left); |
| 460 var rightId = temporaryId(node.right); | 460 var rightId = temporaryId(node.right); |
| 461 return "StringConcat: $leftId + $rightId"; | 461 return "StringConcat: $leftId + $rightId"; |
| 462 } | 462 } |
| 463 | 463 |
| 464 String visitSubtract(HSubtract node) => handleInvokeBinary(node, '-'); | 464 String visitSubtract(HSubtract node) => handleInvokeBinary(node, '-'); |
| 465 | 465 |
| 466 String visitSwitch(HSwitch node) { | 466 String visitSwitch(HSwitch node) { |
| 467 StringBuffer buf = new StringBuffer(); | 467 StringBuffer buf = new StringBuffer(); |
| 468 buf.add("Switch: ("); | 468 buf.write("Switch: ("); |
| 469 buf.add(temporaryId(node.inputs[0])); | 469 buf.write(temporaryId(node.inputs[0])); |
| 470 buf.add(") "); | 470 buf.write(") "); |
| 471 for (int i = 1; i < node.inputs.length; i++) { | 471 for (int i = 1; i < node.inputs.length; i++) { |
| 472 buf.add(temporaryId(node.inputs[i])); | 472 buf.write(temporaryId(node.inputs[i])); |
| 473 buf.add(": B"); | 473 buf.write(": B"); |
| 474 buf.add(node.block.successors[i - 1].id); | 474 buf.write(node.block.successors[i - 1].id); |
| 475 buf.add(", "); | 475 buf.write(", "); |
| 476 } | 476 } |
| 477 buf.add("default: B"); | 477 buf.write("default: B"); |
| 478 buf.add(node.block.successors.last.id); | 478 buf.write(node.block.successors.last.id); |
| 479 return buf.toString(); | 479 return buf.toString(); |
| 480 } | 480 } |
| 481 | 481 |
| 482 String visitThis(HThis node) => "this"; | 482 String visitThis(HThis node) => "this"; |
| 483 | 483 |
| 484 String visitThrow(HThrow node) => "Throw ${temporaryId(node.inputs[0])}"; | 484 String visitThrow(HThrow node) => "Throw ${temporaryId(node.inputs[0])}"; |
| 485 | 485 |
| 486 String visitExitTry(HExitTry node) { | 486 String visitExitTry(HExitTry node) { |
| 487 return "Exit try"; | 487 return "Exit try"; |
| 488 } | 488 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 throw new CompilerCancelledException('Unexpected type guard: $type'); | 531 throw new CompilerCancelledException('Unexpected type guard: $type'); |
| 532 } | 532 } |
| 533 HInstruction guarded = node.guarded; | 533 HInstruction guarded = node.guarded; |
| 534 HInstruction bailoutTarget = node.bailoutTarget; | 534 HInstruction bailoutTarget = node.bailoutTarget; |
| 535 StringBuffer envBuffer = new StringBuffer(); | 535 StringBuffer envBuffer = new StringBuffer(); |
| 536 List<HInstruction> inputs = node.inputs; | 536 List<HInstruction> inputs = node.inputs; |
| 537 assert(inputs.length >= 2); | 537 assert(inputs.length >= 2); |
| 538 assert(inputs[0] == guarded); | 538 assert(inputs[0] == guarded); |
| 539 assert(inputs[1] == bailoutTarget); | 539 assert(inputs[1] == bailoutTarget); |
| 540 for (int i = 2; i < inputs.length; i++) { | 540 for (int i = 2; i < inputs.length; i++) { |
| 541 envBuffer.add(" ${temporaryId(inputs[i])}"); | 541 envBuffer.write(" ${temporaryId(inputs[i])}"); |
| 542 } | 542 } |
| 543 String on = node.isEnabled ? "enabled" : "disabled"; | 543 String on = node.isEnabled ? "enabled" : "disabled"; |
| 544 String guardedId = temporaryId(node.guarded); | 544 String guardedId = temporaryId(node.guarded); |
| 545 String bailoutId = temporaryId(node.bailoutTarget); | 545 String bailoutId = temporaryId(node.bailoutTarget); |
| 546 return "TypeGuard($on): $guardedId is $type bailout: $bailoutId " | 546 return "TypeGuard($on): $guardedId is $type bailout: $bailoutId " |
| 547 "env: $envBuffer"; | 547 "env: $envBuffer"; |
| 548 } | 548 } |
| 549 | 549 |
| 550 String visitIs(HIs node) { | 550 String visitIs(HIs node) { |
| 551 String type = node.typeExpression.toString(); | 551 String type = node.typeExpression.toString(); |
| 552 return "TypeTest: ${temporaryId(node.expression)} is $type"; | 552 return "TypeTest: ${temporaryId(node.expression)} is $type"; |
| 553 } | 553 } |
| 554 | 554 |
| 555 String visitTypeConversion(HTypeConversion node) { | 555 String visitTypeConversion(HTypeConversion node) { |
| 556 return "TypeConversion: ${temporaryId(node.checkedInput)} to " | 556 return "TypeConversion: ${temporaryId(node.checkedInput)} to " |
| 557 "${node.instructionType}"; | 557 "${node.instructionType}"; |
| 558 } | 558 } |
| 559 | 559 |
| 560 String visitRangeConversion(HRangeConversion node) { | 560 String visitRangeConversion(HRangeConversion node) { |
| 561 return "RangeConversion: ${node.checkedInput}"; | 561 return "RangeConversion: ${node.checkedInput}"; |
| 562 } | 562 } |
| 563 } | 563 } |
| OLD | NEW |