changeset 22392:69f871f73009

Added a comment with the assumptions/rational how Node.atomic() works
author Stefan Marr <stefan.marr@jku.at>
date Thu, 19 Nov 2015 15:51:27 +0100
parents 5938e5eb3867
children ab33db2c148c
files truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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> T atomic(Callable<T> 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 {