changeset 18319:56cc1a799a60

(re)converted Value to an interface
author Doug Simon <doug.simon@oracle.com>
date Fri, 07 Nov 2014 22:00:11 +0100
parents da76d42c397e
children 0093dcea7092
files graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/VirtualObject.java graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/AbstractValue.java graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/AllocatableValue.java graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/JavaConstant.java graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Value.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/match/ComplexMatchValue.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMonitorValue.java graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/CompositeValueReplacementTest1.java graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/CompositeValueReplacementTest2.java graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/CompositeValueReplacementTest3.java graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/CompositeValueReplacementTest4.java graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/ValuePositionTest1.java graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/ValuePositionTest2.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/CompositeValue.java src/share/vm/classfile/systemDictionary.hpp src/share/vm/classfile/vmSymbols.hpp src/share/vm/graal/graalCodeInstaller.cpp src/share/vm/graal/graalJavaAccess.hpp
diffstat 18 files changed, 134 insertions(+), 85 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/VirtualObject.java	Fri Nov 07 14:50:43 2014 +0100
+++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/VirtualObject.java	Fri Nov 07 22:00:11 2014 +0100
@@ -31,7 +31,7 @@
  * The information stored in the {@link VirtualObject} is used during deoptimization to recreate the
  * object.
  */
