scala/scala — pull request #1141 by VladUreche (2012-08-14 21:11:38+00:00)
Title: Fixes backend crash due to incorrect consumedTypes

This started out as a compiler crash after Greg copied the
comprehension methods to List and made them final.

The culprit was the dead code elimination phase, which after
sweeping pieces of code was unable to restore the stack to its
original state, thus causing the ASM backend to crash notifying
the resulting bytecode is incorrect.

The dead code elimination phase uses the icode Instructions'
consumedTypes to determine what needs to be dropped from the
stack when an instruction is eliminated, but the consumedTypes
were only defined for a handful of instructions. So dce encountered
a DUP instruction for which it did not have consumedTypes defined
and did not restore the stack correctly.

The consumedTypes/producedTypes for icode instructions are
redundantly defined in 3 separate places:
- Opcodes.scala (consumedTypes/producedTypes)
- ICodeCheckers.scala (for checking icode)
- TypeFlowAnalysis.scala (for computing types on the stack at each
program point)

Since the Opcodes types are the only ones visible outside, I suggest
we use them in ICodeCheckers.scala and TypeFlowAnalysis.scala too. But
we should make such changes after the release, as we're chilling out
by the lake with a glass of good wine: SI-6234

The relevant discussion around it can be found at:
https://groups.google.com/forum/?fromgroups#!topic/scala-internals/qcyTjk8euUI[1-25]

Many thanks to Paul for his help!

Review by @magarciaEPFL or @paulp.