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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 ClassElement cls = element.enclosingClass; | 65 ClassElement cls = element.enclosingClass; |
66 String name = element.name; | 66 String name = element.name; |
67 String className = cls == null ? null : cls.name; | 67 String className = cls == null ? null : cls.name; |
68 LibraryElement library = element.library; | 68 LibraryElement library = element.library; |
69 String libraryName = library == null ? null : library.toString(); | 69 String libraryName = library == null ? null : library.toString(); |
70 // TODO(karlklose): remove this fallback. | 70 // TODO(karlklose): remove this fallback. |
71 // Fallback for a few functions that we know require try-finally and | 71 // Fallback for a few functions that we know require try-finally and |
72 // switch. | 72 // switch. |
73 if (element.isNative || | 73 if (element.isNative || |
74 element.isPatched || | 74 element.isPatched || |
75 libraryName == 'origin library(dart:typed_data)' || | 75 libraryName == 'origin library(dart:typed_data)') { |
76 // Using switch or try-finally. | |
77 library.isInternalLibrary && name == 'unwrapException' || | |
78 library.isPlatformLibrary && className == 'IterableBase' || | |
79 library.isInternalLibrary && className == 'Closure' || | |
80 libraryName == 'origin library(dart:collection)' && | |
81 name == 'mapToString' || | |
82 libraryName == 'library(dart:html)' && name == 'sanitizeNode' || | |
83 className == '_IsolateContext' || | |
84 className == 'IsolateNatives' || | |
85 className == '_Deserializer' || | |
86 name == '_rootRun' || | |
87 name == '_microtaskLoopEntry') { | |
88 compiler.log('Using SSA compiler for platform element $element'); | 76 compiler.log('Using SSA compiler for platform element $element'); |
89 return fallbackCompiler.compile(work); | 77 return fallbackCompiler.compile(work); |
90 } | 78 } |
91 | 79 |
92 if (tracer != null) { | 80 if (tracer != null) { |
93 tracer.traceCompilation(element.name, null); | 81 tracer.traceCompilation(element.name, null); |
94 } | 82 } |
95 cps.FunctionDefinition cpsFunction = compileToCpsIR(element); | 83 cps.FunctionDefinition cpsFunction = compileToCpsIR(element); |
96 cpsFunction = optimizeCpsIR(cpsFunction); | 84 cpsFunction = optimizeCpsIR(cpsFunction); |
97 tree_ir.FunctionDefinition treeFunction = compileToTreeIR(cpsFunction); | 85 tree_ir.FunctionDefinition treeFunction = compileToTreeIR(cpsFunction); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 // TODO(sigurdm): Make a better list of tasks. | 222 // TODO(sigurdm): Make a better list of tasks. |
235 return <CompilerTask>[irBuilderTask]..addAll(fallbackCompiler.tasks); | 223 return <CompilerTask>[irBuilderTask]..addAll(fallbackCompiler.tasks); |
236 } | 224 } |
237 | 225 |
238 js.Node attachPosition(js.Node node, AstElement element) { | 226 js.Node attachPosition(js.Node node, AstElement element) { |
239 return node.withSourceInformation( | 227 return node.withSourceInformation( |
240 sourceInformationFactory.createBuilderForContext(element) | 228 sourceInformationFactory.createBuilderForContext(element) |
241 .buildDeclaration(element)); | 229 .buildDeclaration(element)); |
242 } | 230 } |
243 } | 231 } |
OLD | NEW |