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: pkg/compiler/lib/src/ssa/builder.dart

Issue 1117223002: dart2js: Inline across deferred output units if that leads to reduced size. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 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/ssa/builder.dart
diff --git a/pkg/compiler/lib/src/ssa/builder.dart b/pkg/compiler/lib/src/ssa/builder.dart
index 3c55c53fbf232ae09de1ba053af0b1e2921f0501..c0980beca5a0c5ed1b101bba5a0167bdc77cae7d 100644
--- a/pkg/compiler/lib/src/ssa/builder.dart
+++ b/pkg/compiler/lib/src/ssa/builder.dart
@@ -1293,12 +1293,6 @@ class SsaBuilder extends NewResolvedVisitor {
if (cachedCanBeInlined == false) return false;
bool meetsHardConstraints() {
- // Don't inline from one output unit to another. If something is deferred
- // it is to save space in the loading code.
floitsch 2015/05/04 23:32:58 this comment is incomplete: we must not inline cod
herhut 2015/05/05 14:19:12 I changed it to not inline across deferred imports
- if (!compiler.deferredLoadTask
- .inSameOutputUnit(element,compiler.currentElement)) {
- return false;
- }
if (compiler.disableInlining) return false;
assert(selector != null
@@ -1348,12 +1342,13 @@ class SsaBuilder extends NewResolvedVisitor {
return InlineWeeder.canBeInlined(function, -1, false);
}
// TODO(sra): Measure if inlining would 'reduce' the size. One desirable
- // case we miss my doing nothing is inlining very simple constructors
+ // case we miss by doing nothing is inlining very simple constructors
// where all fields are initialized with values from the arguments at this
// call site. The code is slightly larger (`new Foo(1)` vs `Foo$(1)`) but
// that usually means the factory constructor is left unused and not
// emitted.
- return false;
+ // We at least inline bodies that are empty (and thus have a size of 1).
+ return InlineWeeder.canBeInlined(function, 1, true);
}
bool heuristicSayGoodToGo() {
@@ -1364,7 +1359,14 @@ class SsaBuilder extends NewResolvedVisitor {
if (element.isSynthesized) return true;
- if (inExpressionOfThrow || inLazyInitializerExpression) {
+ // Don't inline from one output unit to another, unless it reduces size.
+ // Similarly do not inline code that is rarely executed.
+ bool fromDifferentOutputUnit = !compiler.deferredLoadTask
+ .inSameOutputUnit(element,compiler.currentElement);
+
+ if (inExpressionOfThrow ||
+ inLazyInitializerExpression ||
+ fromDifferentOutputUnit) {
return reductiveHeuristic();
}
« 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