summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-08-16 07:01:58 -0700
committerPaul Phillips <paulp@improving.org>2012-09-01 20:16:33 -0700
commitd3d195966b4556065d0658e7ed09f38e00eed593 (patch)
tree19804d35f32696679d8059e565b69e46013139ee
parent6b87cdcd7bd6d1932e87e6bf8dc6029d6461a488 (diff)
downloadscala-d3d195966b4556065d0658e7ed09f38e00eed593.tar.gz
scala-d3d195966b4556065d0658e7ed09f38e00eed593.tar.bz2
scala-d3d195966b4556065d0658e7ed09f38e00eed593.zip
Added a heuristic to the inliner.
But it's commented out because I want to get this logging code into 2.10 without including anything "interesting".
-rw-r--r--src/compiler/scala/tools/nsc/backend/opt/Inliners.scala20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala
index 5464b6fc3b..82d44a0e62 100644
--- a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala
+++ b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala
@@ -608,10 +608,11 @@ abstract class Inliners extends SubComponent {
def instructions = m.code.instructions
// def linearized = linearizer linearize m
- def isSmall = (length <= SMALL_METHOD_SIZE) && blocks(0).length < 10
- def isLarge = length > MAX_INLINE_SIZE
- def isRecursive = m.recursive
- def hasHandlers = handlers.nonEmpty || m.bytecodeHasEHs
+ def isSmall = (length <= SMALL_METHOD_SIZE) && blocks(0).length < 10
+ def isLarge = length > MAX_INLINE_SIZE
+ def isRecursive = m.recursive
+ def hasHandlers = handlers.nonEmpty || m.bytecodeHasEHs
+ def hasClosureParam = paramTypes exists (tp => isByNameParamType(tp) || isFunctionType(tp))
def isSynchronized = sym.hasFlag(Flags.SYNCHRONIZED)
def hasNonFinalizerHandler = handlers exists {
@@ -661,9 +662,9 @@ abstract class Inliners extends SubComponent {
*
* TODO handle more robustly the case of a trait var changed at the source-level from public to private[this]
* (eg by having ICodeReader use unpickler, see SI-5442).
-
+
DISABLED
-
+
def potentiallyPublicized(f: Symbol): Boolean = {
(m.sourceFile eq NoSourceFile) && f.name.containsChar('$')
}
@@ -1022,7 +1023,7 @@ abstract class Inliners extends SubComponent {
* - it's bad (useless) to inline inside bridge methods
*/
def isScoreOK: Boolean = {
- debuglog("shouldInline: " + caller.m + " , callee:" + inc.m)
+ debuglog(s"shouldInline: ${caller.m} , callee: ${inc.m}")
var score = 0
@@ -1031,10 +1032,11 @@ abstract class Inliners extends SubComponent {
else if (caller.inlinedCalls < 1) score -= 1 // only monadic methods can trigger the first inline
if (inc.isSmall) score += 1;
+ // if (inc.hasClosureParam) score += 2
if (inc.isLarge) score -= 1;
if (caller.isSmall && isLargeSum) {
score -= 1
- debuglog("shouldInline: score decreased to " + score + " because small " + caller + " would become large")
+ debuglog(s"shouldInline: score decreased to $score because small $caller would become large")
}
if (inc.isMonadic) score += 3
@@ -1043,7 +1045,7 @@ abstract class Inliners extends SubComponent {
if (inc.isInClosure) score += 2;
if (inlinedMethodCount(inc.sym) > 2) score -= 2;
- log("shouldInline(" + inc.m + ") score: " + score)
+ log(s"shouldInline(${inc.m}) score: $score")
score > 0
}