Dotty Documentation

0.10.0-bin-SNAPSHOT

package dotty.tools.backend.jvm

[-] Constructors

[-] Members

[+] class CollectEntryPoints

Created by dark on 26/11/14.

[+] 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 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 DottyPrimitives

Scala primitive operations are represented as methods in Any and AnyVal subclasses. Here we demultiplex them by providing a mapping from their symbols to integers. Different methods exist for different value types, but with the same meaning (like plus, minus, etc.). They will all be mapped to the same int.

Note: The three equal methods have the following semantics: - "==" checks for null, and if non-null, calls java.lang.Object.equals (class: Any; modifier: final). Primitive: EQ - "eq" usual reference comparison (class: AnyRef; modifier: final). Primitive: ID - "equals" user-defined equality (Java semantics) (class: Object; modifier: none). Primitive: EQUALS

Inspired from the scalac compiler.

[+] class GenBCode
[+] object 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-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 Ychecking this phase requires softening scoping rules as it intentionally allowed to break scoping rules inside methods for labels. This is modified by setting labelsReordered flag in Phases.