Chromium Code Reviews| 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 part of dart2js; | 5 part of dart2js; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * If true, print a warning for each method that was resolved, but not | 8 * If true, print a warning for each method that was resolved, but not |
| 9 * compiled. | 9 * compiled. |
| 10 */ | 10 */ |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 51 bool isAnalyzed() => resolutionTree != null; | 51 bool isAnalyzed() => resolutionTree != null; |
| 52 | 52 |
| 53 void run(Compiler compiler, Enqueuer world) { | 53 void run(Compiler compiler, Enqueuer world) { |
| 54 CodeBuffer codeBuffer = world.universe.generatedCode[element]; | 54 CodeBuffer codeBuffer = world.universe.generatedCode[element]; |
| 55 if (codeBuffer != null) return; | 55 if (codeBuffer != null) return; |
| 56 resolutionTree = compiler.analyze(this, world); | 56 resolutionTree = compiler.analyze(this, world); |
| 57 compiler.codegen(this, world); | 57 compiler.codegen(this, world); |
| 58 } | 58 } |
| 59 } | 59 } |
| 60 | 60 |
| 61 class UnreportedTask extends CompilerTask { | |
| 62 UnreportedTask(Compiler compiler) : super(compiler); | |
| 63 String get name => 'Unreported'; | |
| 64 } | |
| 65 | |
| 66 class ReadingFilesTask extends CompilerTask { | |
| 67 ReadingFilesTask(Compiler compiler) : super(compiler); | |
| 68 String get name => 'Reading input files'; | |
| 69 } | |
| 70 | |
| 61 abstract class Backend { | 71 abstract class Backend { |
| 62 final Compiler compiler; | 72 final Compiler compiler; |
| 63 final ConstantSystem constantSystem; | 73 final ConstantSystem constantSystem; |
| 64 | 74 |
| 65 Backend(this.compiler, | 75 Backend(this.compiler, |
| 66 [ConstantSystem constantSystem = DART_CONSTANT_SYSTEM]) | 76 [ConstantSystem constantSystem = DART_CONSTANT_SYSTEM]) |
| 67 : this.constantSystem = constantSystem; | 77 : this.constantSystem = constantSystem; |
| 68 | 78 |
| 69 void enqueueAllTopLevelFunctions(LibraryElement lib, Enqueuer world) { | 79 void enqueueAllTopLevelFunctions(LibraryElement lib, Enqueuer world) { |
| 70 lib.forEachExport((Element e) { | 80 lib.forEachExport((Element e) { |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 183 PatchParserTask patchParser; | 193 PatchParserTask patchParser; |
| 184 LibraryLoader libraryLoader; | 194 LibraryLoader libraryLoader; |
| 185 TreeValidatorTask validator; | 195 TreeValidatorTask validator; |
| 186 ResolverTask resolver; | 196 ResolverTask resolver; |
| 187 closureMapping.ClosureTask closureToClassMapper; | 197 closureMapping.ClosureTask closureToClassMapper; |
| 188 TypeCheckerTask checker; | 198 TypeCheckerTask checker; |
| 189 ti.TypesTask typesTask; | 199 ti.TypesTask typesTask; |
| 190 Backend backend; | 200 Backend backend; |
| 191 ConstantHandler constantHandler; | 201 ConstantHandler constantHandler; |
| 192 EnqueueTask enqueuer; | 202 EnqueueTask enqueuer; |
| 203 CompilerTask unreported; | |
| 204 CompilerTask fileReadingTask; | |
| 193 | 205 |
| 194 static const SourceString MAIN = const SourceString('main'); | 206 static const SourceString MAIN = const SourceString('main'); |
| 195 static const SourceString CALL_OPERATOR_NAME = const SourceString('call'); | 207 static const SourceString CALL_OPERATOR_NAME = const SourceString('call'); |
| 196 static const SourceString NO_SUCH_METHOD = const SourceString('noSuchMethod'); | 208 static const SourceString NO_SUCH_METHOD = const SourceString('noSuchMethod'); |
| 197 static const int NO_SUCH_METHOD_ARG_COUNT = 1; | 209 static const int NO_SUCH_METHOD_ARG_COUNT = 1; |
| 198 static const SourceString INVOKE_ON = const SourceString('invokeOn'); | 210 static const SourceString INVOKE_ON = const SourceString('invokeOn'); |
| 199 static const SourceString RUNTIME_TYPE = const SourceString('runtimeType'); | 211 static const SourceString RUNTIME_TYPE = const SourceString('runtimeType'); |
| 200 static const SourceString START_ROOT_ISOLATE = | 212 static const SourceString START_ROOT_ISOLATE = |
| 201 const SourceString('startRootIsolate'); | 213 const SourceString('startRootIsolate'); |
| 202 bool enabledNoSuchMethod = false; | 214 bool enabledNoSuchMethod = false; |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 225 bool generateSourceMap: true, | 237 bool generateSourceMap: true, |
| 226 bool disallowUnsafeEval: false, | 238 bool disallowUnsafeEval: false, |
| 227 this.analyzeAll: false, | 239 this.analyzeAll: false, |
| 228 this.rejectDeprecatedFeatures: false, | 240 this.rejectDeprecatedFeatures: false, |
| 229 this.checkDeprecationInSdk: false, | 241 this.checkDeprecationInSdk: false, |
| 230 List<String> strips: const []}) | 242 List<String> strips: const []}) |
| 231 : libraries = new Map<String, LibraryElement>(), | 243 : libraries = new Map<String, LibraryElement>(), |
| 232 progress = new Stopwatch() { | 244 progress = new Stopwatch() { |
| 233 progress.start(); | 245 progress.start(); |
| 234 world = new World(this); | 246 world = new World(this); |
| 235 scanner = new ScannerTask(this); | |
| 236 dietParser = new DietParserTask(this); | |
| 237 parser = new ParserTask(this); | |
| 238 patchParser = new PatchParserTask(this); | |
| 239 libraryLoader = new LibraryLoaderTask(this); | |
| 240 validator = new TreeValidatorTask(this); | |
| 241 resolver = new ResolverTask(this); | |
| 242 closureToClassMapper = new closureMapping.ClosureTask(this); | |
| 243 checker = new TypeCheckerTask(this); | |
| 244 typesTask = new ti.TypesTask(this, enableConcreteTypeInference); | |
| 245 backend = emitJavaScript ? | 247 backend = emitJavaScript ? |
| 246 new js_backend.JavaScriptBackend(this, | 248 new js_backend.JavaScriptBackend(this, |
| 247 generateSourceMap, | 249 generateSourceMap, |
| 248 disallowUnsafeEval) : | 250 disallowUnsafeEval) : |
| 249 new dart_backend.DartBackend(this, strips); | 251 new dart_backend.DartBackend(this, strips); |
| 250 constantHandler = new ConstantHandler(this, backend.constantSystem); | 252 |
| 251 enqueuer = new EnqueueTask(this); | 253 // No-op in production mode. |
| 252 tasks = [scanner, dietParser, parser, patchParser, libraryLoader, | 254 validator = new TreeValidatorTask(this); |
| 253 resolver, closureToClassMapper, checker, typesTask, | 255 |
| 254 constantHandler, enqueuer]; | 256 tasks = [ |
| 257 fileReadingTask = new ReadingFilesTask(this), | |
| 258 libraryLoader = new LibraryLoaderTask(this), | |
| 259 scanner = new ScannerTask(this), | |
| 260 dietParser = new DietParserTask(this), | |
| 261 parser = new ParserTask(this), | |
| 262 patchParser = new PatchParserTask(this), | |
| 263 resolver = new ResolverTask(this), | |
| 264 closureToClassMapper = new closureMapping.ClosureTask(this), | |
| 265 checker = new TypeCheckerTask(this), | |
| 266 typesTask = new ti.TypesTask(this, enableConcreteTypeInference), | |
| 267 constantHandler = new ConstantHandler(this, backend.constantSystem), | |
| 268 enqueuer = new EnqueueTask(this)]; | |
| 269 | |
| 255 tasks.addAll(backend.tasks); | 270 tasks.addAll(backend.tasks); |
| 271 tasks.add(unreported = new UnreportedTask(this)); | |
| 256 } | 272 } |
| 257 | 273 |
| 258 Universe get resolverWorld => enqueuer.resolution.universe; | 274 Universe get resolverWorld => enqueuer.resolution.universe; |
| 259 Universe get codegenWorld => enqueuer.codegen.universe; | 275 Universe get codegenWorld => enqueuer.codegen.universe; |
| 260 | 276 |
| 261 int getNextFreeClassId() => nextFreeClassId++; | 277 int getNextFreeClassId() => nextFreeClassId++; |
| 262 | 278 |
| 263 void ensure(bool condition) { | 279 void ensure(bool condition) { |
| 264 if (!condition) cancel('failed assertion in leg'); | 280 if (!condition) cancel('failed assertion in leg'); |
| 265 } | 281 } |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 334 element: element); | 350 element: element); |
| 335 }); | 351 }); |
| 336 } | 352 } |
| 337 | 353 |
| 338 void log(message) { | 354 void log(message) { |
| 339 reportDiagnostic(null, message, api.Diagnostic.VERBOSE_INFO); | 355 reportDiagnostic(null, message, api.Diagnostic.VERBOSE_INFO); |
| 340 } | 356 } |
| 341 | 357 |
| 342 bool run(Uri uri) { | 358 bool run(Uri uri) { |
| 343 try { | 359 try { |
| 344 runCompiler(uri); | 360 unreported.measure(() => runCompiler(uri)); |
|
ngeoffray
2012/11/27 09:14:07
Will that just measure the non-measured time at th
ahe
2012/11/30 12:00:37
I have changed it. Now it looks like this:
info:
| |
| 345 } on CompilerCancelledException catch (exception) { | 361 } on CompilerCancelledException catch (exception) { |
| 346 log('Error: $exception'); | 362 log('Error: $exception'); |
| 347 return false; | 363 return false; |
| 348 } | 364 } |
| 349 tracer.close(); | 365 tracer.close(); |
| 350 return true; | 366 return true; |
| 351 } | 367 } |
| 352 | 368 |
| 353 void enableNoSuchMethod(Element element) { | 369 void enableNoSuchMethod(Element element) { |
| 354 // TODO(ahe): Move this method to Enqueuer. | 370 // TODO(ahe): Move this method to Enqueuer. |
| (...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 938 // TODO(johnniwinther): Use [spannable] and [message] to provide better | 954 // TODO(johnniwinther): Use [spannable] and [message] to provide better |
| 939 // information on assertion errors. | 955 // information on assertion errors. |
| 940 if (condition is Function){ | 956 if (condition is Function){ |
| 941 condition = condition(); | 957 condition = condition(); |
| 942 } | 958 } |
| 943 if (spannable == null || !condition) { | 959 if (spannable == null || !condition) { |
| 944 throw new SpannableAssertionFailure(spannable, message); | 960 throw new SpannableAssertionFailure(spannable, message); |
| 945 } | 961 } |
| 946 return true; | 962 return true; |
| 947 } | 963 } |
| OLD | NEW |