Phase

Enumerations

enum  tm_phase {
  tm_ALLOC, tm_UNMARK, tm_ROOT, tm_SCAN,
  tm_SWEEP, tm_phase_END
}
 

The phases of the allocator.

More...

Functions

void _tm_phase_init (int p)
 Initialize the collection/allocation phase.

Enumeration Type Documentation

enum tm_phase

The phases of the allocator.

These are similar to the phases in typical in a stop-the-world collector, except the work for these phases is done for short periods within tm_alloc().

Enumerator:
tm_ALLOC 

Allocate nodes.

(WHITE->ECRU)

tm_UNMARK 

Unmark nodes.

(BLACK->ECRU)

tm_ROOT 

Begin mark roots.

(ECRU->GREY)

tm_SCAN 

Scan marked nodes.

(ECRU->GREY, GREY->BLACK)

tm_SWEEP 

Sweep unmarked nodes.

(ECRU->WHITE)

tm_phase_END 

Placeholder for size of arrays indexed by tm_phase.

Definition at line 40 of file internal.h.

00040               {
00041   /*! Allocate nodes.         (WHITE->ECRU) */
00042   tm_ALLOC,
00043   /*! Unmark nodes.           (BLACK->ECRU) */
00044   tm_UNMARK,
00045   /*! Begin mark roots.       (ECRU->GREY)  */ 
00046   tm_ROOT,
00047   /*! Scan marked nodes.      (ECRU->GREY, GREY->BLACK) */
00048   tm_SCAN,
00049   /*! Sweep unmarked nodes.   (ECRU->WHITE) */
00050   tm_SWEEP,
00051   /*! Placeholder for size of arrays indexed by tm_phase. */
00052   tm_phase_END
00053 };


Function Documentation

void _tm_phase_init ( int  p  ) 

Initialize the collection/allocation phase.

Initializes a new allocation phase.

  • tm_ALLOC: allocate nodes until memory pressure is high.
  • tm_UNMARK: begin unmarking tm_BLACK nodes as tm_ECRU:

Set up for unmarking.

Keep track of how many tm_BLACK nodes are in use.

  • tm_ROOT: begin scanning roots for potential pointers:

Mark stack and data roots as un-mutated.

Initialize root mark loop.

  • tm_SCAN: begin scanning tm_GREY nodes for internal pointers:

Mark stack and data roots as un-mutated.

Set up for marking.

  • tm_SWEEP: begin reclaiming any ECRU nodes as WHITE.

Definition at line 285 of file tm.c.

References _tm_root_loop_init(), tm_data::alloc_id, tm_data::alloc_since_sweep, tm_data::allocating, tm_data::data_mutations, tm_data::marking, tm_data::n, tm_data::n_phase_transitions, tm_data::scanning, tm_data::stack_mutations, tm_data::sweeping, tm, tm_ALLOC, tm_assert_test, tm_BLACK, tm_ECRU, tm_fatal(), tm_GREY, tm_msg(), tm_node_LOOP_INIT, tm_NU, tm_phase_END, tm_phase_name, tm_ROOT, tm_SCAN, tm_stop(), tm_SWEEP, tm_UNMARK, tm_WHITE, and tm_data::unmarking.

Referenced by _tm_alloc_type_inner(), _tm_check_sweep_error(), _tm_gc_full_type_inner(), and tm_init().

