harpoon.IR.Quads
Class CALL

java.lang.Object
  extended by harpoon.IR.Quads.Quad
      extended by harpoon.IR.Quads.SIGMA
          extended by harpoon.IR.Quads.CALL
All Implemented Interfaces:
HCodeElement, CFGraphable<Quad,Edge>, UseDefable, Graph.Node<Quad,Edge>, Serializable, Cloneable, Comparable<Quad>

public class CALL
extends SIGMA

CALL objects represent method invocations.

The retval field will be null for void methods. For non-static methods, the method receiver (object reference on which to invoke the method) is the first parameter in the params array.

CALL behaves like a conditional branch: if no exception is thrown by the called method, the Temp specified by retval will be assigned the return value, if any, and execution will follow the first outgoing edge, nextEdge(0). If an exception is thrown then the Temp specified by retex will be assigned the non-null reference to the thrown exception and execution will follow the second outgoing edge, nextEdge(1). Calls with explicit exception handling always have exactly two outgoing edges.

In quad-with-try form, the CALL has only one outgoing edge, and exceptions are handled by an implicit control transfer to an appropriate HANDLER quad. The retex field should be null in this case (and only in this case).

Note that exactly one of { retval, retex } will be defined after the execution of CALL; thus it is perfectly valid for retval and retex to be identical. Of course, for type-safety the return type cannot be primitive if this is so.

The Temp not defined by the CALL (if the retex and retval Temps are different) is undefined --- that is, it may have any value at all after the CALL. Both IR.LowQuad.PCALL and IR.Tree.CALL also behave this way.

Version:
$Id: CALL.java,v 1.6 2005/09/28 18:24:16 salcianu Exp $
Author:
C. Scott Ananian <cananian@alumni.princeton.edu>
See Also:
Serialized Form

Field Summary
protected  boolean isTailCall
          Special flag for tail calls.
protected  boolean isVirtual
          Special flag for non-virtual methods.
protected  HMethod method
          The method to invoke.
protected  Temp[] params
          Parameters to pass to the method.
protected  Temp retex
          Destination for any exception thrown by the method.
protected  Temp retval
          Destination for the method's return value; null for void methods.
 
Fields inherited from class harpoon.IR.Quads.SIGMA
dst, src
 
Fields inherited from class harpoon.IR.Quads.Quad
arrayFactory
 
Constructor Summary
CALL(QuadFactory qf, HCodeElement source, HMethod method, Temp[] params, Temp retval, Temp retex, boolean isVirtual, boolean isTailCall, Temp[] src)
          Creates a CALL with an empty dst array of the proper size.
CALL(QuadFactory qf, HCodeElement source, HMethod method, Temp[] params, Temp retval, Temp retex, boolean isVirtual, boolean isTailCall, Temp[][] dst, Temp[] src)
          Creates a CALL quad representing a method invocation with explicit exception handling.
 
