Type

Data Structures

struct  tm_type
 A tm_type represents information about all tm_nodes of a specific size. More...

Functions

__inline void tm_type_init (tm_type *t, size_t size)
 Initialize a new tm_type of a given size.
static __inline tm_typetm_type_new (size_t size)
 Returns a new tm_type for a given size.
static __inline int tm_size_hash (size_t size)
 Returns the tm.type_hash[] index for a size.
static __inline tm_typetm_size_to_type_2 (size_t size)
 Look for a type by size.
static __inline tm_typetm_type_new_2 (size_t size)
 Returns a new tm_type for a given size.
tm_adesctm_adesc_for_size (tm_adesc *desc, int force_new)
 WHAT DOES THIS DO???
static __inline tm_typetm_size_to_type (size_t size)
 Return a tm_type for a size.

Function Documentation

tm_adesc* tm_adesc_for_size ( tm_adesc desc,
int  force_new 
)

WHAT DOES THIS DO???

????

Definition at line 1368 of file tm.c.

References tm_type::desc, tm_adesc::hidden, tm_adesc::size, tm_size_to_type_2(), and tm_type_new_2().

01369 {
01370   tm_type *t;
01371 
01372   if ( ! force_new ) {
01373     t = tm_size_to_type_2(desc->size);
01374     if ( t )
01375       return t->desc;
01376   }
01377 
01378   t = tm_type_new_2(desc->size);
01379   t->desc = desc;
01380   t->desc->hidden = t;
01381 
01382   return t->desc;
01383 }

Here is the call graph for this function:

static __inline int tm_size_hash ( size_t  size  )  [static]

Returns the tm.type_hash[] index for a size.

IMPLEMENT: support for big allocs.

Compute hash bucket index.

Modulus index into hash bucket index.

Definition at line 1296 of file tm.c.

References tm_ALLOC_ALIGN, tm_assert, tm_block_SIZE_MAX, and tm_type_hash_LEN.

Referenced by tm_size_to_type_2(), and tm_type_new_2().

01297 {
01298   int i;
01299 
01300   /*! IMPLEMENT: support for big allocs. */
01301   tm_assert(size <= tm_block_SIZE_MAX);
01302 
01303   /*! Compute hash bucket index. */
01304   i = size / tm_ALLOC_ALIGN;
01305 
01306   /*! Modulus index into hash bucket index. */
01307   i %= tm_type_hash_LEN;
01308 
01309   return i;
01310 }

Here is the caller graph for this function:

static __inline tm_type* tm_size_to_type ( size_t  size  )  [static]

Return a tm_type for a size.

Align size to tm_ALLOC_ALIGN.

If there already exists a type of the size, return it.

Otherwise, align size to the next power of two.

Try to locate a bigger tm_type of that size.

Definition at line 1390 of file tm.c.

References POW2, tm_type::size, tm_ALLOC_ALIGN, tm_assert_test, tm_size_to_type_2(), and tm_type_new_2().

Referenced by _tm_alloc_inner(), and _tm_realloc_inner().

01391 {
01392   tm_type *t;
01393   
01394   /*! Align size to tm_ALLOC_ALIGN. */
01395   size = (size + (tm_ALLOC_ALIGN - 1)) & ~(tm_ALLOC_ALIGN - 1);
01396 
01397   /*! If there already exists a type of the size, return it. */
01398   t = tm_size_to_type_2(size);
01399 
01400   if ( t )
01401     return t;
01402 
01403   /*! Otherwise, align size to the next power of two. */
01404 #define POW2(i) if ( size <= (1UL << i) ) size = (1UL << i); else
01405 
01406   POW2(3)
01407   POW2(4)
01408   POW2(5)
01409   POW2(6)
01410   POW2(7)
01411   POW2(8)
01412   POW2(9)
01413   POW2(10)
01414   POW2(11)
01415   POW2(12)
01416   POW2(13)
01417   POW2(14)
01418   POW2(15)
01419   POW2(16)
01420   (void) 0;
01421 
01422 #undef POW2
01423 
01424   /*! Try to locate a bigger tm_type of that size. */
01425   t = tm_size_to_type_2(size);
01426 
01427   /* If a tm_type was not found, create a new one. */
01428   if ( ! t ) {
01429     t = tm_type_new_2(size);
01430   }
01431   
01432   tm_assert_test(t->size == size);
01433   
01434   return t;
01435 }

Here is the call graph for this function:

Here is the caller graph for this function:

static __inline tm_type* tm_size_to_type_2 ( size_t  size  )  [static]

Look for a type by size.

Look for type by size using tm.type_hash.

If a type of the same size is found,

Definition at line 1317 of file tm.c.

References tm_type::hash_next, tm_type::size, tm, tm_size_hash(), and tm_data::type_hash.

Referenced by tm_adesc_for_size(), and tm_size_to_type().

01318 {
01319   tm_type **tp, *t;
01320   int i;
01321   
01322   i = tm_size_hash(size);
01323 
01324   /*! Look for type by size using tm.type_hash. */
01325   for ( tp = &tm.type_hash[i]; (t = (*tp)); tp = &t->hash_next ) {
01326     /*! If a type of the same size is found, */
01327     if ( t->size == size ) {
01328       /* Move it to front of hash bucket. */
01329       *tp = t->hash_next;
01330       t->hash_next = tm.type_hash[i];
01331       tm.type_hash[i] = t;
01332       break;
01333     }
01334   }
01335 
01336   return t;
01337 }

