Chromium Code Reviews| 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 class SsaCodeGeneratorTask extends CompilerTask { | 5 class SsaCodeGeneratorTask extends CompilerTask { |
| 6 SsaCodeGeneratorTask(Compiler compiler) : super(compiler); | 6 SsaCodeGeneratorTask(Compiler compiler) : super(compiler); |
| 7 String get name() => 'SSA code generator'; | 7 String get name() => 'SSA code generator'; |
| 8 | 8 |
| 9 String generate(WorkItem work, HGraph graph) { | 9 String generate(WorkItem work, HGraph graph) { |
| 10 return measure(() { | 10 return measure(() { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 HGraph currentGraph; | 101 HGraph currentGraph; |
| 102 HBasicBlock currentBlock; | 102 HBasicBlock currentBlock; |
| 103 | 103 |
| 104 // Records a block-information that is being handled specially. | 104 // Records a block-information that is being handled specially. |
| 105 // Used to break bad recursion. | 105 // Used to break bad recursion. |
| 106 HLabeledBlockInformation currentBlockInformation; | 106 HLabeledBlockInformation currentBlockInformation; |
| 107 // The subgraph is used to delimit traversal for some constructions, e.g., | 107 // The subgraph is used to delimit traversal for some constructions, e.g., |
| 108 // if branches. | 108 // if branches. |
| 109 SubGraph subGraph; | 109 SubGraph subGraph; |
| 110 | 110 |
| 111 LibraryElement get currentLibrary() => work.element.getLibrary(); | |
| 112 | |
| 111 SsaCodeGenerator(this.compiler, | 113 SsaCodeGenerator(this.compiler, |
| 112 this.work, | 114 this.work, |
| 113 this.buffer, | 115 this.buffer, |
| 114 this.parameters, | 116 this.parameters, |
| 115 this.parameterNames) | 117 this.parameterNames) |
| 116 : names = new Map<int, String>(), | 118 : names = new Map<int, String>(), |
| 117 prefixes = new Map<String, int>() { | 119 prefixes = new Map<String, int>() { |
| 118 for (final name in parameterNames.getValues()) { | 120 for (final name in parameterNames.getValues()) { |
| 119 prefixes[name] = 0; | 121 prefixes[name] = 0; |
| 120 } | 122 } |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 514 } | 516 } |
| 515 } | 517 } |
| 516 | 518 |
| 517 visitInvokeDynamicMethod(HInvokeDynamicMethod node) { | 519 visitInvokeDynamicMethod(HInvokeDynamicMethod node) { |
| 518 beginExpression(JSPrecedence.CALL_PRECEDENCE); | 520 beginExpression(JSPrecedence.CALL_PRECEDENCE); |
| 519 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE); | 521 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE); |
| 520 buffer.add('.'); | 522 buffer.add('.'); |
| 521 // Avoid adding the generative constructor name to the list of | 523 // Avoid adding the generative constructor name to the list of |
| 522 // seen selectors. | 524 // seen selectors. |
| 523 if (node.inputs[0] is HForeignNew) { | 525 if (node.inputs[0] is HForeignNew) { |
| 526 HForeignNew foreignNew = node.inputs[0]; | |
| 524 // Remove 'this' from the number of arguments. | 527 // Remove 'this' from the number of arguments. |
| 525 int argumentCount = node.inputs.length - 1; | 528 int argumentCount = node.inputs.length - 1; |
| 526 buffer.add(compiler.namer.instanceMethodName(node.name, argumentCount)); | 529 if (node.name.isPrivate()) { |
|
floitsch
2012/03/13 13:28:56
static elements don't need to be mangled wrt priva
ahe
2012/03/17 22:19:44
Done.
| |
| 530 buffer.add(node.name); | |
| 531 } else { | |
| 532 buffer.add(compiler.namer.instanceMethodName(currentLibrary, | |
| 533 node.name, argumentCount)); | |
| 534 } | |
| 527 visitArguments(node.inputs); | 535 visitArguments(node.inputs); |
| 528 } else { | 536 } else { |
| 529 buffer.add(compiler.namer.instanceMethodInvocationName( | 537 buffer.add(compiler.namer.instanceMethodInvocationName( |
| 530 node.name, node.selector)); | 538 currentLibrary, node.name, node.selector)); |
| 531 visitArguments(node.inputs); | 539 visitArguments(node.inputs); |
| 532 compiler.registerDynamicInvocation(node.name, node.selector); | 540 compiler.registerDynamicInvocation(node.name, node.selector); |
| 533 } | 541 } |
| 534 endExpression(JSPrecedence.CALL_PRECEDENCE); | 542 endExpression(JSPrecedence.CALL_PRECEDENCE); |
| 535 } | 543 } |
| 536 | 544 |
| 537 visitInvokeDynamicSetter(HInvokeDynamicSetter node) { | 545 visitInvokeDynamicSetter(HInvokeDynamicSetter node) { |
| 538 beginExpression(JSPrecedence.CALL_PRECEDENCE); | 546 beginExpression(JSPrecedence.CALL_PRECEDENCE); |
| 539 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE); | 547 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE); |
| 540 buffer.add('.'); | 548 buffer.add('.'); |
| 541 buffer.add(compiler.namer.setterName(node.name)); | 549 buffer.add(compiler.namer.setterName(currentLibrary, node.name)); |
| 542 visitArguments(node.inputs); | 550 visitArguments(node.inputs); |
| 543 compiler.registerDynamicSetter(node.name); | 551 compiler.registerDynamicSetter(node.name); |
| 544 endExpression(JSPrecedence.CALL_PRECEDENCE); | 552 endExpression(JSPrecedence.CALL_PRECEDENCE); |
| 545 } | 553 } |
| 546 | 554 |
| 547 visitInvokeDynamicGetter(HInvokeDynamicGetter node) { | 555 visitInvokeDynamicGetter(HInvokeDynamicGetter node) { |
| 548 beginExpression(JSPrecedence.CALL_PRECEDENCE); | 556 beginExpression(JSPrecedence.CALL_PRECEDENCE); |
| 549 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE); | 557 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE); |
| 550 buffer.add('.'); | 558 buffer.add('.'); |
| 551 buffer.add(compiler.namer.getterName(node.name)); | 559 buffer.add(compiler.namer.getterName(currentLibrary, node.name)); |
| 552 visitArguments(node.inputs); | 560 visitArguments(node.inputs); |
| 553 compiler.registerDynamicGetter(node.name); | 561 compiler.registerDynamicGetter(node.name); |
| 554 endExpression(JSPrecedence.CALL_PRECEDENCE); | 562 endExpression(JSPrecedence.CALL_PRECEDENCE); |
| 555 } | 563 } |
| 556 | 564 |
| 557 visitInvokeClosure(HInvokeClosure node) { | 565 visitInvokeClosure(HInvokeClosure node) { |
| 558 beginExpression(JSPrecedence.CALL_PRECEDENCE); | 566 beginExpression(JSPrecedence.CALL_PRECEDENCE); |
| 559 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE); | 567 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE); |
| 560 buffer.add('.'); | 568 buffer.add('.'); |
| 561 buffer.add(compiler.namer.closureInvocationName(node.selector)); | 569 buffer.add(compiler.namer.closureInvocationName(node.selector)); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 574 } | 582 } |
| 575 | 583 |
| 576 visitInvokeSuper(HInvokeSuper node) { | 584 visitInvokeSuper(HInvokeSuper node) { |
| 577 beginExpression(JSPrecedence.CALL_PRECEDENCE); | 585 beginExpression(JSPrecedence.CALL_PRECEDENCE); |
| 578 Element superMethod = node.element; | 586 Element superMethod = node.element; |
| 579 Element superClass = superMethod.enclosingElement; | 587 Element superClass = superMethod.enclosingElement; |
| 580 // Remove the element and 'this'. | 588 // Remove the element and 'this'. |
| 581 int argumentCount = node.inputs.length - 2; | 589 int argumentCount = node.inputs.length - 2; |
| 582 String className = compiler.namer.isolatePropertyAccess(superClass); | 590 String className = compiler.namer.isolatePropertyAccess(superClass); |
| 583 String methodName = compiler.namer.instanceMethodName( | 591 String methodName = compiler.namer.instanceMethodName( |
| 584 superMethod.name, argumentCount); | 592 currentLibrary, superMethod.name, argumentCount); |
| 585 buffer.add('$className.prototype.$methodName.call'); | 593 buffer.add('$className.prototype.$methodName.call'); |
| 586 visitArguments(node.inputs); | 594 visitArguments(node.inputs); |
| 587 endExpression(JSPrecedence.CALL_PRECEDENCE); | 595 endExpression(JSPrecedence.CALL_PRECEDENCE); |
| 588 compiler.registerStaticUse(superMethod); | 596 compiler.registerStaticUse(superMethod); |
| 589 } | 597 } |
| 590 | 598 |
| 591 visitFieldGet(HFieldGet node) { | 599 visitFieldGet(HFieldGet node) { |
| 592 String name = JsNames.getValid(node.element.name.slowToString()); | 600 String name = JsNames.getValid(node.element.name.slowToString()); |
| 593 if (node.receiver !== null) { | 601 if (node.receiver !== null) { |
| 594 beginExpression(JSPrecedence.MEMBER_PRECEDENCE); | 602 beginExpression(JSPrecedence.MEMBER_PRECEDENCE); |
| (...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1427 startBailoutSwitch(); | 1435 startBailoutSwitch(); |
| 1428 } | 1436 } |
| 1429 } | 1437 } |
| 1430 | 1438 |
| 1431 void endElse(HIf node) { | 1439 void endElse(HIf node) { |
| 1432 if (node.elseBlock.hasBailouts()) { | 1440 if (node.elseBlock.hasBailouts()) { |
| 1433 endBailoutSwitch(); | 1441 endBailoutSwitch(); |
| 1434 } | 1442 } |
| 1435 } | 1443 } |
| 1436 } | 1444 } |
| OLD | NEW |