scala/scala — pull request #2603 by magarciaEPFL (2013-05-28 16:47:21+00:00)
Title: new bytecode emitter, GenBCode (10th attempt)

This PR re-submission supersedes #2575 and takes into account review comments so far.

The two last commits include tests for dead-code elimination and jump-chains collapsing, two rewritings that are always desirable and are thus "built-in".

Two other bytecode-level simplifications are also built-in to GenBCode:
- removing unused LabelNodes (where a `LabelNode` represents e.g. the target of a jump)
- removing redundant exception-entries (an exception entry is redundant provided it protects an instruction range that consists of nop instructions only)

In the first case, removal occurs after walking all of a method, collecting references to LabelNodes. Those LabelsNodes never seen during this walk are redundant. Given the procedure is straightforward, no test is necessary.

As for exception entries, each such entry lists the start and end instructions of the range being protected. Any executable instruction other than NOP means the exception-entry should stay. That's what `asm.optimiz.DanglingExcHandlers` implements.

review by @gkossakowski or @JamesIry or @retronym or @paulp