Back to index

plt-scheme  4.2.1
newgc.h
Go to the documentation of this file.
00001 #include "commongc_internal.h"
00002 #include "gc2_obj.h"
00003 
00004 typedef struct mpage {
00005   struct mpage *next;
00006   struct mpage *prev;
00007   void *addr;
00008   unsigned long previous_size; /* for med page, points to place to search for available block */
00009   unsigned long size; /* big page size or med page element size */
00010   unsigned char generation;
00011 /*
00012   unsigned char back_pointers :1;
00013   unsigned char big_page      :2;
00014   unsigned char page_type     :3; 
00015   unsigned char marked_on     :1;
00016   unsigned char has_new       :1;
00017   unsigned char mprotected    :1;
00018 */
00019   unsigned char back_pointers ;
00020   unsigned char size_class    ; /* 1 => med; 2 => big; 3 => big marked */
00021   unsigned char page_type     ; 
00022   unsigned char marked_on     ;
00023   unsigned char has_new       ;
00024   unsigned char mprotected    ;
00025   unsigned char added         ;
00026   unsigned short live_size;
00027   void **backtrace;
00028 } mpage;
00029 
00030 typedef struct Gen0 {
00031  struct mpage *curr_alloc_page;
00032  struct mpage *pages;
00033  struct mpage *big_pages;
00034  unsigned long current_size;
00035  unsigned long max_size;
00036 } Gen0;
00037 
00038 typedef struct MarkSegment {
00039   struct MarkSegment *prev;
00040   struct MarkSegment *next;
00041   void **top;
00042 } MarkSegment;
00043 
00044 typedef struct Weak_Finalizer {
00045   void *p;
00046   int offset;
00047   void *saved;
00048   struct Weak_Finalizer *next;
00049 } Weak_Finalizer;
00050 
00051 typedef struct GC_Thread_Info {
00052   void *thread;
00053   int owner;
00054   struct GC_Thread_Info *next;
00055 } GC_Thread_Info;
00056 
00057 typedef struct AccountHook {
00058   int type;
00059   void *c1;
00060   void *c2;
00061   unsigned long amount;
00062   struct AccountHook *next;
00063 } AccountHook;
00064 
00065 typedef struct OTEntry {
00066   void *originator;
00067   void **members;
00068   unsigned long memory_use;
00069   unsigned long single_time_limit;
00070   unsigned long super_required;
00071   char limit_set;
00072   char required_set;
00073 } OTEntry;
00074 
00075 typedef struct Range {
00076   unsigned long start, len;
00077   struct Range *left, *right, *prev, *next;
00078 } Range;
00079 
00080 typedef struct Page_Range {
00081   Range *range_root;
00082   Range *range_start;
00083   void *range_alloc_block;
00084   unsigned long range_alloc_size;
00085   unsigned long range_alloc_used;
00086 } Page_Range;
00087 
00088 #ifdef MZ_USE_PLACES
00089 typedef struct NewGCMasterInfo {
00090   unsigned short next_GC_id;
00091   mzrt_rwlock *cangc;
00092 } NewGCMasterInfo;
00093 #endif
00094 
00095 #ifdef SIXTY_FOUR_BIT_INTEGERS
00096 typedef mpage ****PageMap;
00097 #else
00098 typedef mpage **PageMap;
00099 #endif
00100 
00101 #define NUM_MED_PAGE_SIZES (((LOG_APAGE_SIZE - 1) - 3) + 1)
00102 
00103 typedef struct NewGC {
00104   Gen0 gen0;
00105   Mark_Proc  *mark_table;   /* the table of mark procs */
00106   Fixup_Proc *fixup_table;  /* the table of repair procs */
00107   PageMap page_maps;
00108   /* All non-gen0 pages are held in the following structure. */
00109   struct mpage *gen1_pages[PAGE_TYPES];
00110   Page_Range *protect_range;
00111 
00112   struct mpage *med_pages[NUM_MED_PAGE_SIZES];
00113   struct mpage *med_freelist_pages[NUM_MED_PAGE_SIZES];
00114 
00115   /* Finalization */
00116   Fnl *run_queue;
00117   Fnl *last_in_queue;
00118   Weak_Finalizer *weak_finalizers;
00119 
00120   struct NewGC *primoridal_gc;
00121   unsigned long max_heap_size;
00122   unsigned long max_pages_in_heap;
00123   unsigned long max_pages_for_use;
00124   unsigned long used_pages;
00125   unsigned long actual_pages_size;
00126   void (*unsafe_allocation_abort)(struct NewGC *);
00127   unsigned long memory_in_use; /* the amount of memory in use */
00128 
00129   /* blame the child thread infos */
00130   GC_Thread_Info *thread_infos;
00131 
00132   mpage *release_pages;
00133   unsigned long stack_base;
00134   int dumping_avoid_collection; /* dumping coutner flag */
00135 
00136   unsigned char generations_available        :1;
00137   unsigned char in_unsafe_allocation_mode    :1;
00138   unsigned char full_needed_for_finalization :1;
00139   unsigned char no_further_modifications     :1;
00140   unsigned char gc_full                      :1; /* a flag saying if this is a full/major collection */
00141   unsigned char running_finalizers           :1;
00142 
00143   /* blame the child */
00144   unsigned int doing_memory_accounting        :1;
00145   unsigned int really_doing_accounting        :1;
00146   unsigned int old_btc_mark                   :1;
00147   unsigned int new_btc_mark                   :1;
00148   unsigned int reset_limits                   :1;
00149   unsigned int reset_required                 :1;
00150   unsigned int kill_propagation_loop          :1;
00151   unsigned int current_mark_owner;
00152   OTEntry **owner_table;
00153   unsigned int owner_table_size;
00154   AccountHook *hooks;
00155 
00156 
00157   unsigned long number_of_gc_runs;
00158   unsigned int since_last_full;
00159   unsigned long last_full_mem_use;
00160 
00161   /* These collect information about memory usage, for use in GC_dump. */
00162   unsigned long peak_memory_use;
00163   unsigned long num_minor_collects;
00164   unsigned long num_major_collects;
00165   
00166   /* THREAD_LOCAL variables that need to be saved off */
00167   MarkSegment  *saved_mark_stack;
00168   void         *saved_GC_variable_stack;
00169   unsigned long saved_GC_gen0_alloc_page_ptr;
00170   unsigned long saved_GC_gen0_alloc_page_end;
00171   /* Distributed GC over places info */
00172 #ifdef MZ_USE_PLACES
00173   objhead       saved_GC_objhead_template;
00174 #endif
00175 
00176 
00177   /* Callbacks */
00178   void (*GC_collect_start_callback)(void);
00179   void (*GC_collect_end_callback)(void);
00180   void (*GC_collect_inform_callback)(int major_gc, long pre_used, long post_used);
00181   unsigned long (*GC_get_thread_stack_base)(void);
00182 
00183   GC_Immobile_Box *immobile_boxes;
00184 
00185   /* Common with CompactGC */
00186   Fnl *finalizers;
00187   Fnl *splayed_finalizers;
00188   int num_fnls;
00189 
00190   void *park[2];
00191   void *park_save[2];
00192 
00193   unsigned short weak_array_tag;
00194   unsigned short weak_box_tag;
00195   unsigned short ephemeron_tag;
00196   unsigned short cust_box_tag;
00197 
00198   Roots roots;
00199   GC_Weak_Array *weak_arrays;
00200   GC_Weak_Box   *weak_boxes;
00201   GC_Ephemeron  *ephemerons;
00202   int num_last_seen_ephemerons;
00203   struct VM     *vm;
00204 
00205 } NewGC;