| 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 // Partial test that the closed world computed from [WorldImpact]s derived from | 5 // Partial test that the closed world computed from [WorldImpact]s derived from | 
| 6 // kernel is equivalent to the original computed from resolution. | 6 // kernel is equivalent to the original computed from resolution. | 
| 7 library dart2js.kernel.closed_world2_test; | 7 library dart2js.kernel.closed_world2_test; | 
| 8 | 8 | 
| 9 import 'package:async_helper/async_helper.dart'; | 9 import 'package:async_helper/async_helper.dart'; | 
| 10 import 'package:compiler/src/closure.dart'; | 10 import 'package:compiler/src/closure.dart'; | 
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 68           Flags.useKernel, | 68           Flags.useKernel, | 
| 69           Flags.enableAssertMessage | 69           Flags.enableAssertMessage | 
| 70         ]); | 70         ]); | 
| 71     ElementResolutionWorldBuilder.useInstantiationMap = true; | 71     ElementResolutionWorldBuilder.useInstantiationMap = true; | 
| 72     compiler.resolution.retainCachesForTesting = true; | 72     compiler.resolution.retainCachesForTesting = true; | 
| 73     await compiler.run(entryPoint); | 73     await compiler.run(entryPoint); | 
| 74     compiler.resolutionWorldBuilder.closeWorld(compiler.reporter); | 74     compiler.resolutionWorldBuilder.closeWorld(compiler.reporter); | 
| 75 | 75 | 
| 76     KernelWorldBuilder worldBuilder = new KernelWorldBuilder( | 76     KernelWorldBuilder worldBuilder = new KernelWorldBuilder( | 
| 77         compiler.reporter, compiler.backend.kernelTask.program); | 77         compiler.reporter, compiler.backend.kernelTask.program); | 
| 78     List list = createKernelResolutionEnqueuerListener( | 78     List list = createKernelResolutionEnqueuerListener(compiler.options, | 
| 79         compiler.options, compiler.deferredLoadTask, worldBuilder); | 79         compiler.reporter, compiler.deferredLoadTask, worldBuilder); | 
| 80     ResolutionEnqueuerListener resolutionEnqueuerListener = list[0]; | 80     ResolutionEnqueuerListener resolutionEnqueuerListener = list[0]; | 
| 81     ImpactTransformer impactTransformer = list[1]; | 81     ImpactTransformer impactTransformer = list[1]; | 
| 82     ResolutionEnqueuer enqueuer = new ResolutionEnqueuer( | 82     ResolutionEnqueuer enqueuer = new ResolutionEnqueuer( | 
| 83         compiler.enqueuer, | 83         compiler.enqueuer, | 
| 84         compiler.options, | 84         compiler.options, | 
| 85         compiler.reporter, | 85         compiler.reporter, | 
| 86         const TreeShakingEnqueuerStrategy(), | 86         const TreeShakingEnqueuerStrategy(), | 
| 87         resolutionEnqueuerListener, | 87         resolutionEnqueuerListener, | 
| 88         new KernelResolutionWorldBuilder( | 88         new KernelResolutionWorldBuilder( | 
| 89             worldBuilder.elementEnvironment, | 89             worldBuilder.elementEnvironment, | 
| 90             worldBuilder.commonElements, | 90             worldBuilder.commonElements, | 
| 91             new NativeBasicDataImpl(), | 91             new NativeBasicDataImpl(), | 
| 92             const OpenWorldStrategy()), | 92             const OpenWorldStrategy()), | 
| 93         new KernelWorkItemBuilder(worldBuilder, impactTransformer), | 93         new KernelWorkItemBuilder(worldBuilder, impactTransformer), | 
| 94         'enqueuer from kelements'); | 94         'enqueuer from kelements'); | 
| 95 | 95 | 
| 96     computeClosedWorld( | 96     computeClosedWorld( | 
| 97         compiler.reporter, enqueuer, worldBuilder.elementEnvironment); | 97         compiler.reporter, enqueuer, worldBuilder.elementEnvironment); | 
| 98   }); | 98   }); | 
| 99 } | 99 } | 
| 100 | 100 | 
| 101 List createKernelResolutionEnqueuerListener(CompilerOptions options, | 101 List createKernelResolutionEnqueuerListener( | 
| 102     DeferredLoadTask deferredLoadTask, KernelWorldBuilder worldBuilder) { | 102     CompilerOptions options, | 
|  | 103     DiagnosticReporter reporter, | 
|  | 104     DeferredLoadTask deferredLoadTask, | 
|  | 105     KernelWorldBuilder worldBuilder) { | 
| 103   ElementEnvironment elementEnvironment = worldBuilder.elementEnvironment; | 106   ElementEnvironment elementEnvironment = worldBuilder.elementEnvironment; | 
| 104   CommonElements commonElements = worldBuilder.commonElements; | 107   CommonElements commonElements = worldBuilder.commonElements; | 
| 105   BackendHelpers helpers = | 108   BackendHelpers helpers = | 
| 106       new BackendHelpers(elementEnvironment, commonElements); | 109       new BackendHelpers(elementEnvironment, commonElements); | 
| 107   BackendImpacts impacts = new BackendImpacts(options, commonElements, helpers); | 110   BackendImpacts impacts = new BackendImpacts(options, commonElements, helpers); | 
| 108 | 111 | 
| 109   // TODO(johnniwinther): Create Kernel based implementations for these: | 112   // TODO(johnniwinther): Create Kernel based implementations for these: | 
| 110   NativeBasicData nativeBasicData = new NativeBasicDataImpl(); | 113   NativeBasicData nativeBasicData = new NativeBasicDataImpl(); | 
| 111   RuntimeTypesNeedBuilder rtiNeedBuilder = new RuntimeTypesNeedBuilderImpl(); | 114   RuntimeTypesNeedBuilder rtiNeedBuilder = new RuntimeTypesNeedBuilderImpl(); | 
| 112   MirrorsDataBuilder mirrorsDataBuilder = new MirrorsDataBuilderImpl(); | 115   MirrorsDataBuilder mirrorsDataBuilder = new MirrorsDataBuilderImpl(); | 
| 113   CustomElementsResolutionAnalysis customElementsResolutionAnalysis = | 116   CustomElementsResolutionAnalysis customElementsResolutionAnalysis = | 
| 114       new CustomElementsResolutionAnalysisImpl(); | 117       new CustomElementsResolutionAnalysisImpl(); | 
| 115   LookupMapResolutionAnalysis lookupMapResolutionAnalysis = |  | 
| 116       new LookupMapResolutionAnalysisImpl(); |  | 
| 117   MirrorsResolutionAnalysis mirrorsResolutionAnalysis = | 118   MirrorsResolutionAnalysis mirrorsResolutionAnalysis = | 
| 118       new MirrorsResolutionAnalysisImpl(); | 119       new MirrorsResolutionAnalysisImpl(); | 
| 119 | 120 | 
|  | 121   LookupMapResolutionAnalysis lookupMapResolutionAnalysis = | 
|  | 122       new LookupMapResolutionAnalysis(reporter, elementEnvironment); | 
| 120   BackendClasses backendClasses = new JavaScriptBackendClasses( | 123   BackendClasses backendClasses = new JavaScriptBackendClasses( | 
| 121       elementEnvironment, helpers, nativeBasicData); | 124       elementEnvironment, helpers, nativeBasicData); | 
| 122   InterceptorDataBuilder interceptorDataBuilder = | 125   InterceptorDataBuilder interceptorDataBuilder = | 
| 123       new InterceptorDataBuilderImpl( | 126       new InterceptorDataBuilderImpl( | 
| 124           nativeBasicData, helpers, elementEnvironment, commonElements); | 127           nativeBasicData, helpers, elementEnvironment, commonElements); | 
| 125   BackendUsageBuilder backendUsageBuilder = | 128   BackendUsageBuilder backendUsageBuilder = | 
| 126       new BackendUsageBuilderImpl(commonElements, helpers); | 129       new BackendUsageBuilderImpl(commonElements, helpers); | 
| 127   NoSuchMethodRegistry noSuchMethodRegistry = new NoSuchMethodRegistry( | 130   NoSuchMethodRegistry noSuchMethodRegistry = new NoSuchMethodRegistry( | 
| 128       helpers, new KernelNoSuchMethodResolver(worldBuilder)); | 131       helpers, new KernelNoSuchMethodResolver(worldBuilder)); | 
| 129   NativeResolutionEnqueuer nativeResolutionEnqueuer = | 132   NativeResolutionEnqueuer nativeResolutionEnqueuer = | 
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 265   @override | 268   @override | 
| 266   void registerStaticUse(MemberEntity element) {} | 269   void registerStaticUse(MemberEntity element) {} | 
| 267 | 270 | 
| 268   @override | 271   @override | 
| 269   void registerInstantiatedClass(ClassEntity classElement) {} | 272   void registerInstantiatedClass(ClassEntity classElement) {} | 
| 270 | 273 | 
| 271   @override | 274   @override | 
| 272   void registerTypeLiteral(DartType type) {} | 275   void registerTypeLiteral(DartType type) {} | 
| 273 } | 276 } | 
| 274 | 277 | 
| 275 class LookupMapResolutionAnalysisImpl implements LookupMapResolutionAnalysis { |  | 
| 276   @override |  | 
| 277   FieldEntity lookupMapVersionVariable; |  | 
| 278   @override |  | 
| 279   LibraryEntity lookupMapLibrary; |  | 
| 280 |  | 
| 281   @override |  | 
| 282   WorldImpact flush() { |  | 
| 283     // TODO(johnniwinther): Implement this. |  | 
| 284     return const WorldImpact(); |  | 
| 285   } |  | 
| 286 |  | 
| 287   @override |  | 
| 288   void init(LibraryEntity library) {} |  | 
| 289 } |  | 
| 290 |  | 
| 291 class MirrorsResolutionAnalysisImpl implements MirrorsResolutionAnalysis { | 278 class MirrorsResolutionAnalysisImpl implements MirrorsResolutionAnalysis { | 
| 292   @override | 279   @override | 
| 293   void onQueueEmpty(Enqueuer enqueuer, Iterable<ClassEntity> recentClasses) {} | 280   void onQueueEmpty(Enqueuer enqueuer, Iterable<ClassEntity> recentClasses) {} | 
| 294 | 281 | 
| 295   @override | 282   @override | 
| 296   MirrorsCodegenAnalysis close() { | 283   MirrorsCodegenAnalysis close() { | 
| 297     throw new UnimplementedError('MirrorsResolutionAnalysisImpl.close'); | 284     throw new UnimplementedError('MirrorsResolutionAnalysisImpl.close'); | 
| 298   } | 285   } | 
| 299 | 286 | 
| 300   @override | 287   @override | 
| (...skipping 18 matching lines...) Expand all  Loading... | 
| 319   final MemberEntity element; | 306   final MemberEntity element; | 
| 320 | 307 | 
| 321   KernelWorkItem(this._worldBuilder, this._impactTransformer, this.element); | 308   KernelWorkItem(this._worldBuilder, this._impactTransformer, this.element); | 
| 322 | 309 | 
| 323   @override | 310   @override | 
| 324   WorldImpact run() { | 311   WorldImpact run() { | 
| 325     ResolutionImpact impact = _worldBuilder.computeWorldImpact(element); | 312     ResolutionImpact impact = _worldBuilder.computeWorldImpact(element); | 
| 326     return _impactTransformer.transformResolutionImpact(impact); | 313     return _impactTransformer.transformResolutionImpact(impact); | 
| 327   } | 314   } | 
| 328 } | 315 } | 
| OLD | NEW | 
|---|