Dotty Documentation

0.9.0-bin-SNAPSHOT

class LazyVals
extends MiniPhase with IdentityDenotTransformer

[-] Constructors

LazyVals ( )

[-] Members

[+] class OffsetInfo

this map contains mutable state of transformation: OffsetDefs to be appended to companion object definitions, and number of bits currently used

[+] val appendOffsetDefs : Map [ Symbol, OffsetInfo ]
[+] val containerFlags : FlagSet
[+] val containerFlagsMask : FlagSet
[+] val initFlags : FlagSet
[+] private var lazyValNullables : IdentityHashMap [ Symbol, ListBuffer [ Symbol ] ]

A map of lazy values to the fields they should null after initialization.

[+] private def addInFront ( prefix: List [ Tree ] , stats: List [ Tree ] ) : List [ Tree ]
[+] override def changesMembers : Boolean

Can this transform create or delete non-private members?

[+] def mkDefNonThreadSafeNonNullable ( target: Symbol , rhs: Tree , nullables: List [ Symbol ] ) ( implicit ctx: Context ) : If

Create non-threadsafe lazy accessor for not-nullable types equivalent to such code

def methodSymbol() = {
 if (target eq null) {
   target = rhs
   nullable = null
   target
 } else target
}
[+] def mkNonThreadSafeDef ( target: Tree , flag: Tree , rhs: Tree , nullables: List [ Symbol ] ) ( implicit ctx: Context ) : If

Create non-threadsafe lazy accessor equivalent to such code

def methodSymbol() = {
 if (flag) target
 else {
   target = rhs
   flag = true
   nullable = null
   target
   }
 }
}
[+] def mkThreadSafeDef ( methodSymbol: TermSymbol , claz: ClassSymbol , ord: Int , target: Symbol , rhs: Tree , tp: Type , offset: Tree , getFlag: Tree , stateMask: Tree , casFlag: Tree , setFlagState: Tree , waitOnLock: Tree , nullables: List [ Symbol ] ) ( implicit ctx: Context ) : DefDef

Create a threadsafe lazy accessor equivalent to such code

def methodSymbol(): Int = {
 val result: Int = 0
 val retry: Boolean = true
 var flag: Long = 0L
 while retry do {
   flag = dotty.runtime.LazyVals.get(this, $claz.$OFFSET)
   dotty.runtime.LazyVals.STATE(flag, 0) match {
     case 0 =>
       if dotty.runtime.LazyVals.CAS(this, $claz.$OFFSET, flag, 1, $ord) {
         try {result = rhs} catch {
           case x: Throwable =>
             dotty.runtime.LazyVals.setFlag(this, $claz.$OFFSET, 0, $ord)
             throw x
         }
         $target = result
         dotty.runtime.LazyVals.setFlag(this, $claz.$OFFSET, 3, $ord)
         retry = false
         }
     case 1 =>
       dotty.runtime.LazyVals.wait4Notification(this, $claz.$OFFSET, flag, $ord)
     case 2 =>
       dotty.runtime.LazyVals.wait4Notification(this, $claz.$OFFSET, flag, $ord)
     case 3 =>
       retry = false
       result = $target
     }
   }
 nullable = null
 result
}
[+] private def nullOut ( nullables: List [ Symbol ] ) ( implicit ctx: Context ) : List [ Tree ]
[+] private def nullableFor ( sym: Symbol ) ( implicit ctx: Context ) : List [ Symbol ]
[+] override def phaseName : String

A name given to the Phase that can be used to debug the compiler. For instance, it is possible to print trees after a given phase using:

$ ./bin/dotc -Xprint:<phaseNameHere> sourceFile.scala
[+] override def prepareForUnit ( tree: Tree ) ( implicit ctx: Context ) : Context
[+] override def runsAfter : Set [ String ]

List of names of phases that should have finished processing of tree before this phase starts processing same tree

[+] override def transformDefDef ( tree: DefDef ) ( implicit ctx: Context ) : Tree
[+] def transformLazyVal ( tree: ValOrDefDef ) ( implicit ctx: Context ) : Tree
[+] def transformLocalDef ( x: ValOrDefDef ) ( implicit ctx: Context ) : Thicket

Replace a local lazy val inside a method, with a LazyHolder from dotty.runtime(eg dotty.runtime.LazyInt)

[+] def transformMemberDefNonVolatile ( x: ValOrDefDef ) ( implicit ctx: Context ) : Thicket
[+] def transformMemberDefVolatile ( x: ValOrDefDef ) ( implicit ctx: Context ) : Thicket
[+] override def transformStats ( trees: List [ Tree ] ) ( implicit ctx: Context ) : List [ Tree ]
[+] def transformSyntheticModule ( tree: ValOrDefDef ) ( implicit ctx: Context ) : Thicket

Make an eager val that would implement synthetic module. Eager val ensures thread safety and has less code generated.

[+] override def transformTemplate ( template: Template ) ( implicit ctx: Context ) : Tree

Append offset fields to companion objects

[+] override def transformValDef ( tree: ValDef ) ( implicit ctx: Context ) : Tree
[+] def transformer : LazyVals