Here is the call graph for this function:

Here is the caller graph for this function:

__inline void tm_type_init ( tm_type t,
size_t  size 
)

Initialize a new tm_type of a given size.

Assign a the tm_type a unique id.

Initialize tm_type's global list pointers.

Mark the tm_type as live.

Initialize the tm_types.blocks list.

Initialize the tm_type node counts.

Initialize the tm_type.color_list.

Force a new tm_block to be allocated and parceled.

Zero the tm_type descriptor.

Definition at line 1217 of file tm.c.

References tm_type::blocks, tm_type::color_list, tm_type::desc, tm_type::id, tm_type::list, tm_type::n, tm_type::parcel_from_block, tm_type::size, tm, tm_list_init(), tm_list_set_color, tm_LIVE_BLOCK, tm_LIVE_TYPE, and tm_data::type_id.

Referenced by tm_init(), and tm_type_new().

01218 {
01219   /*! Assign a the tm_type a unique id. */
01220   t->id = ++ tm.type_id;
01221 
01222   /*! Initialize tm_type's global list pointers. */
01223   tm_list_init(&t->list);
01224   
01225   /*! Mark the tm_type as live. */
01226   tm_list_set_color(&t->list, tm_LIVE_TYPE);
01227 #if tm_name_GUARD
01228   t->name = "TYPE";
01229 #endif
01230   t->size = size;
01231 
01232   /*! Initialize the tm_types.blocks list. */
01233   tm_list_init(&t->blocks);
01234   tm_list_set_color(&t->blocks, tm_LIVE_BLOCK);
01235   
01236   /*! Initialize the tm_type node counts. */
01237   memset(t->n, 0, sizeof(t->n));
01238   
01239   /*! Initialize the tm_type.color_list. */
01240   {
01241     int j;
01242     
01243     for ( j = 0; j < sizeof(t->color_list) / sizeof(t->color_list[0]); ++ j ) {
01244       tm_list_init(&t->color_list[j]);
01245       tm_list_set_color(&t->color_list[j], j);
01246     }
01247   }
01248 
01249   /*! Force a new tm_block to be allocated and parceled. */
01250   t->parcel_from_block = 0;
01251 
01252   /*! Zero the tm_type descriptor. */
01253   t->desc = 0;
01254 }

Here is the call graph for this function:

Here is the caller graph for this function:

static __inline tm_type* tm_type_new ( size_t  size  )  [static]

Returns a new tm_type for a given size.

If possible take a tm_type from global tm.type_free list.

Initialize the tm_type.

Add to global tm.types list.

Allocate some tm_nodes now so the tm_type's free list (tm_WHITE) is not empty. to avoid triggering a collection.

Assume this is being called because an tm_alloc() is envitable.

Definition at line 1261 of file tm.c.

References _tm_node_parcel_or_alloc(), tm_type::hash_next, tm, tm_list_insert(), tm_type_init(), tm_data::type_free, and tm_data::types.

Referenced by tm_type_new_2().

01262 {
01263   tm_type *t;
01264 
01265   /*! If possible take a tm_type from global tm.type_free list. */
01266   if ( tm.type_free ) {
01267     t = tm.type_free;
01268     tm.type_free = t->hash_next;
01269     t->hash_next = 0;
01270   } else {
01271     t = 0;
01272   }
01273 
01274   /*! Initialize the tm_type. */
01275   tm_type_init(t, size);
01276 
01277   /*! Add to global tm.types list. */
01278   tm_list_insert(&tm.types, t);
01279   
01280   /**
01281    * Allocate some tm_nodes now so the tm_type's free list (tm_WHITE) is not empty.
01282    * to avoid triggering a collection.
01283    *
01284    * Assume this is being called because an tm_alloc() is envitable.
01285    */
01286   _tm_node_parcel_or_alloc(t);
01287 
01288   return t;
01289 }

Here is the call graph for this function:

Here is the caller graph for this function:

static __inline tm_type* tm_type_new_2 ( size_t  size  )  [static]

Returns a new tm_type for a given size.

Allocate a new tm_type.

Add to tm.type_hash

Definition at line 1344 of file tm.c.

References tm_type::hash_next, tm_type::size, tm, tm_msg(), tm_size_hash(), tm_type_new(), and tm_data::type_hash.

Referenced by tm_adesc_for_size(), and tm_size_to_type().

01345 {
01346   int i;
01347   tm_type *t;
01348 
01349   /*! Allocate a new tm_type. */
01350   t = tm_type_new(size);
01351   
01352   /*! Add to tm.type_hash */
01353   i = tm_size_hash(t->size);
01354   t->hash_next = tm.type_hash[i];
01355   tm.type_hash[i] = t;
01356   
01357 #if 0
01358   tm_msg("t a t%p %lu\n", (void*) t, (unsigned long) size);
01359 #endif
01360 
01361   return t;
01362 }

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