package dotty.tools.backend.jvm

Constructors

Members

class CollectEntryPoints

Created by dark on 26/11/14.

Created by dark on 26/11/14.

final object CollectEntryPoints
[+] class CollectSuperCalls

Collect all super calls to trait members.

For each super reference to trait member, register a call from the current class to the owner of the reference...

Collect all super calls to trait members.

For each super reference to trait member, register a call from the current class to the owner of the referenced member.

This information is used to know if it is safe to remove a redundant mixin class. A redundant mixin class is one that is implemented by another mixin class. As the methods in a redundant mixin class could be implemented with a default abstract method, the redundant mixin class could be required as a parent by the JVM.

class GenBCode
class GenBCodePipeline
[+] class LabelDefs

Verifies that each Label DefDef has only a single address to jump back and reorders them such that they are not nested and this address is a fall-throug...

Verifies that each Label DefDef has only a single address to jump back and reorders them such that they are not nested and this address is a fall-through address for the JVM.

<label> def foo(i: Int) = {
 <label> def bar = 0
 <label> def dough(i: Int) = if (i == 0) bar else foo(i-1)
 dough(i)
}

foo(100)

will get rewritten to:

<label> def foo(i: Int) = dough(i)
<label> def dough(i: Int) = if (i == 0) bar else foo(i-1)
<label> def bar = 2
 foo(100)

Proposed way to generate this pattern in backend is:

foo(100)
<jump foo>
<label> def foo(i: Int) = dough(i)
// <jump a>                           // unreachable
<label> def dough(i: Int) = if (i == 0) bar else foo(i-1)
// <jump a>                           // unreachable
<label> def bar = 2
// <jump a>                           // unreachable
<asm point a>

Unreachable jumps will be eliminated by local dead code analysis. After JVM is smart enough to remove next-line jumps

Note that Label DefDefs can be only nested in Block, otherwise no one would be able to call them Other DefDefs are eliminated