harpoon.Backend.Runtime1
Class TreeBuilder

java.lang.Object
  extended by harpoon.Backend.Generic.Runtime.TreeBuilder
      extended by harpoon.Backend.Runtime1.TreeBuilder
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
TreeBuilder, TreeBuilder

public class TreeBuilder
extends Runtime.TreeBuilder

Runtime1.TreeBuilder is an implementation of Generic.Runtime.TreeBuilder which creates accessor expressions for the Runtime1 runtime.

Pretty straightforward. No weird hacks.

Version:
$Id: TreeBuilder.java,v 1.10 2004/07/02 01:05:01 cananian Exp $
Author:
C. Scott Ananian <cananian@alumni.princeton.edu>
See Also:
Serialized Form

Field Summary
protected  AllocationStrategy as
          allocation strategy to use.
protected  ClassDepthMap cdm
           
protected  FieldMap cfm
           
protected  int CLAZ_CLAZINFO
           
protected  int CLAZ_COMPONENT_OFF
           
protected  int CLAZ_DEPTH_OFF
           
protected  int CLAZ_DISPLAY_OFF
           
protected  int CLAZ_EXTRAINFO_OFF
           
protected  int CLAZ_GCENTRY_OFF
           
protected  int CLAZ_INTERFACES_OFF
           
protected  int CLAZ_INTERFZ_OFF
           
protected  int CLAZ_METHODS_OFF
           
protected  int CLAZ_SIZE_OFF
           
protected  MethodMap cmm
           
protected  MethodMap imm
           
protected  Linker linker
           
protected  int LONG_WORD_SIZE
           
protected  int OBJ_ALENGTH_OFF
           
protected  int OBJ_AZERO_OFF
           
protected  int OBJ_CLAZ_OFF
           
protected  int OBJ_FZERO_OFF
           
protected  int OBJ_HASH_OFF
           
protected  int OBJECT_HEADER_SIZE
           
protected  int POINTER_SIZE
           
protected  Runtime runtime
           
protected  int WORD_SIZE
           
 
Constructor Summary
protected TreeBuilder(Runtime runtime, Linker linker, AllocationStrategy as, boolean pointersAreLong, int pointerAlignment)
           
 
Method Summary
protected  Stm _call_FNI_Monitor(TreeFactory tf, HCodeElement source, DerivationGenerator dg, Translation.Exp objectref, boolean isEnter)
          wrap objectref and then call FNI_Monitor{Enter|Exit}()
protected  Exp _claz_(TreeFactory tf, HCodeElement source, DerivationGenerator dg, Translation.Exp objectref)
          Returns a pointer to the claz structure associated with the given objectref.
 Translation.Exp arrayBase(TreeFactory tf, HCodeElement source, DerivationGenerator dg, Translation.Exp objectref)
          Return a Translation.Exp representing the array-base of the object referenced by the given objectref Translation.Exp.
 Translation.Exp arrayLength(TreeFactory tf, HCodeElement source, DerivationGenerator dg, Translation.Exp arrayRef)
          Return a Translation.Exp giving the length of the array pointed to by the given expression.
 Translation.Exp arrayNew(TreeFactory tf, HCodeElement source, DerivationGenerator dg, AllocationInformation.AllocationProperties ap, HClass arrayType, Translation.Exp length, boolean initialize)
          Return a Translation.Exp which will create a array of the given type, with length specified by the given expression.
 Translation.Exp arrayOffset(TreeFactory tf, HCodeElement source, DerivationGenerator dg, HClass arrayType, Translation.Exp index)
          Return a Translation.Exp representing the offset from the array base needed to access the array element specified by the index expression.
 Translation.Exp classConst(TreeFactory tf, HCodeElement source, DerivationGenerator dg, HClass classData)
          Return a Translation.Exp which represents a reference to a Class constant.
 Stm clearHashBit(TreeFactory tf, HCodeElement source, DerivationGenerator dg, Exp objExp)
           
 Translation.Exp componentOf(TreeFactory tf, HCodeElement source, DerivationGenerator dg, Translation.Exp arrayref, Translation.Exp componentref)
          Return a Translation.Exp which tests the given object expression for membership in the component type of the given array expression.
