harpoon.Analysis.MemOpt
Class IncompatibilityAnalysis

java.lang.Object
  extended by harpoon.Analysis.MemOpt.IncompatibilityAnalysis

public class IncompatibilityAnalysis
extends Object

Describe class IncompatibilityAnalysis here.

Version:
1.0
Author:
Ovidiu Gheorghioiu

Field Summary
static boolean SHOW_PROGRESS
          If true, the analysis will show progress dots and other progress indicators.
static boolean SHOW_TIMINGS
          If true, the analysis will show timings for all of its stages.
static boolean SIZE_IN_BYTES
          If true, compute the sizes of the classes in bytes, otherwise, compute them in fields (an approximation).
static boolean STAY_IN_DECLARING_CLASS
          If true, the analysis will not descend into classes other than the class of the entry method.
static boolean VERBOSE_STATISTICS
          If true, and SHOW_STATISTICS is also true, printStatistics will show A LOT OF statistics when it finishes.
 
Constructor Summary
IncompatibilityAnalysis(HMethod entry, HCodeFactory codeFactory, CallGraph callGraph, Linker linker)
          Convenience form for the other constructor, calls it with callGraphNeedsSSA set to true.
IncompatibilityAnalysis(HMethod entry, HCodeFactory codeFactory, CallGraph callGraph, Linker linker, boolean callGraphNeedsSSA)
          Creates a new IncompatibilityAnalysis instance.
 
Method Summary
 Collection allAllocationSites()
          Returns all allocation sites encountered by this analysis.
 List allMethods()
          Returns all the methods encountered by this analysis
 Collection getCompatibleClasses()
          Returns a Collection whose members are disjunct Collection of mutually compatible allocation sites (NEW quads in SSI form).
 Collection getCompatibleClasses(Collection allocs)
          Similar to the above, except it operates on a specified set of allocation sites.
 Quad getSSIQuad(Quad q)
          Takes a Quad in NoSSA form, and returns the corresponding quad in SSI form, generated by the HCodeFactory used to create this IncompatibilityAnalysis instance.
 boolean isIncompatible(HCodeElement e1, HCodeElement e2)
          Returns true if the given allocation sites cannot use the same memory to the best of our knowledge, i.e. we have not encountered one or both of them, or we have unable to prove thay can safely use the same memory.
 boolean isSelfIncompatible(HCodeElement e)
          Returns true if the given site shound be dynamic to the best of our knowledge, i.e. if we haven't seen this site for some reason (e.g. it's not reachable from the entry method), or if we have been unable to prove it can be allocated statically.
 void printStatistics(Frame frame, Linker linker)
           
static long sizeStatistics(Collection methods, HCodeFactory factory)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STAY_IN_DECLARING_CLASS

public static final boolean STAY_IN_DECLARING_CLASS
If true, the analysis will not descend into classes other than the class of the entry method. Useful for debugging.

See Also:
Constant Field Values

SHOW_PROGRESS

public static final boolean SHOW_PROGRESS
If true, the analysis will show progress dots and other progress indicators.

See Also:
Constant Field Values

VERBOSE_STATISTICS

public static final boolean VERBOSE_STATISTICS
If true, and SHOW_STATISTICS is also true, printStatistics will show A LOT OF statistics when it finishes.

See Also:
Constant Field Values

SHOW_TIMINGS

public static final boolean SHOW_TIMINGS
If true, the analysis will show timings for all of its stages.

See Also:
Constant Field Values

SIZE_IN_BYTES

public static boolean SIZE_IN_BYTES
If true, compute the sizes of the classes in bytes, otherwise, compute them in fields (an approximation). Default is true.

Constructor Detail

IncompatibilityAnalysis

public IncompatibilityAnalysis(HMethod entry,
                               HCodeFactory codeFactory,
                               CallGraph callGraph,
                               Linker linker)
Convenience form for the other constructor, calls it with callGraphNeedsSSA set to true.


IncompatibilityAnalysis

public IncompatibilityAnalysis(HMethod entry,
                               HCodeFactory codeFactory,
                               CallGraph callGraph,
                               Linker linker,
                               boolean callGraphNeedsSSA)
Creates a new IncompatibilityAnalysis instance.

Parameters:
entry - the entry method
codeFactory - a HCodeFactory. This needs to be caching and in SSI form.
callGraph - the CallGraph the analysis should use.
callGraphNeedsSSA - hack that enables us to use Alex's SmartCallGraph, which only operates on NoSSA form. If you set to true, make sure you have set QuadSSI.KEEP_QUAD_MAP_HACK to true. This is sucky, I know, but there is no fast remedy.
Method Detail

allAllocationSites

public Collection allAllocationSites()
Returns all allocation sites encountered by this analysis.

Returns:
a Collection of all the NEW quads processed.

allMethods

public List allMethods()
Returns all the methods encountered by this analysis

Returns:
a List of all methods processed (as HMethods.)

isSelfIncompatible

public boolean isSelfIncompatible(HCodeElement e)
Returns true if the given site shound be dynamic to the best of our knowledge, i.e. if we haven't seen this site for some reason (e.g. it's not reachable from the entry method), or if we have been unable to prove it can be allocated statically. Requires that the site is a NEW quad in SSI form. This takes the more general

Parameters:
e - the allocation site. Right now, it must be a NEW quad in SSI form. This parameter has the more general HCodeElement because in the future we might want to support other forms and/or ANEW quads.
Returns:
true if the allocation site should not be made static.

isIncompatible

public boolean isIncompatible(HCodeElement e1,
                              HCodeElement e2)
Returns true if the given allocation sites cannot use the same memory to the best of our knowledge, i.e. we have not encountered one or both of them, or we have unable to prove thay can safely use the same memory. You should also call isSelfIncompatible() to check whether the sites can be allocated statically at all.

Parameters:
e1,e2 - the allocation sites. Right now, they must be NEW quads in SSI-form.
Returns:
true if the sites should not use the same memory.

getCompatibleClasses

public Collection getCompatibleClasses()
Returns a Collection whose members are disjunct Collection of mutually compatible allocation sites (NEW quads in SSI form). Every allocation site we have encountered that can be made static is in one of these classes.

Returns:
a Collection of compatible static allocation classes.

getCompatibleClasses

public Collection getCompatibleClasses(Collection allocs)
Similar to the above, except it operates on a specified set of allocation sites.

Parameters:
allocs - a Collection of allocation sites to be divided into compatible classes.
Returns:
a Collection of compatible classes. Every allocation site in alloc that can be safely made static is in one of these classes.

getSSIQuad

public Quad getSSIQuad(Quad q)
Takes a Quad in NoSSA form, and returns the corresponding quad in SSI form, generated by the HCodeFactory used to create this IncompatibilityAnalysis instance. For this to work correctly, our SSI factory *must* be a caching SSI view of a caching SSA view. I wish I had any other way to do this kind of "bridging", but there apparently is none.

Parameters:
q - a Quad in NoSSA form/ @return the corresponding Quad in SSI form, or null if we couldn't find one (check the caching-SSI-of-caching-SSA requirement)

printStatistics

public void printStatistics(Frame frame,
                            Linker linker)

sizeStatistics

public static long sizeStatistics(Collection methods,
                                  HCodeFactory factory)