| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import 'package:kernel/ast.dart' as ir; | 5 import 'package:kernel/ast.dart' as ir; |
| 6 | 6 |
| 7 import '../closure.dart'; | 7 import '../closure.dart'; |
| 8 import '../common.dart'; | 8 import '../common.dart'; |
| 9 import '../common/codegen.dart' show CodegenRegistry; | 9 import '../common/codegen.dart' show CodegenRegistry; |
| 10 import '../common/names.dart'; | 10 import '../common/names.dart'; |
| 11 import '../common_elements.dart'; | 11 import '../common_elements.dart'; |
| 12 import '../compiler.dart'; | 12 import '../compiler.dart'; |
| 13 import '../constants/values.dart' | 13 import '../constants/values.dart' |
| 14 show | 14 show |
| 15 ConstantValue, | 15 ConstantValue, |
| 16 InterceptorConstantValue, | 16 InterceptorConstantValue, |
| 17 StringConstantValue, | 17 StringConstantValue, |
| 18 TypeConstantValue; | 18 TypeConstantValue; |
| 19 import '../elements/elements.dart' show ErroneousElement; | 19 import '../elements/elements.dart' show ErroneousElement; |
| 20 import '../elements/entities.dart'; | 20 import '../elements/entities.dart'; |
| 21 import '../elements/jumps.dart'; | 21 import '../elements/jumps.dart'; |
| 22 import '../elements/resolution_types.dart' | 22 import '../elements/resolution_types.dart' |
| 23 show MalformedType, MethodTypeVariableType; | 23 show MalformedType, MethodTypeVariableType; |
| 24 import '../elements/types.dart'; | 24 import '../elements/types.dart'; |
| 25 import '../io/source_information.dart'; | 25 import '../io/source_information.dart'; |
| 26 import '../js/js.dart' as js; | 26 import '../js/js.dart' as js; |
| 27 import '../js_backend/backend.dart' show JavaScriptBackend; | 27 import '../js_backend/backend.dart' show JavaScriptBackend; |
| 28 import '../js_emitter/js_emitter.dart' show NativeEmitter; |
| 28 import '../kernel/element_map.dart'; | 29 import '../kernel/element_map.dart'; |
| 29 import '../native/native.dart' as native; | 30 import '../native/native.dart' as native; |
| 30 import '../resolution/tree_elements.dart'; | 31 import '../resolution/tree_elements.dart'; |
| 31 import '../tree/nodes.dart' show Node; | 32 import '../tree/nodes.dart' show Node; |
| 32 import '../types/masks.dart'; | 33 import '../types/masks.dart'; |
| 33 import '../universe/selector.dart'; | 34 import '../universe/selector.dart'; |
| 34 import '../universe/side_effects.dart' show SideEffects; | 35 import '../universe/side_effects.dart' show SideEffects; |
| 35 import '../universe/use.dart' show ConstantUse, DynamicUse; | 36 import '../universe/use.dart' show ConstantUse, DynamicUse; |
| 36 import '../universe/world_builder.dart' show CodegenWorldBuilder; | 37 import '../universe/world_builder.dart' show CodegenWorldBuilder; |
| 37 import '../world.dart'; | 38 import '../world.dart'; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 TreeElements get elements => | 87 TreeElements get elements => |
| 87 throw new UnsupportedError('KernelSsaGraphBuilder.elements'); | 88 throw new UnsupportedError('KernelSsaGraphBuilder.elements'); |
| 88 | 89 |
| 89 SourceInformationBuilder sourceInformationBuilder; | 90 SourceInformationBuilder sourceInformationBuilder; |
| 90 final KernelToElementMapForBuilding _elementMap; | 91 final KernelToElementMapForBuilding _elementMap; |
| 91 final KernelToTypeInferenceMap _typeInferenceMap; | 92 final KernelToTypeInferenceMap _typeInferenceMap; |
| 92 final KernelToLocalsMap localsMap; | 93 final KernelToLocalsMap localsMap; |
| 93 LoopHandler<ir.Node> loopHandler; | 94 LoopHandler<ir.Node> loopHandler; |
| 94 TypeBuilder typeBuilder; | 95 TypeBuilder typeBuilder; |
| 95 | 96 |
| 97 final NativeEmitter nativeEmitter; |
| 98 |
| 96 final Map<ir.VariableDeclaration, HInstruction> letBindings = | 99 final Map<ir.VariableDeclaration, HInstruction> letBindings = |
| 97 <ir.VariableDeclaration, HInstruction>{}; | 100 <ir.VariableDeclaration, HInstruction>{}; |
| 98 | 101 |
| 99 /// True if we are visiting the expression of a throw statement; we assume | 102 /// True if we are visiting the expression of a throw statement; we assume |
| 100 /// this is a slow path. | 103 /// this is a slow path. |
| 101 bool _inExpressionOfThrow = false; | 104 bool _inExpressionOfThrow = false; |
| 102 | 105 |
| 103 KernelSsaGraphBuilder( | 106 KernelSsaGraphBuilder( |
| 104 this.targetElement, | 107 this.targetElement, |
| 105 ClassEntity contextClass, | 108 ClassEntity contextClass, |
| 106 this.compiler, | 109 this.compiler, |
| 107 this._elementMap, | 110 this._elementMap, |
| 108 this._typeInferenceMap, | 111 this._typeInferenceMap, |
| 109 this.localsMap, | 112 this.localsMap, |
| 110 this.closedWorld, | 113 this.closedWorld, |
| 111 this._worldBuilder, | 114 this._worldBuilder, |
| 112 this.registry, | 115 this.registry, |
| 113 this.closureDataLookup, | 116 this.closureDataLookup, |
| 117 this.nativeEmitter, |
| 114 // TODO(het): Should sourceInformationBuilder be in GraphBuilder? | 118 // TODO(het): Should sourceInformationBuilder be in GraphBuilder? |
| 115 this.sourceInformationBuilder, | 119 this.sourceInformationBuilder, |
| 116 this.functionNode) { | 120 this.functionNode) { |
| 117 this.loopHandler = new KernelLoopHandler(this); | 121 this.loopHandler = new KernelLoopHandler(this); |
| 118 typeBuilder = new TypeBuilder(this); | 122 typeBuilder = new TypeBuilder(this); |
| 119 graph.element = targetElement; | 123 graph.element = targetElement; |
| 120 graph.sourceInformation = | 124 graph.sourceInformation = |
| 121 sourceInformationBuilder.buildVariableDeclaration(); | 125 sourceInformationBuilder.buildVariableDeclaration(); |
| 122 this.localsHandler = new LocalsHandler(this, targetElement, targetElement, | 126 this.localsHandler = new LocalsHandler(this, targetElement, targetElement, |
| 123 contextClass, null, nativeData, interceptorData); | 127 contextClass, null, nativeData, interceptorData); |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 720 /// Builds a SSA graph for FunctionNodes of external methods. | 724 /// Builds a SSA graph for FunctionNodes of external methods. |
| 721 void buildExternalFunctionNode(ir.FunctionNode functionNode) { | 725 void buildExternalFunctionNode(ir.FunctionNode functionNode) { |
| 722 assert(functionNode.body == null); | 726 assert(functionNode.body == null); |
| 723 openFunction(functionNode); | 727 openFunction(functionNode); |
| 724 ir.TreeNode parent = functionNode.parent; | 728 ir.TreeNode parent = functionNode.parent; |
| 725 if (parent is ir.Procedure && parent.kind == ir.ProcedureKind.Factory) { | 729 if (parent is ir.Procedure && parent.kind == ir.ProcedureKind.Factory) { |
| 726 _addClassTypeVariablesIfNeeded(parent); | 730 _addClassTypeVariablesIfNeeded(parent); |
| 727 } | 731 } |
| 728 | 732 |
| 729 if (closedWorld.nativeData.isNativeMember(targetElement)) { | 733 if (closedWorld.nativeData.isNativeMember(targetElement)) { |
| 734 nativeEmitter.nativeMethods.add(targetElement); |
| 730 String nativeName; | 735 String nativeName; |
| 731 if (closedWorld.nativeData.hasFixedBackendName(targetElement)) { | 736 if (closedWorld.nativeData.hasFixedBackendName(targetElement)) { |
| 732 nativeName = closedWorld.nativeData.getFixedBackendName(targetElement); | 737 nativeName = closedWorld.nativeData.getFixedBackendName(targetElement); |
| 733 } else { | 738 } else { |
| 734 nativeName = targetElement.name; | 739 nativeName = targetElement.name; |
| 735 } | 740 } |
| 736 | 741 |
| 737 String templateReceiver = ''; | 742 String templateReceiver = ''; |
| 738 List<String> templateArguments = <String>[]; | 743 List<String> templateArguments = <String>[]; |
| 739 List<HInstruction> inputs = <HInstruction>[]; | 744 List<HInstruction> inputs = <HInstruction>[]; |
| (...skipping 2995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3735 enterBlock.setBlockFlow( | 3740 enterBlock.setBlockFlow( |
| 3736 new HTryBlockInformation( | 3741 new HTryBlockInformation( |
| 3737 kernelBuilder.wrapStatementGraph(bodyGraph), | 3742 kernelBuilder.wrapStatementGraph(bodyGraph), |
| 3738 exception, | 3743 exception, |
| 3739 kernelBuilder.wrapStatementGraph(catchGraph), | 3744 kernelBuilder.wrapStatementGraph(catchGraph), |
| 3740 kernelBuilder.wrapStatementGraph(finallyGraph)), | 3745 kernelBuilder.wrapStatementGraph(finallyGraph)), |
| 3741 exitBlock); | 3746 exitBlock); |
| 3742 kernelBuilder.inTryStatement = previouslyInTryStatement; | 3747 kernelBuilder.inTryStatement = previouslyInTryStatement; |
| 3743 } | 3748 } |
| 3744 } | 3749 } |
| OLD | NEW |