Skip to content

Commit fed4a72

Browse files
committed
more timely Ydebug error reporting in GenBCode
1 parent 488d31c commit fed4a72

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/compiler/scala/tools/nsc/backend/jvm/BCodeOptIntra.scala

+7
Original file line numberDiff line numberDiff line change
@@ -1118,11 +1118,18 @@ abstract class BCodeOptIntra extends BCodeOptCommon {
11181118
// Type-flow analysis
11191119
//--------------------------------------------------------------------
11201120

1121+
final def runTypeFlowAnalysis() {
1122+
for(m <- JListWrapper(cnode.methods); if asm.optimiz.Util.hasBytecodeInstructions(m)) {
1123+
runTypeFlowAnalysis(m)
1124+
}
1125+
}
1126+
11211127
final def runTypeFlowAnalysis(mnode: MethodNode) {
11221128

11231129
import asm.tree.analysis.{ Analyzer, Frame }
11241130
import asm.tree.AbstractInsnNode
11251131

1132+
Util.computeMaxLocalsMaxStack(mnode)
11261133
val tfa = new Analyzer[TFValue](new TypeFlowInterpreter)
11271134
tfa.analyze(cnode.name, mnode)
11281135
val frames: Array[Frame[TFValue]] = tfa.getFrames()

src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala

+6-1
Original file line numberDiff line numberDiff line change
@@ -427,19 +427,24 @@ abstract class GenBCode extends BCodeOptInter {
427427

428428
if(isOptimizRun) {
429429
val cleanser = new BCodeCleanser(cnode, isIntraProgramOpt)
430+
ifDebug { cleanser.runTypeFlowAnalysis() }
430431
cleanser.codeFixupDCE()
432+
ifDebug { cleanser.runTypeFlowAnalysis() }
431433
// outer-elimination shouldn't be skipped under -o1 , ie it's squashOuter() we're after.
432434
// under -o0 `squashOuter()` is invoked in the else-branch below
433435
// under -o2 `squashOuter()` runs before inlining, ie in `Worker1.visit()`
434436
// under -o3 or higher, rather than `squashOuter()`, the more powerful `minimizeDClosureFields()` is run instead
435437
cleanser.codeFixupSquashLCC(item.lateClosures, item.epByDCName)
438+
ifDebug { cleanser.runTypeFlowAnalysis() }
436439
cleanser.cleanseClass()
440+
ifDebug { cleanser.runTypeFlowAnalysis() }
437441
}
438442
else {
439443
// the minimal fixups needed, even for unoptimized runs.
440444
val essential = new EssentialCleanser(cnode)
441445
essential.codeFixupDCE()
442446
essential.codeFixupSquashLCC(item.lateClosures, item.epByDCName)
447+
ifDebug { essential.runTypeFlowAnalysis() }
443448
}
444449

445450
refreshInnerClasses(cnode)
@@ -967,7 +972,7 @@ abstract class GenBCode extends BCodeOptInter {
967972
/* If the selector type has a member with the right name,
968973
* it is the host class; otherwise the symbol's owner.
969974
*/
970-
def findHostClass(selector: Type, sym: Symbol) = selector member sym.name match {
975+
def findHostClass(selector: Type, sym: Symbol): Symbol = selector member sym.name match {
971976
case NoSymbol => log(s"Rejecting $selector as host class for $sym") ; sym.owner
972977
case _ => selector.typeSymbol
973978
}

0 commit comments

Comments
 (0)