Dotty Documentation

0.12.0-bin-SNAPSHOT

class LazyVals

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

[+] private 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 ( sym: Symbol , target: Symbol , rhs: Tree ) ( implicit ctx: Context ) : DefDef

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

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

Create non-threadsafe lazy accessor equivalent to such code

def methodSymbol() = {
 if (!flag) {
   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 ) ( implicit ctx: Context ) : DefDef

Create a threadsafe lazy accessor equivalent to such code

def methodSymbol(): Int = {
 while (true) {
   val flag = LazyVals.get(this, bitmap_offset)
   val state = LazyVals.STATE(flag, <field-id>)

   if (state == <state-3>) {
     return value_0
   } else if (state == <state-0>) {
     if (LazyVals.CAS(this, bitmap_offset, flag, <state-1>, <field-id>)) {
       try {
         val result = <RHS>
         value_0 = result
         nullable = null
         LazyVals.setFlag(this, bitmap_offset, <state-3>, <field-id>)
         return result
       }
       catch {
         case ex =>
           LazyVals.setFlag(this, bitmap_offset, <state-0>, <field-id>)
           throw ex
       }
     }
   } else /* if (state == <state-1> || state == <state-2>) */ {
     LazyVals.wait4Notification(this, bitmap_offset, flag, <field-id>)
   }
 }
}
[+] 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

Desugar a local lazy val x: Int = <RHS> into:

val x$lzy = new scala.runtime.LazyInt()

def x$lzycompute(): Int = x$lzy.synchronized {
  if (x$lzy.initialized()) x$lzy.value()
  else x$lzy.initialize(<RHS>)
    // TODO: Implement Unit-typed lazy val optimization described below
    // for a Unit-typed lazy val, this becomes `{ rhs ; x$lzy.initialize() }`
    // to avoid passing around BoxedUnit
}

def x(): Int = if (x$lzy.initialized()) x$lzy.value() else x$lzycompute()
[+] 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