OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library cps_ir.optimization.inline; | 5 library cps_ir.optimization.inline; |
6 | 6 |
7 import 'cps_fragment.dart'; | 7 import 'cps_fragment.dart'; |
8 import 'cps_ir_builder.dart' show ThisParameterLocal; | 8 import 'cps_ir_builder.dart' show ThisParameterLocal; |
9 import 'cps_ir_nodes.dart'; | 9 import 'cps_ir_nodes.dart'; |
10 import 'optimizers.dart'; | 10 import 'optimizers.dart'; |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 | 178 |
179 final CpsFunctionCompiler functionCompiler; | 179 final CpsFunctionCompiler functionCompiler; |
180 | 180 |
181 final InliningCache cache = new InliningCache(); | 181 final InliningCache cache = new InliningCache(); |
182 | 182 |
183 final List<StackEntry> stack = <StackEntry>[]; | 183 final List<StackEntry> stack = <StackEntry>[]; |
184 | 184 |
185 Inliner(this.functionCompiler); | 185 Inliner(this.functionCompiler); |
186 | 186 |
187 bool isCalledOnce(Element element) { | 187 bool isCalledOnce(Element element) { |
| 188 if (element is ConstructorBodyElement) { |
| 189 ClassElement class_ = element.enclosingClass; |
| 190 return !functionCompiler.compiler.world.hasAnyStrictSubclass(class_) && |
| 191 class_.constructors.tail?.isEmpty ?? false; |
| 192 } |
188 return functionCompiler.compiler.typesTask.typesInferrer.isCalledOnce( | 193 return functionCompiler.compiler.typesTask.typesInferrer.isCalledOnce( |
189 element); | 194 element); |
190 } | 195 } |
191 | 196 |
192 void rewrite(FunctionDefinition node, [CallStructure callStructure]) { | 197 void rewrite(FunctionDefinition node, [CallStructure callStructure]) { |
193 ExecutableElement function = node.element; | 198 ExecutableElement function = node.element; |
194 | 199 |
195 // Inlining in asynchronous or generator functions is disabled. Inlining | 200 // Inlining in asynchronous or generator functions is disabled. Inlining |
196 // triggers a bug in the async rewriter. | 201 // triggers a bug in the async rewriter. |
197 // TODO(kmillikin): Fix the bug and eliminate this restriction if it makes | 202 // TODO(kmillikin): Fix the bug and eliminate this restriction if it makes |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 (enclosingClass == backend.helpers.jsNumberClass || | 615 (enclosingClass == backend.helpers.jsNumberClass || |
611 enclosingClass == backend.helpers.jsDoubleClass || | 616 enclosingClass == backend.helpers.jsDoubleClass || |
612 enclosingClass == backend.helpers.jsIntClass)) { | 617 enclosingClass == backend.helpers.jsIntClass)) { |
613 // These should be handled by operator specialization. | 618 // These should be handled by operator specialization. |
614 return true; | 619 return true; |
615 } | 620 } |
616 if (target == backend.helpers.stringInterpolationHelper) return true; | 621 if (target == backend.helpers.stringInterpolationHelper) return true; |
617 return false; | 622 return false; |
618 } | 623 } |
619 } | 624 } |
OLD | NEW |