Internal: Routine

Defines

#define _tm_clear_some_stack_words()

Functions

void _tm_phase_init (int p)
 Initializes a new allocation phase.
void tm_node_set_color (tm_node *n, tm_block *b, tm_color c)
 Sets the color of a tm_node, in a tm_block.
void _tm_set_stack_ptr (void *ptr)
 Set the stack pointer.
void __tm_clear_some_stack_words ()
 Clears the stack and initializes register root set.
void * _tm_alloc_inner (size_t size)
 Allocates a node of a particular size.
void * _tm_alloc_desc_inner (tm_adesc *desc)
 Allocates a node of a particular type.
void * _tm_realloc_inner (void *ptr, size_t size)
 Reallocates a node to a particular size.
void _tm_free_inner (void *ptr)
 Manually returns a node back to its tm_type free list.
void _tm_gc_full_inner ()
 Force a full GC sequence.

Define Documentation

 
#define _tm_clear_some_stack_words (  ) 
Value:

Definition at line 429 of file internal.h.

Referenced by tm_alloc(), tm_alloc_desc(), tm_free(), tm_gc_full(), and tm_realloc().


Function Documentation

void __tm_clear_some_stack_words (  ) 

Clears the stack and initializes register root set.

Clears the stack and initializes register root set.

Avoid leaving garbage on the stack Note: Do not move this in to user.c, it might be optimized away.

Definition at line 2171 of file tm.c.

02172 {
02173   int some_words[64];
02174   memset(some_words, 0, sizeof(some_words));
02175 }

void* _tm_alloc_desc_inner ( tm_adesc desc  ) 

Allocates a node of a particular type.

Definition at line 2109 of file tm.c.

References _tm_alloc_type_inner(), tm_data::alloc_request_size, tm_data::alloc_request_type, tm_adesc::hidden, tm_type::size, and tm.

Referenced by tm_alloc_desc().

02110 {
02111   tm_type *type = (tm_type*) desc->hidden;
02112   tm.alloc_request_size = type->size;
02113   tm.alloc_request_type = type;
02114   return _tm_alloc_type_inner(type);
02115 }

Here is the call graph for this function:

Here is the caller graph for this function:

void* _tm_alloc_inner ( size_t  size  ) 

Allocates a node of a particular size.

Definition at line 2097 of file tm.c.

References _tm_alloc_type_inner(), tm_data::alloc_request_size, tm_data::alloc_request_type, tm, and tm_size_to_type().

Referenced by _tm_realloc_inner(), and tm_alloc().

02098 {
02099   tm_type *type = tm_size_to_type(size);
02100   tm.alloc_request_size = size;
02101   tm.alloc_request_type = type;
02102   return _tm_alloc_type_inner(type);  
02103 }

Here is the call graph for this function:

Here is the caller graph for this function:

void _tm_free_inner ( void *  ptr  ) 

Manually returns a node back to its tm_type free list.

Assumes that ptr is pure pointer to the beginning of a tm_node's data space.

Definition at line 2148 of file tm.c.

References tm_data::n, tm_assert, tm_node_color, tm_node_set_color(), tm_node_to_block(), tm_pure_ptr_to_node(), and tm_WHITE.

Referenced by tm_free().

02149 {
02150   tm_block *b;
02151   tm_node *n;
02152 
02153   n = tm_pure_ptr_to_node(ptr);
02154   b = tm_node_to_block(n);
02155   // _tm_block_validate(b);
02156   tm_assert(tm_node_color(n) != tm_WHITE);
02157   tm_node_set_color(n, b, tm_WHITE);
02158 }

Here is the call graph for this function:

Here is the caller graph for this function:

void _tm_gc_full_inner (  ) 

Force a full GC sequence.

Definition at line 1749 of file tm.c.

References _tm_gc_full_type_inner().

Referenced by tm_alloc(), and tm_gc_full().

01750 {
01751   _tm_gc_full_type_inner(0);
01752 }

Here is the call graph for this function:

Here is the caller graph for this function:

void _tm_phase_init ( int  p  ) 

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:

void* _tm_realloc_inner ( void *  ptr,
size_t  size 
)

Reallocates a node to a particular size.

Definition at line 2121 of file tm.c.

References _tm_alloc_inner(), tm_type::size, tm_node_to_type(), tm_pure_ptr_to_node(), and tm_size_to_type().

Referenced by tm_realloc().

02122 {
02123   char *ptr = 0;
02124   tm_type *t, *oldt;
02125 
02126   oldt = tm_node_to_type(tm_pure_ptr_to_node(oldptr));
02127   t = tm_size_to_type(size);
02128 
02129   if ( oldt == t ) {
02130     ptr = oldptr;
02131   } else {
02132     ptr = _tm_alloc_inner(size);
02133     memcpy(ptr, oldptr, size < oldt->size ? size : oldt->size);
02134   }
02135   
02136   return (void*) ptr;
02137 }

Here is the call graph for this function:

Here is the caller graph for this function:

void _tm_set_stack_ptr ( void *  stackvar  ) 

Set the stack pointer.

Adjust for slack.

Definition at line 80 of file mark.c.

Referenced by tm_alloc(), tm_alloc_desc(), tm_free(), tm_gc_full(), tm_init(), and tm_realloc().

00081 {
00082   *tm.stack_ptrp = (char*) stackvar - 64;
00083 }

Here is the caller graph for this function:

void tm_node_set_color ( tm_node n,
tm_block b,
tm_color  c 
)

Sets the color of a tm_node, in a tm_block.

Sets the color of a tm_node, in a tm_block.

The tm_node must reside in the tm_block.

Removes the tm_node from its current tm_type color list and appends the tm_node to the new color_list.

Definition at line 487 of file tm.c.

References _tm_node_set_color(), tm_type::color_list, tm_assert_test, tm_list_remove_and_append(), and tm_block::type.

Referenced by _tm_check_sweep_error(), _tm_free_inner(), _tm_node_init(), _tm_node_mark(), _tm_node_scan(), _tm_node_scan_some(), _tm_node_sweep(), _tm_node_unmark_some(), _tm_type_alloc_node_from_free_list(), and tm_write_barrier_node().

00488 {
00489   tm_type *t;
00490 
00491   tm_assert_test(b);
00492   // _tm_block_validate(b);
00493   tm_assert_test(b->type);
00494   t = b->type;
00495 
00496   _tm_node_set_color(n, b, t, c);
00497 
00498   tm_list_remove_and_append(&t->color_list[c], n);
00499  
00500   // _tm_validate_lists();
00501 }

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