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'; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 new ElementResolutionWorldBuilder( | 105 new ElementResolutionWorldBuilder( |
106 backend, | 106 backend, |
107 compiler.resolution, | 107 compiler.resolution, |
108 backend.nativeBasicData, | 108 backend.nativeBasicData, |
109 backend.nativeDataBuilder, | 109 backend.nativeDataBuilder, |
110 interceptorDataBuilder, | 110 interceptorDataBuilder, |
111 backendUsageBuilder, | 111 backendUsageBuilder, |
112 const OpenWorldStrategy()), | 112 const OpenWorldStrategy()), |
113 new KernelTestWorkItemBuilder(compiler), | 113 new KernelTestWorkItemBuilder(compiler), |
114 'enqueuer from kernel'); | 114 'enqueuer from kernel'); |
115 ClosedWorld closedWorld = computeClosedWorld( | 115 ClosedWorld closedWorld = computeClosedWorld(compiler.reporter, enqueuer, |
116 compiler.reporter, enqueuer, compiler.elementEnvironment); | 116 compiler.frontendStrategy.elementEnvironment); |
117 BackendUsage backendUsage = backendUsageBuilder.close(); | 117 BackendUsage backendUsage = backendUsageBuilder.close(); |
118 checkResolutionEnqueuers( | 118 checkResolutionEnqueuers( |
119 backendUsage, backendUsage, compiler.enqueuer.resolution, enqueuer, | 119 backendUsage, backendUsage, compiler.enqueuer.resolution, enqueuer, |
120 typeEquivalence: (ResolutionDartType a, ResolutionDartType b) { | 120 typeEquivalence: (ResolutionDartType a, ResolutionDartType b) { |
121 return areTypesEquivalent(unalias(a), unalias(b)); | 121 return areTypesEquivalent(unalias(a), unalias(b)); |
122 }, | 122 }, |
123 elementFilter: elementFilter, | 123 elementFilter: elementFilter, |
124 verbose: arguments.verbose, | 124 verbose: arguments.verbose, |
125 // TODO(johnniwinther): Support class usage testing in presence of | 125 // TODO(johnniwinther): Support class usage testing in presence of |
126 // redirecting constructors. | 126 // redirecting constructors. |
127 skipClassUsageTesting: true); | 127 skipClassUsageTesting: true); |
128 checkClosedWorlds( | 128 checkClosedWorlds( |
129 compiler.resolutionWorldBuilder.closedWorldForTesting, closedWorld, | 129 compiler.resolutionWorldBuilder.closedWorldForTesting, closedWorld, |
130 verbose: arguments.verbose); | 130 verbose: arguments.verbose); |
131 }); | 131 }); |
132 } | 132 } |
133 | 133 |
134 List createResolutionEnqueuerListener(Compiler compiler) { | 134 List createResolutionEnqueuerListener(Compiler compiler) { |
135 JavaScriptBackend backend = compiler.backend; | 135 JavaScriptBackend backend = compiler.backend; |
136 BackendUsageBuilder backendUsageBuilder = | 136 BackendUsageBuilder backendUsageBuilder = |
137 new BackendUsageBuilderImpl(compiler.frontendStrategy.commonElements); | 137 new BackendUsageBuilderImpl(compiler.frontendStrategy.commonElements); |
138 InterceptorDataBuilder interceptorDataBuilder = | 138 InterceptorDataBuilder interceptorDataBuilder = |
139 new InterceptorDataBuilderImpl( | 139 new InterceptorDataBuilderImpl( |
140 backend.nativeBasicData, | 140 backend.nativeBasicData, |
141 compiler.elementEnvironment, | 141 compiler.frontendStrategy.elementEnvironment, |
142 compiler.frontendStrategy.commonElements); | 142 compiler.frontendStrategy.commonElements); |
143 ResolutionEnqueuerListener listener = new ResolutionEnqueuerListener( | 143 ResolutionEnqueuerListener listener = new ResolutionEnqueuerListener( |
144 compiler.options, | 144 compiler.options, |
145 compiler.frontendStrategy.elementEnvironment, | 145 compiler.frontendStrategy.elementEnvironment, |
146 compiler.frontendStrategy.commonElements, | 146 compiler.frontendStrategy.commonElements, |
147 backend.impacts, | 147 backend.impacts, |
148 backend.nativeBasicData, | 148 backend.nativeBasicData, |
149 interceptorDataBuilder, | 149 interceptorDataBuilder, |
150 backendUsageBuilder, | 150 backendUsageBuilder, |
151 backend.rtiNeedBuilder, | 151 backend.rtiNeedBuilder, |
(...skipping 14 matching lines...) Expand all Loading... |
166 | 166 |
167 ClosedWorld computeClosedWorld(DiagnosticReporter reporter, | 167 ClosedWorld computeClosedWorld(DiagnosticReporter reporter, |
168 ResolutionEnqueuer enqueuer, ElementEnvironment elementEnvironment) { | 168 ResolutionEnqueuer enqueuer, ElementEnvironment elementEnvironment) { |
169 enqueuer.open(const ImpactStrategy(), elementEnvironment.mainFunction, | 169 enqueuer.open(const ImpactStrategy(), elementEnvironment.mainFunction, |
170 elementEnvironment.libraries); | 170 elementEnvironment.libraries); |
171 enqueuer.forEach((WorkItem work) { | 171 enqueuer.forEach((WorkItem work) { |
172 enqueuer.applyImpact(work.run(), impactSource: work.element); | 172 enqueuer.applyImpact(work.run(), impactSource: work.element); |
173 }); | 173 }); |
174 return enqueuer.worldBuilder.closeWorld(); | 174 return enqueuer.worldBuilder.closeWorld(); |
175 } | 175 } |
OLD | NEW |