summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-08-23 13:55:32 +0200
committerPaul Phillips <paulp@improving.org>2012-08-23 16:43:29 +0200
commit730871371ccc29c68e1c12a9f00aa8515236f139 (patch)
treed9b767855f814f9d45d6422ea12ce4b63ea3891b /src/compiler
parent1a1678dac0d4ff7d08efffbe2c80f324c173a69e (diff)
downloadscala-730871371ccc29c68e1c12a9f00aa8515236f139.tar.gz
scala-730871371ccc29c68e1c12a9f00aa8515236f139.tar.bz2
scala-730871371ccc29c68e1c12a9f00aa8515236f139.zip
Eliminated a metric ton of allocations.
Thanks to the hotspot DTrace probes. I'm not sure why this checkfile changed, but hopefully it's innocuous. Review by @VladUreche for the checkfile and @gkossakowski so he can tell me how much faster.
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala36
1 files changed, 21 insertions, 15 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala b/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala
index 8bbf11650c..486a43614b 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala
@@ -42,10 +42,14 @@ trait BasicBlocks {
private final class SuccessorList() {
private var successors: List[BasicBlock] = Nil
+ /** This method is very hot! Handle with care. */
private def updateConserve() {
- var lb: ListBuffer[BasicBlock] = null
- var matches = 0
- var remaining = successors
+ var lb: ListBuffer[BasicBlock] = null
+ var matches = 0
+ var remaining = successors
+ val direct = directSuccessors
+ var scratchHandlers: List[ExceptionHandler] = method.exh
+ var scratchBlocks: List[BasicBlock] = direct
def addBlock(bb: BasicBlock) {
if (matches < 0)
@@ -60,25 +64,27 @@ trait BasicBlocks {
}
}
- // exceptionSuccessors
- method.exh foreach { handler =>
- if (handler covers outer)
- addBlock(handler.startBlock)
+ while (scratchBlocks ne Nil) {
+ addBlock(scratchBlocks.head)
+ scratchBlocks = scratchBlocks.tail
}
- // directSuccessors
- val direct = directSuccessors
- direct foreach addBlock
-
/** Return a list of successors for 'b' that come from exception handlers
* covering b's (non-exceptional) successors. These exception handlers
* might not cover 'b' itself. This situation corresponds to an
* exception being thrown as the first thing of one of b's successors.
*/
- method.exh foreach { handler =>
- direct foreach { block =>
- if (handler covers block)
+ while (scratchHandlers ne Nil) {
+ val handler = scratchHandlers.head
+ if (handler covers outer)
+ addBlock(handler.startBlock)
+
+ scratchBlocks = direct
+ while (scratchBlocks ne Nil) {
+ if (handler covers scratchBlocks.head)
addBlock(handler.startBlock)
+ scratchBlocks = scratchBlocks.tail
}
+ scratchHandlers = scratchHandlers.tail
}
// Blocks did not align: create a new list.
if (matches < 0)
@@ -101,7 +107,7 @@ trait BasicBlocks {
}
/** Flags of this basic block. */
- private var flags: Int = 0
+ private[this] var flags: Int = 0
/** Does this block have the given flag? */
def hasFlag(flag: Int): Boolean = (flags & flag) != 0