protected static Exp DECLARE(DerivationGenerator dg, Derivation.DList dl, Exp exp)
           
protected static Exp DECLARE(DerivationGenerator dg, HClass hc, Exp exp)
           
protected static Exp DECLARE(DerivationGenerator dg, HClass hc, Temp t, Exp exp)
           
 Translation.Exp fieldBase(TreeFactory tf, HCodeElement source, DerivationGenerator dg, Translation.Exp objectref)
          Return a Translation.Exp representing the field base of the object referenced by the given objectref expression.
 Translation.Exp fieldConst(TreeFactory tf, HCodeElement source, DerivationGenerator dg, HField fieldData)
          Return a Translation.Exp which represents a reference to a java.lang.reflect.Field constant.
 Translation.Exp fieldOffset(TreeFactory tf, HCodeElement source, DerivationGenerator dg, HField field)
          Return a Translation.Exp representing an offset from the field base required to access the given field.
 int headerSize(HClass hc)
          Utility method for external analyses that want to know the size of an object header.
protected  FieldMap initClassFieldMap()
           
 Translation.Exp instanceOf(TreeFactory tf, HCodeElement source, DerivationGenerator dg, Translation.Exp objref, HClass classType)
          Return a Translation.Exp which tests the given expression for membership in the given class or interface.
 Translation.Exp methodBase(TreeFactory tf, HCodeElement source, DerivationGenerator dg, Translation.Exp objectref)
          Return a Translation.Exp representing the method base of the object referenced by the given objectref expression.
 Translation.Exp methodConst(TreeFactory tf, HCodeElement source, DerivationGenerator dg, HMethod methodData)
          Return a Translation.Exp which represents a reference to a java.lang.reflect.Method constant.
 Translation.Exp methodOffset(TreeFactory tf, HCodeElement source, DerivationGenerator dg, HMethod method)
          Return a Translation.Exp representing an offset from the method base required to access the given method.
 Translation.Exp monitorEnter(TreeFactory tf, HCodeElement source, DerivationGenerator dg, Translation.Exp objectref)
          Return a Translation.Exp which acquires the monitor lock of the object specified by the given expression.
 Translation.Exp monitorExit(TreeFactory tf, HCodeElement source, DerivationGenerator dg, Translation.Exp objectref)
          Return a Translation.Exp which releases the monitor lock of the object specified by the given expression.
 Exp objAlloc(TreeFactory tf, HCodeElement source, DerivationGenerator dg, AllocationInformation.AllocationProperties ap, HClass objectType, Exp length)
           
 Translation.Exp objectNew(TreeFactory tf, HCodeElement source, DerivationGenerator dg, AllocationInformation.AllocationProperties ap, HClass classType, boolean initialize)
          Return a Translation.Exp which will create a object of the given type, with length specified by the given expression.
 int objectSize(HClass hc)
          Utility method for external analyses that want to know the exact size of an object.
protected  Exp PTRMASK(TreeFactory tf, HCodeElement source, DerivationGenerator dg, Exp e)
           
 Translation.Exp referenceEqual(TreeFactory tf, HCodeElement source, DerivationGenerator dg, Translation.Exp refLeft, Translation.Exp refRight)
          Return a Translation.Exp representing an comparison between expressions evaluating to two references, refLeft and refRight.
protected  void setClassHierarchy(ClassHierarchy ch)
           
 Translation.Exp stringConst(TreeFactory tf, HCodeElement source, DerivationGenerator dg, String stringData)
          Return a Translation.Exp which represents a reference to a string constant.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

as

protected final AllocationStrategy as
allocation strategy to use.


WORD_SIZE

protected final int WORD_SIZE

LONG_WORD_SIZE

protected final int LONG_WORD_SIZE

POINTER_SIZE

protected final int POINTER_SIZE

OBJECT_HEADER_SIZE

protected int OBJECT_HEADER_SIZE

OBJ_CLAZ_OFF

protected int OBJ_CLAZ_OFF

OBJ_HASH_OFF

protected int OBJ_HASH_OFF

