| 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 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 if (target.asyncMarker != AsyncMarker.SYNC) return null; | 424 if (target.asyncMarker != AsyncMarker.SYNC) return null; |
| 425 // V8 does not optimize functions containing a try statement. Inlining | 425 // V8 does not optimize functions containing a try statement. Inlining |
| 426 // code containing a try statement will make the optimizable calling code | 426 // code containing a try statement will make the optimizable calling code |
| 427 // become unoptimizable. | 427 // become unoptimizable. |
| 428 if (target.resolvedAst.elements.containsTryStatement) { | 428 if (target.resolvedAst.elements.containsTryStatement) { |
| 429 return null; | 429 return null; |
| 430 } | 430 } |
| 431 | 431 |
| 432 // Don't inline methods that never return. They are usually helper functions | 432 // Don't inline methods that never return. They are usually helper functions |
| 433 // that throw an exception. | 433 // that throw an exception. |
| 434 if (invoke.type.isEmpty && !invoke.type.isNullable) { | 434 if (invoke.type.isEmpty) { |
| 435 // TODO(sra): It would be ok to inline if doing so was shrinking. | 435 // TODO(sra): It would be ok to inline if doing so was shrinking. |
| 436 return null; | 436 return null; |
| 437 } | 437 } |
| 438 | 438 |
| 439 if (isBlacklisted(target)) return null; | 439 if (isBlacklisted(target)) return null; |
| 440 | 440 |
| 441 if (invoke.callingConvention == CallingConvention.OneShotIntercepted) { | 441 if (invoke.callingConvention == CallingConvention.OneShotIntercepted) { |
| 442 // One-shot interceptor calls with a known target are only inserted on | 442 // One-shot interceptor calls with a known target are only inserted on |
| 443 // uncommon code paths, so they should not be inlined. | 443 // uncommon code paths, so they should not be inlined. |
| 444 return null; | 444 return null; |
| 445 } | 445 } |
| 446 | 446 |
| 447 Reference<Primitive> dartReceiver = invoke.dartReceiverRef; | 447 Reference<Primitive> dartReceiver = invoke.dartReceiverRef; |
| 448 TypeMask abstractReceiver = | 448 TypeMask abstractReceiver = |
| 449 dartReceiver == null ? null : abstractType(dartReceiver); | 449 dartReceiver == null ? null : abstractType(dartReceiver); |
| 450 // The receiver is non-null in a method body, unless the receiver is known | 450 // The receiver is non-null in a method body, unless the receiver is known |
| 451 // to be `null` (isEmpty covers `null` and unreachable). | 451 // to be `null` (isEmpty covers `null` and unreachable). |
| 452 TypeMask abstractReceiverInMethod = abstractReceiver == null | 452 TypeMask abstractReceiverInMethod = abstractReceiver == null |
| 453 ? null | 453 ? null |
| 454 : abstractReceiver.isEmpty | 454 : abstractReceiver.isEmptyOrNull |
| 455 ? abstractReceiver | 455 ? abstractReceiver |
| 456 : abstractReceiver.nonNullable(); | 456 : abstractReceiver.nonNullable(); |
| 457 List<TypeMask> abstractArguments = | 457 List<TypeMask> abstractArguments = |
| 458 invoke.argumentRefs.map(abstractType).toList(); | 458 invoke.argumentRefs.map(abstractType).toList(); |
| 459 var cachedResult = _inliner.cache.get(target, callStructure, | 459 var cachedResult = _inliner.cache.get(target, callStructure, |
| 460 abstractReceiverInMethod, | 460 abstractReceiverInMethod, |
| 461 abstractArguments); | 461 abstractArguments); |
| 462 | 462 |
| 463 // Negative inlining result in the cache. | 463 // Negative inlining result in the cache. |
| 464 if (cachedResult == InliningCache.NO_INLINE) return null; | 464 if (cachedResult == InliningCache.NO_INLINE) return null; |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 (enclosingClass == backend.helpers.jsNumberClass || | 619 (enclosingClass == backend.helpers.jsNumberClass || |
| 620 enclosingClass == backend.helpers.jsDoubleClass || | 620 enclosingClass == backend.helpers.jsDoubleClass || |
| 621 enclosingClass == backend.helpers.jsIntClass)) { | 621 enclosingClass == backend.helpers.jsIntClass)) { |
| 622 // These should be handled by operator specialization. | 622 // These should be handled by operator specialization. |
| 623 return true; | 623 return true; |
| 624 } | 624 } |
| 625 if (target == backend.helpers.stringInterpolationHelper) return true; | 625 if (target == backend.helpers.stringInterpolationHelper) return true; |
| 626 return false; | 626 return false; |
| 627 } | 627 } |
| 628 } | 628 } |
| OLD | NEW |