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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 compiler.globalDependencies, | 94 compiler.globalDependencies, |
95 backend, | 95 backend, |
96 compiler.commonElements, | 96 compiler.commonElements, |
97 compiler.cacheStrategy, | 97 compiler.cacheStrategy, |
98 'enqueuer from kernel'); | 98 'enqueuer from kernel'); |
99 // TODO(johnniwinther): Store backend info separately. This replacement is | 99 // TODO(johnniwinther): Store backend info separately. This replacement is |
100 // made to reset a field in [TypeVariableHandler] that prevents it from | 100 // made to reset a field in [TypeVariableHandler] that prevents it from |
101 // enqueuing twice. | 101 // enqueuing twice. |
102 backend.typeVariableHandler = new TypeVariableHandler(compiler); | 102 backend.typeVariableHandler = new TypeVariableHandler(compiler); |
103 | 103 |
104 backend.enqueueHelpers(enqueuer); | 104 if (compiler.deferredLoadTask.isProgramSplit) { |
| 105 enqueuer.applyImpact(backend.computeDeferredLoadingImpact()); |
| 106 } |
| 107 enqueuer.applyImpact(backend.computeHelpersImpact()); |
| 108 enqueuer.applyImpact(enqueuer.nativeEnqueuer |
| 109 .processNativeClasses(compiler.libraryLoader.libraries)); |
105 enqueuer.applyImpact( | 110 enqueuer.applyImpact( |
106 compiler.impactStrategy, | 111 backend.computeMainImpact(compiler.mainFunction, forResolution: true)); |
107 enqueuer.nativeEnqueuer | |
108 .processNativeClasses(compiler.libraryLoader.libraries)); | |
109 enqueuer.applyImpact(compiler.impactStrategy, | |
110 backend.computeMainImpact(enqueuer, compiler.mainFunction)); | |
111 enqueuer.forEach((work) { | 112 enqueuer.forEach((work) { |
112 AstElement element = work.element; | 113 AstElement element = work.element; |
113 ResolutionImpact resolutionImpact = build(compiler, element.resolvedAst); | 114 ResolutionImpact resolutionImpact = build(compiler, element.resolvedAst); |
114 WorldImpact worldImpact = compiler.backend.impactTransformer | 115 WorldImpact worldImpact = compiler.backend.impactTransformer |
115 .transformResolutionImpact(enqueuer, resolutionImpact); | 116 .transformResolutionImpact(enqueuer, resolutionImpact); |
116 enqueuer.registerProcessedElement(element); | 117 enqueuer.registerProcessedElement(element); |
117 enqueuer.applyImpact(compiler.impactStrategy, worldImpact, | 118 enqueuer.applyImpact(worldImpact, impactSource: element); |
118 impactSource: element); | |
119 }); | 119 }); |
120 ClosedWorld closedWorld = | 120 ClosedWorld closedWorld = |
121 enqueuer.universe.openWorld.closeWorld(compiler.reporter); | 121 enqueuer.universe.openWorld.closeWorld(compiler.reporter); |
122 | 122 |
123 checkResolutionEnqueuers(compiler.enqueuer.resolution, enqueuer, | 123 checkResolutionEnqueuers(compiler.enqueuer.resolution, enqueuer, |
124 typeEquivalence: (DartType a, DartType b) { | 124 typeEquivalence: (DartType a, DartType b) { |
125 return areTypesEquivalent(unalias(a), unalias(b)); | 125 return areTypesEquivalent(unalias(a), unalias(b)); |
126 }, elementFilter: (Element element) { | 126 }, elementFilter: (Element element) { |
127 if (element is ConstructorElement && element.isRedirectingFactory) { | 127 if (element is ConstructorElement && element.isRedirectingFactory) { |
128 // Redirecting factory constructors are skipped in kernel. | 128 // Redirecting factory constructors are skipped in kernel. |
129 return false; | 129 return false; |
130 } | 130 } |
131 if (element is ClassElement) { | 131 if (element is ClassElement) { |
132 for (ConstructorElement constructor in element.constructors) { | 132 for (ConstructorElement constructor in element.constructors) { |
133 if (!constructor.isRedirectingFactory) { | 133 if (!constructor.isRedirectingFactory) { |
134 return true; | 134 return true; |
135 } | 135 } |
136 } | 136 } |
137 // The class cannot itself be instantiated. | 137 // The class cannot itself be instantiated. |
138 return false; | 138 return false; |
139 } | 139 } |
140 return true; | 140 return true; |
141 }, verbose: arguments.verbose); | 141 }, verbose: arguments.verbose); |
142 checkClosedWorlds(compiler.closedWorld, closedWorld, | 142 checkClosedWorlds(compiler.closedWorld, closedWorld, |
143 verbose: arguments.verbose); | 143 verbose: arguments.verbose); |
144 }); | 144 }); |
145 } | 145 } |
OLD | NEW |