GCC Wikia
Advertisement

このページを編集する際は,編集に関する方針に従ってください.[]

概要[]

実装[]

ggc-zone.c[]

346 /* The global variables.  */
347 static struct globals
348 {
349   /* The linked list of zones.  */

  • zoneの線形連結リスト

350   struct alloc_zone *zones;
351 
352   /* Lookup table for associating allocation pages with object addresses.  */
353   page_table lookup;
354 
355   /* The system's page size, and related constants.  */
356   size_t pagesize;
357   size_t lg_pagesize;
358   size_t page_mask;
359 
360   /* The size to allocate for a small page entry.  This includes
361      the size of the structure and the size of the allocation
362      bitmap.  */
363   size_t small_page_overhead;
364 
365 #if defined (HAVE_MMAP_DEV_ZERO)
366   /* A file descriptor open to /dev/zero for reading.  */
367   int dev_zero_fd;
368 #endif
369 
370   /* Allocate pages in chunks of this size, to throttle calls to memory
371      allocation routines.  The first page is used, the rest go onto the
372      free list.  */
373   size_t quire_size;
374 
375   /* The file descriptor for debugging output.  */
376   FILE *debug_file;
377 } G;

gcc-page.c[]

333 /* The rest of the global variables.  */
334 static struct globals
335 {
336   /* The Nth element in this array is a page with objects of size 2^N.
337      If there are any pages with free objects, they will be at the
338      head of the list.  NULL if there are no page-entries for this
339      object size.  */
340   page_entry *pages[NUM_ORDERS];
341 
342   /* The Nth element in this array is the last page with objects of
343      size 2^N.  NULL if there are no page-entries for this object
344      size.  */
345   page_entry *page_tails[NUM_ORDERS];
346 
347   /* Lookup table for associating allocation pages with object addresses.  */
348   page_table lookup;
349 
350   /* The system's page size.  */
351   size_t pagesize;
352   size_t lg_pagesize;
353 
354   /* Bytes currently allocated.  */
355   size_t allocated;
356 
357   /* Bytes currently allocated at the end of the last collection.  */
358   size_t allocated_last_gc;
359 
360   /* Total amount of memory mapped.  */
361   size_t bytes_mapped;
362 
363   /* Bit N set if any allocations have been done at context depth N.  */
364   unsigned long context_depth_allocations;
365 
366   /* Bit N set if any collections have been done at context depth N.  */
367   unsigned long context_depth_collections;
368 
369   /* The current depth in the context stack.  */
370   unsigned short context_depth;
371 
372   /* A file descriptor open to /dev/zero for reading.  */
373 #if defined (HAVE_MMAP_DEV_ZERO)
374   int dev_zero_fd;
375 #endif
376 
377   /* A cache of free system pages.  */
378   page_entry *free_pages;
379 
380 #ifdef USING_MALLOC_PAGE_GROUPS
381   page_group *page_groups;
382 #endif
383 
384   /* The file descriptor for debugging output.  */
385   FILE *debug_file;
386 
387   /* Current number of elements in use in depth below.  */
388   unsigned int depth_in_use;
389 
390   /* Maximum number of elements that can be used before resizing.  */
391   unsigned int depth_max;
392 
393   /* Each element of this arry is an index in by_depth where the given
394      depth starts.  This structure is indexed by that given depth we
395      are interested in.  */
396   unsigned int *depth;
397 
398   /* Current number of elements in use in by_depth below.  */
399   unsigned int by_depth_in_use;
400 
401   /* Maximum number of elements that can be used before resizing.  */
402   unsigned int by_depth_max;
403 
404   /* Each element of this array is a pointer to a page_entry, all
405      page_entries can be found in here by increasing depth.
406      index_by_depth in the page_entry is the index into this data
407      structure where that page_entry can be found.  This is used to
408      speed up finding all page_entries at a particular depth.  */
409   page_entry **by_depth;
410 
411   /* Each element is a pointer to the saved in_use_p bits, if any,
412      zero otherwise.  We allocate them all together, to enable a
413      better runtime data access pattern.  */
414   unsigned long **save_in_use;
415 
416 #ifdef ENABLE_GC_ALWAYS_COLLECT
417   /* List of free objects to be verified as actually free on the
418      next collection.  */
419   struct free_object
420   {
421     void *object;
422     struct free_object *next;
423   } *free_object_list;
424 #endif
425 
426 #ifdef GATHER_STATISTICS
427   struct
428   {
429     /* Total memory allocated with ggc_alloc.  */
430     unsigned long long total_allocated;
431     /* Total overhead for memory to be allocated with ggc_alloc.  */
432     unsigned long long total_overhead;
433 
434     /* Total allocations and overhead for sizes less than 32, 64 and 128.
435        These sizes are interesting because they are typical cache line
436        sizes.  */
437    
438     unsigned long long total_allocated_under32;
439     unsigned long long total_overhead_under32;
440   
441     unsigned long long total_allocated_under64;
442     unsigned long long total_overhead_under64;
443   
444     unsigned long long total_allocated_under128;
445     unsigned long long total_overhead_under128;
446   
447     /* The allocations for each of the allocation orders.  */
448     unsigned long long total_allocated_per_order[NUM_ORDERS];
449 
450     /* The overhead for each of the allocation orders.  */
451     unsigned long long total_overhead_per_order[NUM_ORDERS];
452   } stats;
453 #endif
454 } G;



リンク元

Advertisement