changeset 22504:943c2bf064fa

Collapse Value and AbstractValue into a single abstract base class.
author Roland Schatz <roland.schatz@oracle.com>
date Wed, 02 Sep 2015 12:02:17 +0200
parents 6fa5f9a1a371
children 575eb1036ea9
files jvmci/jdk.internal.jvmci.meta/src/jdk/internal/jvmci/meta/AbstractValue.java jvmci/jdk.internal.jvmci.meta/src/jdk/internal/jvmci/meta/AllocatableValue.java jvmci/jdk.internal.jvmci.meta/src/jdk/internal/jvmci/meta/Value.java src/share/vm/classfile/systemDictionary.hpp src/share/vm/jvmci/jvmciCodeInstaller.cpp src/share/vm/jvmci/jvmciJavaAccess.hpp src/share/vm/jvmci/systemDictionary_jvmci.hpp src/share/vm/jvmci/vmSymbols_jvmci.hpp
diffstat 8 files changed, 71 insertions(+), 122 deletions(-) [+]
line wrap: on
line diff
--- a/jvmci/jdk.internal.jvmci.meta/src/jdk/internal/jvmci/meta/AbstractValue.java	Tue Sep 01 18:58:12 2015 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,98 +0,0 @@
-/*
- * 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 jdk.internal.jvmci.meta;
-
-/**
- * Abstract base class for values.
- */
-public abstract class AbstractValue implements Value {
-
-    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.
-     */
-    public final boolean identityEquals(AbstractValue other) {
-        return this == other;
-    }
-}
--- a/jvmci/jdk.internal.jvmci.meta/src/jdk/internal/jvmci/meta/AllocatableValue.java	Tue Sep 01 18:58:12 2015 +0200
+++ b/jvmci/jdk.internal.jvmci.meta/src/jdk/internal/jvmci/meta/AllocatableValue.java	Wed Sep 02 12:02:17 2015 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, 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
@@ -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 AbstractValue implements JavaValue {
+public abstract class AllocatableValue extends Value implements JavaValue {
 
     public static final AllocatableValue[] NONE = {};
 
--- a/jvmci/jdk.internal.jvmci.meta/src/jdk/internal/jvmci/meta/Value.java	Tue Sep 01 18:58:12 2015 +0200
+++ b/jvmci/jdk.internal.jvmci.meta/src/jdk/internal/jvmci/meta/Value.java	Wed Sep 02 12:02:17 2015 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015, 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
@@ -23,16 +23,15 @@
 package jdk.internal.jvmci.meta;
 
 /**
- * Interface for values manipulated by the compiler. All values have a {@linkplain Kind kind} and
- * are immutable.
+ * Abstract base class for values.
  */
-public interface Value extends TrustedInterface {
+public abstract class Value {
 
-    Value[] NO_VALUES = new Value[0];
+    public static final Value[] NO_VALUES = new Value[0];
 
-    AllocatableValue ILLEGAL = new IllegalValue();
+    public static final AllocatableValue ILLEGAL = new IllegalValue();
 
-    public final class IllegalValue extends AllocatableValue {
+    private static final class IllegalValue extends AllocatableValue {
         private IllegalValue() {
             super(LIRKind.Illegal);
         }
@@ -50,14 +49,62 @@
         }
     }
 
-    Kind getKind();
+    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;
+        }
+    }
 
-    LIRKind getLIRKind();
+    /**
+     * 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.
      */
-    PlatformKind getPlatformKind();
+    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;
+    }
 
     /**
      * Checks if this value is identical to {@code other}.
@@ -65,7 +112,7 @@
      * Warning: Use with caution! Usually equivalence {@link #equals(Object)} is sufficient and
      * should be used.
      */
-    default boolean identityEquals(Value other) {
+    public final boolean identityEquals(Value other) {
         return this == other;
     }
 }
--- a/src/share/vm/classfile/systemDictionary.hpp	Tue Sep 01 18:58:12 2015 +0200
+++ b/src/share/vm/classfile/systemDictionary.hpp	Wed Sep 02 12:02:17 2015 +0200
@@ -219,7 +219,7 @@
 
 #if INCLUDE_JVMCI
     FIRST_JVMCI_WKID = WK_KLASS_ENUM_NAME(HotSpotCompiledCode_klass),
-    LAST_JVMCI_WKID  = WK_KLASS_ENUM_NAME(AbstractValue_klass),
+    LAST_JVMCI_WKID  = WK_KLASS_ENUM_NAME(Value_klass),
 #endif
 
     FIRST_WKID = NO_WKID + 1
--- a/src/share/vm/jvmci/jvmciCodeInstaller.cpp	Tue Sep 01 18:58:12 2015 +0200
+++ b/src/share/vm/jvmci/jvmciCodeInstaller.cpp	Wed Sep 02 12:02:17 2015 +0200
@@ -166,7 +166,7 @@
   if (constant->is_a(HotSpotMetaspaceConstantImpl::klass())) {
     oop obj = HotSpotMetaspaceConstantImpl::metaspaceObject(constant);
     jlong prim = HotSpotMetaspaceConstantImpl::primitive(constant);
-    assert(Kind::typeChar(AbstractValue::kind(constant)) == 'j', "must have word kind");
+    assert(Kind::typeChar(Value::kind(constant)) == 'j', "must have word kind");
     assert(obj != NULL, "must have an object");
     assert(prim != 0, "must have a primitive value");
 
@@ -179,7 +179,7 @@
 }
 
 static Location::Type get_oop_type(oop value) {
-  oop lirKind = AbstractValue::lirKind(value);
+  oop lirKind = Value::lirKind(value);
   oop platformKind = LIRKind::platformKind(lirKind);
   assert(LIRKind::referenceMask(lirKind) == 1, "unexpected referenceMask");
   
@@ -192,7 +192,7 @@
 
 ScopeValue* CodeInstaller::get_scope_value(oop value, BasicType type, GrowableArray<ScopeValue*>* objects, ScopeValue* &second) {
   second = NULL;
-  if (value == AbstractValue::ILLEGAL()) {
+  if (value == Value::ILLEGAL()) {
     assert(type == T_ILLEGAL, "expected legal value");
     return _illegal_value;
   } else if (value->is_a(RegisterValue::klass())) {
@@ -811,7 +811,7 @@
       if (second != NULL) {
         i++;
         assert(i < values->length(), "double-slot value not followed by Value.ILLEGAL");
-        assert(values->obj_at(i) == AbstractValue::ILLEGAL(), "double-slot value not followed by Value.ILLEGAL");
+        assert(values->obj_at(i) == Value::ILLEGAL(), "double-slot value not followed by Value.ILLEGAL");
       }
     }
 
--- a/src/share/vm/jvmci/jvmciJavaAccess.hpp	Tue Sep 01 18:58:12 2015 +0200
+++ b/src/share/vm/jvmci/jvmciJavaAccess.hpp	Wed Sep 02 12:02:17 2015 +0200
@@ -227,10 +227,10 @@
     oop_field(LIRKind, platformKind, "Ljdk/internal/jvmci/meta/PlatformKind;")                                                                                   \
     int_field(LIRKind, referenceMask)                                                                                                                          \
   end_class                                                                                                                                                    \
-  start_class(AbstractValue)                                                                                                                                   \
-    oop_field(AbstractValue, kind, "Ljdk/internal/jvmci/meta/Kind;")                                                                                             \
-    oop_field(AbstractValue, lirKind, "Ljdk/internal/jvmci/meta/LIRKind;")                                                                                       \
-    static_oop_field(AbstractValue, ILLEGAL, "Ljdk/internal/jvmci/meta/AllocatableValue;");                                                                      \
+  start_class(Value)                                                                                                                                           \
+    oop_field(Value, kind, "Ljdk/internal/jvmci/meta/Kind;")                                                                                                   \
+    oop_field(Value, lirKind, "Ljdk/internal/jvmci/meta/LIRKind;")                                                                                             \
+    static_oop_field(Value, ILLEGAL, "Ljdk/internal/jvmci/meta/AllocatableValue;");                                                                            \
   end_class                                                                                                                                                    \
   start_class(RegisterValue)                                                                                                                                   \
     oop_field(RegisterValue, reg, "Ljdk/internal/jvmci/code/Register;")                                                                                          \
--- a/src/share/vm/jvmci/systemDictionary_jvmci.hpp	Tue Sep 01 18:58:12 2015 +0200
+++ b/src/share/vm/jvmci/systemDictionary_jvmci.hpp	Wed Sep 02 12:02:17 2015 +0200
@@ -79,7 +79,7 @@
   do_klass(ExceptionHandler_klass,                       jdk_internal_jvmci_meta_ExceptionHandler,                       Jvmci) \
   do_klass(Kind_klass,                                   jdk_internal_jvmci_meta_Kind,                                   Jvmci) \
   do_klass(LIRKind_klass,                                jdk_internal_jvmci_meta_LIRKind,                                Jvmci) \
-  do_klass(AbstractValue_klass,                          jdk_internal_jvmci_meta_AbstractValue,                          Jvmci)
+  do_klass(Value_klass,                                  jdk_internal_jvmci_meta_Value,                                  Jvmci)
 #endif
 
 #endif // SHARE_VM_JVMCI_SYSTEMDICTIONARY_JVMCI_HPP
--- a/src/share/vm/jvmci/vmSymbols_jvmci.hpp	Tue Sep 01 18:58:12 2015 +0200
+++ b/src/share/vm/jvmci/vmSymbols_jvmci.hpp	Wed Sep 02 12:02:17 2015 +0200
@@ -52,7 +52,7 @@
   template(jdk_internal_jvmci_meta_ExceptionHandler,                   "jdk/internal/jvmci/meta/ExceptionHandler")                        \
   template(jdk_internal_jvmci_meta_Kind,                               "jdk/internal/jvmci/meta/Kind")                                    \
   template(jdk_internal_jvmci_meta_LIRKind,                            "jdk/internal/jvmci/meta/LIRKind")                                 \
-  template(jdk_internal_jvmci_meta_AbstractValue,                      "jdk/internal/jvmci/meta/AbstractValue")                           \
+  template(jdk_internal_jvmci_meta_Value,                              "jdk/internal/jvmci/meta/Value")                                   \
   template(jdk_internal_jvmci_meta_Assumptions_ConcreteSubtype,        "jdk/internal/jvmci/meta/Assumptions$ConcreteSubtype")             \
   template(jdk_internal_jvmci_meta_Assumptions_LeafType,               "jdk/internal/jvmci/meta/Assumptions$LeafType")                    \
   template(jdk_internal_jvmci_meta_Assumptions_NoFinalizableSubclass,  "jdk/internal/jvmci/meta/Assumptions$NoFinalizableSubclass")       \