Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Side by Side Diff: pkg/compiler/lib/src/cps_ir/inline.dart

Issue 1779723002: dart2js cps: Inline constructor bodies that are only called once. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Update test expectation Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tests/compiler/dart2js/cps_ir/expected/constructor_9.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | tests/compiler/dart2js/cps_ir/expected/constructor_9.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698