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

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

Issue 17580016: Limit the amount of inlining we do to try to avoid generating too much code. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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: 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 a6a779ad4be04cacabe5f64f1e547eada7db41b8..3b3c999d1d2e732bcbf8c4915cff5762478baca3 100644
--- a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
+++ b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
@@ -53,7 +53,6 @@ class SsaBuilderTask extends CompilerTask {
assert(graph.isValid());
if (!identical(kind, ElementKind.FIELD)) {
FunctionElement function = element;
- graph.calledInLoop = compiler.world.isCalledInLoop(function);
FunctionSignature signature = function.computeSignature(compiler);
signature.forEachOptionalParameter((Element parameter) {
// This ensures the default value will be computed.
@@ -932,10 +931,14 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
static const MAX_INLINING_DEPTH = 3;
static const MAX_INLINING_NODES = 46;
+
List<InliningState> inliningStack;
+
Element returnElement;
DartType returnType;
+
bool inTryStatement = false;
+ int loopNesting = 0;
HBasicBlock get current => _current;
void set current(c) {
@@ -1002,6 +1005,7 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
*/
HGraph buildMethod(FunctionElement functionElement) {
assert(invariant(functionElement, functionElement.isImplementation));
+ graph.calledInLoop = compiler.world.isCalledInLoop(functionElement);
FunctionExpression function = functionElement.parseNode(compiler);
assert(function != null);
assert(!function.modifiers.isExternal());
@@ -1222,7 +1226,10 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
// connected-component of the deferred library.
if (compiler.deferredLoadTask.isDeferred(element)) return false;
if (compiler.disableInlining) return false;
- if (inliningStack.length > MAX_INLINING_DEPTH) return false;
+
+ if (loopNesting == 0 && !graph.calledInLoop) return false;
+ int maxDepth = (loopNesting > 0) ? MAX_INLINING_DEPTH : 1;
+ if (inliningStack.length >= maxDepth) return false;
// Ensure that [element] is an implementation element.
element = element.implementation;
@@ -2099,6 +2106,7 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
new SubExpression(initializerBlock, current);
}
+ loopNesting++;
JumpHandler jumpHandler = beginLoopHeader(loop);
HLoopInformation loopInfo = current.loopInformation;
HBasicBlock conditionBlock = current;
@@ -2258,6 +2266,7 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
}
}
jumpHandler.close();
+ loopNesting--;
}
visitFor(For node) {
@@ -2312,6 +2321,7 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
assert(isReachable);
LocalsHandler savedLocals = new LocalsHandler.from(localsHandler);
localsHandler.startLoop(node);
+ loopNesting++;
JumpHandler jumpHandler = beginLoopHeader(node);
HLoopInformation loopInfo = current.loopInformation;
HBasicBlock loopEntryBlock = current;
@@ -2437,6 +2447,7 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
}
}
jumpHandler.close();
+ loopNesting--;
}
visitFunctionExpression(FunctionExpression node) {
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/enqueue.dart ('k') | sdk/lib/_internal/compiler/implementation/ssa/codegen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698