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

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

Issue 1587053003: Don't inline methods that only throw. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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/language/language_dart2js.status » ('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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 // targets containing a try statement. 365 // targets containing a try statement.
366 if (!target.hasNode) return null; 366 if (!target.hasNode) return null;
367 if (target.asyncMarker != AsyncMarker.SYNC) return null; 367 if (target.asyncMarker != AsyncMarker.SYNC) return null;
368 // V8 does not optimize functions containing a try statement. Inlining 368 // V8 does not optimize functions containing a try statement. Inlining
369 // code containing a try statement will make the optimizable calling code 369 // code containing a try statement will make the optimizable calling code
370 // become unoptimizable. 370 // become unoptimizable.
371 if (target.resolvedAst.elements.containsTryStatement) { 371 if (target.resolvedAst.elements.containsTryStatement) {
372 return null; 372 return null;
373 } 373 }
374 374
375 // Don't inline methods that never return. They are usually helper functions
376 // that throw an exception.
377 if (invoke.type.isEmpty && !invoke.type.isNullable) {
378 // TODO(sra): It would be ok to inline if doing so was shrinking.
379 return null;
380 }
381
375 Reference<Primitive> dartReceiver = invoke.dartReceiverReference; 382 Reference<Primitive> dartReceiver = invoke.dartReceiverReference;
376 TypeMask abstractReceiver = 383 TypeMask abstractReceiver =
377 dartReceiver == null ? null : abstractType(dartReceiver); 384 dartReceiver == null ? null : abstractType(dartReceiver);
378 // The receiver is non-null in a method body, unless the receiver is known 385 // The receiver is non-null in a method body, unless the receiver is known
379 // to be `null` (isEmpty covers `null` and unreachable). 386 // to be `null` (isEmpty covers `null` and unreachable).
380 TypeMask abstractReceiverInMethod = abstractReceiver == null 387 TypeMask abstractReceiverInMethod = abstractReceiver == null
381 ? null 388 ? null
382 : abstractReceiver.isEmpty 389 : abstractReceiver.isEmpty
383 ? abstractReceiver 390 ? abstractReceiver
384 : abstractReceiver.nonNullable(); 391 : abstractReceiver.nonNullable();
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 // We cannot inline a constructor invocation containing type arguments 534 // We cannot inline a constructor invocation containing type arguments
528 // because CreateInstance in the body does not know the type arguments. 535 // because CreateInstance in the body does not know the type arguments.
529 // We would incorrectly instantiate a class like A instead of A<B>. 536 // We would incorrectly instantiate a class like A instead of A<B>.
530 // TODO(kmillikin): try to fix this. 537 // TODO(kmillikin): try to fix this.
531 GenericType generic = node.dartType; 538 GenericType generic = node.dartType;
532 if (generic.typeArguments.any((DartType t) => !t.isDynamic)) return null; 539 if (generic.typeArguments.any((DartType t) => !t.isDynamic)) return null;
533 } 540 }
534 return tryInlining(node, node.target, null); 541 return tryInlining(node, node.target, null);
535 } 542 }
536 } 543 }
OLDNEW
« no previous file with comments | « no previous file | tests/language/language_dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698