Attachment 'vm_gc_interface.txt'

Download

   1 /**
   2  * @file
   3  * These are the functions that a GC may call.
   4 
   5 /**
   6  * @return the number of bytes allocated by VM in VTable
   7  *         for use by GC.
   8  */
   9 VMEXPORT size_t vm_number_of_gc_bytes_in_vtable();
  10 
  11 /**
  12  * @return the number of bytes allocated by VM in thread-local
  13  *         storage for use by GC.
  14  */
  15 VMEXPORT size_t vm_number_of_gc_bytes_in_thread_local();
  16 
  17 /**
  18  * @return the pointer to thread-local area of current thread.
  19  */
  20 VMEXPORT void *vm_get_gc_thread_local();
  21 
  22 
  23 /**
  24  * Acquire the lock that guards all GC-related operations in the VM.
  25  * If the lock can't be acquired the thread waits until the lock is available.
  26  * This operation marks the current thread as being safe for root set
  27  * enumeration.
  28  */
  29 VMEXPORT void vm_gc_lock_enum();
  30 
  31 
  32 /**
  33  * Release the system-wide lock acquired by vm_gc_lock_enum().
  34  * The thread is marked as unsafe for root set enumeration.
  35  */
  36 VMEXPORT void vm_gc_unlock_enum();
  37 
  38 
  39 /**
  40  * GC calls this function to command VM to start root set enumeration.
  41  *
  42  * Root set enumeration for all managed threads.
  43  */
  44 VMEXPORT void vm_enumerate_root_set_all_threads();
  45 
  46 
  47 /**
  48  * GC calls this function to restart managed threads after root set 
  49  * enumeration is complete.
  50  *
  51  * This function resumes all threads suspended by 
  52  * vm_enumerate_root_set_all_threads()
  53  */
  54 VMEXPORT void vm_resume_threads_after();
  55 
  56 
  57 /**
  58  * thread state as concerns root set enumeration.
  59  */
  60 enum safepoint_state {
  61     nill = 0,
  62 
  63     /** 
  64      * thread is stopped for root set enumeration,
  65      * as is the whole world (all managed threads).
  66      * For sapphire just means sapphire is running.
  67      */
  68     enumerate_the_universe,
  69 
  70     /** 
  71      * thread is stopped for root set enumeration
  72      */
  73     java_suspend_one_thread,
  74 
  75     /**
  76      * thread is stopped by java debugger.
  77      */
  78     java_debugger
  79 };
  80 
  81 /**
  82  * @return thread safepoint state.
  83  */
  84 VMEXPORT enum safepoint_state get_global_safepoint_status();
  85 
  86 /**
  87  * @return TRUE if no apparent trash was found in the object.
  88  * 
  89  * Used for debugging.
  90  */
  91 VMEXPORT Boolean verify_object_header(void *ptr);
  92 
  93 
  94 /*
  95  * *****
  96  * *
  97  * *  Routines to support finalization of objects.
  98  * * 
  99  * *****
 100  */
 101 
 102 /**
 103  * GC should call this function when an object becomes
 104  * "f-reachable, finalizable"
 105  * The VM later finalizes those objects in a way that
 106  * is not part of this interface.
 107  *
 108  * VM must not call finalizer immediately to prevent
 109  * deadlocks in user code, because this functions
 110  * may be called during the stop-the-world phase.
 111  */
 112 VMEXPORT void vm_finalize_object(Managed_Object_Handle p_obj);
 113 
 114 /**
 115  * GC should call this function when an phantom reference object
 116  * is to be enqueued, i.e. when the reference is not reachable anymore.
 117  */
 118 VMEXPORT void vm_enqueue_reference(Managed_Object_Handle p_obj);
 119 
 120 enum WeakReferenceType {
 121     NOT_REFERENCE = 0,
 122     WEAK_REFERENCE,
 123     SOFT_REFERENCE,
 124     PHANTOM_REFERENCE
 125 };
 126 
 127 /**
 128  * Returns non-zero value if the class represented by Class_Handle
 129  * is a descendant of java.lang.ref.Reference. The particular type
 130  * of reference (weak, soft or phantom) is encoded by the return 
 131  * value of WeakReferenceType.
 132  */
 133 VMEXPORT WeakReferenceType class_is_reference(Class_Handle clss);
 134 
 135 /**
 136  * Returns the offset of the referent field 
 137  * in the java.lang.ref.Reference object.
 138  *
 139  * clss is assumed to represent the reference object,
 140  * i.e. class_is_reference() returned non-zero value.
 141  *
 142  * @note the returned value is most probably a constant,
 143  *       and is not dependent on the clss.
 144  *
 145  * @note this interface allows only one non-strong (i.e. weak
 146  *       soft or phantom) reference per object.
 147  *       It seems to be sufficient for JVM Spec.
 148  */
 149 VMEXPORT int class_get_referent_offset(Class_Handle clss);
 150 
 151 
 152 #define CL_PROP_ALIGNMENT_MASK      0x00FFF     ///< @see class_properties
 153 #define CL_PROP_NON_REF_ARRAY_MASK  0x01000     ///< @see class_properties
 154 #define CL_PROP_ARRAY_MASK          0x02000     ///< @see class_properties
 155 #define CL_PROP_PINNED_MASK         0x04000     ///< @see class_properties
 156 #define CL_PROP_FINALIZABLE_MASK    0x08000     ///< @see class_properties
 157 
 158 
 159 /**
 160  * @section class_properties Class properties flags
 161  * 3322|2222|2222|1111|1111|1100|0000|0000
 162  * 1098|7654|3210|9876|5432|1098|7654|3210
 163  *                          ^^^^^^^^^^^^^^------ CL_PROP_ALIGNMENT_MASK
 164  *                        ^--------------------- CL_PROP_NON_REF_ARRAY_MASK
 165  *                       ^---------------------- CL_PROP_ARRAY_MASK
 166  *                      ^----------------------- CL_PROP_PINNED_MASK
 167  *                     ^------------------------ CL_PROP_FINALIZABLE_MASK 
 168  */
 169 
 170 
 171 /**
 172  * extract the recursion counter from object lockword.
 173  */
 174 #define P_RECURSION_BYTE(x)       ( (uint8 *)(((x)->get_obj_info_addr())) + 1 )  
 175 
 176 #ifdef GC_PUBLIC_PRIVATE
 177 
 178 /**
 179  * mask of recursion counter
 180  */
 181 #define RECURSION_MASK 0x7f
 182 
 183 /**
 184  * mask of recursion counter shifted to its position in lockword.
 185  */
 186 #define RECURSION_MASK_SHIFTED 0x7f00
 187 #define PUBLIC_PRIVATE_MASK 0x80

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.

You are not allowed to attach a file to this page.