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 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1012 for (JumpTarget target in targetIndexMap.keys) { | 1012 for (JumpTarget target in targetIndexMap.keys) { |
1013 builder.jumpTargets.remove(target); | 1013 builder.jumpTargets.remove(target); |
1014 } | 1014 } |
1015 super.close(); | 1015 super.close(); |
1016 } | 1016 } |
1017 } | 1017 } |
1018 | 1018 |
1019 /** | 1019 /** |
1020 * This class builds SSA nodes for functions represented in AST. | 1020 * This class builds SSA nodes for functions represented in AST. |
1021 */ | 1021 */ |
1022 class SsaBuilder extends NewResolvedVisitor { | 1022 class SsaBuilder extends ast.Visitor |
| 1023 with BaseImplementationOfCompoundsMixin, |
| 1024 SendResolverMixin, |
| 1025 SemanticSendResolvedMixin, |
| 1026 NewBulkMixin |
| 1027 implements SemanticSendVisitor { |
1023 final Compiler compiler; | 1028 final Compiler compiler; |
1024 final JavaScriptBackend backend; | 1029 final JavaScriptBackend backend; |
1025 final ConstantSystem constantSystem; | 1030 final ConstantSystem constantSystem; |
1026 final CodegenWorkItem work; | 1031 final CodegenWorkItem work; |
1027 final RuntimeTypes rti; | 1032 final RuntimeTypes rti; |
| 1033 TreeElements elements; |
1028 SourceInformationBuilder sourceInformationBuilder; | 1034 SourceInformationBuilder sourceInformationBuilder; |
1029 bool inLazyInitializerExpression = false; | 1035 bool inLazyInitializerExpression = false; |
1030 | 1036 |
1031 /* This field is used by the native handler. */ | 1037 /* This field is used by the native handler. */ |
1032 final NativeEmitter nativeEmitter; | 1038 final NativeEmitter nativeEmitter; |
1033 | 1039 |
1034 final HGraph graph = new HGraph(); | 1040 final HGraph graph = new HGraph(); |
1035 | 1041 |
1036 /** | 1042 /** |
1037 * The current block to add instructions to. Might be null, if we are | 1043 * The current block to add instructions to. Might be null, if we are |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1112 | 1118 |
1113 SsaBuilder(JavaScriptBackend backend, | 1119 SsaBuilder(JavaScriptBackend backend, |
1114 CodegenWorkItem work, | 1120 CodegenWorkItem work, |
1115 this.nativeEmitter, | 1121 this.nativeEmitter, |
1116 SourceInformationFactory sourceInformationFactory) | 1122 SourceInformationFactory sourceInformationFactory) |
1117 : this.compiler = backend.compiler, | 1123 : this.compiler = backend.compiler, |
1118 this.backend = backend, | 1124 this.backend = backend, |
1119 this.constantSystem = backend.constantSystem, | 1125 this.constantSystem = backend.constantSystem, |
1120 this.work = work, | 1126 this.work = work, |
1121 this.rti = backend.rti, | 1127 this.rti = backend.rti, |
1122 super(work.resolutionTree) { | 1128 this.elements = work.resolutionTree { |
1123 localsHandler = new LocalsHandler(this, work.element, null); | 1129 localsHandler = new LocalsHandler(this, work.element, null); |
1124 sourceElementStack.add(work.element); | 1130 sourceElementStack.add(work.element); |
1125 sourceInformationBuilder = | 1131 sourceInformationBuilder = |
1126 sourceInformationFactory.forContext(work.element.implementation); | 1132 sourceInformationFactory.forContext(work.element.implementation); |
1127 } | 1133 } |
1128 | 1134 |
| 1135 @override |
| 1136 SemanticSendVisitor get sendVisitor => this; |
| 1137 |
| 1138 @override |
| 1139 void visitNode(ast.Node node) { |
| 1140 internalError(node, "Unhandled node: $node"); |
| 1141 } |
| 1142 |
| 1143 @override |
| 1144 void apply(ast.Node node, [_]) { |
| 1145 node.accept(this); |
| 1146 } |
| 1147 |
1129 CodegenRegistry get registry => work.registry; | 1148 CodegenRegistry get registry => work.registry; |
1130 | 1149 |
1131 /// Returns the current source element. | 1150 /// Returns the current source element. |
1132 /// | 1151 /// |
1133 /// The returned element is a declaration element. | 1152 /// The returned element is a declaration element. |
1134 // TODO(johnniwinther): Check that all usages of sourceElement agree on | 1153 // TODO(johnniwinther): Check that all usages of sourceElement agree on |
1135 // implementation/declaration distinction. | 1154 // implementation/declaration distinction. |
1136 Element get sourceElement => sourceElementStack.last; | 1155 Element get sourceElement => sourceElementStack.last; |
1137 | 1156 |
1138 bool get _checkOrTrustTypes => | 1157 bool get _checkOrTrustTypes => |
(...skipping 1977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3116 } | 3135 } |
3117 | 3136 |
3118 visitFunctionDeclaration(ast.FunctionDeclaration node) { | 3137 visitFunctionDeclaration(ast.FunctionDeclaration node) { |
3119 assert(isReachable); | 3138 assert(isReachable); |
3120 visit(node.function); | 3139 visit(node.function); |
3121 LocalFunctionElement localFunction = | 3140 LocalFunctionElement localFunction = |
3122 elements.getFunctionDefinition(node.function); | 3141 elements.getFunctionDefinition(node.function); |
3123 localsHandler.updateLocal(localFunction, pop()); | 3142 localsHandler.updateLocal(localFunction, pop()); |
3124 } | 3143 } |
3125 | 3144 |
| 3145 @override |
| 3146 void visitThisGet(ast.Identifier node, [_]) { |
| 3147 stack.add(localsHandler.readThis()); |
| 3148 } |
| 3149 |
3126 visitIdentifier(ast.Identifier node) { | 3150 visitIdentifier(ast.Identifier node) { |
3127 if (node.isThis()) { | 3151 if (node.isThis()) { |
3128 stack.add(localsHandler.readThis()); | 3152 visitThisGet(node); |
3129 } else { | 3153 } else { |
3130 compiler.internalError(node, | 3154 compiler.internalError(node, |
3131 "SsaFromAstMixin.visitIdentifier on non-this."); | 3155 "SsaFromAstMixin.visitIdentifier on non-this."); |
3132 } | 3156 } |
3133 } | 3157 } |
3134 | 3158 |
3135 visitIf(ast.If node) { | 3159 visitIf(ast.If node) { |
3136 assert(isReachable); | 3160 assert(isReachable); |
3137 handleIf(node, | 3161 handleIf(node, |
3138 () => visit(node.condition), | 3162 () => visit(node.condition), |
(...skipping 1255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4394 /// Access an unresolved super property. | 4418 /// Access an unresolved super property. |
4395 void handleUnresolvedSuperInvoke(ast.Send node) { | 4419 void handleUnresolvedSuperInvoke(ast.Send node) { |
4396 Selector selector = elements.getSelector(node); | 4420 Selector selector = elements.getSelector(node); |
4397 List<HInstruction> arguments = <HInstruction>[]; | 4421 List<HInstruction> arguments = <HInstruction>[]; |
4398 if (!node.isPropertyAccess) { | 4422 if (!node.isPropertyAccess) { |
4399 addGenericSendArgumentsToList(node.arguments, arguments); | 4423 addGenericSendArgumentsToList(node.arguments, arguments); |
4400 } | 4424 } |
4401 generateSuperNoSuchMethodSend(node, selector, arguments); | 4425 generateSuperNoSuchMethodSend(node, selector, arguments); |
4402 } | 4426 } |
4403 | 4427 |
4404 /// Handle super constructor invocation. | |
4405 @override | |
4406 void handleSuperConstructorInvoke(ast.Send node) { | |
4407 Selector selector = elements.getSelector(node); | |
4408 Element element = elements[node]; | |
4409 if (selector.applies(element, compiler.world)) { | |
4410 generateSuperInvoke(node, element); | |
4411 } else { | |
4412 generateWrongArgumentCountError(node, element, node.arguments); | |
4413 } | |
4414 } | |
4415 | |
4416 @override | 4428 @override |
4417 void visitUnresolvedSuperIndex( | 4429 void visitUnresolvedSuperIndex( |
4418 ast.Send node, | 4430 ast.Send node, |
4419 Element element, | 4431 Element element, |
4420 ast.Node index, | 4432 ast.Node index, |
4421 _) { | 4433 _) { |
4422 handleUnresolvedSuperInvoke(node); | 4434 handleUnresolvedSuperInvoke(node); |
4423 } | 4435 } |
4424 | 4436 |
4425 @override | 4437 @override |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4568 handleSuperMethodInvoke(node, method); | 4580 handleSuperMethodInvoke(node, method); |
4569 } | 4581 } |
4570 | 4582 |
4571 @override | 4583 @override |
4572 void visitSuperMethodIncompatibleInvoke( | 4584 void visitSuperMethodIncompatibleInvoke( |
4573 ast.Send node, | 4585 ast.Send node, |
4574 MethodElement method, | 4586 MethodElement method, |
4575 ast.NodeList arguments, | 4587 ast.NodeList arguments, |
4576 CallStructure callStructure, | 4588 CallStructure callStructure, |
4577 _) { | 4589 _) { |
| 4590 handleInvalidSuperInvoke(node, arguments); |
| 4591 } |
| 4592 |
| 4593 @override |
| 4594 void visitSuperSetterInvoke( |
| 4595 ast.Send node, |
| 4596 SetterElement setter, |
| 4597 ast.NodeList arguments, |
| 4598 CallStructure callStructure, |
| 4599 _) { |
| 4600 handleInvalidSuperInvoke(node, arguments); |
| 4601 } |
| 4602 |
| 4603 void handleInvalidSuperInvoke(ast.Send node, ast.NodeList arguments) { |
4578 Selector selector = elements.getSelector(node); | 4604 Selector selector = elements.getSelector(node); |
4579 List<HInstruction> inputs = <HInstruction>[]; | 4605 List<HInstruction> inputs = <HInstruction>[]; |
4580 addGenericSendArgumentsToList(arguments.nodes, inputs); | 4606 addGenericSendArgumentsToList(arguments.nodes, inputs); |
4581 generateSuperNoSuchMethodSend(node, selector, inputs); | 4607 generateSuperNoSuchMethodSend(node, selector, inputs); |
4582 } | 4608 } |
4583 | 4609 |
4584 bool needsSubstitutionForTypeVariableAccess(ClassElement cls) { | 4610 bool needsSubstitutionForTypeVariableAccess(ClassElement cls) { |
4585 ClassWorld classWorld = compiler.world; | 4611 ClassWorld classWorld = compiler.world; |
4586 if (classWorld.isUsedAsMixin(cls)) return true; | 4612 if (classWorld.isUsedAsMixin(cls)) return true; |
4587 | 4613 |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4753 typeMask: backend.dynamicType); | 4779 typeMask: backend.dynamicType); |
4754 | 4780 |
4755 // The new object will now be referenced through the | 4781 // The new object will now be referenced through the |
4756 // `setRuntimeTypeInfo` call. We therefore set the type of that | 4782 // `setRuntimeTypeInfo` call. We therefore set the type of that |
4757 // instruction to be of the object's type. | 4783 // instruction to be of the object's type. |
4758 assert(stack.last is HInvokeStatic || stack.last == newObject); | 4784 assert(stack.last is HInvokeStatic || stack.last == newObject); |
4759 stack.last.instructionType = newObject.instructionType; | 4785 stack.last.instructionType = newObject.instructionType; |
4760 return pop(); | 4786 return pop(); |
4761 } | 4787 } |
4762 | 4788 |
4763 handleNewSend(ast.NewExpression node) { | 4789 void handleNewSend(ast.NewExpression node) { |
4764 ast.Send send = node.send; | 4790 ast.Send send = node.send; |
4765 generateIsDeferredLoadedCheckOfSend(send); | 4791 generateIsDeferredLoadedCheckOfSend(send); |
4766 | 4792 |
4767 bool isFixedList = false; | 4793 bool isFixedList = false; |
4768 bool isFixedListConstructorCall = | 4794 bool isFixedListConstructorCall = |
4769 Elements.isFixedListConstructorCall(elements[send], send, compiler); | 4795 Elements.isFixedListConstructorCall(elements[send], send, compiler); |
4770 bool isGrowableListConstructorCall = | 4796 bool isGrowableListConstructorCall = |
4771 Elements.isGrowableListConstructorCall(elements[send], send, compiler); | 4797 Elements.isGrowableListConstructorCall(elements[send], send, compiler); |
4772 | 4798 |
4773 TypeMask computeType(element) { | 4799 TypeMask computeType(element) { |
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5420 signature.forEachParameter((Element parameter) { | 5446 signature.forEachParameter((Element parameter) { |
5421 existingArguments.add(parameter.name); | 5447 existingArguments.add(parameter.name); |
5422 }); | 5448 }); |
5423 generateThrowNoSuchMethod(diagnosticNode, | 5449 generateThrowNoSuchMethod(diagnosticNode, |
5424 function.name, | 5450 function.name, |
5425 argumentNodes: argumentNodes, | 5451 argumentNodes: argumentNodes, |
5426 existingArguments: existingArguments); | 5452 existingArguments: existingArguments); |
5427 } | 5453 } |
5428 | 5454 |
5429 @override | 5455 @override |
5430 handleNewExpression(ast.NewExpression node) { | 5456 void bulkHandleNode(ast.Node node, String message, _) { |
| 5457 internalError(node, "Unexpected bulk handled node: $node"); |
| 5458 } |
| 5459 |
| 5460 @override |
| 5461 void bulkHandleNew(ast.NewExpression node, [_]) { |
5431 Element element = elements[node.send]; | 5462 Element element = elements[node.send]; |
5432 final bool isSymbolConstructor = element == compiler.symbolConstructor; | 5463 final bool isSymbolConstructor = element == compiler.symbolConstructor; |
5433 if (!Elements.isErroneous(element)) { | 5464 if (!Elements.isErroneous(element)) { |
5434 ConstructorElement function = element; | 5465 ConstructorElement function = element; |
5435 element = function.effectiveTarget; | 5466 element = function.effectiveTarget; |
5436 } | 5467 } |
5437 if (Elements.isErroneous(element)) { | 5468 if (Elements.isErroneous(element)) { |
5438 if (element is !ErroneousElement) { | 5469 if (element is !ErroneousElement) { |
5439 // TODO(ahe): Do something like [generateWrongArgumentCountError]. | 5470 // TODO(ahe): Do something like [generateWrongArgumentCountError]. |
5440 stack.add(graph.addConstantNull(compiler)); | 5471 stack.add(graph.addConstantNull(compiler)); |
(...skipping 15 matching lines...) Expand all Loading... |
5456 ConstructedConstantValue symbol = getConstantForNode(node); | 5487 ConstructedConstantValue symbol = getConstantForNode(node); |
5457 StringConstantValue stringConstant = symbol.fields.values.single; | 5488 StringConstantValue stringConstant = symbol.fields.values.single; |
5458 String nameString = stringConstant.toDartString().slowToString(); | 5489 String nameString = stringConstant.toDartString().slowToString(); |
5459 registry.registerConstSymbol(nameString); | 5490 registry.registerConstSymbol(nameString); |
5460 } | 5491 } |
5461 } else { | 5492 } else { |
5462 handleNewSend(node); | 5493 handleNewSend(node); |
5463 } | 5494 } |
5464 } | 5495 } |
5465 | 5496 |
| 5497 @override |
| 5498 void errorNonConstantConstructorInvoke( |
| 5499 ast.NewExpression node, |
| 5500 Element element, |
| 5501 DartType type, |
| 5502 ast.NodeList arguments, |
| 5503 CallStructure callStructure, |
| 5504 _) { |
| 5505 bulkHandleNew(node); |
| 5506 } |
| 5507 |
5466 void pushInvokeDynamic(ast.Node node, | 5508 void pushInvokeDynamic(ast.Node node, |
5467 Selector selector, | 5509 Selector selector, |
5468 TypeMask mask, | 5510 TypeMask mask, |
5469 List<HInstruction> arguments, | 5511 List<HInstruction> arguments, |
5470 {ast.Node location}) { | 5512 {ast.Node location}) { |
5471 if (location == null) location = node; | 5513 if (location == null) location = node; |
5472 | 5514 |
5473 // We prefer to not inline certain operations on indexables, | 5515 // We prefer to not inline certain operations on indexables, |
5474 // because the constant folder will handle them better and turn | 5516 // because the constant folder will handle them better and turn |
5475 // them into simpler instructions that allow further | 5517 // them into simpler instructions that allow further |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5683 } else { | 5725 } else { |
5684 handleComplexOperatorSend(node, getterInstruction, arguments); | 5726 handleComplexOperatorSend(node, getterInstruction, arguments); |
5685 setterInputs.add(pop()); | 5727 setterInputs.add(pop()); |
5686 generateSuperSendSet(); | 5728 generateSuperSendSet(); |
5687 stack.add(node.isPostfix ? getterInstruction : setterInputs.last); | 5729 stack.add(node.isPostfix ? getterInstruction : setterInputs.last); |
5688 } | 5730 } |
5689 } | 5731 } |
5690 } | 5732 } |
5691 | 5733 |
5692 @override | 5734 @override |
| 5735 void handleSuperCompounds( |
| 5736 ast.SendSet node, |
| 5737 Element getter, |
| 5738 CompoundGetter getterKind, |
| 5739 Element setter, |
| 5740 CompoundSetter setterKind, |
| 5741 CompoundRhs rhs, |
| 5742 _) { |
| 5743 handleSuperSendSet(node); |
| 5744 } |
| 5745 |
| 5746 @override |
| 5747 void visitFinalSuperFieldSet( |
| 5748 ast.SendSet node, |
| 5749 FieldElement field, |
| 5750 ast.Node rhs, |
| 5751 _) { |
| 5752 handleSuperSendSet(node); |
| 5753 } |
| 5754 |
| 5755 @override |
| 5756 void visitSuperFieldSet( |
| 5757 ast.SendSet node, |
| 5758 FieldElement field, |
| 5759 ast.Node rhs, |
| 5760 _) { |
| 5761 handleSuperSendSet(node); |
| 5762 } |
| 5763 |
| 5764 @override |
| 5765 void visitSuperGetterSet( |
| 5766 ast.SendSet node, |
| 5767 FunctionElement getter, |
| 5768 ast.Node rhs, |
| 5769 _) { |
| 5770 handleSuperSendSet(node); |
| 5771 } |
| 5772 |
| 5773 @override |
| 5774 void visitSuperIndexSet( |
| 5775 ast.SendSet node, |
| 5776 FunctionElement function, |
| 5777 ast.Node index, |
| 5778 ast.Node rhs, |
| 5779 _) { |
| 5780 handleSuperSendSet(node); |
| 5781 } |
| 5782 |
| 5783 @override |
| 5784 void visitSuperMethodSet( |
| 5785 ast.Send node, |
| 5786 MethodElement method, |
| 5787 ast.Node rhs, |
| 5788 _) { |
| 5789 handleSuperSendSet(node); |
| 5790 } |
| 5791 |
| 5792 @override |
| 5793 void visitSuperSetterSet( |
| 5794 ast.SendSet node, |
| 5795 FunctionElement setter, |
| 5796 ast.Node rhs, |
| 5797 _) { |
| 5798 handleSuperSendSet(node); |
| 5799 } |
| 5800 |
| 5801 @override |
| 5802 void visitUnresolvedSuperIndexSet( |
| 5803 ast.Send node, |
| 5804 Element element, |
| 5805 ast.Node index, |
| 5806 ast.Node rhs, |
| 5807 _) { |
| 5808 handleSuperSendSet(node); |
| 5809 } |
| 5810 |
| 5811 @override |
| 5812 void visitSuperIndexPrefix( |
| 5813 ast.Send node, |
| 5814 MethodElement indexFunction, |
| 5815 MethodElement indexSetFunction, |
| 5816 ast.Node index, |
| 5817 IncDecOperator operator, |
| 5818 _) { |
| 5819 handleSuperSendSet(node); |
| 5820 } |
| 5821 |
| 5822 @override |
| 5823 void visitSuperIndexPostfix( |
| 5824 ast.Send node, |
| 5825 MethodElement indexFunction, |
| 5826 MethodElement indexSetFunction, |
| 5827 ast.Node index, |
| 5828 IncDecOperator operator, |
| 5829 _) { |
| 5830 handleSuperSendSet(node); |
| 5831 } |
| 5832 |
| 5833 @override |
| 5834 void visitUnresolvedSuperGetterIndexPrefix( |
| 5835 ast.Send node, |
| 5836 Element element, |
| 5837 MethodElement setter, |
| 5838 ast.Node index, |
| 5839 IncDecOperator operator, |
| 5840 _) { |
| 5841 handleSuperSendSet(node); |
| 5842 } |
| 5843 |
| 5844 @override |
| 5845 void visitUnresolvedSuperGetterIndexPostfix( |
| 5846 ast.Send node, |
| 5847 Element element, |
| 5848 MethodElement setter, |
| 5849 ast.Node index, |
| 5850 IncDecOperator operator, |
| 5851 _) { |
| 5852 handleSuperSendSet(node); |
| 5853 } |
| 5854 |
| 5855 @override |
| 5856 void visitUnresolvedSuperSetterIndexPrefix( |
| 5857 ast.Send node, |
| 5858 MethodElement indexFunction, |
| 5859 Element element, |
| 5860 ast.Node index, |
| 5861 IncDecOperator operator, |
| 5862 _) { |
| 5863 handleSuperSendSet(node); |
| 5864 } |
| 5865 |
| 5866 @override |
| 5867 void visitUnresolvedSuperSetterIndexPostfix( |
| 5868 ast.Send node, |
| 5869 MethodElement indexFunction, |
| 5870 Element element, |
| 5871 ast.Node index, |
| 5872 IncDecOperator operator, |
| 5873 _) { |
| 5874 handleSuperSendSet(node); |
| 5875 } |
| 5876 |
| 5877 @override |
| 5878 void visitUnresolvedSuperIndexPrefix( |
| 5879 ast.Send node, |
| 5880 Element element, |
| 5881 ast.Node index, |
| 5882 IncDecOperator operator, |
| 5883 _) { |
| 5884 handleSuperSendSet(node); |
| 5885 } |
| 5886 |
| 5887 @override |
| 5888 void visitUnresolvedSuperIndexPostfix( |
| 5889 ast.Send node, |
| 5890 Element element, |
| 5891 ast.Node index, |
| 5892 IncDecOperator operator, |
| 5893 _) { |
| 5894 handleSuperSendSet(node); |
| 5895 } |
| 5896 |
| 5897 @override |
| 5898 void visitSuperCompoundIndexSet( |
| 5899 ast.SendSet node, |
| 5900 MethodElement getter, |
| 5901 MethodElement setter, |
| 5902 ast.Node index, |
| 5903 AssignmentOperator operator, |
| 5904 ast.Node rhs, |
| 5905 _) { |
| 5906 handleSuperSendSet(node); |
| 5907 } |
| 5908 |
| 5909 @override |
| 5910 void visitUnresolvedSuperGetterCompoundIndexSet( |
| 5911 ast.Send node, |
| 5912 Element element, |
| 5913 MethodElement setter, |
| 5914 ast.Node index, |
| 5915 AssignmentOperator operator, |
| 5916 ast.Node rhs, |
| 5917 _) { |
| 5918 handleSuperSendSet(node); |
| 5919 } |
| 5920 |
| 5921 @override |
| 5922 void visitUnresolvedSuperSetterCompoundIndexSet( |
| 5923 ast.Send node, |
| 5924 MethodElement getter, |
| 5925 Element element, |
| 5926 ast.Node index, |
| 5927 AssignmentOperator operator, |
| 5928 ast.Node rhs, |
| 5929 _) { |
| 5930 handleSuperSendSet(node); |
| 5931 } |
| 5932 |
| 5933 @override |
| 5934 void visitUnresolvedSuperCompoundIndexSet( |
| 5935 ast.Send node, |
| 5936 Element element, |
| 5937 ast.Node index, |
| 5938 AssignmentOperator operator, |
| 5939 ast.Node rhs, |
| 5940 _) { |
| 5941 handleSuperSendSet(node); |
| 5942 } |
| 5943 |
| 5944 @override |
| 5945 void visitSuperFieldCompound( |
| 5946 ast.Send node, |
| 5947 FieldElement field, |
| 5948 AssignmentOperator operator, |
| 5949 ast.Node rhs, |
| 5950 _) { |
| 5951 handleSuperSendSet(node); |
| 5952 } |
| 5953 |
| 5954 @override |
| 5955 void visitFinalSuperFieldCompound( |
| 5956 ast.Send node, |
| 5957 FieldElement field, |
| 5958 AssignmentOperator operator, |
| 5959 ast.Node rhs, |
| 5960 _) { |
| 5961 handleSuperSendSet(node); |
| 5962 } |
| 5963 |
| 5964 @override |
| 5965 void visitFinalSuperFieldPrefix( |
| 5966 ast.Send node, |
| 5967 FieldElement field, |
| 5968 IncDecOperator operator, |
| 5969 _) { |
| 5970 handleSuperSendSet(node); |
| 5971 } |
| 5972 |
| 5973 @override |
| 5974 void visitUnresolvedSuperPrefix( |
| 5975 ast.Send node, |
| 5976 Element element, |
| 5977 IncDecOperator operator, |
| 5978 _) { |
| 5979 handleSuperSendSet(node); |
| 5980 } |
| 5981 |
| 5982 @override |
| 5983 void visitUnresolvedSuperPostfix( |
| 5984 ast.Send node, |
| 5985 Element element, |
| 5986 IncDecOperator operator, |
| 5987 _) { |
| 5988 handleSuperSendSet(node); |
| 5989 } |
| 5990 |
| 5991 @override |
| 5992 void visitUnresolvedSuperCompound( |
| 5993 ast.Send node, |
| 5994 Element element, |
| 5995 AssignmentOperator operator, |
| 5996 ast.Node rhs, |
| 5997 _) { |
| 5998 handleSuperSendSet(node); |
| 5999 } |
| 6000 |
| 6001 @override |
| 6002 void visitFinalSuperFieldPostfix( |
| 6003 ast.Send node, |
| 6004 FieldElement field, |
| 6005 IncDecOperator operator, |
| 6006 _) { |
| 6007 handleSuperSendSet(node); |
| 6008 } |
| 6009 |
| 6010 @override |
| 6011 void visitSuperFieldFieldCompound( |
| 6012 ast.Send node, |
| 6013 FieldElement readField, |
| 6014 FieldElement writtenField, |
| 6015 AssignmentOperator operator, |
| 6016 ast.Node rhs, |
| 6017 _) { |
| 6018 handleSuperSendSet(node); |
| 6019 } |
| 6020 |
| 6021 @override |
| 6022 void visitSuperGetterSetterCompound( |
| 6023 ast.Send node, |
| 6024 FunctionElement getter, |
| 6025 FunctionElement setter, |
| 6026 AssignmentOperator operator, |
| 6027 ast.Node rhs, |
| 6028 _) { |
| 6029 handleSuperSendSet(node); |
| 6030 } |
| 6031 |
| 6032 @override |
| 6033 void visitSuperMethodSetterCompound( |
| 6034 ast.Send node, |
| 6035 FunctionElement method, |
| 6036 FunctionElement setter, |
| 6037 AssignmentOperator operator, |
| 6038 ast.Node rhs, |
| 6039 _) { |
| 6040 handleSuperSendSet(node); |
| 6041 } |
| 6042 |
| 6043 @override |
| 6044 void visitSuperMethodCompound( |
| 6045 ast.Send node, |
| 6046 FunctionElement method, |
| 6047 AssignmentOperator operator, |
| 6048 ast.Node rhs, |
| 6049 _) { |
| 6050 handleSuperSendSet(node); |
| 6051 } |
| 6052 |
| 6053 @override |
| 6054 void visitUnresolvedSuperGetterCompound( |
| 6055 ast.Send node, |
| 6056 Element element, |
| 6057 MethodElement setter, |
| 6058 AssignmentOperator operator, |
| 6059 ast.Node rhs, |
| 6060 _) { |
| 6061 handleSuperSendSet(node); |
| 6062 } |
| 6063 |
| 6064 @override |
| 6065 void visitUnresolvedSuperSetterCompound( |
| 6066 ast.Send node, |
| 6067 MethodElement getter, |
| 6068 Element element, |
| 6069 AssignmentOperator operator, |
| 6070 ast.Node rhs, |
| 6071 _) { |
| 6072 handleSuperSendSet(node); |
| 6073 } |
| 6074 |
| 6075 @override |
| 6076 void visitSuperFieldSetterCompound( |
| 6077 ast.Send node, |
| 6078 FieldElement field, |
| 6079 FunctionElement setter, |
| 6080 AssignmentOperator operator, |
| 6081 ast.Node rhs, |
| 6082 _) { |
| 6083 handleSuperSendSet(node); |
| 6084 } |
| 6085 |
| 6086 @override |
| 6087 void visitSuperGetterFieldCompound( |
| 6088 ast.Send node, |
| 6089 FunctionElement getter, |
| 6090 FieldElement field, |
| 6091 AssignmentOperator operator, |
| 6092 ast.Node rhs, |
| 6093 _) { |
| 6094 handleSuperSendSet(node); |
| 6095 } |
| 6096 |
| 6097 @override |
5693 void visitIndexSet( | 6098 void visitIndexSet( |
5694 ast.SendSet node, | 6099 ast.SendSet node, |
5695 ast.Node receiver, | 6100 ast.Node receiver, |
5696 ast.Node index, | 6101 ast.Node index, |
5697 ast.Node rhs, | 6102 ast.Node rhs, |
5698 _) { | 6103 _) { |
5699 generateDynamicSend(node); | 6104 generateDynamicSend(node); |
5700 } | 6105 } |
5701 | 6106 |
| 6107 @override |
| 6108 void visitCompoundIndexSet( |
| 6109 ast.SendSet node, |
| 6110 ast.Node receiver, |
| 6111 ast.Node index, |
| 6112 AssignmentOperator operator, |
| 6113 ast.Node rhs, |
| 6114 _) { |
| 6115 generateIsDeferredLoadedCheckOfSend(node); |
| 6116 handleIndexSendSet(node); |
| 6117 } |
| 6118 |
| 6119 @override |
| 6120 void visitIndexPrefix( |
| 6121 ast.Send node, |
| 6122 ast.Node receiver, |
| 6123 ast.Node index, |
| 6124 IncDecOperator operator, |
| 6125 _) { |
| 6126 generateIsDeferredLoadedCheckOfSend(node); |
| 6127 handleIndexSendSet(node); |
| 6128 } |
| 6129 |
| 6130 @override |
| 6131 void visitIndexPostfix( |
| 6132 ast.Send node, |
| 6133 ast.Node receiver, |
| 6134 ast.Node index, |
| 6135 IncDecOperator operator, |
| 6136 _) { |
| 6137 generateIsDeferredLoadedCheckOfSend(node); |
| 6138 handleIndexSendSet(node); |
| 6139 } |
| 6140 |
5702 void handleIndexSendSet(ast.SendSet node) { | 6141 void handleIndexSendSet(ast.SendSet node) { |
5703 ast.Operator op = node.assignmentOperator; | 6142 ast.Operator op = node.assignmentOperator; |
5704 if ("=" == op.source) { | 6143 if ("=" == op.source) { |
5705 internalError(node, "Unexpected index set."); | 6144 internalError(node, "Unexpected index set."); |
5706 } else { | 6145 } else { |
5707 visit(node.receiver); | 6146 visit(node.receiver); |
5708 HInstruction receiver = pop(); | 6147 HInstruction receiver = pop(); |
5709 Link<ast.Node> arguments = node.arguments; | 6148 Link<ast.Node> arguments = node.arguments; |
5710 HInstruction index; | 6149 HInstruction index; |
5711 if (node.isIndex) { | 6150 if (node.isIndex) { |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6101 HInstruction value = pop(); | 6540 HInstruction value = pop(); |
6102 generateNonInstanceSetter(node, element, value); | 6541 generateNonInstanceSetter(node, element, value); |
6103 } | 6542 } |
6104 if (node.isPostfix) { | 6543 if (node.isPostfix) { |
6105 pop(); | 6544 pop(); |
6106 stack.add(getterInstruction); | 6545 stack.add(getterInstruction); |
6107 } | 6546 } |
6108 } | 6547 } |
6109 | 6548 |
6110 @override | 6549 @override |
6111 handleSendSet(ast.SendSet node) { | 6550 void handleDynamicCompounds( |
6112 ast.Operator op = node.assignmentOperator; | 6551 ast.Send node, |
6113 generateIsDeferredLoadedCheckOfSend(node); | 6552 ast.Node receiver, |
6114 Element element = elements[node]; | 6553 CompoundRhs rhs, |
6115 if (!Elements.isUnresolved(element) && element.impliesType) { | 6554 Selector getterSelector, |
6116 ast.Identifier selector = node.selector; | 6555 Selector setterSelector, |
6117 generateThrowNoSuchMethod(node, selector.source, | 6556 _) { |
6118 argumentNodes: node.arguments); | 6557 handleCompoundSendSet(node); |
6119 } else if (node.isSuperCall) { | 6558 } |
6120 handleSuperSendSet(node); | 6559 |
6121 } else if (node.isIndex) { | 6560 @override |
6122 handleIndexSendSet(node); | 6561 void handleLocalCompounds( |
6123 } else if ("=" == op.source) { | 6562 ast.SendSet node, |
6124 internalError(node, "Unexpected assignment."); | 6563 LocalElement local, |
6125 } else if (identical(op.source, "is")) { | 6564 CompoundRhs rhs, |
6126 compiler.internalError(op, "is-operator as SendSet."); | 6565 _, |
6127 } else { | 6566 {bool isSetterValid}) { |
6128 assert("++" == op.source || "--" == op.source || | 6567 handleCompoundSendSet(node); |
6129 node.assignmentOperator.source.endsWith("=")); | 6568 } |
6130 handleCompoundSendSet(node); | 6569 |
6131 } | 6570 @override |
| 6571 void handleStaticCompounds( |
| 6572 ast.SendSet node, |
| 6573 Element getter, |
| 6574 CompoundGetter getterKind, |
| 6575 Element setter, |
| 6576 CompoundSetter setterKind, |
| 6577 CompoundRhs rhs, |
| 6578 _) { |
| 6579 handleCompoundSendSet(node); |
6132 } | 6580 } |
6133 | 6581 |
6134 void visitLiteralInt(ast.LiteralInt node) { | 6582 void visitLiteralInt(ast.LiteralInt node) { |
6135 stack.add(graph.addConstantInt(node.value, compiler)); | 6583 stack.add(graph.addConstantInt(node.value, compiler)); |
6136 } | 6584 } |
6137 | 6585 |
6138 void visitLiteralDouble(ast.LiteralDouble node) { | 6586 void visitLiteralDouble(ast.LiteralDouble node) { |
6139 stack.add(graph.addConstantDouble(node.value, compiler)); | 6587 stack.add(graph.addConstantDouble(node.value, compiler)); |
6140 } | 6588 } |
6141 | 6589 |
(...skipping 1422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7564 visitInlinedFunction(function); | 8012 visitInlinedFunction(function); |
7565 } | 8013 } |
7566 | 8014 |
7567 void emitReturn(HInstruction value, ast.Node node) { | 8015 void emitReturn(HInstruction value, ast.Node node) { |
7568 if (inliningStack.isEmpty) { | 8016 if (inliningStack.isEmpty) { |
7569 closeAndGotoExit(attachPosition(new HReturn(value), node)); | 8017 closeAndGotoExit(attachPosition(new HReturn(value), node)); |
7570 } else { | 8018 } else { |
7571 localsHandler.updateLocal(returnLocal, value); | 8019 localsHandler.updateLocal(returnLocal, value); |
7572 } | 8020 } |
7573 } | 8021 } |
| 8022 |
| 8023 @override |
| 8024 void handleTypeLiteralConstantCompounds( |
| 8025 ast.SendSet node, |
| 8026 ConstantExpression constant, |
| 8027 CompoundRhs rhs, |
| 8028 _) { |
| 8029 if (rhs.operator.kind == BinaryOperatorKind.IF_NULL) { |
| 8030 handleCompoundSendSet(node); |
| 8031 } else { |
| 8032 handleTypeLiteralCompound(node); |
| 8033 } |
| 8034 } |
| 8035 |
| 8036 @override |
| 8037 void handleTypeVariableTypeLiteralCompounds( |
| 8038 ast.SendSet node, |
| 8039 TypeVariableElement typeVariable, |
| 8040 CompoundRhs rhs, |
| 8041 _) { |
| 8042 handleTypeLiteralCompound(node); |
| 8043 } |
| 8044 |
| 8045 void handleTypeLiteralCompound(ast.SendSet node) { |
| 8046 generateIsDeferredLoadedCheckOfSend(node); |
| 8047 ast.Identifier selector = node.selector; |
| 8048 generateThrowNoSuchMethod(node, selector.source, |
| 8049 argumentNodes: node.arguments); |
| 8050 } |
| 8051 |
| 8052 @override |
| 8053 void visitConstantGet( |
| 8054 ast.Send node, |
| 8055 ConstantExpression constant, |
| 8056 _) { |
| 8057 visitNode(node); |
| 8058 } |
| 8059 |
| 8060 @override |
| 8061 void visitConstantInvoke( |
| 8062 ast.Send node, |
| 8063 ConstantExpression constant, |
| 8064 ast.NodeList arguments, |
| 8065 CallStructure callStreucture, |
| 8066 _) { |
| 8067 visitNode(node); |
| 8068 } |
| 8069 |
| 8070 @override |
| 8071 void errorInvalidAssert( |
| 8072 ast.Send node, |
| 8073 ast.NodeList arguments, |
| 8074 _) { |
| 8075 visitNode(node); |
| 8076 } |
| 8077 |
| 8078 @override |
| 8079 void errorUndefinedBinaryExpression( |
| 8080 ast.Send node, |
| 8081 ast.Node left, |
| 8082 ast.Operator operator, |
| 8083 ast.Node right, |
| 8084 _) { |
| 8085 visitNode(node); |
| 8086 } |
| 8087 |
| 8088 @override |
| 8089 void errorUndefinedUnaryExpression( |
| 8090 ast.Send node, |
| 8091 ast.Operator operator, |
| 8092 ast.Node expression, |
| 8093 _) { |
| 8094 visitNode(node); |
| 8095 } |
7574 } | 8096 } |
7575 | 8097 |
7576 /** | 8098 /** |
7577 * Visitor that handles generation of string literals (LiteralString, | 8099 * Visitor that handles generation of string literals (LiteralString, |
7578 * StringInterpolation), and otherwise delegates to the given visitor for | 8100 * StringInterpolation), and otherwise delegates to the given visitor for |
7579 * non-literal subexpressions. | 8101 * non-literal subexpressions. |
7580 */ | 8102 */ |
7581 class StringBuilderVisitor extends ast.Visitor { | 8103 class StringBuilderVisitor extends ast.Visitor { |
7582 final SsaBuilder builder; | 8104 final SsaBuilder builder; |
7583 final ast.Node diagnosticNode; | 8105 final ast.Node diagnosticNode; |
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8160 if (unaliased is TypedefType) throw 'unable to unalias $type'; | 8682 if (unaliased is TypedefType) throw 'unable to unalias $type'; |
8161 unaliased.accept(this, builder); | 8683 unaliased.accept(this, builder); |
8162 } | 8684 } |
8163 | 8685 |
8164 void visitDynamicType(DynamicType type, SsaBuilder builder) { | 8686 void visitDynamicType(DynamicType type, SsaBuilder builder) { |
8165 JavaScriptBackend backend = builder.compiler.backend; | 8687 JavaScriptBackend backend = builder.compiler.backend; |
8166 ClassElement cls = backend.findHelper('DynamicRuntimeType'); | 8688 ClassElement cls = backend.findHelper('DynamicRuntimeType'); |
8167 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); | 8689 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); |
8168 } | 8690 } |
8169 } | 8691 } |
OLD | NEW |