⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 runtime.h

📁 内存垃圾收集程序
💻 H
📖 第 1 页 / 共 2 页
字号:
/* Copyright 1988,1989 Hans-J. Boehm, Alan J. Demers *//*********************************//*                               *//* Definitions for conservative  *//* collector                     *//*                               *//*********************************//*********************************//*                               *//* Easily changeable parameters  *//*                               *//*********************************/# if defined(sun) && defined(mc68000)#    define M68K#    define mach_type_known# endif# if defined(vax)#    define VAX#    define mach_type_known# endif# if defined(mips)#    define MIPS#    define mach_type_known# endif# if defined(sequent) && defined(i386)#    define I386#    define mach_type_known# endif# if defined(ibm032)#   define RT#   define mach_type_known# endif# if defined(sun) && defined(sparc)#   define SPARC#   define mach_type_known# endif/* Feel free to add more clauses here *//* Or manually define the machine type here: */# ifndef mach_type_known#   define M68K     /* This is a Motorola 68000, as opposed to a SPARC, VAX, */		    /* RT, I386, MIPS, or NS32K.                             */		    /* We assume:  M68K ==> Sun3, I386 ==> Sequent Symmetry */		    /* NS32K ==> Encore Multimax, MIPS ==> R2000 or R3000   */# endif#define PRINTSTATS  /* Print garbage collection statistics                  */		    /* For less verbose output, undefine in reclaim.c      */#define PRINTTIMES  /* Print the amount of time consumed by each garbage   */		    /* collection.                                         */#define PRINTBLOCKS /* Print object sizes associated with heap blocks,     */		    /* whether the objects are atomic or composite, and    */		    /* whether or not the block was found to be empty      */		    /* duing the reclaim phase.  Typically generates       */		    /* about one screenful per garbage collection.         */#undef PRINTBLOCKS#define HBLK_MAP    /* Maintain a map of all potential heap blocks        */		    /* starting at heapstart.                             */		    /* Normally, this performs about as well as the       */		    /* standard stack of chunk pointers that is used      */		    /* otherwise.  It loses if a small section of the     */		    /* heap consists of garbage collected objects.        */		    /* It is ESSENTIAL if pointers to object interiors    */		    /* are considered valid, i.e. if INTERIOR_POINTERS    */		    /* is defined.                                        */#undef HBLK_MAP#define MAP_SIZE 8192  /* total data size < MAP_SIZE * HBLKSIZE = 32 Meg  */#define MAXHBLKS 4096  /* Maximum number of chunks which can be           */		       /* allocated                                       */#define INTERIOR_POINTERS		    /* Follow pointers to the interior of an object.      */		    /* Substantially increases the probability of         */		    /* unnnecessary space retention.  May be necessary    */		    /* with gcc -O or other C compilers that may clobber  */		    /* values of dead variables prematurely.  Pcc         */		    /* derived compilers appear to pose no such problems. */		    /* Empirical evidence suggests that this is probably  */		    /* still OK for most purposes, so long as pointers    */		    /* are known to be 32 bit aligned.  The combination   */		    /* of INTERIOR_POINTERS and UNALIGNED (e.g. on a      */		    /* Sun 3 with the standard compiler) causes easily    */		    /* observable spurious retention and performance      */		    /* degradation.                                       */#undef INTERIOR_POINTERS#if defined(INTERIOR_POINTERS) && !defined(HBLK_MAP)    --> check for interior pointers requires a heap block map#endif#define MERGE_SIZES /* Round up some object sizes, so that fewer distinct */		    /* free lists are actually maintained.  This applies  */		    /* only to the top level routines in misc.c, not to   */		    /* user generated code that calls allocobj and        */		    /* allocaobj directly.                                */		    /* Slows down average programs slightly.  May however */		    /* substantially reduce fragmentation if allocation   */		    /* request sizes are widely scattered.                */#undef MERGE_SIZES#ifdef M68K#  define UNALIGNED       /* Pointers are not longword aligned         */#  define ALIGNMENT   2   /* Pointers are aligned on 2 byte boundaries */			  /* by the Sun C compiler.                    */#else#  ifdef VAX#    undef UNALIGNED      /* Pointers are longword aligned by 4.2 C compiler */#    define ALIGNMENT 4#  else#    ifdef RT#      undef UNALIGNED#      define ALIGNMENT 4#    else#      ifdef SPARC#        undef UNALIGNED#        define ALIGNMENT 4#      else#        ifdef I386#           undef UNALIGNED         /* Sequent compiler aligns pointers */#           define ALIGNMENT 4#        else#          ifdef NS32K#            undef UNALIGNED        /* Pointers are aligned on NS32K */#            define ALIGNMENT 4#          else#            ifdef MIPS#              undef UNALIGNED      /* MIPS hardware requires pointer */				    /* alignment                      */#              define ALIGNMENT 4#            else		 --> specify alignment <--#            endif#          endif#        endif#      endif#    endif#  endif# endif# ifdef M68K#   define STACKTOP ((char *)0xf000000) /* Beginning of stack on a Sun 3 */					/* Sun 2 value is 0x1000000      */# else#   ifdef VAX#     define STACKTOP ((char *)0x80000000) /* Beginning of stack under 4.n BSD */#   else#     ifdef RT#       define STACKTOP ((char *) 0x1fffd800)#     else#       ifdef SPARC#         define STACKTOP ((char *) 0xf8000000)#       else#         ifdef I386#           define STACKTOP ((char *) 0x3ffff000)  /* For Sequent */#         else#           ifdef NS32K#             define STACKTOP ((char *) 0xfffff000) /* for Encore */#           else#             ifdef MIPS#               define STACKTOP ((char *) 0x7ffff000)			      /* Could probably be slightly lower since  */			      /* startup code allocates lots of junk     */#             else		--> specify#             endif#           endif#         endif#       endif#     endif#   endif# endif/* Start of data segment for each of the above systems.  Note that the *//* default case works only for contiguous text and data, such as on a  *//* Vax.                                                                */# ifdef M68K#   define DATASTART ((char *)((((long) (&etext)) + 0x1ffff) & ~0x1ffff))# else#   ifdef RT#     define DATASTART ((char *) 0x10000000)#   else#     ifdef I386#       define DATASTART ((char *)((((long) (&etext)) + 0xfff) & ~0xfff))#     else#       ifdef NS32K	  extern char **environ;#         define DATASTART ((char *)(&environ))			      /* hideous kludge: environ is the first   */			      /* word in crt0.o, and delimits the start */			      /* of the data segment, no matter which   */			      /* ld options were passed through.        */#       else#         ifdef MIPS#           define DATASTART 0x10000000			      /* Could probably be slightly higher since */			      /* startup code allocates lots of junk     */#         else#           define DATASTART (&etext)#         endif#       endif#     endif#   endif# endif# define HINCR 16          /* Initial heap increment, in blocks of 4K        */# define HINCR_MULT 3      /* After each new allocation, hincr is multiplied */# define HINCR_DIV 2       /* by HINCR_MULT/HINCR_DIV                        */# define GC_MULT 3         /* Don't collect if the fraction of   */			   /* non-collectable memory in the heap */			   /* exceeds GC_MUL/GC_DIV              */# define GC_DIV  4# define NON_GC_HINCR 8    /* Heap increment if most of heap if collection */			   /* was suppressed because most of heap is not   */			   /* collectable                                  *//*  heap address bounds.  These are extreme bounds used for sanity checks. *//*  HEAPLIM may have to be increased for machines with incredibly large    *//*  amounts of memory.                                                     */#ifdef RT#   define HEAPSTART 0x10000000#   define HEAPLIM   0x1fff0000#else# ifdef M68K#   define HEAPSTART 0x00010000#   define HEAPLIM   0x04000000# else#   ifdef SPARC#       define HEAPSTART 0x00010000#       define HEAPLIM   0x10000000#   else#     ifdef VAX#       define HEAPSTART 0x400#       define HEAPLIM   0x10000000#     else#       ifdef I386#         define HEAPSTART 0x1000#         define HEAPLIM 0x10000000#       else#         ifdef NS32K#           define HEAPSTART 0x2000#           define HEAPLIM   0x10000000#         else#           ifdef MIPS#             define HEAPSTART 0x10000000#             define HEAPLIM 0x20000000#           else	       --> values unknown <--#           endif#         endif#       endif#     endif#   endif# endif#endif/*********************************//*                               *//* Machine-dependent defines     *//*                               *//*********************************/#define WORDS_TO_BYTES(x)   ((x)<<2)#define BYTES_TO_WORDS(x)   ((x)>>2)#define WORDSZ              32#define LOGWL               5    /* log[2] of above */#define BYTES_PER_WORD      (sizeof (word))#define NREGS               16#define ONES                0xffffffff#define MSBYTE              0xff000000#define SIGNB               0x80000000#define MAXSHORT            0x7fff#define modHALFWORDSZ(n) ((n) & 0xf)    /* mod n by size of half word    */#define divHALFWORDSZ(n) ((n) >> 4)	/* divide n by size of half word */#define modWORDSZ(n) ((n) & 0x1f)       /* mod n by size of word         */#define divWORDSZ(n) ((n) >> 5)         /* divide n by size of word      */#define twice(n) ((n) << 1)             /* double n                      */typedef unsigned long word;#define TRUE  1#define FALSE 0/*********************//*                   *//*  Size Parameters  *//*                   *//*********************//*  heap block size, bytes *//* for RT see comment below */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -