diff graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ConstantReflectionProvider.java @ 18472:de179c27cad3

Add support for stable array constants
author Andreas Woess <andreas.woess@jku.at>
date Thu, 20 Nov 2014 13:22:12 +0100
parents f0a8b72315c1
children b8a622c3e99f
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ConstantReflectionProvider.java	Wed Nov 19 17:45:40 2014 +0100
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ConstantReflectionProvider.java	Thu Nov 20 13:22:12 2014 +0100
@@ -56,6 +56,13 @@
     JavaConstant readArrayElement(JavaConstant array, int index);
 
     /**
+     * Reads a value from the given array at the given index if it is a stable array. Returns
+     * {@code null} if the constant is not a stable array, if it is a default value, if the index is
+     * out of bounds, or if the value is not available at this point.
+     */
+    JavaConstant readConstantArrayElement(JavaConstant array, int index);
+
+    /**
      * Gets the constant value of this field. Note that a {@code static final} field may not be
      * considered constant if its declaring class is not yet initialized or if it is a well known
      * field that can be updated via other means (e.g., {@link System#setOut(java.io.PrintStream)}).
@@ -68,10 +75,11 @@
     JavaConstant readConstantFieldValue(JavaField field, JavaConstant receiver);
 
     /**
-     * Gets the current value of this field for a given object, if available. There is no guarantee
-     * that the same value will be returned by this method for a field unless the field is
-     * considered to be {@linkplain #readConstantFieldValue(JavaField, JavaConstant) constant} by
-     * the runtime.
+     * Gets the current value of this field for a given object, if available.
+     *
+     * There is no guarantee that the same value will be returned by this method for a field unless
+     * the field is considered to be {@linkplain #readConstantFieldValue(JavaField, JavaConstant)
+     * constant} by the runtime.
      *
      * @param receiver object from which this field's value is to be read. This value is ignored if
      *            this field is static.
@@ -81,6 +89,22 @@
     JavaConstant readFieldValue(JavaField field, JavaConstant receiver);
 
     /**
+     * Gets the current value of this field for a given object, if available. Like
+     * {@link #readFieldValue(JavaField, JavaConstant)} but treats array fields as stable.
+     *
+     * There is no guarantee that the same value will be returned by this method for a field unless
+     * the field is considered to be {@linkplain #readConstantFieldValue(JavaField, JavaConstant)
+     * constant} by the runtime.
+     *
+     * @param receiver object from which this field's value is to be read. This value is ignored if
+     *            this field is static.
+     * @param isDefaultStable if {@code true}, default values are considered stable
+     * @return the value of this field or {@code null} if the value is not available (e.g., because
+     *         the field holder is not yet initialized).
+     */
+    JavaConstant readStableFieldValue(JavaField field, JavaConstant receiver, boolean isDefaultStable);
+
+    /**
      * Reads a value of this kind using a base address and a displacement. No bounds checking or
      * type checking is performed. Returns {@code null} if the value is not available at this point.
      *