Method Summary
<T> T
accept(QuadValueVisitor<T> v)
           
 void accept(QuadVisitor v)
          Accept a visitor.
 Temp[] def()
          Returns all the Temps defined by this Quad.
 boolean isInterfaceMethod()
          Determines whether this CALL is to an interface method.
 boolean isStatic()
          Determines whether this CALL is to a static method.
 boolean isTailCall()
          Returns true if this method should return the same value the callee returns or throw whatever exception the callee throws (in which case we can get rid of our stack and let the callee return directly to our caller.
 boolean isVirtual()
          Returns true if the method is dispatched virtually, or false otherwise.
 int kind()
          Return an integer enumeration of the kind of this Quad.
 HMethod method()
          Returns the method invoked by this CALL.
 Temp[] params()
          Returns the parameters of this method invocation.
 Temp params(int i)
          Returns a specified parameter in the params array.
 int paramsLength()
          Returns the number of parameters in the params array.
 HClass paramType(int i)
          Returns the type of the specified parameter.
 Quad rename(QuadFactory qqf, TempMap defMap, TempMap useMap)
          Create a new Quad identical to the receiver, but with all Temps renamed according to a mapping.
 Temp retex()
          Returns the Temp which will get any exception thrown by the called method, or null if exceptions are not caught.
 Temp retval()
          Returns the Temp which will hold the return value of the method, or the value null if the method returns no value.
 String toString()
          Returns human-readable representation.
 Temp[] use()
          Returns all the Temps used by this Quad.
 
Methods inherited from class harpoon.IR.Quads.SIGMA
arity, assign, dst, dst, dst, numSigmas, removeSigma, src, src
 
Methods inherited from class harpoon.IR.Quads.Quad
addEdge, addEdges, addHandlers, clone, clone, clone, compareTo, defC, edgeC, edges, getFactory, getID, getLineNumber, getSourceFile, handlers, hashCode, isPred, isSucc, map, map, map, next, next, nextEdge, nextEdge, nextLength, pred, predC, prev, prev, prevEdge, prevEdge, prevLength, remove, removeHandlers, rename, replace, succ, succC, toLongString, transferHandlers, useC
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

method

protected final HMethod method
The method to invoke.


params

protected Temp[] params
Parameters to pass to the method. The object on which to invoke the method is the first element in the parameter list of a virtual method.


retval

protected Temp retval
Destination for the method's return value; null for void methods.


retex

protected Temp retex
Destination for any exception thrown by the method. If null exceptions are thrown, not caught.


isVirtual

protected final boolean isVirtual
Special flag for non-virtual methods. (INVOKESPECIAL has different invoke semantics)


isTailCall

protected final boolean isTailCall
Special flag for tail calls.

Constructor Detail

CALL

public CALL(QuadFactory qf,
            HCodeElement source,
            HMethod method,
            Temp[] params,
            Temp retval,
            Temp retex,
            boolean isVirtual,
            boolean isTailCall,
            Temp[][] dst,
            Temp[] src)
Creates a CALL quad representing a method invocation with explicit exception handling.

Parameters:
method - the method to invoke.
params - an array of Temps containing the parameters to pass to the method. The object on which to invoke the method is the first element in the parameter list of a non-static method; static methods do not need to specify a receiver. For static methods, params should match exactly the number and types of parameters in the method descriptor. For non-static methods, the receiver object (which is not included in the descriptor) is element zero of the params array.
retval - the destination Temp for the method's return value, or null if the method returns no value (return type is void.
retex - the destination Temp for any exception thrown by the called method. If null then this CALL has arity one and handles exceptions implicitly; else it has arity two and exception handling is explicit.
isVirtual - true if invocation semantics are that of a virtual method; false for constructors, private methods, and static initializers, which have non-virtual invocation semantics. Value doesn't matter for static methods; the isVirtual() method will always return false in this case.
isTailCall - true if this method should return the same value the callee returns or throw whatever exception the callee throws (in which case we can get rid of our stack and let the callee return directly to our caller. Usually false.
dst - the elements of the pairs on the left-hand side of the sigma function assignment block associated with this CALL.
src - the arguments to the sigma functions associated with this CALL.

CALL

public CALL(QuadFactory qf,
            HCodeElement source,
            HMethod method,
            Temp[] params,
            Temp retval,
            Temp retex,
            boolean isVirtual,
            boolean isTailCall,
            Temp[] src)
Creates a CALL with an empty dst array of the proper size. Other arguments as above.

Method Detail

method

public HMethod method()
Returns the method invoked by this CALL.


params

public Temp[] params()
Returns the parameters of this method invocation.


params

public Temp params(int i)
Returns a specified parameter in the params array.


paramsLength

public int paramsLength()
Returns the number of parameters in the params array.


paramType

public HClass paramType(int i)
Returns the type of the specified parameter.


retval

public Temp retval()
Returns the Temp which will hold the return value of the method, or the value null if the method returns no value.


retex

public Temp retex()
Returns the Temp which will get any exception thrown by the called method, or null if exceptions are not caught.


isVirtual

public boolean isVirtual()
Returns true if the method is dispatched virtually, or false otherwise. Static methods return false, constructors and static initializers return false, and all other method types return true.


isTailCall

public boolean isTailCall()
Returns true if this method should return the same value the callee returns or throw whatever exception the callee throws (in which case we can get rid of our stack and let the callee return directly to our caller. Usually false.


use

public Temp[] use()
Returns all the Temps used by this Quad.

Specified by:
use in interface UseDefable
Overrides:
use in class SIGMA
Returns:
the params array.

def

public Temp[] def()
Returns all the Temps defined by this Quad.

Specified by:
def in interface UseDefable
Overrides:
def in class SIGMA
Returns:
The non-null members of { retval, retex }.

kind

public int kind()
Description copied from class: Quad
Return an integer enumeration of the kind of this Quad. The enumerated values are defined in QuadKind.

Specified by:
kind in class Quad

rename

public Quad rename(QuadFactory qqf,
                   TempMap defMap,
                   TempMap useMap)
Description copied from class: Quad
Create a new Quad identical to the receiver, but with all Temps renamed according to a mapping. The new Quad will have no edges.

The new Quad will come from the specified QuadFactory.

Specified by:
rename in class Quad

accept

public void accept(QuadVisitor v)
Description copied from class: Quad
Accept a visitor.

Overrides:
accept in class SIGMA

accept

public <T> T accept(QuadValueVisitor<T> v)
Overrides:
accept in class SIGMA

toString

public String toString()
Returns human-readable representation.

Overrides:
toString in class SIGMA

isInterfaceMethod

public boolean isInterfaceMethod()
Determines whether this CALL is to an interface method.


isStatic

public boolean isStatic()
Determines whether this CALL is to a static method.