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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 @override | 73 @override |
74 CodegenWorldBuilder createCodegenWorldBuilder( | 74 CodegenWorldBuilder createCodegenWorldBuilder( |
75 NativeBasicData nativeBasicData, | 75 NativeBasicData nativeBasicData, |
76 ClosedWorld closedWorld, | 76 ClosedWorld closedWorld, |
77 SelectorConstraintsStrategy selectorConstraintsStrategy) { | 77 SelectorConstraintsStrategy selectorConstraintsStrategy) { |
78 return new KernelCodegenWorldBuilder(closedWorld.elementEnvironment, | 78 return new KernelCodegenWorldBuilder(closedWorld.elementEnvironment, |
79 nativeBasicData, closedWorld, selectorConstraintsStrategy); | 79 nativeBasicData, closedWorld, selectorConstraintsStrategy); |
80 } | 80 } |
81 | 81 |
82 @override | 82 @override |
83 SsaBuilderTask createSsaBuilderTask(JavaScriptBackend backend, | 83 SsaBuilder createSsaBuilder(CompilerTask task, JavaScriptBackend backend, |
84 SourceInformationStrategy sourceInformationStrategy) { | 84 SourceInformationStrategy sourceInformationStrategy) { |
85 return new KernelSsaBuilderTask(backend.compiler); | 85 KernelFrontEndStrategy strategy = backend.compiler.frontendStrategy; |
| 86 KernelToElementMap elementMap = strategy.elementMap; |
| 87 return new KernelSsaBuilder(task, backend.compiler, elementMap); |
86 } | 88 } |
87 | 89 |
88 @override | 90 @override |
89 SourceInformationStrategy get sourceInformationStrategy => | 91 SourceInformationStrategy get sourceInformationStrategy => |
90 const JavaScriptSourceInformationStrategy(); | 92 const JavaScriptSourceInformationStrategy(); |
91 } | 93 } |
92 | 94 |
93 class KernelCodegenWorkItemBuilder implements WorkItemBuilder { | 95 class KernelCodegenWorkItemBuilder implements WorkItemBuilder { |
94 final JavaScriptBackend _backend; | 96 final JavaScriptBackend _backend; |
95 final ClosedWorld _closedWorld; | 97 final ClosedWorld _closedWorld; |
(...skipping 25 matching lines...) Expand all Loading... |
121 KernelCodegenWorkItem(this._backend, this._closedWorld, this.element) | 123 KernelCodegenWorkItem(this._backend, this._closedWorld, this.element) |
122 : registry = new CodegenRegistry(element); | 124 : registry = new CodegenRegistry(element); |
123 | 125 |
124 @override | 126 @override |
125 WorldImpact run() { | 127 WorldImpact run() { |
126 return _backend.codegen(this, _closedWorld); | 128 return _backend.codegen(this, _closedWorld); |
127 } | 129 } |
128 } | 130 } |
129 | 131 |
130 /// Task for building SSA from kernel IR loaded from .dill. | 132 /// Task for building SSA from kernel IR loaded from .dill. |
131 class KernelSsaBuilderTask extends CompilerTask implements SsaBuilderTask { | 133 class KernelSsaBuilder implements SsaBuilder { |
| 134 final CompilerTask task; |
132 final Compiler _compiler; | 135 final Compiler _compiler; |
| 136 final KernelToElementMap _elementMap; |
133 | 137 |
134 KernelSsaBuilderTask(this._compiler) : super(_compiler.measurer); | 138 KernelSsaBuilder(this.task, this._compiler, this._elementMap); |
135 | |
136 KernelToElementMapImpl get _elementMap { | |
137 KernelFrontEndStrategy frontendStrategy = _compiler.frontendStrategy; | |
138 return frontendStrategy.elementMap; | |
139 } | |
140 | 139 |
141 @override | 140 @override |
142 HGraph build(CodegenWorkItem work, ClosedWorld closedWorld) { | 141 HGraph build(CodegenWorkItem work, ClosedWorld closedWorld) { |
143 KernelSsaBuilder builder = new KernelSsaBuilder( | 142 KernelSsaGraphBuilder builder = new KernelSsaGraphBuilder( |
144 work.element, | 143 work.element, |
145 work.element.enclosingClass, | 144 work.element.enclosingClass, |
146 _elementMap.getMemberNode(work.element), | 145 _elementMap.getMemberNode(work.element), |
147 _compiler, | 146 _compiler, |
148 _elementMap, | 147 _elementMap, |
149 new KernelToTypeInferenceMapImpl(closedWorld), | 148 new KernelToTypeInferenceMapImpl(closedWorld), |
150 new KernelToLocalsMapImpl(work.element), | 149 new KernelToLocalsMapImpl(work.element), |
151 closedWorld, | 150 closedWorld, |
152 _compiler.codegenWorldBuilder, | 151 _compiler.codegenWorldBuilder, |
153 work.registry, | 152 work.registry, |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 Iterable<ClassEntity> sortClasses(Iterable<ClassEntity> classes) { | 376 Iterable<ClassEntity> sortClasses(Iterable<ClassEntity> classes) { |
378 return classes.toList() | 377 return classes.toList() |
379 ..sort((ClassEntity a, ClassEntity b) { | 378 ..sort((ClassEntity a, ClassEntity b) { |
380 int r = _compareLibraries(a.library, b.library); | 379 int r = _compareLibraries(a.library, b.library); |
381 if (r != 0) return r; | 380 if (r != 0) return r; |
382 return _compareNodes( | 381 return _compareNodes( |
383 a, elementMap.getClassNode(a), b, elementMap.getClassNode(b)); | 382 a, elementMap.getClassNode(a), b, elementMap.getClassNode(b)); |
384 }); | 383 }); |
385 } | 384 } |
386 } | 385 } |
OLD | NEW |