| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 /// Generate code using the cps-based IR pipeline. | 5 /// Generate code using the cps-based IR pipeline. |
| 6 library code_generator_task; | 6 library code_generator_task; |
| 7 | 7 |
| 8 import 'glue.dart'; | 8 import 'glue.dart'; |
| 9 import 'codegen.dart'; | 9 import 'codegen.dart'; |
| 10 import 'unsugar.dart'; | 10 import 'unsugar.dart'; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 | 55 |
| 56 String get name => 'CPS Ir pipeline'; | 56 String get name => 'CPS Ir pipeline'; |
| 57 | 57 |
| 58 /// Generates JavaScript code for `work.element`. First tries to use the | 58 /// Generates JavaScript code for `work.element`. First tries to use the |
| 59 /// Cps Ir -> tree ir -> js pipeline, and if that fails due to language | 59 /// Cps Ir -> tree ir -> js pipeline, and if that fails due to language |
| 60 /// features not implemented it will fall back to the ssa pipeline (for | 60 /// features not implemented it will fall back to the ssa pipeline (for |
| 61 /// platform code) or will cancel compilation (for user code). | 61 /// platform code) or will cancel compilation (for user code). |
| 62 js.Fun compile(CodegenWorkItem work) { | 62 js.Fun compile(CodegenWorkItem work) { |
| 63 types = new TypeMaskSystem(compiler); | 63 types = new TypeMaskSystem(compiler); |
| 64 AstElement element = work.element; | 64 AstElement element = work.element; |
| 65 JavaScriptBackend backend = compiler.backend; |
| 65 return compiler.withCurrentElement(element, () { | 66 return compiler.withCurrentElement(element, () { |
| 66 if (element.library.isPlatformLibrary) { | 67 if (element.library.isPlatformLibrary || |
| 68 element.library == backend.interceptorsLibrary) { |
| 67 compiler.log('Using SSA compiler for platform element $element'); | 69 compiler.log('Using SSA compiler for platform element $element'); |
| 68 return fallbackCompiler.compile(work); | 70 return fallbackCompiler.compile(work); |
| 69 } | 71 } |
| 70 try { | 72 try { |
| 71 if (tracer != null) { | 73 if (tracer != null) { |
| 72 tracer.traceCompilation(element.name, null); | 74 tracer.traceCompilation(element.name, null); |
| 73 } | 75 } |
| 74 cps.FunctionDefinition cpsFunction = compileToCpsIR(element); | 76 cps.FunctionDefinition cpsFunction = compileToCpsIR(element); |
| 75 cpsFunction = optimizeCpsIR(cpsFunction); | 77 cpsFunction = optimizeCpsIR(cpsFunction); |
| 76 tree_ir.FunctionDefinition treeFunction = compileToTreeIR(cpsFunction); | 78 tree_ir.FunctionDefinition treeFunction = compileToTreeIR(cpsFunction); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 endSourcePosition = | 228 endSourcePosition = |
| 227 new TokenSourceFileLocation(sourceFile, endToken, name); | 229 new TokenSourceFileLocation(sourceFile, endToken, name); |
| 228 } | 230 } |
| 229 return node.withPosition(sourcePosition, endSourcePosition); | 231 return node.withPosition(sourcePosition, endSourcePosition); |
| 230 } | 232 } |
| 231 | 233 |
| 232 SourceFile sourceFileOfElement(Element element) { | 234 SourceFile sourceFileOfElement(Element element) { |
| 233 return element.implementation.compilationUnit.script.file; | 235 return element.implementation.compilationUnit.script.file; |
| 234 } | 236 } |
| 235 } | 237 } |
| OLD | NEW |