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

Unified Diff: sdk/lib/_internal/compiler/implementation/ssa/builder.dart

Issue 543583002: Add a whitelist for functions that we always want to inline. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove optimizations for ListIterator.moveNext for now. Created 6 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
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/js_backend/backend.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/ssa/builder.dart
diff --git a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
index 06ebf8962cfea79447a88d956b8996545239366c..8565a0f75c465ebbe352ab7570e32f332f3b07dd 100644
--- a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
+++ b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
@@ -1254,6 +1254,13 @@ class SsaBuilder extends ResolvedVisitor {
if (cachedCanBeInlined == true) return cachedCanBeInlined;
+ if (backend.functionsToAlwaysInline.contains(function)) {
+ // Inline this function regardless of it's size.
+ assert(InlineWeeder.canBeInlined(function.node, -1, false,
+ allowLoops: true));
+ return true;
+ }
+
int numParameters = function.functionSignature.parameterCount;
int maxInliningNodes;
bool useMaxInliningNodes = true;
@@ -5994,6 +6001,9 @@ class StringBuilderVisitor extends ast.Visitor {
* This class visits the method that is a candidate for inlining and
* finds whether it is too difficult to inline.
*/
+// TODO(karlklose): refactor to make it possible to distinguish between
+// implementation restrictions (for example, we *can't* inline multiple returns)
+// and heuristics (we *shouldn't* inline large functions).
class InlineWeeder extends ast.Visitor {
// Invariant: *INSIDE_LOOP* > *OUTSIDE_LOOP*
static const INLINING_NODES_OUTSIDE_LOOP = 18;
@@ -6006,14 +6016,18 @@ class InlineWeeder extends ast.Visitor {
int nodeCount = 0;
final int maxInliningNodes;
final bool useMaxInliningNodes;
+ final bool allowLoops;
- InlineWeeder(this.maxInliningNodes, this.useMaxInliningNodes);
+ InlineWeeder(this.maxInliningNodes,
+ this.useMaxInliningNodes,
+ this.allowLoops);
static bool canBeInlined(ast.FunctionExpression functionExpression,
int maxInliningNodes,
- bool useMaxInliningNodes) {
+ bool useMaxInliningNodes,
+ {bool allowLoops: false}) {
InlineWeeder weeder =
- new InlineWeeder(maxInliningNodes, useMaxInliningNodes);
+ new InlineWeeder(maxInliningNodes, useMaxInliningNodes, allowLoops);
weeder.visit(functionExpression.initializers);
weeder.visit(functionExpression.body);
return !weeder.tooDifficult;
@@ -6061,7 +6075,7 @@ class InlineWeeder extends ast.Visitor {
// It's actually not difficult to inline a method with a loop, but
// our measurements show that it's currently better to not inline a
// method that contains a loop.
- tooDifficult = true;
+ if (!allowLoops) tooDifficult = true;
}
void visitRedirectingFactoryBody(ast.RedirectingFactoryBody node) {
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/js_backend/backend.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698