OLD | NEW |
---|---|
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; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
83 import 'universe/world_impact.dart' show ImpactStrategy, WorldImpact; | 83 import 'universe/world_impact.dart' show ImpactStrategy, WorldImpact; |
84 import 'util/util.dart' show Link, Setlet; | 84 import 'util/util.dart' show Link, Setlet; |
85 import 'world.dart' show World; | 85 import 'world.dart' show World; |
86 | 86 |
87 typedef Backend MakeBackendFuncion(Compiler compiler); | 87 typedef Backend MakeBackendFuncion(Compiler compiler); |
88 | 88 |
89 typedef CompilerDiagnosticReporter MakeReporterFunction( | 89 typedef CompilerDiagnosticReporter MakeReporterFunction( |
90 Compiler compiler, CompilerOptions options); | 90 Compiler compiler, CompilerOptions options); |
91 | 91 |
92 abstract class Compiler implements LibraryLoaderListener { | 92 abstract class Compiler implements LibraryLoaderListener { |
93 /// Helper instance for measurements in [CompilerTask]. | 93 Measurer get measurer; |
94 /// | |
95 /// Note: MUST be first field to ensure [Measurer.wallclock] is started | |
96 /// before other computations. | |
97 final Measurer measurer = new Measurer(); | |
98 | 94 |
99 final IdGenerator idGenerator = new IdGenerator(); | 95 final IdGenerator idGenerator = new IdGenerator(); |
100 World world; | 96 World world; |
101 Types types; | 97 Types types; |
102 _CompilerCoreTypes _coreTypes; | 98 _CompilerCoreTypes _coreTypes; |
103 CompilerDiagnosticReporter _reporter; | 99 CompilerDiagnosticReporter _reporter; |
104 _CompilerResolution _resolution; | 100 _CompilerResolution _resolution; |
105 ParsingContext _parsingContext; | 101 ParsingContext _parsingContext; |
106 | 102 |
107 final CacheStrategy cacheStrategy; | 103 final CacheStrategy cacheStrategy; |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
242 ParserTask parser; | 238 ParserTask parser; |
243 PatchParserTask patchParser; | 239 PatchParserTask patchParser; |
244 LibraryLoaderTask libraryLoader; | 240 LibraryLoaderTask libraryLoader; |
245 SerializationTask serialization; | 241 SerializationTask serialization; |
246 ResolverTask resolver; | 242 ResolverTask resolver; |
247 closureMapping.ClosureTask closureToClassMapper; | 243 closureMapping.ClosureTask closureToClassMapper; |
248 TypeCheckerTask checker; | 244 TypeCheckerTask checker; |
249 ti.TypesTask typesTask; | 245 ti.TypesTask typesTask; |
250 Backend backend; | 246 Backend backend; |
251 | 247 |
252 GenericTask reuseLibraryTask; | |
Siggi Cherem (dart-lang)
2016/05/25 01:45:18
now measured as a subtask of the loader
| |
253 | |
254 GenericTask selfTask; | 248 GenericTask selfTask; |
255 | 249 |
256 /// The constant environment for the frontend interpretation of compile-time | 250 /// The constant environment for the frontend interpretation of compile-time |
257 /// constants. | 251 /// constants. |
258 ConstantEnvironment constants; | 252 ConstantEnvironment constants; |
259 | 253 |
260 EnqueueTask enqueuer; | 254 EnqueueTask enqueuer; |
261 DeferredLoadTask deferredLoadTask; | 255 DeferredLoadTask deferredLoadTask; |
262 MirrorUsageAnalyzerTask mirrorUsageAnalyzerTask; | 256 MirrorUsageAnalyzerTask mirrorUsageAnalyzerTask; |
263 DumpInfoTask dumpInfoTask; | 257 DumpInfoTask dumpInfoTask; |
264 | 258 |
265 /// A customizable filter that is applied to enqueued work items. | 259 /// A customizable filter that is applied to enqueued work items. |
266 QueueFilter enqueuerFilter = new QueueFilter(); | 260 QueueFilter enqueuerFilter = new QueueFilter(); |
267 | 261 |
268 static const String CREATE_INVOCATION_MIRROR = 'createInvocationMirror'; | |
Siggi Cherem (dart-lang)
2016/05/25 01:45:18
only used in one place, no reason to have it here.
| |
269 | |
270 bool enabledRuntimeType = false; | 262 bool enabledRuntimeType = false; |
271 bool enabledFunctionApply = false; | 263 bool enabledFunctionApply = false; |
272 bool enabledInvokeOn = false; | 264 bool enabledInvokeOn = false; |
273 bool hasIsolateSupport = false; | 265 bool hasIsolateSupport = false; |
274 | 266 |
275 bool get hasCrashed => _reporter.hasCrashed; | 267 bool get hasCrashed => _reporter.hasCrashed; |
276 | 268 |
277 Stopwatch progress; | 269 Stopwatch progress; |
278 | 270 |
279 bool get shouldPrintProgress { | 271 bool get shouldPrintProgress { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
337 } | 329 } |
338 } | 330 } |
339 | 331 |
340 if (options.dumpInfo && options.useStartupEmitter) { | 332 if (options.dumpInfo && options.useStartupEmitter) { |
341 throw new ArgumentError( | 333 throw new ArgumentError( |
342 '--dump-info is not supported with the fast startup emitter'); | 334 '--dump-info is not supported with the fast startup emitter'); |
343 } | 335 } |
344 | 336 |
345 tasks = [ | 337 tasks = [ |
346 dietParser = | 338 dietParser = |
347 new DietParserTask(this, options, idGenerator, backend, reporter), | 339 new DietParserTask(options, idGenerator, backend, reporter, measurer), |
Siggi Cherem (dart-lang)
2016/05/25 01:45:18
now diet parser and scanner below no longer need a
| |
348 scanner = createScannerTask(), | 340 scanner = createScannerTask(), |
349 serialization = new SerializationTask(this), | 341 serialization = new SerializationTask(this), |
350 libraryLoader = new LibraryLoaderTask( | 342 libraryLoader = new LibraryLoaderTask( |
351 this, | 343 this, |
352 this.resolvedUriTranslator, | 344 this.resolvedUriTranslator, |
353 new _ScriptLoader(this), | 345 new _ScriptLoader(this), |
354 new _ElementScanner(scanner), | 346 new _ElementScanner(scanner), |
355 this.serialization, | 347 this.serialization, |
356 this, | 348 this, |
357 environment), | 349 environment), |
358 parser = new ParserTask(this, options), | 350 parser = new ParserTask(this, options), |
359 patchParser = new PatchParserTask(this, options), | 351 patchParser = new PatchParserTask(this, options), |
360 resolver = createResolverTask(), | 352 resolver = createResolverTask(), |
361 closureToClassMapper = new closureMapping.ClosureTask(this), | 353 closureToClassMapper = new closureMapping.ClosureTask(this), |
362 checker = new TypeCheckerTask(this), | 354 checker = new TypeCheckerTask(this), |
363 typesTask = new ti.TypesTask(this), | 355 typesTask = new ti.TypesTask(this), |
364 constants = backend.constantCompilerTask, | 356 constants = backend.constantCompilerTask, |
365 deferredLoadTask = new DeferredLoadTask(this), | 357 deferredLoadTask = new DeferredLoadTask(this), |
366 mirrorUsageAnalyzerTask = new MirrorUsageAnalyzerTask(this), | 358 mirrorUsageAnalyzerTask = new MirrorUsageAnalyzerTask(this), |
367 enqueuer = backend.makeEnqueuer(), | 359 enqueuer = backend.makeEnqueuer(), |
368 dumpInfoTask = new DumpInfoTask(this), | 360 dumpInfoTask = new DumpInfoTask(this), |
369 reuseLibraryTask = new GenericTask('Reuse library', this), | 361 selfTask = new GenericTask('self', measurer), |
370 selfTask = new GenericTask('self', this), | |
371 ]; | 362 ]; |
372 if (options.resolveOnly) { | 363 if (options.resolveOnly) { |
373 serialization.supportSerialization = true; | 364 serialization.supportSerialization = true; |
374 } | 365 } |
375 | 366 |
376 _parsingContext = | 367 _parsingContext = |
377 new ParsingContext(reporter, options, parser, patchParser, backend); | 368 new ParsingContext(reporter, options, parser, patchParser, backend); |
378 | 369 |
379 tasks.addAll(backend.tasks); | 370 tasks.addAll(backend.tasks); |
380 } | 371 } |
381 | 372 |
382 /// Creates the scanner task. | 373 /// Creates the scanner task. |
383 /// | 374 /// |
384 /// Override this to mock the scanner for testing. | 375 /// Override this to mock the scanner for testing. |
385 ScannerTask createScannerTask() => new ScannerTask(this, dietParser, | 376 ScannerTask createScannerTask() => |
386 preserveComments: options.preserveComments, commentMap: commentMap); | 377 new ScannerTask(dietParser, reporter, measurer, |
378 preserveComments: options.preserveComments, commentMap: commentMap); | |
387 | 379 |
388 /// Creates the resolver task. | 380 /// Creates the resolver task. |
389 /// | 381 /// |
390 /// Override this to mock the resolver for testing. | 382 /// Override this to mock the resolver for testing. |
391 ResolverTask createResolverTask() { | 383 ResolverTask createResolverTask() { |
392 return new ResolverTask(this, backend.constantCompilerTask); | 384 return new ResolverTask(this, backend.constantCompilerTask); |
393 } | 385 } |
394 | 386 |
395 Universe get resolverWorld => enqueuer.resolution.universe; | 387 Universe get resolverWorld => enqueuer.resolution.universe; |
396 Universe get codegenWorld => enqueuer.codegen.universe; | 388 Universe get codegenWorld => enqueuer.codegen.universe; |
(...skipping 1719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2116 _ElementScanner(this.scanner); | 2108 _ElementScanner(this.scanner); |
2117 void scanLibrary(LibraryElement library) => scanner.scanLibrary(library); | 2109 void scanLibrary(LibraryElement library) => scanner.scanLibrary(library); |
2118 void scanUnit(CompilationUnitElement unit) => scanner.scan(unit); | 2110 void scanUnit(CompilationUnitElement unit) => scanner.scan(unit); |
2119 } | 2111 } |
2120 | 2112 |
2121 class _EmptyEnvironment implements Environment { | 2113 class _EmptyEnvironment implements Environment { |
2122 const _EmptyEnvironment(); | 2114 const _EmptyEnvironment(); |
2123 | 2115 |
2124 String valueOf(String key) => null; | 2116 String valueOf(String key) => null; |
2125 } | 2117 } |
OLD | NEW |