-public final class VirtualObject extends Value implements JavaValue {
+public final class VirtualObject extends AbstractValue implements JavaValue {
 
     private static final long serialVersionUID = -2907197776426346021L;
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/AbstractValue.java	Fri Nov 07 22:00:11 2014 +0100
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.api.meta;
+
+import java.io.*;
+
+/**
+ * Abstract base class for values.
+ */
+public abstract class AbstractValue implements Serializable, Value, KindProvider {
+
+    private static final long serialVersionUID = -6909397188697766469L;
+
+    public static final AllocatableValue ILLEGAL = Value.ILLEGAL;
+
+    private final Kind kind;
+    private final LIRKind lirKind;
+
+    /**
+     * Initializes a new value of the specified kind.
+     *
+     * @param lirKind the kind
+     */
+    protected AbstractValue(LIRKind lirKind) {
+        this.lirKind = lirKind;
+        if (getPlatformKind() instanceof Kind) {
+            this.kind = (Kind) getPlatformKind();
+        } else {
+            this.kind = Kind.Illegal;
+        }
+    }
+
+    /**
+     * Returns a String representation of the kind, which should be the end of all
+     * {@link #toString()} implementation of subclasses.
+     */
+    protected final String getKindSuffix() {
+        return "|" + getKind().getTypeChar();
+    }
+
+    /**
+     * Returns the kind of this value.
+     */
+    public final Kind getKind() {
+        return kind;
+    }
+
+    public final LIRKind getLIRKind() {
+        return lirKind;
+    }
+
+    /**
+     * Returns the platform specific kind used to store this value.
+     */
+    public final PlatformKind getPlatformKind() {
+        return lirKind.getPlatformKind();
+    }
+
+    @Override
+    public int hashCode() {
+        return 41 + lirKind.hashCode();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (obj instanceof AbstractValue) {
+            AbstractValue that = (AbstractValue) obj;
+            return kind.equals(that.kind) && lirKind.equals(that.lirKind);
+        }
+        return false;
+    }
+
+    /**
+     * Checks if this value is identical to {@code other}.
+     *
+     * Warning: Use with caution! Usually equivalence {@link #equals(Object)} is sufficient and
+     * should be used.
+     */
+    @ExcludeFromIdentityComparisonVerification
+    public final boolean identityEquals(AbstractValue other) {
+        return this == other;
+    }
+}
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/AllocatableValue.java	Fri Nov 07 14:50:43 2014 +0100
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/AllocatableValue.java	Fri Nov 07 22:00:11 2014 +0100
@@ -26,7 +26,7 @@
  * Common base class for values that are stored in some location that's managed by the register
  * allocator (e.g. register, stack slot).
  */
-public abstract class AllocatableValue extends Value implements JavaValue {
+public abstract class AllocatableValue extends AbstractValue implements JavaValue, KindProvider {
 
     private static final long serialVersionUID = 153019506717492133L;
 
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/JavaConstant.java	Fri Nov 07 14:50:43 2014 +0100
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/JavaConstant.java	Fri Nov 07 22:00:11 2014 +0100
@@ -28,7 +28,7 @@
  * {@code JavaConstant} instances that represent frequently used constant values, such as
  * {@link #NULL_OBJECT}.
  */
-public abstract class JavaConstant extends Value implements Constant, JavaValue {
+public abstract class JavaConstant extends AbstractValue implements Constant, JavaValue {
 
     private static final long serialVersionUID = -6355452536852663986L;
 
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Value.java	Fri Nov 07 14:50:43 2014 +0100
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Value.java	Fri Nov 07 22:00:11 2014 +0100
@@ -22,17 +22,13 @@
  */
 package com.oracle.graal.api.meta;
 
-import java.io.*;
-
 /**
- * Abstract base class for values manipulated by the compiler. All values have a {@linkplain Kind
- * kind} and are immutable.
+ * Interface for values manipulated by the compiler. All values have a {@linkplain Kind kind} and
+ * are immutable.
  */
-public abstract class Value implements Serializable, KindProvider {
+public interface Value extends KindProvider {
 
-    private static final long serialVersionUID = -6909397188697766469L;
-
-    @SuppressWarnings("serial") public static final AllocatableValue ILLEGAL = new AllocatableValue(LIRKind.Illegal) {
+    @SuppressWarnings("serial") AllocatableValue ILLEGAL = new AllocatableValue(LIRKind.Illegal) {
 
         @Override
         public String toString() {
@@ -40,62 +36,12 @@
         }
     };
 
-    private final Kind kind;
-    private final LIRKind lirKind;
-
-    /**
-     * Initializes a new value of the specified kind.
-     *
-     * @param lirKind the kind
-     */
-    protected Value(LIRKind lirKind) {
-        this.lirKind = lirKind;
-        if (getPlatformKind() instanceof Kind) {
-            this.kind = (Kind) getPlatformKind();
-        } else {
-            this.kind = Kind.Illegal;
-        }
-    }
-
-    /**
-     * Returns a String representation of the kind, which should be the end of all
-     * {@link #toString()} implementation of subclasses.
-     */
-    protected final String getKindSuffix() {
-        return "|" + getKind().getTypeChar();
-    }
-
-    /**
-     * Returns the kind of this value.
-     */
-    public final Kind getKind() {
-        return kind;
-    }
-
-    public final LIRKind getLIRKind() {
-        return lirKind;
-    }
+    LIRKind getLIRKind();
 
     /**
      * Returns the platform specific kind used to store this value.
      */
-    public final PlatformKind getPlatformKind() {
-        return lirKind.getPlatformKind();
-    }
-
-    @Override
-    public int hashCode() {
-        return 41 + lirKind.hashCode();
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (obj instanceof Value) {
-            Value that = (Value) obj;
-            return kind.equals(that.kind) && lirKind.equals(that.lirKind);
-        }
-        return false;
-    }
+    PlatformKind getPlatformKind();
 
     /**
      * Checks if this value is identical to {@code other}.
@@ -104,7 +50,7 @@
      * should be used.
      */
     @ExcludeFromIdentityComparisonVerification
-    public final boolean identityEquals(Value other) {
+    default boolean identityEquals(Value other) {
         return this == other;
     }
 }
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/match/ComplexMatchValue.java	Fri Nov 07 14:50:43 2014 +0100
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/match/ComplexMatchValue.java	Fri Nov 07 22:00:11 2014 +0100
@@ -30,14 +30,14 @@
  * closure because Value is serializable which is a hassle for the little inner classes which
  * usually occur here.
  */
-public class ComplexMatchValue extends Value {
+public class ComplexMatchValue extends AbstractValue {
     private static final long serialVersionUID = -4734670273590368770L;
 
     /**
      * This is the Value of a node which was matched as part of a complex match. The value isn't
      * actually useable but this marks it as having been evaluated.
      */
-    @SuppressWarnings("serial") public static final Value INTERIOR_MATCH = new Value(LIRKind.Illegal) {
+    @SuppressWarnings("serial") public static final Value INTERIOR_MATCH = new AbstractValue(LIRKind.Illegal) {
 
         @Override
         public String toString() {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMonitorValue.java	Fri Nov 07 14:50:43 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMonitorValue.java	Fri Nov 07 22:00:11 2014 +0100
@@ -28,7 +28,7 @@
 /**
  * Represents lock information in the debug information.
  */
-public final class HotSpotMonitorValue extends Value implements JavaValue {
+public final class HotSpotMonitorValue extends AbstractValue implements JavaValue {
 
     private static final long serialVersionUID = 8241681800464483691L;
 
--- a/graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/CompositeValueReplacementTest1.java	Fri Nov 07 14:50:43 2014 +0100
+++ b/graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/CompositeValueReplacementTest1.java	Fri Nov 07 22:00:11 2014 +0100
@@ -50,7 +50,7 @@
 
     }
 
-    private static class DummyValue extends Value {
+    private static class DummyValue extends AbstractValue {
 
         private static final long serialVersionUID = -645435039553382737L;
         private final int id;
--- a/graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/CompositeValueReplacementTest2.java	Fri Nov 07 14:50:43 2014 +0100
+++ b/graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/CompositeValueReplacementTest2.java	Fri Nov 07 22:00:11 2014 +0100
@@ -51,7 +51,7 @@
 
     }
 
-    private static class DummyValue extends Value {
+    private static class DummyValue extends AbstractValue {
 
         private static final long serialVersionUID = -645435039553382737L;
         private final int id;
--- a/graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/CompositeValueReplacementTest3.java	Fri Nov 07 14:50:43 2014 +0100
+++ b/graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/CompositeValueReplacementTest3.java	Fri Nov 07 22:00:11 2014 +0100
@@ -51,7 +51,7 @@
 
     }
 
-    private static class DummyValue extends Value {
+    private static class DummyValue extends AbstractValue {
 
         private static final long serialVersionUID = -645435039553382737L;
         private final int id;
--- a/graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/CompositeValueReplacementTest4.java	Fri Nov 07 14:50:43 2014 +0100
+++ b/graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/CompositeValueReplacementTest4.java	Fri Nov 07 22:00:11 2014 +0100
@@ -51,7 +51,7 @@
 
     }
 
-    private static class DummyValue extends Value {
+    private static class DummyValue extends AbstractValue {
 
         private static final long serialVersionUID = -645435039553382737L;
         private final int id;
--- a/graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/ValuePositionTest1.java	Fri Nov 07 14:50:43 2014 +0100
+++ b/graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/ValuePositionTest1.java	Fri Nov 07 22:00:11 2014 +0100
@@ -48,7 +48,7 @@
 
     }
 
-    private static class DummyValue extends Value {
+    private static class DummyValue extends AbstractValue {
 
         private static final long serialVersionUID = -645435039553382737L;
         private final int id;
--- a/graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/ValuePositionTest2.java	Fri Nov 07 14:50:43 2014 +0100
+++ b/graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/ValuePositionTest2.java	Fri Nov 07 22:00:11 2014 +0100
@@ -50,7 +50,7 @@
 
     }
 
-    private static class DummyValue extends Value {
+    private static class DummyValue extends AbstractValue {
 
         private static final long serialVersionUID = 3620305384660607012L;
         private final int id;
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/CompositeValue.java	Fri Nov 07 14:50:43 2014 +0100
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/CompositeValue.java	Fri Nov 07 22:00:11 2014 +0100
@@ -33,7 +33,7 @@
 /**
  * Base class to represent values that need to be stored in more than one register.
  */
-public abstract class CompositeValue extends Value implements Cloneable {
+public abstract class CompositeValue extends AbstractValue implements Cloneable {
 
     private static final long serialVersionUID = -169180052684126180L;
 
--- a/src/share/vm/classfile/systemDictionary.hpp	Fri Nov 07 14:50:43 2014 +0100
+++ b/src/share/vm/classfile/systemDictionary.hpp	Fri Nov 07 22:00:11 2014 +0100
@@ -242,7 +242,7 @@
   GRAAL_ONLY(do_klass(LIRKind_klass,                         com_oracle_graal_api_meta_LIRKind,                            Graal)) \
   GRAAL_ONLY(do_klass(JavaMethod_klass,                      com_oracle_graal_api_meta_JavaMethod,                         Graal)) \
   GRAAL_ONLY(do_klass(JavaType_klass,                        com_oracle_graal_api_meta_JavaType,                           Graal)) \
-  GRAAL_ONLY(do_klass(Value_klass,                           com_oracle_graal_api_meta_Value,                              Graal)) \
+  GRAAL_ONLY(do_klass(AbstractValue_klass,                   com_oracle_graal_api_meta_AbstractValue,                      Graal)) \
 
   /*end*/
 
@@ -263,7 +263,7 @@
 
 #ifdef GRAAL
     FIRST_GRAAL_WKID = WK_KLASS_ENUM_NAME(CompilerThread_klass),
-    LAST_GRAAL_WKID  = WK_KLASS_ENUM_NAME(Value_klass),
+    LAST_GRAAL_WKID  = WK_KLASS_ENUM_NAME(AbstractValue_klass),
 #endif
 
     FIRST_WKID = NO_WKID + 1
--- a/src/share/vm/classfile/vmSymbols.hpp	Fri Nov 07 14:50:43 2014 +0100
+++ b/src/share/vm/classfile/vmSymbols.hpp	Fri Nov 07 22:00:11 2014 +0100
@@ -321,7 +321,7 @@
   GRAAL_ONLY(template(com_oracle_graal_api_meta_JavaType,                       "com/oracle/graal/api/meta/JavaType"))                            \
   GRAAL_ONLY(template(com_oracle_graal_api_meta_Kind,                           "com/oracle/graal/api/meta/Kind"))                                \
   GRAAL_ONLY(template(com_oracle_graal_api_meta_LIRKind,                        "com/oracle/graal/api/meta/LIRKind"))                             \
-  GRAAL_ONLY(template(com_oracle_graal_api_meta_Value,                          "com/oracle/graal/api/meta/Value"))                               \
+  GRAAL_ONLY(template(com_oracle_graal_api_meta_AbstractValue,                  "com/oracle/graal/api/meta/AbstractValue"))                       \
   GRAAL_ONLY(template(com_oracle_graal_api_code_Assumptions,                    "com/oracle/graal/api/code/Assumptions"))                         \
   GRAAL_ONLY(template(com_oracle_graal_api_code_Assumptions_MethodContents,     "com/oracle/graal/api/code/Assumptions$MethodContents"))          \
   GRAAL_ONLY(template(com_oracle_graal_api_code_Assumptions_ConcreteSubtype,    "com/oracle/graal/api/code/Assumptions$ConcreteSubtype"))         \
--- a/src/share/vm/graal/graalCodeInstaller.cpp	Fri Nov 07 14:50:43 2014 +0100
+++ b/src/share/vm/graal/graalCodeInstaller.cpp	Fri Nov 07 22:00:11 2014 +0100
@@ -191,7 +191,7 @@
   if (constant->is_a(HotSpotMetaspaceConstantImpl::klass())) {
     oop obj = HotSpotMetaspaceConstantImpl::metaspaceObject(constant);
     jlong prim = HotSpotMetaspaceConstantImpl::primitive(constant);
-    assert(Kind::typeChar(Value::kind(constant)) == 'j', "must have word kind");
+    assert(Kind::typeChar(AbstractValue::kind(constant)) == 'j', "must have word kind");
     assert(obj != NULL, "must have an object");
     assert(prim != 0, "must have a primitive value");
 
@@ -205,11 +205,11 @@
 
 ScopeValue* CodeInstaller::get_scope_value(oop value, int total_frame_size, GrowableArray<ScopeValue*>* objects, ScopeValue* &second, OopRecorder* oop_recorder) {
   second = NULL;
-  if (value == Value::ILLEGAL()) {
+  if (value == AbstractValue::ILLEGAL()) {
     return _illegal_value;
   }
 
-  oop lirKind = Value::lirKind(value);
+  oop lirKind = AbstractValue::lirKind(value);
   oop platformKind = LIRKind::platformKind(lirKind);
   jint referenceMask = LIRKind::referenceMask(lirKind);
   assert(referenceMask == 0 || referenceMask == 1, "unexpected referenceMask");
@@ -803,7 +803,7 @@
       if (second != NULL) {
         i++;
         assert(i < values->length(), "double-slot value not followed by Value.ILLEGAL");
-        assert(values->obj_at(i) == Value::ILLEGAL(), "double-slot value not followed by Value.ILLEGAL");
+        assert(values->obj_at(i) == AbstractValue::ILLEGAL(), "double-slot value not followed by Value.ILLEGAL");
       }
     }
 
--- a/src/share/vm/graal/graalJavaAccess.hpp	Fri Nov 07 14:50:43 2014 +0100
+++ b/src/share/vm/graal/graalJavaAccess.hpp	Fri Nov 07 22:00:11 2014 +0100
@@ -224,10 +224,10 @@
     oop_field(LIRKind, platformKind, "Lcom/oracle/graal/api/meta/PlatformKind;")                                                                               \
     int_field(LIRKind, referenceMask)                                                                                                                          \
   end_class                                                                                                                                                    \
-  start_class(Value)                                                                                                                                           \
-    oop_field(Value, kind, "Lcom/oracle/graal/api/meta/Kind;")                                                                                                 \
-    oop_field(Value, lirKind, "Lcom/oracle/graal/api/meta/LIRKind;")                                                                                           \
-    static_oop_field(Value, ILLEGAL, "Lcom/oracle/graal/api/meta/AllocatableValue;");                                                                          \
+  start_class(AbstractValue)                                                                                                                                   \
+    oop_field(AbstractValue, kind, "Lcom/oracle/graal/api/meta/Kind;")                                                                                         \
+    oop_field(AbstractValue, lirKind, "Lcom/oracle/graal/api/meta/LIRKind;")                                                                                   \
+    static_oop_field(AbstractValue, ILLEGAL, "Lcom/oracle/graal/api/meta/AllocatableValue;");                                                                  \
   end_class                                                                                                                                                    \
   start_class(RegisterValue)                                                                                                                                   \
     oop_field(RegisterValue, reg, "Lcom/oracle/graal/api/code/Register;")                                                                                      \