Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: pkg/compiler/lib/src/compiler.dart

Issue 2349163003: Move towards using WorldImpact for codegen (Closed)
Patch Set: Cleanup. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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.compiler_base; 5 library dart2js.compiler_base;
6 6
7 import 'dart:async' show EventSink, Future; 7 import 'dart:async' show EventSink, Future;
8 8
9 import '../compiler_new.dart' as api; 9 import '../compiler_new.dart' as api;
10 import 'cache_strategy.dart' show CacheStrategy; 10 import 'cache_strategy.dart' show CacheStrategy;
11 import 'closure.dart' as closureMapping show ClosureTask; 11 import 'closure.dart' as closureMapping show ClosureTask;
12 import 'common/backend_api.dart' show Backend; 12 import 'common/backend_api.dart' show Backend;
13 import 'common/codegen.dart' show CodegenWorkItem; 13 import 'common/codegen.dart' show CodegenWorkItem;
14 import 'common/names.dart' show Selectors; 14 import 'common/names.dart' show Selectors;
15 import 'common/names.dart' show Identifiers, Uris; 15 import 'common/names.dart' show Identifiers, Uris;
16 import 'common/registry.dart' show EagerRegistry, Registry; 16 import 'common/registry.dart' show Registry;
17 import 'common/resolution.dart' 17 import 'common/resolution.dart'
18 show 18 show
19 ParsingContext, 19 ParsingContext,
20 Resolution, 20 Resolution,
21 ResolutionWorkItem, 21 ResolutionWorkItem,
22 ResolutionImpact, 22 ResolutionImpact,
23 Target; 23 Target;
24 import 'common/tasks.dart' show CompilerTask, GenericTask, Measurer; 24 import 'common/tasks.dart' show CompilerTask, GenericTask, Measurer;
25 import 'common/work.dart' show WorkItem; 25 import 'common/work.dart' show WorkItem;
26 import 'common.dart'; 26 import 'common.dart';
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 _coreTypes = new _CompilerCoreTypes(_resolution, reporter); 237 _coreTypes = new _CompilerCoreTypes(_resolution, reporter);
238 types = new Types(_resolution); 238 types = new Types(_resolution);
239 tracer = new Tracer(this, this.outputProvider); 239 tracer = new Tracer(this, this.outputProvider);
240 240
241 if (options.verbose) { 241 if (options.verbose) {
242 progress = new Stopwatch()..start(); 242 progress = new Stopwatch()..start();
243 } 243 }
244 244
245 // TODO(johnniwinther): Separate the dependency tracking from the enqueuing 245 // TODO(johnniwinther): Separate the dependency tracking from the enqueuing
246 // for global dependencies. 246 // for global dependencies.
247 globalDependencies = new GlobalDependencyRegistry(this); 247 globalDependencies = new GlobalDependencyRegistry();
248 248
249 if (makeBackend != null) { 249 if (makeBackend != null) {
250 backend = makeBackend(this); 250 backend = makeBackend(this);
251 } else { 251 } else {
252 js_backend.JavaScriptBackend jsBackend = new js_backend.JavaScriptBackend( 252 js_backend.JavaScriptBackend jsBackend = new js_backend.JavaScriptBackend(
253 this, 253 this,
254 generateSourceMap: options.generateSourceMap, 254 generateSourceMap: options.generateSourceMap,
255 useStartupEmitter: options.useStartupEmitter, 255 useStartupEmitter: options.useStartupEmitter,
256 useNewSourceInfo: options.useNewSourceInfo, 256 useNewSourceInfo: options.useNewSourceInfo,
257 useKernel: options.useKernel); 257 useKernel: options.useKernel);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 } 303 }
304 304
305 /// The world currently being computed by resolution. This forms a basis for 305 /// The world currently being computed by resolution. This forms a basis for
306 /// the [inferenceWorld] and later the [closedWorld]. 306 /// the [inferenceWorld] and later the [closedWorld].
307 OpenWorld get openWorld => _world; 307 OpenWorld get openWorld => _world;
308 308
309 /// The closed world after resolution but currently refined by inference. 309 /// The closed world after resolution but currently refined by inference.
310 InferenceWorld get inferenceWorld => _world; 310 InferenceWorld get inferenceWorld => _world;
311 311
312 /// The closed world after resolution and inference. 312 /// The closed world after resolution and inference.
313 ClosedWorld get closedWorld => _world; 313 ClosedWorld get closedWorld {
314 assert(invariant(CURRENT_ELEMENT_SPANNABLE, _world.isClosed,
315 message: "Closed world not computed yet."));
316 return _world;
317 }
314 318
315 /// Creates the scanner task. 319 /// Creates the scanner task.
316 /// 320 ///
317 /// Override this to mock the scanner for testing. 321 /// Override this to mock the scanner for testing.
318 ScannerTask createScannerTask() => 322 ScannerTask createScannerTask() =>
319 new ScannerTask(dietParser, reporter, measurer, 323 new ScannerTask(dietParser, reporter, measurer,
320 preserveComments: options.preserveComments, commentMap: commentMap); 324 preserveComments: options.preserveComments, commentMap: commentMap);
321 325
322 /// Creates the resolver task. 326 /// Creates the resolver task.
323 /// 327 ///
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 // compiler from analyzing all the code. 716 // compiler from analyzing all the code.
713 // TODO(johnniwinther): Reenable this when the reporting is more 717 // TODO(johnniwinther): Reenable this when the reporting is more
714 // precise. 718 // precise.
715 //reportUnusedCode(); 719 //reportUnusedCode();
716 } 720 }
717 return; 721 return;
718 } 722 }
719 assert(mainFunction != null); 723 assert(mainFunction != null);
720 phase = PHASE_DONE_RESOLVING; 724 phase = PHASE_DONE_RESOLVING;
721 725
722 openWorld.populate(); 726 openWorld.closeWorld();
Harry Terkelsen 2016/09/19 21:17:52 consider renaming 'closeWorld' to close?
723 // Compute whole-program-knowledge that the backend needs. (This might 727 // Compute whole-program-knowledge that the backend needs. (This might
724 // require the information computed in [world.populate].) 728 // require the information computed in [world.populate].)
725 backend.onResolutionComplete(); 729 backend.onResolutionComplete();
726 730
727 deferredLoadTask.onResolutionComplete(mainFunction); 731 deferredLoadTask.onResolutionComplete(mainFunction);
728 732
729 reporter.log('Inferring types...'); 733 reporter.log('Inferring types...');
730 globalInference.runGlobalTypeInference(mainFunction); 734 globalInference.runGlobalTypeInference(mainFunction);
731 735
732 if (stopAfterTypeInference) return; 736 if (stopAfterTypeInference) return;
(...skipping 1450 matching lines...) Expand 10 before | Expand all | Expand 10 after
2183 if (field == null) return false; 2187 if (field == null) return false;
2184 if (!hasBeenResolved(field)) return false; 2188 if (!hasBeenResolved(field)) return false;
2185 if (_proxyConstant == null) { 2189 if (_proxyConstant == null) {
2186 _proxyConstant = constants 2190 _proxyConstant = constants
2187 .getConstantValue(resolver.constantCompiler.compileConstant(field)); 2191 .getConstantValue(resolver.constantCompiler.compileConstant(field));
2188 } 2192 }
2189 return _proxyConstant == value; 2193 return _proxyConstant == value;
2190 } 2194 }
2191 } 2195 }
2192 2196
2193 class GlobalDependencyRegistry extends EagerRegistry { 2197 class GlobalDependencyRegistry extends Registry {
2194 final Compiler compiler;
2195 Setlet<Element> _otherDependencies; 2198 Setlet<Element> _otherDependencies;
2196 2199
2197 GlobalDependencyRegistry(this.compiler) : super('GlobalDependencies', null); 2200 GlobalDependencyRegistry();
2198
2199 // TODO(johnniwinther): Rename world/universe/enqueuer through out the
2200 // compiler.
2201 @override
2202 Enqueuer get world => compiler.enqueuer.codegen;
2203 2201
2204 void registerDependency(Element element) { 2202 void registerDependency(Element element) {
2205 if (element == null) return; 2203 if (element == null) return;
2206 if (_otherDependencies == null) { 2204 if (_otherDependencies == null) {
2207 _otherDependencies = new Setlet<Element>(); 2205 _otherDependencies = new Setlet<Element>();
2208 } 2206 }
2209 _otherDependencies.add(element.implementation); 2207 _otherDependencies.add(element.implementation);
2210 } 2208 }
2211 2209
2212 Iterable<Element> get otherDependencies { 2210 Iterable<Element> get otherDependencies {
2213 return _otherDependencies != null ? _otherDependencies : const <Element>[]; 2211 return _otherDependencies != null ? _otherDependencies : const <Element>[];
2214 } 2212 }
2213
2214 String get name => 'GlobalDependencies';
2215 } 2215 }
2216 2216
2217 class _ScriptLoader implements ScriptLoader { 2217 class _ScriptLoader implements ScriptLoader {
2218 Compiler compiler; 2218 Compiler compiler;
2219 _ScriptLoader(this.compiler); 2219 _ScriptLoader(this.compiler);
2220 2220
2221 Future<Script> readScript(Uri uri, [Spannable spannable]) => 2221 Future<Script> readScript(Uri uri, [Spannable spannable]) =>
2222 compiler.readScript(uri, spannable); 2222 compiler.readScript(uri, spannable);
2223 } 2223 }
2224 2224
(...skipping 14 matching lines...) Expand all
2239 _ElementScanner(this.scanner); 2239 _ElementScanner(this.scanner);
2240 void scanLibrary(LibraryElement library) => scanner.scanLibrary(library); 2240 void scanLibrary(LibraryElement library) => scanner.scanLibrary(library);
2241 void scanUnit(CompilationUnitElement unit) => scanner.scan(unit); 2241 void scanUnit(CompilationUnitElement unit) => scanner.scan(unit);
2242 } 2242 }
2243 2243
2244 class _EmptyEnvironment implements Environment { 2244 class _EmptyEnvironment implements Environment {
2245 const _EmptyEnvironment(); 2245 const _EmptyEnvironment();
2246 2246
2247 String valueOf(String key) => null; 2247 String valueOf(String key) => null;
2248 } 2248 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698