OBJ_ALENGTH_OFF

protected int OBJ_ALENGTH_OFF

OBJ_AZERO_OFF

protected int OBJ_AZERO_OFF

OBJ_FZERO_OFF

protected int OBJ_FZERO_OFF

CLAZ_INTERFACES_OFF

protected final int CLAZ_INTERFACES_OFF

CLAZ_CLAZINFO

protected final int CLAZ_CLAZINFO

CLAZ_COMPONENT_OFF

protected final int CLAZ_COMPONENT_OFF

CLAZ_INTERFZ_OFF

protected final int CLAZ_INTERFZ_OFF

CLAZ_SIZE_OFF

protected final int CLAZ_SIZE_OFF

CLAZ_DEPTH_OFF

protected final int CLAZ_DEPTH_OFF

CLAZ_GCENTRY_OFF

protected final int CLAZ_GCENTRY_OFF

CLAZ_EXTRAINFO_OFF

protected final int CLAZ_EXTRAINFO_OFF

CLAZ_DISPLAY_OFF

protected final int CLAZ_DISPLAY_OFF

CLAZ_METHODS_OFF

protected int CLAZ_METHODS_OFF

runtime

protected final Runtime runtime

linker

protected final Linker linker

cdm

protected ClassDepthMap cdm

imm

protected MethodMap imm

cmm

protected final MethodMap cmm

cfm

protected final FieldMap cfm
Constructor Detail

TreeBuilder

protected TreeBuilder(Runtime runtime,
                      Linker linker,
                      AllocationStrategy as,
                      boolean pointersAreLong,
                      int pointerAlignment)
Method Detail

initClassFieldMap

protected FieldMap initClassFieldMap()

setClassHierarchy

protected void setClassHierarchy(ClassHierarchy ch)

DECLARE

protected static Exp DECLARE(DerivationGenerator dg,
                             HClass hc,
                             Exp exp)

DECLARE

protected static Exp DECLARE(DerivationGenerator dg,
                             HClass hc,
                             Temp t,
                             Exp exp)

DECLARE

protected static Exp DECLARE(DerivationGenerator dg,
                             Derivation.DList dl,
                             Exp exp)

PTRMASK

protected Exp PTRMASK(TreeFactory tf,
                      HCodeElement source,
                      DerivationGenerator dg,
                      Exp e)

objectSize

public int objectSize(HClass hc)
Description copied from class: Runtime.TreeBuilder
Utility method for external analyses that want to know the exact size of an object. This returns the size in bytes not including the header.

Specified by:
objectSize in class Runtime.TreeBuilder

headerSize

public int headerSize(HClass hc)
Description copied from class: Runtime.TreeBuilder
Utility method for external analyses that want to know the size of an object header. Returns the header size in bytes. The total allocated memory for an object is objectSize(hc)+headerSize(hc).

Specified by:
headerSize in class Runtime.TreeBuilder

objAlloc

public Exp objAlloc(TreeFactory tf,
                    HCodeElement source,
                    DerivationGenerator dg,
                    AllocationInformation.AllocationProperties ap,
                    HClass objectType,
                    Exp length)

clearHashBit

public Stm clearHashBit(TreeFactory tf,
                        HCodeElement source,
                        DerivationGenerator dg,
                        Exp objExp)

arrayLength

public Translation.Exp arrayLength(TreeFactory tf,
                                   HCodeElement source,
                                   DerivationGenerator dg,
                                   Translation.Exp arrayRef)
Description copied from class: Runtime.TreeBuilder
Return a Translation.Exp giving the length of the array pointed to by the given expression.

Specified by:
arrayLength in class Runtime.TreeBuilder

arrayNew

public Translation.Exp arrayNew(TreeFactory tf,
                                HCodeElement source,
                                DerivationGenerator dg,
                                AllocationInformation.AllocationProperties ap,
                                HClass arrayType,
                                Translation.Exp length,
                                boolean initialize)
Description copied from class: Runtime.TreeBuilder
Return a Translation.Exp which will create a array of the given type, with length specified by the given expression. Only a single dimension of a multidimensional array will be created. Elements of the array are only initialized if the initialize parameter is true; however the internal object header, length, and any internal fields of the array inherited from java.lang.Object are always initialized.

