summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@gmail.com>2015-12-13 09:39:43 +0100
committerLukas Rytz <lukas.rytz@gmail.com>2015-12-13 09:41:50 +0100
commitecbca547ac04ad33d336c0d41e72193a17dcf0ab (patch)
tree0cf0ec829dd6b341a89e89268c333b2b09429c5c /src
parent11614455e71530292c1ed98dc4fbda5efee0b84d (diff)
downloadscala-ecbca547ac04ad33d336c0d41e72193a17dcf0ab.tar.gz
scala-ecbca547ac04ad33d336c0d41e72193a17dcf0ab.tar.bz2
scala-ecbca547ac04ad33d336c0d41e72193a17dcf0ab.zip
Don't run closure optimizer on methods too large for prod-cons
For methods that are too large to run a producers-consumers analysis, don't run the closure optimizer. This is an oversight, all data flow analyses in the backend are guarded by a method size check.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/opt/ClosureOptimizer.scala16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/opt/ClosureOptimizer.scala b/src/compiler/scala/tools/nsc/backend/jvm/opt/ClosureOptimizer.scala
index 4e1e878aa8..61d10eeae9 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/opt/ClosureOptimizer.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/opt/ClosureOptimizer.scala
@@ -79,13 +79,15 @@ class ClosureOptimizer[BT <: BTypes](val btypes: BT) {
val callsitesToRewrite: List[(ClosureInstantiation, List[Either[RewriteClosureApplyToClosureBodyFailed, (MethodInsnNode, Int)]])] = {
closureInstantiations.iterator.flatMap({
case (methodNode, closureInits) =>
- // A lazy val to ensure the analysis only runs if necessary (the value is passed by name to `closureCallsites`)
- // We don't need to worry about the method being too large for running an analysis: large
- // methods are not added to the call graph / closureInstantiations map.
- lazy val prodCons = new ProdConsAnalyzer(methodNode, closureInits.valuesIterator.next().ownerClass.internalName)
- // sorting for bytecode stability (e.g. indices of local vars created during the rewrite)
- val sortedInits = immutable.TreeSet.empty ++ closureInits.values
- sortedInits.iterator.map(init => (init, closureCallsites(init, prodCons))).filter(_._2.nonEmpty)
+ if (!AsmAnalyzer.sizeOKForSourceValue(methodNode)) Nil else {
+ // A lazy val to ensure the analysis only runs if necessary (the value is passed by name to `closureCallsites`)
+ // We don't need to worry about the method being too large for running an analysis: large
+ // methods are not added to the call graph / closureInstantiations map.
+ lazy val prodCons = new ProdConsAnalyzer(methodNode, closureInits.valuesIterator.next().ownerClass.internalName)
+ // sorting for bytecode stability (e.g. indices of local vars created during the rewrite)
+ val sortedInits = immutable.TreeSet.empty ++ closureInits.values
+ sortedInits.iterator.map(init => (init, closureCallsites(init, prodCons))).filter(_._2.nonEmpty)
+ }
}).toList // mapping to a list (not a map) to keep the sorting
}