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 glue = new Glue(compiler); | 55 glue = new Glue(compiler); |
56 | 56 |
57 String get name => 'CPS Ir pipeline'; | 57 String get name => 'CPS Ir pipeline'; |
58 | 58 |
59 /// Generates JavaScript code for `work.element`. | 59 /// Generates JavaScript code for `work.element`. |
60 js.Fun compile(CodegenWorkItem work) { | 60 js.Fun compile(CodegenWorkItem work) { |
61 AstElement element = work.element; | 61 AstElement element = work.element; |
62 JavaScriptBackend backend = compiler.backend; | 62 JavaScriptBackend backend = compiler.backend; |
63 return compiler.withCurrentElement(element, () { | 63 return compiler.withCurrentElement(element, () { |
64 try { | 64 try { |
65 ClassElement cls = element.enclosingClass; | |
66 String name = element.name; | |
67 String className = cls == null ? null : cls.name; | |
68 LibraryElement library = element.library; | |
69 String libraryName = library == null ? null : library.toString(); | |
70 // TODO(karlklose): remove this fallback. | 65 // TODO(karlklose): remove this fallback. |
71 // Fallback for a few functions that we know require try-finally and | 66 // Fallback for a few functions that we know require try-finally and |
72 // switch. | 67 // switch. |
73 if (element.isNative || | 68 if (element.isNative) { |
74 element.isPatched || | |
75 libraryName == 'origin library(dart:typed_data)') { | |
76 compiler.log('Using SSA compiler for platform element $element'); | 69 compiler.log('Using SSA compiler for platform element $element'); |
77 return fallbackCompiler.compile(work); | 70 return fallbackCompiler.compile(work); |
78 } | 71 } |
79 | 72 |
80 if (tracer != null) { | 73 if (tracer != null) { |
81 tracer.traceCompilation(element.name, null); | 74 tracer.traceCompilation(element.name, null); |
82 } | 75 } |
83 cps.FunctionDefinition cpsFunction = compileToCpsIR(element); | 76 cps.FunctionDefinition cpsFunction = compileToCpsIR(element); |
84 cpsFunction = optimizeCpsIR(cpsFunction); | 77 cpsFunction = optimizeCpsIR(cpsFunction); |
85 tree_ir.FunctionDefinition treeFunction = compileToTreeIR(cpsFunction); | 78 tree_ir.FunctionDefinition treeFunction = compileToTreeIR(cpsFunction); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 // TODO(sigurdm): Make a better list of tasks. | 220 // TODO(sigurdm): Make a better list of tasks. |
228 return <CompilerTask>[irBuilderTask]..addAll(fallbackCompiler.tasks); | 221 return <CompilerTask>[irBuilderTask]..addAll(fallbackCompiler.tasks); |
229 } | 222 } |
230 | 223 |
231 js.Node attachPosition(js.Node node, AstElement element) { | 224 js.Node attachPosition(js.Node node, AstElement element) { |
232 return node.withSourceInformation( | 225 return node.withSourceInformation( |
233 sourceInformationFactory.createBuilderForContext(element) | 226 sourceInformationFactory.createBuilderForContext(element) |
234 .buildDeclaration(element)); | 227 .buildDeclaration(element)); |
235 } | 228 } |
236 } | 229 } |
OLD | NEW |