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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 // | 387 // |
388 // The [Primitive] representing the result of the inlined call is returned | 388 // The [Primitive] representing the result of the inlined call is returned |
389 // if the call was inlined, and the inlined function body is available in | 389 // if the call was inlined, and the inlined function body is available in |
390 // [_fragment]. If the call was not inlined, null is returned. | 390 // [_fragment]. If the call was not inlined, null is returned. |
391 Primitive tryInlining(InvocationPrimitive invoke, FunctionElement target, | 391 Primitive tryInlining(InvocationPrimitive invoke, FunctionElement target, |
392 CallStructure callStructure) { | 392 CallStructure callStructure) { |
393 // Quick checks: do not inline or even cache calls to targets without an | 393 // Quick checks: do not inline or even cache calls to targets without an |
394 // AST node, targets that are asynchronous or generator functions, or | 394 // AST node, targets that are asynchronous or generator functions, or |
395 // targets containing a try statement. | 395 // targets containing a try statement. |
396 if (!target.hasNode) return null; | 396 if (!target.hasNode) return null; |
| 397 if (backend.isJsInterop(target)) return null; |
397 if (target.asyncMarker != AsyncMarker.SYNC) return null; | 398 if (target.asyncMarker != AsyncMarker.SYNC) return null; |
398 // V8 does not optimize functions containing a try statement. Inlining | 399 // V8 does not optimize functions containing a try statement. Inlining |
399 // code containing a try statement will make the optimizable calling code | 400 // code containing a try statement will make the optimizable calling code |
400 // become unoptimizable. | 401 // become unoptimizable. |
401 if (target.resolvedAst.elements.containsTryStatement) { | 402 if (target.resolvedAst.elements.containsTryStatement) { |
402 return null; | 403 return null; |
403 } | 404 } |
404 | 405 |
405 // Don't inline methods that never return. They are usually helper functions | 406 // Don't inline methods that never return. They are usually helper functions |
406 // that throw an exception. | 407 // that throw an exception. |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 if (target.isOperator && | 593 if (target.isOperator && |
593 (enclosingClass == backend.helpers.jsNumberClass || | 594 (enclosingClass == backend.helpers.jsNumberClass || |
594 enclosingClass == backend.helpers.jsDoubleClass || | 595 enclosingClass == backend.helpers.jsDoubleClass || |
595 enclosingClass == backend.helpers.jsIntClass)) { | 596 enclosingClass == backend.helpers.jsIntClass)) { |
596 // These should be handled by operator specialization. | 597 // These should be handled by operator specialization. |
597 return true; | 598 return true; |
598 } | 599 } |
599 return false; | 600 return false; |
600 } | 601 } |
601 } | 602 } |
OLD | NEW |