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 '../closure.dart'; |
(...skipping 22 matching lines...) Expand all Loading... |
33 import '../universe/selector.dart'; | 33 import '../universe/selector.dart'; |
34 import '../universe/world_builder.dart'; | 34 import '../universe/world_builder.dart'; |
35 import '../universe/world_impact.dart'; | 35 import '../universe/world_impact.dart'; |
36 import '../world.dart'; | 36 import '../world.dart'; |
37 import 'closure.dart'; | 37 import 'closure.dart'; |
38 import 'element_map_impl.dart'; | 38 import 'element_map_impl.dart'; |
39 import 'kernel_strategy.dart'; | 39 import 'kernel_strategy.dart'; |
40 | 40 |
41 /// A backend strategy based on Kernel IR nodes. | 41 /// A backend strategy based on Kernel IR nodes. |
42 abstract class KernelBackendStrategy implements BackendStrategy { | 42 abstract class KernelBackendStrategy implements BackendStrategy { |
43 KernelToElementMap get elementMap; | 43 KernelToElementMapForBuilding get elementMap; |
44 GlobalLocalsMap get globalLocalsMapForTesting; | 44 GlobalLocalsMap get globalLocalsMapForTesting; |
45 } | 45 } |
46 | 46 |
47 /// Backend strategy that uses the kernel elements as the backend model. | 47 /// Backend strategy that uses the kernel elements as the backend model. |
48 // TODO(redemption): Replace this with a strategy based on the J-element | 48 // TODO(redemption): Replace this with a strategy based on the J-element |
49 // model. | 49 // model. |
50 class KernelBackendStrategyImpl implements KernelBackendStrategy { | 50 class KernelBackendStrategyImpl implements KernelBackendStrategy { |
51 final Compiler _compiler; | 51 final Compiler _compiler; |
52 Sorter _sorter; | 52 Sorter _sorter; |
53 ClosureConversionTask _closureDataLookup; | 53 ClosureConversionTask _closureDataLookup; |
54 final GlobalLocalsMap _globalLocalsMap = new GlobalLocalsMap(); | 54 final GlobalLocalsMap _globalLocalsMap = new GlobalLocalsMap(); |
55 | 55 |
56 KernelBackendStrategyImpl(this._compiler); | 56 KernelBackendStrategyImpl(this._compiler); |
57 | 57 |
58 KernelToElementMap get elementMap { | 58 KernelToElementMapForBuilding get elementMap { |
59 KernelFrontEndStrategy frontendStrategy = _compiler.frontendStrategy; | 59 KernelFrontEndStrategy frontendStrategy = _compiler.frontendStrategy; |
60 return frontendStrategy.elementMap; | 60 return frontendStrategy.elementMap; |
61 } | 61 } |
62 | 62 |
63 GlobalLocalsMap get globalLocalsMapForTesting => _globalLocalsMap; | 63 GlobalLocalsMap get globalLocalsMapForTesting => _globalLocalsMap; |
64 | 64 |
65 @override | 65 @override |
66 ClosedWorldRefiner createClosedWorldRefiner( | 66 ClosedWorldRefiner createClosedWorldRefiner( |
67 covariant KernelClosedWorld closedWorld) { | 67 covariant KernelClosedWorld closedWorld) { |
68 return closedWorld; | 68 return closedWorld; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 @override | 146 @override |
147 WorldImpact run() { | 147 WorldImpact run() { |
148 return _backend.codegen(this, _closedWorld); | 148 return _backend.codegen(this, _closedWorld); |
149 } | 149 } |
150 } | 150 } |
151 | 151 |
152 /// Task for building SSA from kernel IR loaded from .dill. | 152 /// Task for building SSA from kernel IR loaded from .dill. |
153 class KernelSsaBuilder implements SsaBuilder { | 153 class KernelSsaBuilder implements SsaBuilder { |
154 final CompilerTask task; | 154 final CompilerTask task; |
155 final Compiler _compiler; | 155 final Compiler _compiler; |
156 final KernelToElementMap _elementMap; | 156 final KernelToElementMapForBuilding _elementMap; |
157 final GlobalLocalsMap _globalLocalsMap; | 157 final GlobalLocalsMap _globalLocalsMap; |
158 | 158 |
159 KernelSsaBuilder( | 159 KernelSsaBuilder( |
160 this.task, this._compiler, this._elementMap, this._globalLocalsMap); | 160 this.task, this._compiler, this._elementMap, this._globalLocalsMap); |
161 | 161 |
162 @override | 162 @override |
163 HGraph build(CodegenWorkItem work, ClosedWorld closedWorld) { | 163 HGraph build(CodegenWorkItem work, ClosedWorld closedWorld) { |
164 KernelToLocalsMap localsMap = _globalLocalsMap.getLocalsMap(work.element); | 164 KernelToLocalsMap localsMap = _globalLocalsMap.getLocalsMap(work.element); |
165 KernelSsaGraphBuilder builder = new KernelSsaGraphBuilder( | 165 KernelSsaGraphBuilder builder = new KernelSsaGraphBuilder( |
166 work.element, | 166 work.element, |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 Iterable<ClassEntity> sortClasses(Iterable<ClassEntity> classes) { | 568 Iterable<ClassEntity> sortClasses(Iterable<ClassEntity> classes) { |
569 return classes.toList() | 569 return classes.toList() |
570 ..sort((ClassEntity a, ClassEntity b) { | 570 ..sort((ClassEntity a, ClassEntity b) { |
571 int r = _compareLibraries(a.library, b.library); | 571 int r = _compareLibraries(a.library, b.library); |
572 if (r != 0) return r; | 572 if (r != 0) return r; |
573 return _compareNodes( | 573 return _compareNodes( |
574 a, elementMap.getClassNode(a), b, elementMap.getClassNode(b)); | 574 a, elementMap.getClassNode(a), b, elementMap.getClassNode(b)); |
575 }); | 575 }); |
576 } | 576 } |
577 } | 577 } |
OLD | NEW |