harpoon.Analysis.MemOpt
Class PreallocOpt

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

public abstract class PreallocOpt
extends Object

PreallocOpt

Version:
$Id: PreallocOpt.java,v 1.25 2004/02/08 03:19:53 cananian Exp $
Author:
Alexandru Salcianu <salcianu@MIT.edu>

Nested Class Summary
static class PreallocOpt.QuadPass
           
static class PreallocOpt.SafeCachingCodeFactory
          A CachingCodeFactory that ignores all calls to clear (hence the name).
static class PreallocOpt.TreePass
           
 
Field Summary
static boolean HACKED_GC
          Set this to true only if you use the hacked BDW GC version that has "GC_malloc_prealloc".
static int highBound
           
static int lowBound
           
static boolean ONLY_SYNC_REMOVAL
          Use the incompatibility analysis only to remove syncronizations on the objects that can be preallocated (but don't actually preallocate them).
static boolean PREALLOC_OPT
          If true, the compiler uses the static memory pre-allocation optimization (via IncompatibilityAnalysis.
static boolean RANGE_DEBUG
          If true, we do not preallocate allocation sites whose unique identifier is not between lowBound and highBound.
 
Constructor Summary
PreallocOpt()
           
 
Method Summary
static HCodeFactory addMemoryPreallocation(Linker linker, HCodeFactory hcf, Frame frame)
          Add the code that preallocates memory and initializes the static fields that point to the preallocated memory chunks.
static HData getData(HClass hclass, Frame frame)
           
static HCodeFactory getHCFWithEmptyInitCode(HCodeFactory hcf)
          Returns a code factory that provides an intermediate representation for the empty body of the preallocated memory initialization.
static HCodeFactory preallocAnalysis(Linker linker, HCodeFactory hcf, ClassHierarchy ch, HMethod mainM, Set roots, AllocationStatistics as, Frame frame)
          Executes the IncompatibilityAnalysis and creates a (QuadSSI) code factory that produces code with the allocation properties set to reflect the fact that some allocation sites can use pre-allocated memory space.
static void updateRoots(Set roots, Linker linker)
          Adds to the set of roots the classes/methods that are called by the runtime when the preallocation optimization is used.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PREALLOC_OPT

public static boolean PREALLOC_OPT
If true, the compiler uses the static memory pre-allocation optimization (via IncompatibilityAnalysis. Default is false.


ONLY_SYNC_REMOVAL

public static boolean ONLY_SYNC_REMOVAL
Use the incompatibility analysis only to remove syncronizations on the objects that can be preallocated (but don't actually preallocate them). Useful when we want to measure the reduction of the memory management overhead: the optimized program has to remove syncs on the preallocated objects (for complicated reasons, inflating them would make it crsah). Therefore we want the normal version to run without syncs on the preallocatable objects, too.


RANGE_DEBUG

public static boolean RANGE_DEBUG
If true, we do not preallocate allocation sites whose unique identifier is not between lowBound and highBound. (The unique id is obtained from a AllocationStatistics object.


lowBound

public static int lowBound

highBound

public static int highBound

HACKED_GC

public static boolean HACKED_GC
Set this to true only if you use the hacked BDW GC version that has "GC_malloc_prealloc".

Constructor Detail

PreallocOpt

public PreallocOpt()
Method Detail

updateRoots

public static void updateRoots(Set roots,
                               Linker linker)
Adds to the set of roots the classes/methods that are called by the runtime when the preallocation optimization is used.

Parameters:
roots - set of roots
linker - linker used to get classes

getHCFWithEmptyInitCode

public static HCodeFactory getHCFWithEmptyInitCode(HCodeFactory hcf)
Returns a code factory that provides an intermediate representation for the empty body of the preallocated memory initialization.

Parameters:
hcf - Code factory providing the code for the rest of the code (currently, it has to be quad-with-try).
Returns:
Code factory identical to the hcf parameter, except that it also provides a default, empty body for the preallocated memory initilaization.

preallocAnalysis

public static HCodeFactory preallocAnalysis(Linker linker,
                                            HCodeFactory hcf,
                                            ClassHierarchy ch,
                                            HMethod mainM,
                                            Set roots,
                                            AllocationStatistics as,
                                            Frame frame)
Executes the IncompatibilityAnalysis and creates a (QuadSSI) code factory that produces code with the allocation properties set to reflect the fact that some allocation sites can use pre-allocated memory space. In addition, it adds static fields to the class named by PreallocOpt.PREALLOC_MEM_CLASS_NAME; at runtime, these fields will point to pre-allocated chunks of memory, one for each compatibility class found by the analysis.

Parameters:
linker - linker used to get classes
hcf - initial code factory; it has to be convertible to a QuadSSI code factory.
ch - class hierarchy for the program
mainM - main method of the program
roots - set of roots
as - allocation (dynamic) statistics; if non-null, the method prints some static and dynamic statistics.
frame - Backend specific information for compilation (data size and data layout details). Used only for statistics; in particular, unused if as is null.
Returns:
QuadSSI code factory; it produces Codes where allocation sites that can be pre-allocated have the attached PreallocAllocationStrategy.

getData

public static HData getData(HClass hclass,
                            Frame frame)

addMemoryPreallocation

public static HCodeFactory addMemoryPreallocation(Linker linker,
                                                  HCodeFactory hcf,
                                                  Frame frame)
Add the code that preallocates memory and initializes the static fields that point to the preallocated memory chunks.

Parameters:
linker - Linker for loading classes
hcf - Code factory for the current vesrion of the program (without the memory preallocation code).
frame - Backend specific information for compilation (data size and data layout details).
Returns:
A code factory that produces code that already contains the memory preallocation code.