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

Unified Diff: pkg/compiler/lib/src/cps_ir/inline.dart

Issue 1554083002: dart2js: Do not inline when try is seen. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 12 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/cps_ir/inline.dart
diff --git a/pkg/compiler/lib/src/cps_ir/inline.dart b/pkg/compiler/lib/src/cps_ir/inline.dart
index c50b56108f04e1c62df49c82fbb30eb64cedb1e1..42acd2cd6f5373e7e8f05fc0f523887634c23869 100644
--- a/pkg/compiler/lib/src/cps_ir/inline.dart
+++ b/pkg/compiler/lib/src/cps_ir/inline.dart
@@ -166,7 +166,7 @@ class Inliner implements Pass {
}
void rewrite(FunctionDefinition node, [CallStructure callStructure]) {
- Element function = node.element;
+ ExecutableElement function = node.element;
// Inlining in asynchronous or generator functions is disabled. Inlining
// triggers a bug in the async rewriter.
@@ -177,6 +177,13 @@ class Inliner implements Pass {
return;
}
+ // Do not inline in functions containing try statements. V8 does not
+ // optimize code in such functions, so inlining will move optimizable code
+ // into a context where it cannot be optimized.
+ if (function.resolvedAst.elements.containsTryStatement) {
+ return;
+ }
+
stack.add(new StackEntry(function, callStructure));
new InliningVisitor(this).visit(node);
assert(stack.last.match(function, callStructure));
@@ -353,9 +360,16 @@ class InliningVisitor extends TrampolineRecursiveVisitor {
Primitive tryInlining(InvocationPrimitive invoke, FunctionElement target,
CallStructure callStructure) {
// Quick checks: do not inline or even cache calls to targets without an
- // AST node or targets that are asynchronous or generator functions.
+ // AST node, targets that are asynchronous or generator functions, or
+ // targets containing a try statement.
if (!target.hasNode) return null;
if (target.asyncMarker != AsyncMarker.SYNC) return null;
+ // V8 does not optimize functions containing a try statement. Inlining
+ // code containing a try statement will make the optimizable calling code
+ // become unoptimizable.
+ if (target.resolvedAst.elements.containsTryStatement) {
+ return null;
+ }
Reference<Primitive> dartReceiver = invoke.dartReceiverReference;
TypeMask abstractReceiver =
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698