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 // Tests that the closed world computed from [WorldImpact]s derived from kernel | 5 // Tests that the closed world computed from [WorldImpact]s derived from kernel |
6 // is equivalent to the original computed from resolution. | 6 // is equivalent to the original computed from resolution. |
7 library dart2js.kernel.closed_world_test; | 7 library dart2js.kernel.closed_world_test; |
8 | 8 |
9 import 'package:async_helper/async_helper.dart'; | 9 import 'package:async_helper/async_helper.dart'; |
10 import 'package:compiler/src/commandline_options.dart'; | 10 import 'package:compiler/src/commandline_options.dart'; |
11 import 'package:compiler/src/common.dart'; | 11 import 'package:compiler/src/common.dart'; |
| 12 import 'package:compiler/src/common_elements.dart'; |
12 import 'package:compiler/src/common/resolution.dart'; | 13 import 'package:compiler/src/common/resolution.dart'; |
13 import 'package:compiler/src/compiler.dart'; | 14 import 'package:compiler/src/compiler.dart'; |
14 import 'package:compiler/src/elements/resolution_types.dart'; | 15 import 'package:compiler/src/elements/resolution_types.dart'; |
15 import 'package:compiler/src/elements/elements.dart'; | 16 import 'package:compiler/src/elements/elements.dart'; |
16 import 'package:compiler/src/enqueue.dart'; | 17 import 'package:compiler/src/enqueue.dart'; |
17 import 'package:compiler/src/js_backend/backend.dart'; | 18 import 'package:compiler/src/js_backend/backend.dart'; |
| 19 import 'package:compiler/src/js_backend/backend_helpers.dart'; |
| 20 import 'package:compiler/src/js_backend/backend_impact.dart'; |
18 import 'package:compiler/src/js_backend/backend_usage.dart'; | 21 import 'package:compiler/src/js_backend/backend_usage.dart'; |
| 22 import 'package:compiler/src/js_backend/custom_elements_analysis.dart'; |
| 23 import 'package:compiler/src/js_backend/native_data.dart'; |
| 24 import 'package:compiler/src/js_backend/interceptor_data.dart'; |
| 25 import 'package:compiler/src/js_backend/lookup_map_analysis.dart'; |
| 26 import 'package:compiler/src/js_backend/mirrors_analysis.dart'; |
| 27 import 'package:compiler/src/js_backend/mirrors_data.dart'; |
| 28 import 'package:compiler/src/js_backend/no_such_method_registry.dart'; |
| 29 import 'package:compiler/src/js_backend/resolution_listener.dart'; |
19 import 'package:compiler/src/js_backend/type_variable_handler.dart'; | 30 import 'package:compiler/src/js_backend/type_variable_handler.dart'; |
20 import 'package:compiler/src/js_backend/resolution_listener.dart'; | 31 import 'package:compiler/src/native/enqueue.dart'; |
| 32 import 'package:compiler/src/kernel/world_builder.dart'; |
| 33 import 'package:compiler/src/options.dart'; |
21 import 'package:compiler/src/ssa/kernel_impact.dart'; | 34 import 'package:compiler/src/ssa/kernel_impact.dart'; |
22 import 'package:compiler/src/serialization/equivalence.dart'; | 35 import 'package:compiler/src/serialization/equivalence.dart'; |
23 import 'package:compiler/src/universe/world_builder.dart'; | 36 import 'package:compiler/src/universe/world_builder.dart'; |
24 import 'package:compiler/src/universe/world_impact.dart'; | 37 import 'package:compiler/src/universe/world_impact.dart'; |
25 import 'package:compiler/src/world.dart'; | 38 import 'package:compiler/src/world.dart'; |
26 import 'impact_test.dart'; | 39 import 'impact_test.dart'; |
27 import '../memory_compiler.dart'; | 40 import '../memory_compiler.dart'; |
28 import '../serialization/helper.dart'; | 41 import '../serialization/helper.dart'; |
29 import '../serialization/model_test_helper.dart'; | 42 import '../serialization/model_test_helper.dart'; |
30 | 43 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 }, verbose: arguments.verbose); | 132 }, verbose: arguments.verbose); |
120 checkClosedWorlds( | 133 checkClosedWorlds( |
121 compiler.resolutionWorldBuilder.closedWorldForTesting, closedWorld, | 134 compiler.resolutionWorldBuilder.closedWorldForTesting, closedWorld, |
122 verbose: arguments.verbose); | 135 verbose: arguments.verbose); |
123 }); | 136 }); |
124 } | 137 } |
125 | 138 |
126 EnqueuerListener createResolutionEnqueuerListener(Compiler compiler) { | 139 EnqueuerListener createResolutionEnqueuerListener(Compiler compiler) { |
127 JavaScriptBackend backend = compiler.backend; | 140 JavaScriptBackend backend = compiler.backend; |
128 return new ResolutionEnqueuerListener( | 141 return new ResolutionEnqueuerListener( |
129 backend.kernelTask, | |
130 compiler.options, | 142 compiler.options, |
131 compiler.elementEnvironment, | 143 compiler.elementEnvironment, |
132 compiler.commonElements, | 144 compiler.commonElements, |
133 backend.helpers, | 145 backend.helpers, |
134 backend.impacts, | 146 backend.impacts, |
135 backend.backendClasses, | 147 backend.backendClasses, |
136 backend.nativeBasicData, | 148 backend.nativeBasicData, |
137 backend.interceptorDataBuilder, | 149 backend.interceptorDataBuilder, |
138 backend.backendUsageBuilder, | 150 backend.backendUsageBuilder, |
139 backend.rtiNeedBuilder, | 151 backend.rtiNeedBuilder, |
140 backend.mirrorsDataBuilder, | 152 backend.mirrorsDataBuilder, |
141 backend.noSuchMethodRegistry, | 153 backend.noSuchMethodRegistry, |
142 backend.customElementsResolutionAnalysis, | 154 backend.customElementsResolutionAnalysis, |
143 backend.lookupMapResolutionAnalysis, | 155 backend.lookupMapResolutionAnalysis, |
144 backend.mirrorsResolutionAnalysis, | 156 backend.mirrorsResolutionAnalysis, |
145 new TypeVariableResolutionAnalysis(compiler.elementEnvironment, | 157 new TypeVariableResolutionAnalysis(compiler.elementEnvironment, |
146 backend.impacts, backend.backendUsageBuilder), | 158 backend.impacts, backend.backendUsageBuilder), |
147 backend.nativeResolutionEnqueuer); | 159 backend.nativeResolutionEnqueuer, |
| 160 backend.kernelTask); |
| 161 } |
| 162 |
| 163 EnqueuerListener createKernelResolutionEnqueuerListener( |
| 164 CompilerOptions options, KernelWorldBuilder worldBuilder) { |
| 165 ElementEnvironment elementEnvironment = worldBuilder.elementEnvironment; |
| 166 CommonElements commonElements = worldBuilder.commonElements; |
| 167 BackendHelpers helpers = |
| 168 new BackendHelpers(elementEnvironment, commonElements); |
| 169 BackendImpacts impacts = new BackendImpacts(options, commonElements, helpers); |
| 170 |
| 171 // TODO(johnniwinther): Create Kernel based implementations for these: |
| 172 NativeBasicData nativeBasicData; |
| 173 InterceptorDataBuilder interceptorDataBuilder; |
| 174 BackendUsageBuilder backendUsageBuilder; |
| 175 RuntimeTypesNeedBuilder rtiNeedBuilder; |
| 176 MirrorsDataBuilder mirrorsDataBuilder; |
| 177 NoSuchMethodRegistry noSuchMethodRegistry; |
| 178 CustomElementsResolutionAnalysis customElementsResolutionAnalysis; |
| 179 LookupMapResolutionAnalysis lookupMapResolutionAnalysis; |
| 180 MirrorsResolutionAnalysis mirrorsResolutionAnalysis; |
| 181 NativeResolutionEnqueuer nativeResolutionEnqueuer; |
| 182 |
| 183 return new ResolutionEnqueuerListener( |
| 184 options, |
| 185 elementEnvironment, |
| 186 commonElements, |
| 187 helpers, |
| 188 impacts, |
| 189 new JavaScriptBackendClasses( |
| 190 elementEnvironment, helpers, nativeBasicData), |
| 191 nativeBasicData, |
| 192 interceptorDataBuilder, |
| 193 backendUsageBuilder, |
| 194 rtiNeedBuilder, |
| 195 mirrorsDataBuilder, |
| 196 noSuchMethodRegistry, |
| 197 customElementsResolutionAnalysis, |
| 198 lookupMapResolutionAnalysis, |
| 199 mirrorsResolutionAnalysis, |
| 200 new TypeVariableResolutionAnalysis( |
| 201 elementEnvironment, impacts, backendUsageBuilder), |
| 202 nativeResolutionEnqueuer); |
148 } | 203 } |
149 | 204 |
150 ClosedWorld computeClosedWorld(Compiler compiler, ResolutionEnqueuer enqueuer) { | 205 ClosedWorld computeClosedWorld(Compiler compiler, ResolutionEnqueuer enqueuer) { |
151 JavaScriptBackend backend = compiler.backend; | 206 JavaScriptBackend backend = compiler.backend; |
152 | 207 |
153 if (compiler.deferredLoadTask.isProgramSplit) { | 208 if (compiler.deferredLoadTask.isProgramSplit) { |
154 enqueuer.applyImpact(backend.computeDeferredLoadingImpact()); | 209 enqueuer.applyImpact(backend.computeDeferredLoadingImpact()); |
155 } | 210 } |
156 enqueuer.open(const ImpactStrategy(), compiler.mainFunction, | 211 enqueuer.open(const ImpactStrategy(), compiler.mainFunction, |
157 compiler.libraryLoader.libraries); | 212 compiler.libraryLoader.libraries); |
158 enqueuer.forEach((work) { | 213 enqueuer.forEach((work) { |
159 MemberElement element = work.element; | 214 MemberElement element = work.element; |
160 ResolutionImpact resolutionImpact = build(compiler, element.resolvedAst); | 215 ResolutionImpact resolutionImpact = build(compiler, element.resolvedAst); |
161 WorldImpact worldImpact = compiler.backend.impactTransformer | 216 WorldImpact worldImpact = compiler.backend.impactTransformer |
162 .transformResolutionImpact(enqueuer, resolutionImpact); | 217 .transformResolutionImpact(enqueuer, resolutionImpact); |
163 enqueuer.applyImpact(worldImpact, impactSource: element); | 218 enqueuer.applyImpact(worldImpact, impactSource: element); |
164 }); | 219 }); |
165 return enqueuer.worldBuilder.closeWorld(compiler.reporter); | 220 return enqueuer.worldBuilder.closeWorld(compiler.reporter); |
166 } | 221 } |
OLD | NEW |