Chromium Code Reviews| 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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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. The throw sequence is b | |
|
Siggi Cherem (dart-lang)
2016/01/14 22:50:51
end sentence?
| |
| 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 Loading... | |
| 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 } |
| OLD | NEW |