changeset 19768:8caabd6cf363

Truffle-DSL: removeSame does not need to run using atomic. It is always used in an atomic block already.
author Christian Humer <christian.humer@gmail.com>
date Tue, 10 Mar 2015 21:13:07 +0100
parents e6a4ba0980dd
children e773cc48d3e8
files graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/internal/SpecializationNode.java
diffstat 1 files changed, 18 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/internal/SpecializationNode.java	Tue Mar 10 21:11:12 2015 +0100
+++ b/graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/internal/SpecializationNode.java	Tue Mar 10 21:13:07 2015 +0100
@@ -266,11 +266,18 @@
     }
 
     protected final SpecializationNode removeSame(final CharSequence reason) {
-        return atomic(new Callable<SpecializationNode>() {
-            public SpecializationNode call() throws Exception {
-                return removeSameImpl(SpecializationNode.this, reason);
+        SpecializationNode start = SpecializationNode.this.findStart();
+        SpecializationNode current = start;
+        while (current != null) {
+            if (current.isSame(SpecializationNode.this)) {
+                NodeUtil.nonAtomicReplace(current, current.next, reason);
+                if (current == start) {
+                    start = start.next;
+                }
             }
-        });
+            current = current.next;
+        }
+        return SpecializationNode.this.findEnd().findStart();
     }
 
     /** Find the topmost of the specialization chain. */
@@ -767,7 +774,7 @@
         }
 
         public SpecializationNode call() throws Exception {
-            return removeSameImpl(source, this);
+            return source.removeSame(this);
         }
 
     }
@@ -779,7 +786,7 @@
         }
 
         public SpecializationNode call() throws Exception {
-            return removeSameImpl(source, this);
+            return source.removeSame(this);
         }
 
     }
@@ -791,7 +798,7 @@
         }
 
         public SpecializationNode call() throws Exception {
-            return removeSameImpl(source, this);
+            return source.removeSame(this);
         }
 
     }
@@ -803,7 +810,7 @@
         }
 
         public SpecializationNode call() throws Exception {
-            return removeSameImpl(source, this);
+            return source.removeSame(this);
         }
 
     }
@@ -815,7 +822,7 @@
         }
 
         public SpecializationNode call() throws Exception {
-            return removeSameImpl(source, this);
+            return source.removeSame(this);
         }
 
     }
@@ -827,7 +834,7 @@
         }
 
         public SpecializationNode call() throws Exception {
-            return removeSameImpl(source, this);
+            return source.removeSame(this);
         }
 
     }
@@ -839,7 +846,7 @@
         }
 
         public SpecializationNode call() throws Exception {
-            return removeSameImpl(source, this);
+            return source.removeSame(this);
         }
     }