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 } } }
C.x
Graphs for Here are the graphs for the method C.x
.
0 after parsing
1 before phase lowering
2 after high tier
3 after mid tier
4 after low tier
Test.main
Graphs for object Test { def main(args: Array[String]): Unit = { val c = new C while(true) c.x } }
0 after parsing
1 before phase lowering
2 after high tier
3 after mid tier
4 after low tier