| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 dart2js.ir_tracer; | 5 library dart2js.ir_tracer; |
| 6 | 6 |
| 7 import 'dart:async' show EventSink; | 7 import 'dart:async' show EventSink; |
| 8 import 'cps_ir_nodes.dart' as cps_ir hide Function; | 8 import 'cps_ir_nodes.dart' as cps_ir hide Function; |
| 9 import '../tracer.dart'; | 9 import '../tracer.dart'; |
| 10 | 10 |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 } | 220 } |
| 221 | 221 |
| 222 visitBranch(cps_ir.Branch node) { | 222 visitBranch(cps_ir.Branch node) { |
| 223 String dummy = names.name(node); | 223 String dummy = names.name(node); |
| 224 String condition = visit(node.condition); | 224 String condition = visit(node.condition); |
| 225 String trueCont = formatReference(node.trueContinuation); | 225 String trueCont = formatReference(node.trueContinuation); |
| 226 String falseCont = formatReference(node.falseContinuation); | 226 String falseCont = formatReference(node.falseContinuation); |
| 227 printStmt(dummy, "Branch $condition ($trueCont, $falseCont)"); | 227 printStmt(dummy, "Branch $condition ($trueCont, $falseCont)"); |
| 228 } | 228 } |
| 229 | 229 |
| 230 visitSetMutableVariable(cps_ir.SetMutableVariable node) { | 230 visitSetMutable(cps_ir.SetMutable node) { |
| 231 String dummy = names.name(node); | |
| 232 String variable = names.name(node.variable.definition); | 231 String variable = names.name(node.variable.definition); |
| 233 String value = formatReference(node.value); | 232 String value = formatReference(node.value); |
| 234 printStmt(dummy, 'SetMutableVariable $variable := $value'); | 233 return 'SetMutable $variable := $value'; |
| 235 visit(node.body); | |
| 236 } | 234 } |
| 237 | 235 |
| 238 String formatReference(cps_ir.Reference ref) { | 236 String formatReference(cps_ir.Reference ref) { |
| 239 cps_ir.Definition target = ref.definition; | 237 cps_ir.Definition target = ref.definition; |
| 240 if (target is cps_ir.Continuation && target.isReturnContinuation) { | 238 if (target is cps_ir.Continuation && target.isReturnContinuation) { |
| 241 return "return"; // Do not generate a name for the return continuation | 239 return "return"; // Do not generate a name for the return continuation |
| 242 } else { | 240 } else { |
| 243 return names.name(ref.definition); | 241 return names.name(ref.definition); |
| 244 } | 242 } |
| 245 } | 243 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 260 | 258 |
| 261 visitContinuation(cps_ir.Continuation node) { | 259 visitContinuation(cps_ir.Continuation node) { |
| 262 return "Continuation ${names.name(node)}"; | 260 return "Continuation ${names.name(node)}"; |
| 263 } | 261 } |
| 264 | 262 |
| 265 visitIsTrue(cps_ir.IsTrue node) { | 263 visitIsTrue(cps_ir.IsTrue node) { |
| 266 return "IsTrue(${names.name(node.value.definition)})"; | 264 return "IsTrue(${names.name(node.value.definition)})"; |
| 267 } | 265 } |
| 268 | 266 |
| 269 visitSetField(cps_ir.SetField node) { | 267 visitSetField(cps_ir.SetField node) { |
| 270 String dummy = names.name(node); | |
| 271 String object = formatReference(node.object); | 268 String object = formatReference(node.object); |
| 272 String field = node.field.name; | 269 String field = node.field.name; |
| 273 String value = formatReference(node.value); | 270 String value = formatReference(node.value); |
| 274 printStmt(dummy, 'SetField $object.$field = $value'); | 271 return 'SetField $object.$field = $value'; |
| 275 visit(node.body); | |
| 276 } | 272 } |
| 277 | 273 |
| 278 visitGetField(cps_ir.GetField node) { | 274 visitGetField(cps_ir.GetField node) { |
| 279 String object = formatReference(node.object); | 275 String object = formatReference(node.object); |
| 280 String field = node.field.name; | 276 String field = node.field.name; |
| 281 return 'GetField($object.$field)'; | 277 return 'GetField($object.$field)'; |
| 282 } | 278 } |
| 283 | 279 |
| 284 visitGetStatic(cps_ir.GetStatic node) { | 280 visitGetStatic(cps_ir.GetStatic node) { |
| 285 String element = node.element.name; | 281 String element = node.element.name; |
| 286 return 'GetStatic($element)'; | 282 return 'GetStatic($element)'; |
| 287 } | 283 } |
| 288 | 284 |
| 289 visitSetStatic(cps_ir.SetStatic node) { | 285 visitSetStatic(cps_ir.SetStatic node) { |
| 290 String dummy = names.name(node); | |
| 291 String element = node.element.name; | 286 String element = node.element.name; |
| 292 String value = formatReference(node.value); | 287 String value = formatReference(node.value); |
| 293 printStmt(dummy, 'SetStatic $element = $value'); | 288 return 'SetStatic $element = $value'; |
| 294 visit(node.body); | |
| 295 } | 289 } |
| 296 | 290 |
| 297 visitGetLazyStatic(cps_ir.GetLazyStatic node) { | 291 visitGetLazyStatic(cps_ir.GetLazyStatic node) { |
| 298 String dummy = names.name(node); | 292 String dummy = names.name(node); |
| 299 String kont = formatReference(node.continuation); | 293 String kont = formatReference(node.continuation); |
| 300 printStmt(dummy, "GetLazyStatic $kont"); | 294 printStmt(dummy, "GetLazyStatic $kont"); |
| 301 } | 295 } |
| 302 | 296 |
| 303 visitCreateBox(cps_ir.CreateBox node) { | 297 visitCreateBox(cps_ir.CreateBox node) { |
| 304 return 'CreateBox'; | 298 return 'CreateBox'; |
| 305 } | 299 } |
| 306 | 300 |
| 307 visitCreateInstance(cps_ir.CreateInstance node) { | 301 visitCreateInstance(cps_ir.CreateInstance node) { |
| 308 String className = node.classElement.name; | 302 String className = node.classElement.name; |
| 309 String arguments = node.arguments.map(formatReference).join(', '); | 303 String arguments = node.arguments.map(formatReference).join(', '); |
| 310 String typeInformation = | 304 String typeInformation = |
| 311 node.typeInformation.map(formatReference).join(', '); | 305 node.typeInformation.map(formatReference).join(', '); |
| 312 return 'CreateInstance $className ($arguments) <$typeInformation>'; | 306 return 'CreateInstance $className ($arguments) <$typeInformation>'; |
| 313 } | 307 } |
| 314 | 308 |
| 315 visitInterceptor(cps_ir.Interceptor node) { | 309 visitInterceptor(cps_ir.Interceptor node) { |
| 316 return "Interceptor(${formatReference(node.input)})"; | 310 return "Interceptor(${formatReference(node.input)})"; |
| 317 } | 311 } |
| 318 | 312 |
| 319 visitCreateFunction(cps_ir.CreateFunction node) { | 313 visitCreateFunction(cps_ir.CreateFunction node) { |
| 320 return "CreateFunction ${node.definition.element.name}"; | 314 return "CreateFunction ${node.definition.element.name}"; |
| 321 } | 315 } |
| 322 | 316 |
| 323 visitGetMutableVariable(cps_ir.GetMutableVariable node) { | 317 visitGetMutable(cps_ir.GetMutable node) { |
| 324 String variable = names.name(node.variable.definition); | 318 String variable = names.name(node.variable.definition); |
| 325 return 'GetMutableVariable $variable'; | 319 return 'GetMutable $variable'; |
| 326 } | 320 } |
| 327 | 321 |
| 328 visitReadTypeVariable(cps_ir.ReadTypeVariable node) { | 322 visitReadTypeVariable(cps_ir.ReadTypeVariable node) { |
| 329 return "ReadTypeVariable ${node.variable.element} " | 323 return "ReadTypeVariable ${node.variable.element} " |
| 330 "${formatReference(node.target)}"; | 324 "${formatReference(node.target)}"; |
| 331 } | 325 } |
| 332 | 326 |
| 333 visitReifyRuntimeType(cps_ir.ReifyRuntimeType node) { | 327 visitReifyRuntimeType(cps_ir.ReifyRuntimeType node) { |
| 334 return "ReifyRuntimeType ${formatReference(node.value)}"; | 328 return "ReifyRuntimeType ${formatReference(node.value)}"; |
| 335 } | 329 } |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 | 510 |
| 517 visitThrow(cps_ir.Throw exp) { | 511 visitThrow(cps_ir.Throw exp) { |
| 518 } | 512 } |
| 519 | 513 |
| 520 visitRethrow(cps_ir.Rethrow exp) { | 514 visitRethrow(cps_ir.Rethrow exp) { |
| 521 } | 515 } |
| 522 | 516 |
| 523 visitUnreachable(cps_ir.Unreachable node) { | 517 visitUnreachable(cps_ir.Unreachable node) { |
| 524 } | 518 } |
| 525 | 519 |
| 526 visitSetMutableVariable(cps_ir.SetMutableVariable exp) { | |
| 527 visit(exp.body); | |
| 528 } | |
| 529 | |
| 530 visitSetField(cps_ir.SetField exp) { | |
| 531 visit(exp.body); | |
| 532 } | |
| 533 | |
| 534 visitSetStatic(cps_ir.SetStatic exp) { | |
| 535 visit(exp.body); | |
| 536 } | |
| 537 | |
| 538 visitGetLazyStatic(cps_ir.GetLazyStatic exp) { | 520 visitGetLazyStatic(cps_ir.GetLazyStatic exp) { |
| 539 addEdgeToContinuation(exp.continuation); | 521 addEdgeToContinuation(exp.continuation); |
| 540 } | 522 } |
| 541 | 523 |
| 542 visitBranch(cps_ir.Branch exp) { | 524 visitBranch(cps_ir.Branch exp) { |
| 543 cps_ir.Continuation trueTarget = exp.trueContinuation.definition; | 525 cps_ir.Continuation trueTarget = exp.trueContinuation.definition; |
| 544 if (!trueTarget.isReturnContinuation) { | 526 if (!trueTarget.isReturnContinuation) { |
| 545 currentBlock.addEdgeTo(getBlock(trueTarget)); | 527 currentBlock.addEdgeTo(getBlock(trueTarget)); |
| 546 } | 528 } |
| 547 cps_ir.Continuation falseTarget = exp.falseContinuation.definition; | 529 cps_ir.Continuation falseTarget = exp.falseContinuation.definition; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 576 } | 558 } |
| 577 | 559 |
| 578 visitConstant(cps_ir.Constant node) { | 560 visitConstant(cps_ir.Constant node) { |
| 579 unexpectedNode(node); | 561 unexpectedNode(node); |
| 580 } | 562 } |
| 581 | 563 |
| 582 visitCreateFunction(cps_ir.CreateFunction node) { | 564 visitCreateFunction(cps_ir.CreateFunction node) { |
| 583 unexpectedNode(node); | 565 unexpectedNode(node); |
| 584 } | 566 } |
| 585 | 567 |
| 586 visitGetMutableVariable(cps_ir.GetMutableVariable node) { | 568 visitGetMutable(cps_ir.GetMutable node) { |
| 587 unexpectedNode(node); | 569 unexpectedNode(node); |
| 588 } | 570 } |
| 589 | 571 |
| 590 visitParameter(cps_ir.Parameter node) { | 572 visitParameter(cps_ir.Parameter node) { |
| 591 unexpectedNode(node); | 573 unexpectedNode(node); |
| 592 } | 574 } |
| 593 | 575 |
| 594 visitMutableVariable(cps_ir.MutableVariable node) { | 576 visitMutableVariable(cps_ir.MutableVariable node) { |
| 595 unexpectedNode(node); | 577 unexpectedNode(node); |
| 596 } | 578 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 } | 634 } |
| 653 | 635 |
| 654 visitGetIndex(cps_ir.GetIndex node) { | 636 visitGetIndex(cps_ir.GetIndex node) { |
| 655 unexpectedNode(node); | 637 unexpectedNode(node); |
| 656 } | 638 } |
| 657 | 639 |
| 658 visitSetIndex(cps_ir.SetIndex node) { | 640 visitSetIndex(cps_ir.SetIndex node) { |
| 659 unexpectedNode(node); | 641 unexpectedNode(node); |
| 660 } | 642 } |
| 661 | 643 |
| 644 visitSetMutable(cps_ir.SetMutable node) { |
| 645 unexpectedNode(node); |
| 646 } |
| 647 |
| 648 visitSetField(cps_ir.SetField node) { |
| 649 unexpectedNode(node); |
| 650 } |
| 651 |
| 652 visitSetStatic(cps_ir.SetStatic node) { |
| 653 unexpectedNode(node); |
| 654 } |
| 655 |
| 662 @override | 656 @override |
| 663 visitForeignCode(cps_ir.ForeignCode node) { | 657 visitForeignCode(cps_ir.ForeignCode node) { |
| 664 if (node.continuation != null) { | 658 if (node.continuation != null) { |
| 665 addEdgeToContinuation(node.continuation); | 659 addEdgeToContinuation(node.continuation); |
| 666 } | 660 } |
| 667 } | 661 } |
| 668 } | 662 } |
| OLD | NEW |