| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 library dart2js.kernel.backend_strategy; | 5 library dart2js.kernel.backend_strategy; |
| 6 | 6 |
| 7 import 'package:kernel/ast.dart' as ir; | 7 import 'package:kernel/ast.dart' as ir; |
| 8 | 8 |
| 9 import '../backend_strategy.dart'; | 9 import '../backend_strategy.dart'; |
| 10 import '../closure.dart'; |
| 10 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem; | 11 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem; |
| 11 import '../common/tasks.dart'; | 12 import '../common/tasks.dart'; |
| 12 import '../compiler.dart'; | 13 import '../compiler.dart'; |
| 13 import '../elements/entities.dart'; | 14 import '../elements/entities.dart'; |
| 14 import '../enqueue.dart'; | 15 import '../enqueue.dart'; |
| 15 import '../io/source_information.dart'; | 16 import '../io/source_information.dart'; |
| 16 import '../js_backend/backend.dart'; | 17 import '../js_backend/backend.dart'; |
| 17 import '../js_backend/native_data.dart'; | 18 import '../js_backend/native_data.dart'; |
| 18 import '../js_emitter/sorter.dart'; | 19 import '../js_emitter/sorter.dart'; |
| 19 import '../kernel/element_map.dart'; | 20 import '../kernel/element_map.dart'; |
| 21 import '../kernel/element_map_impl.dart'; |
| 20 import '../native/behavior.dart'; | 22 import '../native/behavior.dart'; |
| 21 import '../ssa/builder_kernel.dart'; | 23 import '../ssa/builder_kernel.dart'; |
| 22 import '../ssa/nodes.dart'; | 24 import '../ssa/nodes.dart'; |
| 23 import '../ssa/ssa.dart'; | 25 import '../ssa/ssa.dart'; |
| 24 import '../ssa/types.dart'; | 26 import '../ssa/types.dart'; |
| 25 import '../types/types.dart'; | 27 import '../types/types.dart'; |
| 26 import '../universe/selector.dart'; | 28 import '../universe/selector.dart'; |
| 27 import '../universe/world_builder.dart'; | 29 import '../universe/world_builder.dart'; |
| 28 import '../universe/world_impact.dart'; | 30 import '../universe/world_impact.dart'; |
| 29 import '../world.dart'; | 31 import '../world.dart'; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 return _backend.codegen(this, _closedWorld); | 101 return _backend.codegen(this, _closedWorld); |
| 100 } | 102 } |
| 101 } | 103 } |
| 102 | 104 |
| 103 /// Task for building SSA from kernel IR loaded from .dill. | 105 /// Task for building SSA from kernel IR loaded from .dill. |
| 104 class KernelSsaBuilderTask extends CompilerTask implements SsaBuilderTask { | 106 class KernelSsaBuilderTask extends CompilerTask implements SsaBuilderTask { |
| 105 final Compiler _compiler; | 107 final Compiler _compiler; |
| 106 | 108 |
| 107 KernelSsaBuilderTask(this._compiler) : super(_compiler.measurer); | 109 KernelSsaBuilderTask(this._compiler) : super(_compiler.measurer); |
| 108 | 110 |
| 109 KernelToElementMap get _elementMap { | 111 KernelToElementMapImpl get _elementMap { |
| 110 KernelFrontEndStrategy frontEndStrategy = _compiler.frontEndStrategy; | 112 KernelFrontEndStrategy frontEndStrategy = _compiler.frontEndStrategy; |
| 111 return frontEndStrategy.elementMap; | 113 return frontEndStrategy.elementMap; |
| 112 } | 114 } |
| 113 | 115 |
| 114 @override | 116 @override |
| 115 HGraph build(CodegenWorkItem work, ClosedWorld closedWorld) { | 117 HGraph build(CodegenWorkItem work, ClosedWorld closedWorld) { |
| 116 KernelSsaBuilder builder = new KernelSsaBuilder( | 118 KernelSsaBuilder builder = new KernelSsaBuilder( |
| 117 work.element, | 119 work.element, |
| 120 _elementMap.getMemberRoot(work.element), |
| 118 _compiler, | 121 _compiler, |
| 119 _elementMap, | 122 _elementMap, |
| 120 new KernelToTypeInferenceMapImpl(closedWorld), | 123 new KernelToTypeInferenceMapImpl(closedWorld), |
| 121 closedWorld, | 124 closedWorld, |
| 122 work.registry, | 125 work.registry, |
| 126 const KernelClosureClassMaps(), |
| 123 const SourceInformationBuilder(), | 127 const SourceInformationBuilder(), |
| 124 null); | 128 // TODO(johnniwinther): Support these: |
| 129 null, // Function node used as capture scope id. |
| 130 targetIsConstructorBody: false); |
| 125 return builder.build(); | 131 return builder.build(); |
| 126 } | 132 } |
| 127 } | 133 } |
| 128 | 134 |
| 129 class KernelToTypeInferenceMapImpl implements KernelToTypeInferenceMap { | 135 class KernelToTypeInferenceMapImpl implements KernelToTypeInferenceMap { |
| 130 final ClosedWorld _closedWorld; | 136 final ClosedWorld _closedWorld; |
| 131 | 137 |
| 132 KernelToTypeInferenceMapImpl(this._closedWorld); | 138 KernelToTypeInferenceMapImpl(this._closedWorld); |
| 133 | 139 |
| 134 @override | 140 @override |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 TypeMask typeOfInvocation( | 199 TypeMask typeOfInvocation( |
| 194 ir.MethodInvocation invocation, ClosedWorld closedWorld) { | 200 ir.MethodInvocation invocation, ClosedWorld closedWorld) { |
| 195 return _closedWorld.commonMasks.dynamicType; | 201 return _closedWorld.commonMasks.dynamicType; |
| 196 } | 202 } |
| 197 | 203 |
| 198 @override | 204 @override |
| 199 TypeMask getReturnTypeOf(FunctionEntity function) { | 205 TypeMask getReturnTypeOf(FunctionEntity function) { |
| 200 return _closedWorld.commonMasks.dynamicType; | 206 return _closedWorld.commonMasks.dynamicType; |
| 201 } | 207 } |
| 202 } | 208 } |
| 209 |
| 210 /// TODO(johnniwinther,efortuna): Implement this. |
| 211 class KernelClosureClassMaps implements ClosureClassMaps { |
| 212 const KernelClosureClassMaps(); |
| 213 |
| 214 @override |
| 215 ClosureClassMap getLocalFunctionMap(Local localFunction) { |
| 216 return new ClosureClassMap(null, null, null, null); |
| 217 } |
| 218 |
| 219 @override |
| 220 ClosureClassMap getMemberMap(MemberEntity member) { |
| 221 return new ClosureClassMap(null, null, null, null); |
| 222 } |
| 223 } |
| OLD | NEW |