| 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 part of ssa; | 5 part of ssa; |
| 6 | 6 |
| 7 class SsaFunctionCompiler implements FunctionCompiler { | 7 class SsaFunctionCompiler implements FunctionCompiler { |
| 8 SsaCodeGeneratorTask generator; | 8 SsaCodeGeneratorTask generator; |
| 9 SsaBuilderTask builder; | 9 SsaBuilderTask builder; |
| 10 SsaOptimizerTask optimizer; | 10 SsaOptimizerTask optimizer; |
| (...skipping 3140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3151 @override | 3151 @override |
| 3152 void visitBinary(ast.Send node, | 3152 void visitBinary(ast.Send node, |
| 3153 ast.Node left, | 3153 ast.Node left, |
| 3154 BinaryOperator operator, | 3154 BinaryOperator operator, |
| 3155 ast.Node right, _) { | 3155 ast.Node right, _) { |
| 3156 handleBinary(node, left, right); | 3156 handleBinary(node, left, right); |
| 3157 } | 3157 } |
| 3158 | 3158 |
| 3159 @override | 3159 @override |
| 3160 void visitIndex(ast.Send node, ast.Node receiver, ast.Node index, _) { | 3160 void visitIndex(ast.Send node, ast.Node receiver, ast.Node index, _) { |
| 3161 // TODO(johnniwinther): Add a new helper to join the paths used by | 3161 generateDynamicSend(node); |
| 3162 // [visitIndex], [visitDynamicSend] and [handleSendSet]. | |
| 3163 visitDynamicSend(node); | |
| 3164 } | 3162 } |
| 3165 | 3163 |
| 3166 @override | 3164 @override |
| 3167 void visitEquals(ast.Send node, ast.Node left, ast.Node right, _) { | 3165 void visitEquals(ast.Send node, ast.Node left, ast.Node right, _) { |
| 3168 handleBinary(node, left, right); | 3166 handleBinary(node, left, right); |
| 3169 } | 3167 } |
| 3170 | 3168 |
| 3171 @override | 3169 @override |
| 3172 void visitNotEquals(ast.Send node, ast.Node left, ast.Node right, _) { | 3170 void visitNotEquals(ast.Send node, ast.Node left, ast.Node right, _) { |
| 3173 handleBinary(node, left, right); | 3171 handleBinary(node, left, right); |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3678 handleConstantForOptionalParameter); | 3676 handleConstantForOptionalParameter); |
| 3679 } | 3677 } |
| 3680 | 3678 |
| 3681 void addGenericSendArgumentsToList(Link<ast.Node> link, List<HInstruction> lis
t) { | 3679 void addGenericSendArgumentsToList(Link<ast.Node> link, List<HInstruction> lis
t) { |
| 3682 for (; !link.isEmpty; link = link.tail) { | 3680 for (; !link.isEmpty; link = link.tail) { |
| 3683 visit(link.head); | 3681 visit(link.head); |
| 3684 list.add(pop()); | 3682 list.add(pop()); |
| 3685 } | 3683 } |
| 3686 } | 3684 } |
| 3687 | 3685 |
| 3688 visitDynamicSend(ast.Send node) { | 3686 /// Generate a dynamic method, getter or setter invocation. |
| 3687 void generateDynamicSend(ast.Send node) { |
| 3689 Selector selector = elements.getSelector(node); | 3688 Selector selector = elements.getSelector(node); |
| 3690 | 3689 |
| 3691 List<HInstruction> inputs = <HInstruction>[]; | 3690 List<HInstruction> inputs = <HInstruction>[]; |
| 3692 HInstruction receiver = generateInstanceSendReceiver(node); | 3691 HInstruction receiver = generateInstanceSendReceiver(node); |
| 3693 inputs.add(receiver); | 3692 inputs.add(receiver); |
| 3694 addDynamicSendArgumentsToList(node, inputs); | 3693 addDynamicSendArgumentsToList(node, inputs); |
| 3695 | 3694 |
| 3696 pushInvokeDynamic(node, selector, inputs); | 3695 pushInvokeDynamic(node, selector, inputs); |
| 3697 if (selector.isSetter || selector.isIndexSet) { | 3696 if (selector.isSetter || selector.isIndexSet) { |
| 3698 pop(); | 3697 pop(); |
| 3699 stack.add(inputs.last); | 3698 stack.add(inputs.last); |
| 3700 } | 3699 } |
| 3701 } | 3700 } |
| 3702 | 3701 |
| 3703 @override | 3702 @override |
| 3703 visitDynamicPropertyInvoke( |
| 3704 ast.Send node, |
| 3705 ast.Node receiver, |
| 3706 ast.NodeList arguments, |
| 3707 Selector selector, |
| 3708 _) { |
| 3709 generateDynamicSend(node); |
| 3710 } |
| 3711 |
| 3712 @override |
| 3713 visitThisPropertyInvoke( |
| 3714 ast.Send node, |
| 3715 ast.NodeList arguments, |
| 3716 Selector selector, |
| 3717 _) { |
| 3718 generateDynamicSend(node); |
| 3719 } |
| 3720 |
| 3721 @override |
| 3704 visitExpressionInvoke( | 3722 visitExpressionInvoke( |
| 3705 ast.Send node, | 3723 ast.Send node, |
| 3706 ast.Node expression, | 3724 ast.Node expression, |
| 3707 ast.NodeList arguments, | 3725 ast.NodeList arguments, |
| 3708 Selector selector, | 3726 Selector selector, |
| 3709 _) { | 3727 _) { |
| 3710 generateCallInvoke(node, visitAndPop(expression)); | 3728 generateCallInvoke(node, visitAndPop(expression)); |
| 3711 } | 3729 } |
| 3712 | 3730 |
| 3713 @override | 3731 @override |
| (...skipping 1767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5481 || !setterSelector.applies(element, compiler.world)) { | 5499 || !setterSelector.applies(element, compiler.world)) { |
| 5482 generateSuperNoSuchMethodSend( | 5500 generateSuperNoSuchMethodSend( |
| 5483 node, setterSelector, setterInputs); | 5501 node, setterSelector, setterInputs); |
| 5484 pop(); | 5502 pop(); |
| 5485 } else { | 5503 } else { |
| 5486 add(buildInvokeSuper(setterSelector, element, setterInputs)); | 5504 add(buildInvokeSuper(setterSelector, element, setterInputs)); |
| 5487 } | 5505 } |
| 5488 stack.add(result); | 5506 stack.add(result); |
| 5489 } else if (node.isIndex) { | 5507 } else if (node.isIndex) { |
| 5490 if ("=" == op.source) { | 5508 if ("=" == op.source) { |
| 5491 visitDynamicSend(node); | 5509 generateDynamicSend(node); |
| 5492 } else { | 5510 } else { |
| 5493 visit(node.receiver); | 5511 visit(node.receiver); |
| 5494 HInstruction receiver = pop(); | 5512 HInstruction receiver = pop(); |
| 5495 Link<ast.Node> arguments = node.arguments; | 5513 Link<ast.Node> arguments = node.arguments; |
| 5496 HInstruction index; | 5514 HInstruction index; |
| 5497 if (node.isIndex) { | 5515 if (node.isIndex) { |
| 5498 visit(arguments.head); | 5516 visit(arguments.head); |
| 5499 arguments = arguments.tail; | 5517 arguments = arguments.tail; |
| 5500 index = pop(); | 5518 index = pop(); |
| 5501 } | 5519 } |
| (...skipping 2087 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7589 if (unaliased is TypedefType) throw 'unable to unalias $type'; | 7607 if (unaliased is TypedefType) throw 'unable to unalias $type'; |
| 7590 unaliased.accept(this, builder); | 7608 unaliased.accept(this, builder); |
| 7591 } | 7609 } |
| 7592 | 7610 |
| 7593 void visitDynamicType(DynamicType type, SsaBuilder builder) { | 7611 void visitDynamicType(DynamicType type, SsaBuilder builder) { |
| 7594 JavaScriptBackend backend = builder.compiler.backend; | 7612 JavaScriptBackend backend = builder.compiler.backend; |
| 7595 ClassElement cls = backend.findHelper('DynamicRuntimeType'); | 7613 ClassElement cls = backend.findHelper('DynamicRuntimeType'); |
| 7596 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); | 7614 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); |
| 7597 } | 7615 } |
| 7598 } | 7616 } |
| OLD | NEW |