1 cananian 1.1.2.1 // AllocationInformation.java, created Thu Mar 30 05:39:25 2000 by cananian
 2 cananian 1.1.2.1 // Copyright (C) 1999 C. Scott Ananian <cananian@alumni.princeton.edu>
 3 cananian 1.1.2.1 // Licensed under the terms of the GNU GPL; see COPYING for details.
 4 cananian 1.1.2.1 package harpoon.Analysis.Maps;
 5 cananian 1.1.2.1 
 6 kkz      1.1.2.5 import harpoon.ClassFile.HClass;
 7 cananian 1.1.2.1 import harpoon.ClassFile.HCodeElement;
 8 salcianu 1.7     import harpoon.Temp.Label;
 9 cananian 1.1.2.1 import harpoon.Temp.Temp;
10 salcianu 1.7     
11 cananian 1.1.2.1 /**
12 cananian 1.1.2.1  * An <code>AllocationInformation</code> maps allocation sites
13 cananian 1.1.2.1  * to information about the allocation done at that site.
14 cananian 1.1.2.1  * 
15 cananian 1.1.2.1  * @author  C. Scott Ananian <cananian@alumni.princeton.edu>
16 salcianu 1.7      * @version $Id: AllocationInformation.java,v 1.7 2003/03/03 23:41:34 salcianu Exp $
17 cananian 1.1.2.1  */
18 cananian 1.4     public interface AllocationInformation<HCE extends HCodeElement>  {
19 cananian 1.1.2.1     
20 cananian 1.1.2.1     /** <code>AllocationProperties</code> contains tests for the various
21 cananian 1.1.2.1      *  possibly properties of an allocation site.  "Atomic" allocations
22 cananian 1.1.2.1      *  (of objects not containing interior pointers) can be done, as well
23 cananian 1.1.2.1      *  as stack allocation, thread-local allocation, and pre-thread-start
24 cananian 1.1.2.1      *  thread-local allocation.  If none of these properties are true,
25 cananian 1.1.2.1      *  the object must be allocated in a global heap. */
26 cananian 1.1.2.1     public static interface AllocationProperties {
27 cananian 1.1.2.1         /** @return <code>true</code> if the object allocated at this
28 bdemsky  1.1.2.3          *  site has interior pointers; that is, it is not a primitive
29 bdemsky  1.1.2.3          *  array, and some field in the allocated object is not primitive.
30 cananian 1.1.2.1          */
31 cananian 1.1.2.2         public boolean hasInteriorPointers();
32 cananian 1.1.2.1         /** @return <code>true</code> if the object can be allocated on
33 cananian 1.1.2.1          *  the stack; that is, the lifetime of the object does not
34 cananian 1.1.2.1          *  exceed the execution of the method containing the allocation.
35 cananian 1.1.2.1          */
36 cananian 1.1.2.2         public boolean canBeStackAllocated();
37 cananian 1.1.2.1         /** @return <code>true</code> if the object can be allocated on
38 cananian 1.1.2.1          *  a thread-local heap; that is, the lifetime of the object does
39 cananian 1.1.2.1          *  not exceed the lifetime of the thread object specified
40 cananian 1.1.2.1          *  by the <code>allocationHeap</code> method. */
41 cananian 1.1.2.2         public boolean canBeThreadAllocated();
42 cananian 1.1.2.4         /** @return <code>true</code> if a thread-local heap should be
43 cananian 1.1.2.4          *  associated with this object --- typically this means that
44 cananian 1.1.2.2          *  the allocation site is a thread creation.  If this is
45 cananian 1.1.2.4          *  <code>true</code> and <code>canBeThreadAllocated()</code>
46 cananian 1.1.2.4          *  is also <code>true</code>, then the new object will be
47 cananian 1.1.2.4          *  itself allocated on the created heap; otherwise the
48 cananian 1.1.2.4          *  new object will be globally allocated.
49 cananian 1.1.2.2          */
50 cananian 1.1.2.4         public boolean makeHeap();
51 cananian 1.1.2.1         /** @return a <code>Temp</code> which at the allocation site
52 cananian 1.1.2.1          * contains a reference to either the thread object of a
53 cananian 1.1.2.1          * thread-local allocation, or to another object whose lifetime
54 cananian 1.1.2.1          * is correlated with that of the (not-yet-created) thread object.
55 cananian 1.1.2.1          * Returns <code>null</code> if the allocation should use the
56 cananian 1.1.2.2          * heap associated with the "current" thread. 
57 cananian 1.1.2.2          * If this returns non-<code>null</code>, then
58 cananian 1.1.2.4          * <code>makeHeap()</code> should return <code>false</code> and
59 cananian 1.1.2.2          * <code>canBeThreadAllocated()</code> should return <code>true</code>.
60 cananian 1.1.2.2          */
61 cananian 1.1.2.2         public Temp    allocationHeap();
62 kkz      1.1.2.5         /** @return the <code>HClass</code> representing the
63 kkz      1.1.2.5          * "actual" or instantiated class of the object for which
64 kkz      1.1.2.5          * memory is being allocated (as opposed to the declared
65 kkz      1.1.2.5          * class).
66 kkz      1.1.2.5          */
67 kkz      1.1.2.5         public HClass actualClass();
68 salcianu 1.1.2.6 
69 salcianu 1.1.2.6         /* Each sync on this object consists of NOTHING. */
70 salcianu 1.1.2.6         public boolean noSync();
71 kkz      1.3             /** @return <code>true</code> if the dynamic write barrier 
72 kkz      1.3              *  flag needs to be set when the object is allocated--this 
73 kkz      1.3              *  typically means that one or more write barriers associated 
74 kkz      1.3              *  with stores into the object created at this allocation site
75 kkz      1.3              *  have been optimistically removed. */
76 kkz      1.3             public boolean setDynamicWBFlag();
77 salcianu 1.5     
78 salcianu 1.7             /** @return a <code>Label</code> for a pointer that points (at
79 salcianu 1.7                 runtime) to a preallocated memory chunk to be used for
80 salcianu 1.7                 this allocation site.  Returns <code>null</code> if we
81 salcianu 1.7                 cannot preallocate this allocation site. */
82 salcianu 1.7             public Label getLabelOfPtrToMemoryChunk();
83 salcianu 1.6     
84 salcianu 1.6             /** @return an unique integer ID for the allocation site. 
85 salcianu 1.6                 Useful for instrumentation purposes. */
86 salcianu 1.6             public int getUniqueID();
87 cananian 1.1.2.1     }
88 cananian 1.1.2.1 
89 cananian 1.1.2.1     /** Query the properties of the allocation at the specified site. */
90 cananian 1.4         public AllocationProperties query(HCE allocationSite);
91 cananian 1.2     }