Specified by:
arrayNew in class Runtime.TreeBuilder

componentOf

public Translation.Exp componentOf(TreeFactory tf,
                                   HCodeElement source,
                                   DerivationGenerator dg,
                                   Translation.Exp arrayref,
                                   Translation.Exp componentref)
Description copied from class: Runtime.TreeBuilder
Return a Translation.Exp which tests the given object expression for membership in the component type of the given array expression.

Specified by:
componentOf in class Runtime.TreeBuilder

instanceOf

public Translation.Exp instanceOf(TreeFactory tf,
                                  HCodeElement source,
                                  DerivationGenerator dg,
                                  Translation.Exp objref,
                                  HClass classType)
Description copied from class: Runtime.TreeBuilder
Return a Translation.Exp which tests the given expression for membership in the given class or interface.

Specified by:
instanceOf in class Runtime.TreeBuilder

monitorEnter

public Translation.Exp monitorEnter(TreeFactory tf,
                                    HCodeElement source,
                                    DerivationGenerator dg,
                                    Translation.Exp objectref)
Description copied from class: Runtime.TreeBuilder
Return a Translation.Exp which acquires the monitor lock of the object specified by the given expression.

Specified by:
monitorEnter in class Runtime.TreeBuilder

monitorExit

public Translation.Exp monitorExit(TreeFactory tf,
                                   HCodeElement source,
                                   DerivationGenerator dg,
                                   Translation.Exp objectref)
Description copied from class: Runtime.TreeBuilder
Return a Translation.Exp which releases the monitor lock of the object specified by the given expression.

Specified by:
monitorExit in class Runtime.TreeBuilder

_call_FNI_Monitor

protected Stm _call_FNI_Monitor(TreeFactory tf,
                                HCodeElement source,
                                DerivationGenerator dg,
                                Translation.Exp objectref,
                                boolean isEnter)
wrap objectref and then call FNI_Monitor{Enter|Exit}()


objectNew

public Translation.Exp objectNew(TreeFactory tf,
                                 HCodeElement source,
                                 DerivationGenerator dg,
                                 AllocationInformation.AllocationProperties ap,
                                 HClass classType,
                                 boolean initialize)
Description copied from class: Runtime.TreeBuilder
Return a Translation.Exp which will create a object of the given type, with length specified by the given expression. Fields of the object are only initialized if the initialize parameter is true; however the internal object header is always created and initialized.

Specified by:
objectNew in class Runtime.TreeBuilder

classConst

public Translation.Exp classConst(TreeFactory tf,
                                  HCodeElement source,
                                  DerivationGenerator dg,
                                  HClass classData)
Description copied from class: Runtime.TreeBuilder
Return a Translation.Exp which represents a reference to a Class constant. The runtime may implement this by a call to Class.forName(classname) or other lookup function, or may return a NAME if the class objects are statically allocated.

Specified by:
classConst in class Runtime.TreeBuilder

fieldConst

public Translation.Exp fieldConst(TreeFactory tf,
                                  HCodeElement source,
                                  DerivationGenerator dg,
                                  HField fieldData)
Description copied from class: Runtime.TreeBuilder
Return a Translation.Exp which represents a reference to a java.lang.reflect.Field constant. The runtime may implement this by a call to Class.forName(classname).getDeclaredField(fieldname) or other lookup functions, or may return a NAME if the Field objects are statically allocated.

Specified by:
fieldConst in class Runtime.TreeBuilder

methodConst

public Translation.Exp methodConst(TreeFactory tf,
                                   HCodeElement source,
                                   DerivationGenerator dg,
                                   HMethod methodData)
Description copied from class: Runtime.TreeBuilder
Return a Translation.Exp which represents a reference to a java.lang.reflect.Method constant. The runtime may implement this by a call to Class.forName(classname).getDeclaredMethod(name,...) or other lookup functions, or may return a NAME if the Method objects are statically allocated.

Specified by:
methodConst in class Runtime.TreeBuilder

stringConst

