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

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

Issue 1311403003: dart2js cps: Track existence of try statements in resolution instead of traversing AST/IR nodes to … (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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
Index: pkg/compiler/lib/src/cps_ir/type_propagation.dart
diff --git a/pkg/compiler/lib/src/cps_ir/type_propagation.dart b/pkg/compiler/lib/src/cps_ir/type_propagation.dart
index 1ac163ee538b0732f31819e3dfb1f7c485a61acb..2a0d840284bf713eb529c522757b8a1ebc00e30e 100644
--- a/pkg/compiler/lib/src/cps_ir/type_propagation.dart
+++ b/pkg/compiler/lib/src/cps_ir/type_propagation.dart
@@ -1645,6 +1645,11 @@ class TransformingVisitor extends LeafVisitor {
Selector targetSelector = new Selector.fromElement(functionElement);
if (call.callStructure != targetSelector.callStructure) return false;
+ // Don't inline if [target] contains try-catch or try-finally. JavaScript
+ // engines typically do poor optimization of the entire function containing
+ // the 'try'.
+ if (functionElement.resolvedAst.elements.containsTryStatement) return false;
+
FunctionDefinition target =
functionCompiler.compileToCpsIR(functionElement);
@@ -1662,11 +1667,6 @@ class TransformingVisitor extends LeafVisitor {
return false;
}
- // Don't inline if [target] contains try-catch or try-finally. JavaScript
- // engines typically do poor optimization of the entire function containing
- // the 'try'.
- if (ContainsTry.analyze(target)) return false;
-
node.receiver.definition.substituteFor(target.thisParameter);
for (int i = 0; i < node.arguments.length; ++i) {
node.arguments[i].definition.substituteFor(target.parameters[i]);
@@ -1850,9 +1850,8 @@ class TransformingVisitor extends LeafVisitor {
ast.Statement body = node.target.node.body;
bool shouldInline() {
- if (backend.annotations.noInline(node.target)) {
- return false;
- }
+ if (backend.annotations.noInline(node.target)) return false;
+ if (node.target.resolvedAst.elementd.containsTryStatement) return false;
Kevin Millikin (Google) 2015/09/07 09:11:17 Typo: elementd ==> elements.
// Inline functions that are a single return statement, expression
// statement, or block containing a return statement or expression
@@ -2875,25 +2874,3 @@ class ResetAnalysisInfo extends RecursiveVisitor {
values.remove(node.variable);
}
}
-
-
-class ContainsTry extends RecursiveVisitor {
- bool _found = false;
- ContainsTry._();
-
- /// Scans [root] for evidence of try-catch and try-finally.
- static bool analyze(Node root) {
- ContainsTry visitor = new ContainsTry._();
- visitor.visit(root);
- return visitor._found;
- }
-
- visit(Node node) {
- if (_found) return; // Early exit if we know the answer.
- super.visit(node);
- }
-
- processLetHandler(LetHandler node) {
- _found = true;
- }
-}
« no previous file with comments | « no previous file | pkg/compiler/lib/src/resolution/members.dart » ('j') | pkg/compiler/lib/src/resolution/members.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698