| 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 class WorkItem { | 5 class WorkItem { |
| 6 final Element element; | 6 final Element element; |
| 7 TreeElements resolutionTree; | 7 TreeElements resolutionTree; |
| 8 Function run; | 8 Function run; |
| 9 Map<int, BailoutInfo> bailouts = null; | 9 Map<int, BailoutInfo> bailouts = null; |
| 10 bool allowSpeculativeOptimization = true; | 10 bool allowSpeculativeOptimization = true; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 DietParserTask dietParser; | 67 DietParserTask dietParser; |
| 68 ParserTask parser; | 68 ParserTask parser; |
| 69 TreeValidatorTask validator; | 69 TreeValidatorTask validator; |
| 70 ResolverTask resolver; | 70 ResolverTask resolver; |
| 71 TypeCheckerTask checker; | 71 TypeCheckerTask checker; |
| 72 SsaBuilderTask builder; | 72 SsaBuilderTask builder; |
| 73 SsaOptimizerTask optimizer; | 73 SsaOptimizerTask optimizer; |
| 74 SsaCodeGeneratorTask generator; | 74 SsaCodeGeneratorTask generator; |
| 75 CodeEmitterTask emitter; | 75 CodeEmitterTask emitter; |
| 76 CompileTimeConstantHandler compileTimeConstantHandler; | 76 CompileTimeConstantHandler compileTimeConstantHandler; |
| 77 native.NativeHandler nativeHandler; |
| 77 | 78 |
| 78 static final SourceString MAIN = const SourceString('main'); | 79 static final SourceString MAIN = const SourceString('main'); |
| 79 static final SourceString NO_SUCH_METHOD = const SourceString('noSuchMethod'); | 80 static final SourceString NO_SUCH_METHOD = const SourceString('noSuchMethod'); |
| 80 | 81 |
| 81 Compiler() : this.withCurrentDirectory(io.getCurrentDirectory()); | 82 Compiler() : this.withCurrentDirectory(io.getCurrentDirectory()); |
| 82 | 83 |
| 83 Compiler.withCurrentDirectory(String this.currentDirectory) | 84 Compiler.withCurrentDirectory(String this.currentDirectory) |
| 84 : types = new Types(), | 85 : types = new Types(), |
| 85 universe = new Universe(), | 86 universe = new Universe(), |
| 86 worklist = new Queue<WorkItem>() { | 87 worklist = new Queue<WorkItem>() { |
| 87 namer = new Namer(this); | 88 namer = new Namer(this); |
| 88 compileTimeConstantHandler = new CompileTimeConstantHandler(this); | 89 compileTimeConstantHandler = new CompileTimeConstantHandler(this); |
| 89 scanner = new ScannerTask(this); | 90 scanner = new ScannerTask(this); |
| 90 dietParser = new DietParserTask(this); | 91 dietParser = new DietParserTask(this); |
| 91 parser = new ParserTask(this); | 92 parser = new ParserTask(this); |
| 92 validator = new TreeValidatorTask(this); | 93 validator = new TreeValidatorTask(this); |
| 93 resolver = new ResolverTask(this); | 94 resolver = new ResolverTask(this); |
| 94 checker = new TypeCheckerTask(this); | 95 checker = new TypeCheckerTask(this); |
| 95 builder = new SsaBuilderTask(this); | 96 builder = new SsaBuilderTask(this); |
| 96 optimizer = new SsaOptimizerTask(this); | 97 optimizer = new SsaOptimizerTask(this); |
| 97 generator = new SsaCodeGeneratorTask(this); | 98 generator = new SsaCodeGeneratorTask(this); |
| 98 emitter = new CodeEmitterTask(this); | 99 emitter = new CodeEmitterTask(this); |
| 100 nativeHandler = new native.NativeHandler(this); |
| 99 tasks = [scanner, dietParser, parser, resolver, checker, | 101 tasks = [scanner, dietParser, parser, resolver, checker, |
| 100 builder, optimizer, generator, | 102 builder, optimizer, generator, |
| 101 emitter, compileTimeConstantHandler]; | 103 emitter, compileTimeConstantHandler, nativeHandler]; |
| 102 } | 104 } |
| 103 | 105 |
| 104 void ensure(bool condition) { | 106 void ensure(bool condition) { |
| 105 if (!condition) cancel('failed assertion in leg'); | 107 if (!condition) cancel('failed assertion in leg'); |
| 106 } | 108 } |
| 107 | 109 |
| 108 void unimplemented(String methodName, | 110 void unimplemented(String methodName, |
| 109 [Node node, Token token, HInstruction instruction, | 111 [Node node, Token token, HInstruction instruction, |
| 110 Element element]) { | 112 Element element]) { |
| 111 cancel("$methodName not implemented", node, token, instruction, element); | 113 cancel("$methodName not implemented", node, token, instruction, element); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 } | 246 } |
| 245 } | 247 } |
| 246 } | 248 } |
| 247 } | 249 } |
| 248 } | 250 } |
| 249 } | 251 } |
| 250 | 252 |
| 251 void runCompiler(Script script) { | 253 void runCompiler(Script script) { |
| 252 scanBuiltinLibraries(); | 254 scanBuiltinLibraries(); |
| 253 mainApp = new LibraryElement(script); | 255 mainApp = new LibraryElement(script); |
| 254 native.checkNativeSupport(this, mainApp, null); | 256 nativeHandler.checkNativeSupport(mainApp, null); |
| 255 | 257 |
| 256 Element element; | 258 Element element; |
| 257 withCurrentElement(mainApp, () { | 259 withCurrentElement(mainApp, () { |
| 258 scanner.scan(currentElement); | 260 scanner.scan(currentElement); |
| 259 element = mainApp.find(MAIN); | 261 element = mainApp.find(MAIN); |
| 260 if (element === null) cancel('Could not find $MAIN'); | 262 if (element === null) cancel('Could not find $MAIN'); |
| 261 }); | 263 }); |
| 262 worklist.add(new WorkItem.toCompile(element)); | 264 worklist.add(new WorkItem.toCompile(element)); |
| 263 do { | 265 do { |
| 264 while (!worklist.isEmpty()) { | 266 while (!worklist.isEmpty()) { |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 | 401 |
| 400 class CompilerCancelledException implements Exception { | 402 class CompilerCancelledException implements Exception { |
| 401 final String reason; | 403 final String reason; |
| 402 CompilerCancelledException(this.reason); | 404 CompilerCancelledException(this.reason); |
| 403 | 405 |
| 404 String toString() { | 406 String toString() { |
| 405 String banner = 'compiler cancelled'; | 407 String banner = 'compiler cancelled'; |
| 406 return (reason !== null) ? '$banner: $reason' : '$banner'; | 408 return (reason !== null) ? '$banner: $reason' : '$banner'; |
| 407 } | 409 } |
| 408 } | 410 } |
| OLD | NEW |