# HG changeset patch # User Stefan Marr # Date 1447944687 -3600 # Node ID 69f871f730099e75eacbfcc7d85fd5d972957e95 # Parent 5938e5eb38674be03c4792071029cb9f4540bd95 Added a comment with the assumptions/rational how Node.atomic() works diff -r 5938e5eb3867 -r 69f871f73009 truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java --- a/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java Thu Nov 19 15:49:00 2015 +0100 +++ b/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java Thu Nov 19 15:51:27 2015 +0100 @@ -430,6 +430,9 @@ public final void atomic(Runnable closure) { RootNode rootNode = getRootNode(); + // Major Assumption: parent is never null after a node got adopted + // it is never reset to null, and thus, rootNode is always reachable. + // GIL: used for nodes that are replace in ASTs that are not yet adopted synchronized (rootNode != null ? rootNode : GIL) { assert enterAtomic(); try { @@ -443,6 +446,9 @@ public final T atomic(Callable closure) { try { RootNode rootNode = getRootNode(); + // Major Assumption: parent is never null after a node got adopted + // it is never reset to null, and thus, rootNode is always reachable. + // GIL: used for nodes that are replace in ASTs that are not yet adopted synchronized (rootNode != null ? rootNode : GIL) { assert enterAtomic(); try {