summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/backend/jvm/opt/Inliner.scala
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@gmail.com>2015-09-16 14:59:27 +0200
committerLukas Rytz <lukas.rytz@gmail.com>2015-09-17 22:05:06 +0200
commitc7112d997452fc6d0e7c69a1fec4928bd6c072ad (patch)
tree8f18d76efa6a84a5392a795aafb8203fb1fd5186 /src/compiler/scala/tools/nsc/backend/jvm/opt/Inliner.scala
parent0e2c23a34654da667c6a6c88149b090307bdb2ba (diff)
downloadscala-c7112d997452fc6d0e7c69a1fec4928bd6c072ad.tar.gz
scala-c7112d997452fc6d0e7c69a1fec4928bd6c072ad.tar.bz2
scala-c7112d997452fc6d0e7c69a1fec4928bd6c072ad.zip
Avoid running data flow analyses on very large methods
Data flow analyses take a long time to converge (many seconds) when analyzing large methods. This commit prevents running analyses that would take too long. This means for example that callsites in very large methods are not added to the call graph and will therefore not be inlined.
Diffstat (limited to 'src/compiler/scala/tools/nsc/backend/jvm/opt/Inliner.scala')
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/opt/Inliner.scala4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/opt/Inliner.scala b/src/compiler/scala/tools/nsc/backend/jvm/opt/Inliner.scala
index 4c36377128..54f1b99876 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/opt/Inliner.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/opt/Inliner.scala
@@ -143,6 +143,8 @@ class Inliner[BT <: BTypes](val btypes: BT) {
// VerifyError. We run a `SourceInterpreter` to find all producer instructions of the
// receiver value and add a cast to the self type after each.
if (!selfTypeOk) {
+ // We don't need to worry about the method being too large for running an analysis.
+ // Callsites of large methods are not added to the call graph.
localOpt.minimalRemoveUnreachableCode(callsite.callsiteMethod, callsite.callsiteClass.internalName)
val analyzer = new AsmAnalyzer(callsite.callsiteMethod, callsite.callsiteClass.internalName, new Analyzer(new SourceInterpreter))
val receiverValue = analyzer.frameAt(callsite.callsiteInstruction).peekStack(traitMethodArgumentTypes.length)
@@ -367,6 +369,8 @@ class Inliner[BT <: BTypes](val btypes: BT) {
// We run an interpreter to know the stack height at each xRETURN instruction and the sizes
// of the values on the stack.
+ // We don't need to worry about the method being too large for running an analysis. Callsites of
+ // large methods are not added to the call graph.
val analyzer = new AsmAnalyzer(callee, calleeDeclarationClass.internalName)
for (originalReturn <- callee.instructions.iterator().asScala if isReturn(originalReturn)) {