diff options
author | Paul Phillips <paulp@improving.org> | 2011-07-04 20:40:05 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-07-04 20:40:05 +0000 |
commit | 257a7e65deb01c9e161c83ea5fd7a2b3c862e5e1 (patch) | |
tree | bccde9a93d807606c604ba898968316ff61fbaf5 /src/compiler/scala/tools/nsc/backend/icode/analysis/ReachingDefinitions.scala | |
parent | 9e7d7e021cd49851257aca44b81e20427d886529 (diff) | |
download | scala-257a7e65deb01c9e161c83ea5fd7a2b3c862e5e1.tar.gz scala-257a7e65deb01c9e161c83ea5fd7a2b3c862e5e1.tar.bz2 scala-257a7e65deb01c9e161c83ea5fd7a2b3c862e5e1.zip |
Fixed a bug in the optimizer which was preventi...
Fixed a bug in the optimizer which was preventing private methods from
being inlined. Also relaxes a condition related to the "liftedTry"
problem: the inliner has to exclude certain methods from consideration
if there is a value on the stack and the method being inlined has
exception handlers. The new condition is as before, except that it does
not exclude methods of the "try/finally" variety (i.e. finalizers, but
no other exception handlers.) This is necessary to optimize this common
pattern:
@inline private def foo(body: => Unit) {
val saved = something
try body
finally something = saved
}
The closure for "body" can be fully eliminated, but only if the contents
of foo can be inlined into the caller.
Closes #4764, review by rompf.
Diffstat (limited to 'src/compiler/scala/tools/nsc/backend/icode/analysis/ReachingDefinitions.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/icode/analysis/ReachingDefinitions.scala | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/ReachingDefinitions.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/ReachingDefinitions.scala index 31a2dbfbec..cc4619c68f 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/analysis/ReachingDefinitions.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/ReachingDefinitions.scala @@ -241,12 +241,10 @@ abstract class ReachingDefinitions { findDefs(bb, idx, m, 0) override def toString: String = { - val sb = new StringBuilder - sb.append("rdef: \n") - for (b <- method.code.blocks) - sb.append("rdef_entry(" + b + ")= " + in(b)).append("\nrdef_exit(" + b + ")= " + out(b)) - sb.toString() + method.code.blocks map { b => + " entry(%s) = %s\n".format(b, in(b)) + + " exit(%s) = %s\n".format(b, out(b)) + } mkString ("ReachingDefinitions {\n", "\n", "\n}") } - } } |