diff options
author | Paul Phillips <paulp@improving.org> | 2011-12-20 14:45:11 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-01-03 10:57:06 -0800 |
commit | 45a26ce3102f54e4f72165aef42fab7f73681c1d (patch) | |
tree | d13f32bce0859bb162d96b844fbdc10a368d1df6 /src/compiler/scala/tools/nsc/backend/opt/InlineExceptionHandlers.scala | |
parent | 471a63a9e6618f25feb3a5266c38ad98ea2a5ac7 (diff) | |
download | scala-45a26ce3102f54e4f72165aef42fab7f73681c1d.tar.gz scala-45a26ce3102f54e4f72165aef42fab7f73681c1d.tar.bz2 scala-45a26ce3102f54e4f72165aef42fab7f73681c1d.zip |
Optimization/robustness in the backend.
Trying to help icode/jvm get through their business a bit faster, and
also make things more robust. Less null, more distinguished objects.
More encapsulation, fewer public vars. Helping updateSuccessorList()
to avoid assembling a list of successors on every call only to find
most of the time that it's the same list it already had (e.g. compiling
quick.lib it says "59076 calls, 690 requiring allocation" rather than
59076 calls, 59076 requiring allocation.)
Diffstat (limited to 'src/compiler/scala/tools/nsc/backend/opt/InlineExceptionHandlers.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/opt/InlineExceptionHandlers.scala | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/opt/InlineExceptionHandlers.scala b/src/compiler/scala/tools/nsc/backend/opt/InlineExceptionHandlers.scala index 1d971beae4..a37a3406a8 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/InlineExceptionHandlers.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/InlineExceptionHandlers.scala @@ -79,7 +79,7 @@ abstract class InlineExceptionHandlers extends SubComponent { /* Type Flow Analysis */ private val tfa: analysis.MethodTFA = new analysis.MethodTFA() private var tfaCache: Map[Int, tfa.lattice.Elem] = Map.empty - private var analyzedMethod: IMethod = null + private var analyzedMethod: IMethod = NoIMethod /* Blocks that need to be analyzed */ private var todoBlocks: List[BasicBlock] = Nil @@ -110,7 +110,7 @@ abstract class InlineExceptionHandlers extends SubComponent { * inlined blocks, so worst case scenario we double the size of the code */ private def applyMethod(method: IMethod): Unit = { - if (method.code ne null) { + if (method.hasCode) { // create the list of starting blocks todoBlocks = global.icodes.linearizer.linearize(method) @@ -127,7 +127,7 @@ abstract class InlineExceptionHandlers extends SubComponent { todoBlocks = Nil // Type flow analysis cleanup - analyzedMethod = null + analyzedMethod = NoIMethod tfaCache = Map.empty //TODO: Need a way to clear tfa structures } @@ -151,7 +151,7 @@ abstract class InlineExceptionHandlers extends SubComponent { * - we change the THROW exception to the new Clear stack + JUMP code */ for { - (instr @ THROW(clazz), index) <- bblock.zipWithIndex + (instr @ THROW(clazz), index) <- bblock.iterator.zipWithIndex // Decide if any handler fits this exception // If not, then nothing to do, we cannot determine statically which handler will catch the exception (handler, caughtException) <- findExceptionHandler(toTypeKind(clazz.tpe), bblock.exceptionSuccessors) @@ -181,7 +181,7 @@ abstract class InlineExceptionHandlers extends SubComponent { if (!canReplaceHandler) { currentClass.cunit.warning(NoPosition, "Unable to inline the exception handler inside incorrect" + - " block:\n" + bblock.mkString("\n") + "\nwith stack: " + typeInfo + " just " + + " block:\n" + bblock.iterator.mkString("\n") + "\nwith stack: " + typeInfo + " just " + "before instruction index " + index) } else { @@ -261,13 +261,13 @@ abstract class InlineExceptionHandlers extends SubComponent { private def getTypesAtBlockEntry(bblock: BasicBlock): tfa.lattice.Elem = { // lazily perform tfa, because it's expensive // cache results by block label, as rewriting the code messes up the block's hashCode - if (analyzedMethod eq null) { + if (analyzedMethod eq NoIMethod) { analyzedMethod = bblock.method tfa.init(bblock.method) tfa.run log(" performed tfa on method: " + bblock.method) - for (block <- bblock.method.code.blocks.sortBy(_.label)) + for (block <- bblock.method.blocks.sortBy(_.label)) tfaCache += block.label -> tfa.in(block) } @@ -360,7 +360,7 @@ abstract class InlineExceptionHandlers extends SubComponent { val caughtException = toTypeKind(caughtClass.tpe) // copy the exception handler code once again, dropping the LOAD_EXCEPTION val copy = handler.code.newBlock - copy.emitOnly(handler drop dropCount: _*) + copy.emitOnly(handler.iterator drop dropCount toSeq: _*) // extend the handlers of the handler to the copy for (parentHandler <- handler.method.exh ; if parentHandler covers handler) { @@ -382,7 +382,7 @@ abstract class InlineExceptionHandlers extends SubComponent { case _ => currentClass.cunit.warning(NoPosition, "Unable to inline the exception handler due to incorrect format:\n" + - handler.mkString("\n")) + handler.iterator.mkString("\n")) None } } |