changeset 18511:62aac33db669

Truffle: refactor NodeCloneable interface to abstract class
author Andreas Woess <andreas.woess@jku.at>
date Wed, 26 Nov 2014 01:06:38 +0100
parents cb4d5cc2b52b
children bcf66634c55c 7a3bba33f2b7
files graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeCloneable.java graal/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/BranchProfile.java graal/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/ConditionProfile.java
diffstat 3 files changed, 12 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeCloneable.java	Tue Nov 25 13:21:50 2014 +0100
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeCloneable.java	Wed Nov 26 01:06:38 2014 +0100
@@ -25,8 +25,15 @@
 package com.oracle.truffle.api.nodes;
 
 /**
- * Declarative interface for node fields that are to be cloned together with the containing node.
+ * Declarative base class for node fields that are to be cloned together with the containing node.
  */
-public interface NodeCloneable extends Cloneable {
-    public Object clone();
+public abstract class NodeCloneable implements Cloneable {
+    @Override
+    protected Object clone() {
+        try {
+            return super.clone();
+        } catch (CloneNotSupportedException e) {
+            throw new AssertionError();
+        }
+    }
 }
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/BranchProfile.java	Tue Nov 25 13:21:50 2014 +0100
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/BranchProfile.java	Wed Nov 26 01:06:38 2014 +0100
@@ -37,7 +37,7 @@
  * All {@code BranchProfile} instances must be held in {@code final} fields for compiler
  * optimizations to take effect.
  */
-public final class BranchProfile implements NodeCloneable {
+public final class BranchProfile extends NodeCloneable {
 
     @CompilationFinal private boolean visited;
 
@@ -63,13 +63,4 @@
     public String toString() {
         return String.format("%s(%s)@%x", getClass().getSimpleName(), visited ? "visited" : "not-visited", hashCode());
     }
-
-    @Override
-    public Object clone() {
-        try {
-            return super.clone();
-        } catch (CloneNotSupportedException e) {
-            throw new AssertionError(e);
-        }
-    }
 }
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/ConditionProfile.java	Tue Nov 25 13:21:50 2014 +0100
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/ConditionProfile.java	Wed Nov 26 01:06:38 2014 +0100
@@ -51,7 +51,7 @@
  * @see #createCountingProfile()
  * @see #createBinaryProfile()
  */
-public abstract class ConditionProfile implements NodeCloneable {
+public abstract class ConditionProfile extends NodeCloneable {
 
     public abstract boolean profile(boolean value);
 
@@ -80,13 +80,4 @@
     public static ConditionProfile createBinaryProfile() {
         return new BinaryConditionProfile();
     }
-
-    @Override
-    public final Object clone() {
-        try {
-            return super.clone();
-        } catch (CloneNotSupportedException e) {
-            throw new AssertionError(e);
-        }
-    }
 }