public Translation.Exp stringConst(TreeFactory tf,
                                   HCodeElement source,
                                   DerivationGenerator dg,
                                   String stringData)
Description copied from class: Runtime.TreeBuilder
Return a Translation.Exp which represents a reference to a string constant. Note that invoking String.intern() on the String object reference returned must return a result identical to the reference. This may involve fix-up and/or addition of objects to the class or global HData; these tasks are the responsibility of the Generic.Runtime, and it is anticipated that the invocation of this method may have such side-effects (although other implementations are certainly possible).

Specified by:
stringConst in class Runtime.TreeBuilder

arrayBase

public Translation.Exp arrayBase(TreeFactory tf,
                                 HCodeElement source,
                                 DerivationGenerator dg,
                                 Translation.Exp objectref)
Description copied from class: Runtime.TreeBuilder
Return a Translation.Exp representing the array-base of the object referenced by the given objectref Translation.Exp. This expression should point to the zero'th element of the array object specified by objectref.

Specified by:
arrayBase in class Runtime.TreeBuilder

arrayOffset

public Translation.Exp arrayOffset(TreeFactory tf,
                                   HCodeElement source,
                                   DerivationGenerator dg,
                                   HClass arrayType,
                                   Translation.Exp index)
Description copied from class: Runtime.TreeBuilder
Return a Translation.Exp representing the offset from the array base needed to access the array element specified by the index expression. If index is zero, then the Translation.Exp returned should also have value zero.

Specified by:
arrayOffset in class Runtime.TreeBuilder

fieldBase

public Translation.Exp fieldBase(TreeFactory tf,
                                 HCodeElement source,
                                 DerivationGenerator dg,
                                 Translation.Exp objectref)
Description copied from class: Runtime.TreeBuilder
Return a Translation.Exp representing the field base of the object referenced by the given objectref expression. This expression should point to the first field in the object.

Specified by:
fieldBase in class Runtime.TreeBuilder

fieldOffset

public Translation.Exp fieldOffset(TreeFactory tf,
                                   HCodeElement source,
                                   DerivationGenerator dg,
                                   HField field)
Description copied from class: Runtime.TreeBuilder
Return a Translation.Exp representing an offset from the field base required to access the given field. If the given field is the first in the object, then the Translation.Exp returned should have value zero.

Specified by:
fieldOffset in class Runtime.TreeBuilder

_claz_

protected Exp _claz_(TreeFactory tf,
                     HCodeElement source,
                     DerivationGenerator dg,
                     Translation.Exp objectref)
Returns a pointer to the claz structure associated with the given objectref.


methodBase

public Translation.Exp methodBase(TreeFactory tf,
                                  HCodeElement source,
                                  DerivationGenerator dg,
                                  Translation.Exp objectref)
Description copied from class: Runtime.TreeBuilder
Return a Translation.Exp representing the method base of the object referenced by the given objectref expression. This expression should point a location containing a pointer to the first method of the object.

Specified by:
methodBase in class Runtime.TreeBuilder

methodOffset

public Translation.Exp methodOffset(TreeFactory tf,
                                    HCodeElement source,
                                    DerivationGenerator dg,
                                    HMethod method)
Description copied from class: Runtime.TreeBuilder
Return a Translation.Exp representing an offset from the method base required to access the given method. If the given method is the first of the object, then the Translation.Exp returned should have value zero.

Specified by:
methodOffset in class Runtime.TreeBuilder

referenceEqual

public Translation.Exp referenceEqual(TreeFactory tf,
                                      HCodeElement source,
                                      DerivationGenerator dg,
                                      Translation.Exp refLeft,
                                      Translation.Exp refRight)
Description copied from class: Runtime.TreeBuilder
Return a Translation.Exp representing an comparison between expressions evaluating to two references, refLeft and refRight. Note that this is *reference* equality, not *POINTER* equality. The fieldBase method, for example, is required to return a POINTER expression (which is typically a bit-masked and offset version of the reference value); one valid implementation of referenceEqual would be to compare the values returned by a call to fieldBase() on the operands, but there is typically a more efficient means.

Specified by:
referenceEqual in class Runtime.TreeBuilder