Thanks to visit codestin.com
Credit goes to github.com

Skip to content

liufengyun/graal-lazy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Graal compilation of Lazy Val

Note: all the graphs are outdated and not in sync with the code file.

You need to use Ideal Graph Visualizer to open the file data.bgv to visualize the graphs.

Code

For more detailed code, see lazy.scala:

class C {
  def x: String = {
    val current = _x
    if (current.isInstanceOf[String])
      current.asInstanceOf[String]
    else
      x$lzy
  }

  def x$lzy: String = {
    val current = _x
    if (current.isInstanceOf[String])
      current.asInstanceOf[String]
    else {
      val offset = C.x_offset
      if (current == null) {
        if (LazyRuntime.isUnitialized(this, offset)) {
          try LazyRuntime.initialize(this, offset, 3 + "value")
          catch {
            case ex: Throwable =>
              LazyRuntime.initialize(this, offset, null)
              throw ex
          }
        }
      }
      else
        LazyRuntime.awaitInitialized(this, offset, current)
      x$lzy
    }
  }
}

Graphs for C.x

Here are the graphs for the method C.x.

0 after parsing

./images/0-after-parsing.png

1 before phase lowering

./images/1-before-phase-lowering.png

2 after high tier

./images/2-after-high-tier.png

3 after mid tier

./images/3-after-mid-tier.png

4 after low tier

./images/4-after-low-tier.png

Graphs for Test.main

object Test {
  def main(args: Array[String]): Unit = {
    val c = new C
    while(true) c.x
  }
}

0 after parsing

./images/0-after-parsing-main.png

1 before phase lowering

./images/1-before-phase-lowering-main.png

2 after high tier

./images/2-after-high-tier-main.png

3 after mid tier

./images/3-after-mid-tier-main.png

4 after low tier

./images/4-after-lower-tier-main.png

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published