00286 {
00287   tm_msg("p %s\n", tm_phase_name[p]);
00288 
00289 #if 0
00290   /* DEBUG: DELETE ME! */
00291   if ( tm.alloc_id == 1987 )
00292     tm_stop();
00293 #endif
00294 
00295   ++ tm.n_phase_transitions[tm.phase][p];
00296   ++ tm.n_phase_transitions[tm.phase][tm_phase_END];
00297   ++ tm.n_phase_transitions[tm_phase_END][p];
00298   ++ tm.n_phase_transitions[tm_phase_END][tm_phase_END];
00299 
00300   if ( tm.phase == tm_SWEEP && tm.phase != p ) {
00301     tm.alloc_since_sweep = 0;
00302   }
00303 
00304 #if 0
00305   fprintf(stderr, "\n%s->%s #%lu %lu %lu %lu %lu\n", tm_phase_name[tm.phase], tm_phase_name[p], (unsigned long) tm.alloc_id,
00306           (unsigned long) tm.n[tm_WHITE],
00307           (unsigned long) tm.n[tm_ECRU],
00308           (unsigned long) tm.n[tm_GREY],
00309           (unsigned long) tm.n[tm_BLACK],
00310           0
00311           );
00312 #endif
00313 
00314   switch ( (tm.phase = p) ) {
00315   case tm_ALLOC:
00316     /**
00317      * - tm_ALLOC: allocate nodes until memory pressure is high.
00318      */
00319     tm.allocating = 1;
00320     tm.unmarking = 0;
00321     tm.marking = 0;
00322     tm.scanning = 0;
00323     tm.sweeping = 0;
00324     break;
00325 
00326   case tm_UNMARK:
00327     /**
00328      * - tm_UNMARK: begin unmarking tm_BLACK nodes as tm_ECRU:
00329      */
00330     tm.allocating = 0;
00331     tm.unmarking = 1;
00332     tm.marking = 0;
00333     tm.scanning = 0;
00334     tm.sweeping = 0;
00335 
00336     /*! Set up for unmarking. */
00337     tm_node_LOOP_INIT(tm_BLACK);
00338 
00339     /*! Keep track of how many tm_BLACK nodes are in use. */
00340     tm.n[tm_NU] = tm.n[tm_BLACK];
00341     break;
00342 
00343   case tm_ROOT:
00344     /**
00345      * - tm_ROOT: begin scanning roots for potential pointers:
00346      */
00347     tm.allocating = 0;
00348     tm.unmarking = 0;
00349     tm.marking = 1;
00350     tm.scanning = 0;
00351     tm.sweeping = 0;
00352 
00353     /*! Mark stack and data roots as un-mutated. */
00354     tm.stack_mutations = tm.data_mutations = 0;
00355 
00356     /*! Initialize root mark loop. */
00357     _tm_root_loop_init();
00358     break;
00359 
00360   case tm_SCAN:
00361     /**
00362      * - tm_SCAN: begin scanning tm_GREY nodes for internal pointers:
00363      */
00364     tm.allocating = 0;
00365     tm.unmarking = 0;
00366     tm.marking = 1;
00367     tm.scanning = 1;
00368     tm.sweeping = 0;
00369 
00370     /*! Mark stack and data roots as un-mutated. */
00371     tm.stack_mutations = tm.data_mutations = 0;
00372 
00373     /*! Set up for marking. */
00374     tm_node_LOOP_INIT(tm_GREY);
00375     break;
00376 
00377   case tm_SWEEP:
00378     /**
00379      * - tm_SWEEP: begin reclaiming any ECRU nodes as WHITE.
00380      */
00381     tm.allocating = 0;
00382     tm.unmarking = 0;
00383     tm.marking = 0;
00384     tm.scanning = 0;
00385     tm.sweeping = 1;
00386 
00387     tm_assert_test(tm.n[tm_GREY] == 0);
00388 
00389     /* Set up for scanning. */
00390     // tm_node_LOOP_INIT(tm_GREY);
00391 
00392     /* Set up for sweeping. */
00393     // tm_node_LOOP_INIT(tm_ECRU);
00394     break;
00395 
00396   default:
00397     tm_fatal();
00398     break;
00399   }
00400 
00401   if ( 1 || p == tm_SWEEP ) {
00402     // tm_print_stats();
00403   }
00404   //tm_validate_lists();
00405 }

Here is the call graph for this function:

Here is the caller graph for this function:


Generated on Mon Jan 25 06:33:12 2010 for TM(tredmill) by  doxygen 1.6.1