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 final SsaCodeGeneratorTask generator; | 8 final SsaCodeGeneratorTask generator; |
9 final SsaBuilderTask builder; | 9 final SsaBuilderTask builder; |
10 final SsaOptimizerTask optimizer; | 10 final SsaOptimizerTask optimizer; |
(...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
983 } | 983 } |
984 super.close(); | 984 super.close(); |
985 } | 985 } |
986 } | 986 } |
987 | 987 |
988 /** | 988 /** |
989 * This class builds SSA nodes for functions represented in AST. | 989 * This class builds SSA nodes for functions represented in AST. |
990 */ | 990 */ |
991 class SsaBuilder extends ast.Visitor | 991 class SsaBuilder extends ast.Visitor |
992 with BaseImplementationOfCompoundsMixin, | 992 with BaseImplementationOfCompoundsMixin, |
| 993 BaseImplementationOfSetIfNullsMixin, |
993 SendResolverMixin, | 994 SendResolverMixin, |
994 SemanticSendResolvedMixin, | 995 SemanticSendResolvedMixin, |
995 NewBulkMixin, | 996 NewBulkMixin, |
996 ErrorBulkMixin | 997 ErrorBulkMixin |
997 implements SemanticSendVisitor { | 998 implements SemanticSendVisitor { |
998 final Compiler compiler; | 999 final Compiler compiler; |
999 final JavaScriptBackend backend; | 1000 final JavaScriptBackend backend; |
1000 final ConstantSystem constantSystem; | 1001 final ConstantSystem constantSystem; |
1001 final CodegenWorkItem work; | 1002 final CodegenWorkItem work; |
1002 final RuntimeTypes rti; | 1003 final RuntimeTypes rti; |
(...skipping 5718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6721 ast.SendSet node, | 6722 ast.SendSet node, |
6722 Element getter, | 6723 Element getter, |
6723 CompoundGetter getterKind, | 6724 CompoundGetter getterKind, |
6724 Element setter, | 6725 Element setter, |
6725 CompoundSetter setterKind, | 6726 CompoundSetter setterKind, |
6726 CompoundRhs rhs, | 6727 CompoundRhs rhs, |
6727 _) { | 6728 _) { |
6728 handleCompoundSendSet(node); | 6729 handleCompoundSendSet(node); |
6729 } | 6730 } |
6730 | 6731 |
| 6732 @override |
| 6733 handleDynamicSetIfNulls( |
| 6734 ast.Send node, |
| 6735 ast.Node receiver, |
| 6736 Name name, |
| 6737 ast.Node rhs, |
| 6738 arg) { |
| 6739 handleCompoundSendSet(node); |
| 6740 } |
| 6741 |
| 6742 @override |
| 6743 handleLocalSetIfNulls( |
| 6744 ast.SendSet node, |
| 6745 LocalElement local, |
| 6746 ast.Node rhs, |
| 6747 arg, |
| 6748 {bool isSetterValid}) { |
| 6749 handleCompoundSendSet(node); |
| 6750 } |
| 6751 |
| 6752 @override |
| 6753 handleStaticSetIfNulls( |
| 6754 ast.SendSet node, |
| 6755 Element getter, |
| 6756 CompoundGetter getterKind, |
| 6757 Element setter, |
| 6758 CompoundSetter setterKind, |
| 6759 ast.Node rhs, |
| 6760 arg) { |
| 6761 handleCompoundSendSet(node); |
| 6762 } |
| 6763 |
| 6764 @override |
| 6765 handleSuperSetIfNulls( |
| 6766 ast.SendSet node, |
| 6767 Element getter, |
| 6768 CompoundGetter getterKind, |
| 6769 Element setter, |
| 6770 CompoundSetter setterKind, |
| 6771 ast.Node rhs, |
| 6772 arg) { |
| 6773 handleSuperSendSet(node); |
| 6774 } |
| 6775 |
| 6776 @override |
| 6777 handleTypeLiteralConstantSetIfNulls( |
| 6778 ast.SendSet node, |
| 6779 ConstantExpression constant, |
| 6780 ast.Node rhs, |
| 6781 arg) { |
| 6782 // The type variable is never `null`. |
| 6783 generateConstantTypeLiteral(node); |
| 6784 } |
| 6785 |
| 6786 @override |
| 6787 visitTypeVariableTypeLiteralSetIfNull( |
| 6788 ast.Send node, |
| 6789 TypeVariableElement element, |
| 6790 ast.Node rhs, |
| 6791 arg) { |
| 6792 // The type variable is never `null`. |
| 6793 generateTypeVariableLiteral(node, element.type); |
| 6794 } |
| 6795 |
6731 void visitLiteralInt(ast.LiteralInt node) { | 6796 void visitLiteralInt(ast.LiteralInt node) { |
6732 stack.add(graph.addConstantInt(node.value, compiler)); | 6797 stack.add(graph.addConstantInt(node.value, compiler)); |
6733 } | 6798 } |
6734 | 6799 |
6735 void visitLiteralDouble(ast.LiteralDouble node) { | 6800 void visitLiteralDouble(ast.LiteralDouble node) { |
6736 stack.add(graph.addConstantDouble(node.value, compiler)); | 6801 stack.add(graph.addConstantDouble(node.value, compiler)); |
6737 } | 6802 } |
6738 | 6803 |
6739 void visitLiteralBool(ast.LiteralBool node) { | 6804 void visitLiteralBool(ast.LiteralBool node) { |
6740 stack.add(graph.addConstantBool(node.value, compiler)); | 6805 stack.add(graph.addConstantBool(node.value, compiler)); |
(...skipping 1443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8184 localsHandler.updateLocal(returnLocal, value); | 8249 localsHandler.updateLocal(returnLocal, value); |
8185 } | 8250 } |
8186 } | 8251 } |
8187 | 8252 |
8188 @override | 8253 @override |
8189 void handleTypeLiteralConstantCompounds( | 8254 void handleTypeLiteralConstantCompounds( |
8190 ast.SendSet node, | 8255 ast.SendSet node, |
8191 ConstantExpression constant, | 8256 ConstantExpression constant, |
8192 CompoundRhs rhs, | 8257 CompoundRhs rhs, |
8193 _) { | 8258 _) { |
8194 if (rhs.operator.kind == BinaryOperatorKind.IF_NULL) { | 8259 handleTypeLiteralCompound(node); |
8195 handleCompoundSendSet(node); | |
8196 } else { | |
8197 handleTypeLiteralCompound(node); | |
8198 } | |
8199 } | 8260 } |
8200 | 8261 |
8201 @override | 8262 @override |
8202 void handleTypeVariableTypeLiteralCompounds( | 8263 void handleTypeVariableTypeLiteralCompounds( |
8203 ast.SendSet node, | 8264 ast.SendSet node, |
8204 TypeVariableElement typeVariable, | 8265 TypeVariableElement typeVariable, |
8205 CompoundRhs rhs, | 8266 CompoundRhs rhs, |
8206 _) { | 8267 _) { |
8207 handleTypeLiteralCompound(node); | 8268 handleTypeLiteralCompound(node); |
8208 } | 8269 } |
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8865 if (unaliased is TypedefType) throw 'unable to unalias $type'; | 8926 if (unaliased is TypedefType) throw 'unable to unalias $type'; |
8866 unaliased.accept(this, builder); | 8927 unaliased.accept(this, builder); |
8867 } | 8928 } |
8868 | 8929 |
8869 void visitDynamicType(DynamicType type, SsaBuilder builder) { | 8930 void visitDynamicType(DynamicType type, SsaBuilder builder) { |
8870 JavaScriptBackend backend = builder.compiler.backend; | 8931 JavaScriptBackend backend = builder.compiler.backend; |
8871 ClassElement cls = backend.findHelper('DynamicRuntimeType'); | 8932 ClassElement cls = backend.findHelper('DynamicRuntimeType'); |
8872 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); | 8933 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); |
8873 } | 8934 } |
8874 } | 8935 } |
OLD | NEW |