org.jikesrvm.compilers.opt
Class StaticFieldReader

java.lang.Object
  extended by org.jikesrvm.compilers.opt.StaticFieldReader
All Implemented Interfaces:
SizeConstants

public abstract class StaticFieldReader
extends Object
implements SizeConstants

Code for accessing the value of a static field at compile time. This is used to optimize getstatic's of initialized static fields by replacing the getstatic with a constant operand.


Field Summary
 
Fields inherited from interface org.jikesrvm.SizeConstants
BITS_IN_ADDRESS, BITS_IN_BOOLEAN, BITS_IN_BYTE, BITS_IN_CHAR, BITS_IN_DOUBLE, BITS_IN_EXTENT, BITS_IN_FLOAT, BITS_IN_INT, BITS_IN_LONG, BITS_IN_OFFSET, BITS_IN_PAGE, BITS_IN_SHORT, BITS_IN_WORD, BYTES_IN_ADDRESS, BYTES_IN_BOOLEAN, BYTES_IN_BYTE, BYTES_IN_CHAR, BYTES_IN_DOUBLE, BYTES_IN_EXTENT, BYTES_IN_FLOAT, BYTES_IN_INT, BYTES_IN_LONG, BYTES_IN_OFFSET, BYTES_IN_PAGE, BYTES_IN_SHORT, BYTES_IN_WORD, LOG_BITS_IN_ADDRESS, LOG_BITS_IN_BOOLEAN, LOG_BITS_IN_BYTE, LOG_BITS_IN_CHAR, LOG_BITS_IN_DOUBLE, LOG_BITS_IN_EXTENT, LOG_BITS_IN_FLOAT, LOG_BITS_IN_INT, LOG_BITS_IN_LONG, LOG_BITS_IN_OFFSET, LOG_BITS_IN_PAGE, LOG_BITS_IN_SHORT, LOG_BITS_IN_WORD, LOG_BYTES_IN_ADDRESS, LOG_BYTES_IN_BOOLEAN, LOG_BYTES_IN_BYTE, LOG_BYTES_IN_CHAR, LOG_BYTES_IN_DOUBLE, LOG_BYTES_IN_EXTENT, LOG_BYTES_IN_FLOAT, LOG_BYTES_IN_INT, LOG_BYTES_IN_LONG, LOG_BYTES_IN_OFFSET, LOG_BYTES_IN_PAGE, LOG_BYTES_IN_SHORT, LOG_BYTES_IN_WORD
 
Constructor Summary
StaticFieldReader()
           
 
Method Summary
static Address getAddressStaticFieldValue(RVMField field)
          Returns the current contents of a Address static field.
static double getDoubleStaticFieldValue(RVMField field)
          Returns the current contents of a double static field.
static ConstantOperand getFieldValueAsConstant(RVMField field, Object obj)
          Read the field from obj and return as the appropriate constant
static float getFloatStaticFieldValue(RVMField field)
          Returns the current contents of a float static field.
static int getIntStaticFieldValue(RVMField field)
          Returns the current contents of an int-like static field.
private static Field getJDKField(RVMField field)
          Utilitiy to convert a RVMField to a java.lang.reflect.Field
static long getLongStaticFieldValue(RVMField field)
          Returns the current contents of a long static field.
static Object getObjectStaticFieldValue(RVMField field)
          Returns the current contents of a reference static field.
static ConstantOperand getStaticFieldValue(RVMField field)
          Returns a constant operand with the current value of a static field.
static TypeReference getTypeFromStaticField(RVMField field)
          Get the type of an object contained in a static field.
static boolean isStaticFieldNull(RVMField field)
          Does a static field null contain null?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StaticFieldReader

public StaticFieldReader()
Method Detail

getFieldValueAsConstant

public static ConstantOperand getFieldValueAsConstant(RVMField field,
                                                      Object obj)
                                               throws NoSuchFieldException
Read the field from obj and return as the appropriate constant

Throws:
NoSuchFieldException

getStaticFieldValue

public static ConstantOperand getStaticFieldValue(RVMField field)
                                           throws NoSuchFieldException
Returns a constant operand with the current value of a static field.

Parameters:
field - the static field whose current value we want to read
Returns:
a constant operand representing the current value of the field.
Throws:
NoSuchFieldException

getIntStaticFieldValue

public static int getIntStaticFieldValue(RVMField field)
                                  throws NoSuchFieldException
Returns the current contents of an int-like static field.

Parameters:
field - a static field
Returns:
the current value of the field
Throws:
NoSuchFieldException

getFloatStaticFieldValue

public static float getFloatStaticFieldValue(RVMField field)
                                      throws NoSuchFieldException
Returns the current contents of a float static field.

Parameters:
field - a static field
Returns:
the current value of the field
Throws:
NoSuchFieldException

getLongStaticFieldValue

public static long getLongStaticFieldValue(RVMField field)
                                    throws NoSuchFieldException
Returns the current contents of a long static field.

Parameters:
field - a static field
Returns:
the current value of the field
Throws:
NoSuchFieldException

getDoubleStaticFieldValue

public static double getDoubleStaticFieldValue(RVMField field)
                                        throws NoSuchFieldException
Returns the current contents of a double static field.

Parameters:
field - a static field
Returns:
the current value of the field
Throws:
NoSuchFieldException

getObjectStaticFieldValue

public static Object getObjectStaticFieldValue(RVMField field)
                                        throws NoSuchFieldException
Returns the current contents of a reference static field.

Parameters:
field - a static field
Returns:
the current value of the field
Throws:
NoSuchFieldException

getAddressStaticFieldValue

public static Address getAddressStaticFieldValue(RVMField field)
                                          throws NoSuchFieldException
Returns the current contents of a Address static field.

Parameters:
field - a static field
Returns:
the current value of the field
Throws:
NoSuchFieldException

isStaticFieldNull

public static boolean isStaticFieldNull(RVMField field)
                                 throws NoSuchFieldException
Does a static field null contain null?

Parameters:
field - a static field
Returns:
true if the field contains null, false otherwise
Throws:
NoSuchFieldException

getTypeFromStaticField

public static TypeReference getTypeFromStaticField(RVMField field)
                                            throws NoSuchFieldException
Get the type of an object contained in a static field.

Parameters:
field - a static field
Returns:
type of value contained in the field
Throws:
NoSuchFieldException

getJDKField

private static Field getJDKField(RVMField field)
                          throws NoSuchFieldException
Utilitiy to convert a RVMField to a java.lang.reflect.Field

Throws:
NoSuchFieldException