diff options
author | Iulian Dragos <jaguarul@gmail.com> | 2006-04-10 09:47:38 +0000 |
---|---|---|
committer | Iulian Dragos <jaguarul@gmail.com> | 2006-04-10 09:47:38 +0000 |
commit | 2c4293b4495f454b4445064fc434b7039c71f033 (patch) | |
tree | 040c7f4fa4ae798d91f6e66f5d82aa30e75a0b26 | |
parent | 264a2ef48a39d96281977e56b7afed16fa705110 (diff) | |
download | scala-2c4293b4495f454b4445064fc434b7039c71f033.tar.gz scala-2c4293b4495f454b4445064fc434b7039c71f033.tar.bz2 scala-2c4293b4495f454b4445064fc434b7039c71f033.zip |
Added 'loop header' field to basic blocks to ea...
Added 'loop header' field to basic blocks to ease Andre's computation of
the cut set.
5 files changed, 14 insertions, 19 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index 5ad34ef612..1d73da9005 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -662,7 +662,7 @@ trait Parsers requires SyntaxAnalyzer { Try(body, catches, finalizer) } case WHILE => - val lname: Name = unit.fresh.newName("label$"); + val lname: Name = unit.fresh.newName("while$"); val pos = in.skipToken(); accept(LPAREN); val cond = expr(); @@ -671,7 +671,7 @@ trait Parsers requires SyntaxAnalyzer { val body = expr(); atPos(pos) { makeWhile(lname, cond, body) } case DO => - val lname: Name = unit.fresh.newName("label$"); + val lname: Name = unit.fresh.newName("doWhile$"); val pos = in.skipToken(); val body = expr(); if (in.token == SEMI || in.token == NEWLINE) in.nextToken(); diff --git a/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala b/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala index 59e3aa5d6d..7bb3d9c8d2 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala @@ -24,20 +24,17 @@ trait BasicBlocks requires ICodes { extends AnyRef with ProgramPoint[BasicBlock] { - /** The type stack at the begining of the block */ - var initialStack : TypeStack = null; - /** The label of the block */ val label = theLabel; - /** The stack at the end of the block */ - var endStack : TypeStack = null; - /** When set, the 'emit' methods will be ignored. */ var ignore: Boolean = false; var preds: List[BasicBlock] = null; + /** Is this block the head of a while? */ + var loopHeader = false; + /** ICode instructions, used as temporary storage while emitting code. * Once closed is called, only the `instrs' array should be used. */ @@ -85,14 +82,6 @@ trait BasicBlocks requires ICodes { else instructionList.length; - /** Initialize the stack of the block, must be done before evaluation - * the type stack */ - def initStack(stack : TypeStack) = { - if (initialStack == null) { - initialStack = stack; - endStack = null; - } - } ///////////////////// Substitutions /////////////////////// diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala index 95909722ce..fd82a4f0d6 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala @@ -336,6 +336,9 @@ abstract class GenICode extends SubComponent { val resCtx: Context = tree match { case LabelDef(name, params, rhs) => val ctx1 = ctx.newBlock; + if (isLoopHeaderLabel(name)) + ctx1.bb.loopHeader = true; + ctx1.labels.get(tree.symbol) match { case Some(label) => label.anchor(ctx1.bb); @@ -1382,6 +1385,9 @@ abstract class GenICode extends SubComponent { { (x, y) => x.symbol == y.symbol } ); + def isLoopHeaderLabel(name: Name): Boolean = + name.startsWith("while$") || name.startsWith("doWhile$"); + /////////////////////// Context //////////////////////////////// diff --git a/src/compiler/scala/tools/nsc/backend/icode/Members.scala b/src/compiler/scala/tools/nsc/backend/icode/Members.scala index 6eb47ac8f7..c93d318d5a 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Members.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Members.scala @@ -35,8 +35,6 @@ trait Members requires ICodes { // Constructor code startBlock = newBlock; - startBlock.initStack(new TypeStack); - def removeBlock(b: BasicBlock) = { if (settings.debug.value) { diff --git a/src/compiler/scala/tools/nsc/backend/icode/Printers.scala b/src/compiler/scala/tools/nsc/backend/icode/Printers.scala index bc0104ce78..5e249cf17f 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Printers.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Printers.scala @@ -113,7 +113,9 @@ abstract class Printers { } def printBlock(bb: BasicBlock): Unit = { - print(bb.label); print(": "); indent; println; + print(bb.label); + if (bb.loopHeader) print("[loop header]"); + print(": "); indent; println; bb.toList foreach printInstruction; undent; println; } |