harpoon.Analysis.MetaMethods
Class MetaMethod

java.lang.Object
  extended by harpoon.Analysis.MetaMethods.MetaMethod
All Implemented Interfaces:
Serializable

public class MetaMethod
extends Object
implements Serializable

MetaMethod is a specialization of a method, function of the types of its arguments.
For example, if we have a method foo declared as having a single parameter of type Object, if we know that in a specific call site it is called with an argument of type A and in some other call site with an argument of type B, then we can say that in the first case we call the meta-method consisting of method <foo,A> while in the second one we call the meta-method <foo,B>.
In languages that relies very heavily on inheritance and dynamic dispatch (virtual methods) such as Java, this will lead to a sparser call graph, removing some unrealizable call chains. In particular, it will simplify or even totally remove some artificial strongly connected components of pseudo mutually recursive methods.
In short, a meta-method is simply a method plus some types for its parameters. These types are supposed to be identically to or, preferably, narrower than the declared types for that method. Something you should keep in mind if you plan to use meta-methods is that many meta-methods can be generated through specialization from the same method. So, if you decide to modify only one of them, you should first make a copy of it, do whatever optimizations you do on that copy and modify the concerned call-sites to point to it.

Version:
$Id: MetaMethod.java,v 1.4 2002/04/10 03:00:22 cananian Exp $
Author:
Alexandru SALCIANU <salcianu@retezat.lcs.mit.edu>
See Also:
Serialized Form

Constructor Summary
MetaMethod(HMethod hm)
          Creates a MetaMethod corresponding to the method hm and the types declared for it.
MetaMethod(HMethod hm, boolean polymorphic)
          Creates a MetaMethod corresponding to the method hm and the types declared for it.
MetaMethod(HMethod hm, GenType[] types)
          Creates a MetaMethod corresponding to the method hm and the types from the array "types".
 
Method Summary
 boolean equals(Object o)
          Checks the equality of this object with object o.
 HMethod getHMethod()
          Returns the HMethod that this meta-method is a specialization of.
 GenType getType(int i)
          Returns the type of the i-th parameter.
 int hashCode()
          Computes the hash code of this object.
static boolean identical(MetaMethod mm1, MetaMethod mm2)
          Checks whether two MetaMethods are equal or not.
 int nbParams()
          Returns the number of parameters of this metamethod.
 void setType(int i, GenType gt)
          Set the type of the i-th argument of this meta-method.
 String toString()
          Pretty printer for debug purposes.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MetaMethod

public MetaMethod(HMethod hm,
                  GenType[] types)
Creates a MetaMethod corresponding to the method hm and the types from the array "types".


MetaMethod

public MetaMethod(HMethod hm,
                  boolean polymorphic)
Creates a MetaMethod corresponding to the method hm and the types declared for it. The types appearing in the declaration of the method are considered to be polymorphic or not, depending whether polymorphic is switched on/off.


MetaMethod

public MetaMethod(HMethod hm)
Creates a MetaMethod corresponding to the method hm and the types declared for it. All the types appearing in the declaration of the method are considered to be polymorphic., that is we are maximally conservative in our initial estimation. The types of can be specialized to by using setType.

Method Detail

getHMethod

public HMethod getHMethod()
Returns the HMethod that this meta-method is a specialization of.


getType

public GenType getType(int i)
Returns the type of the i-th parameter.


setType

public void setType(int i,
                    GenType gt)
Set the type of the i-th argument of this meta-method. The arguments are 0-indexed, with the receiver of the method in the first place if the method is non-static. This method should be used to specialize the types of the arguments.


nbParams

public int nbParams()
Returns the number of parameters of this metamethod.


hashCode

public int hashCode()
Computes the hash code of this object.

Overrides:
hashCode in class Object

equals

public boolean equals(Object o)
Checks the equality of this object with object o.

Overrides:
equals in class Object

identical

public static boolean identical(MetaMethod mm1,
                                MetaMethod mm2)
Checks whether two MetaMethods are equal or not. handle null arguments.


toString

public String toString()
Pretty printer for debug purposes.

Overrides:
toString in class Object