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

📄 readme

📁 linux下建立JAVA虚拟机的源码KAFFE
💻
📖 第 1 页 / 共 3 页
字号:
  The variable GC_non_gc_bytes, which is normally 0, may be changed to reflectthe amount of memory allocated by the above routines that should not beconsidered as a candidate for collection.  Careless use may, of course, resultin excessive memory consumption.  Some additional tuning is possible through the parameters definednear the top of gc_priv.h.    If only GC_malloc is intended to be used, it might be appropriate to define:#define malloc(n) GC_malloc(n)#define calloc(m,n) GC_malloc((m)*(n))  For small pieces of VERY allocation intensive code, gc_inl.hincludes some allocation macros that may be used in place of GC_mallocand friends.  All externally visible names in the garbage collector start with "GC_".To avoid name conflicts, client code should avoid this prefix, except whenaccessing garbage collector routines or variables.  There are provisions for allocation with explicit type information.This is rarely necessary.  Details can be found in gc_typed.h.THE C++ INTERFACE TO THE ALLOCATOR:  The Ellis-Hull C++ interface to the collector is included inthe collector distribution.  If you intend to use this, type"make c++" after the initial build of the collector is complete.See gc_cpp.h for the definition of the interface.  This interfacetries to approximate the Ellis-Detlefs C++ garbage collectionproposal without compiler changes.Cautions:1. Arrays allocated without new placement syntax areallocated as uncollectable objects.  They are traced by thecollector, but will not be reclaimed.2. Failure to use "make c++" in combination with (1) willresult in arrays allocated using the default new operator.This is likely to result in disaster without linker warnings.3. If your compiler supports an overloaded new[] operator,then gc_cpp.cc and gc_cpp.h should be suitably modified.4. Many current C++ compilers have deficiencies thatbreak some of the functionality.  See the comments in gc_cpp.hfor suggested workarounds.USE AS LEAK DETECTOR:  The collector may be used to track down leaks in C programs that areintended to run with malloc/free (e.g. code with extreme real-time orportability constraints).  To do so define FIND_LEAK in MakefileThis will cause the collector to invoke the report_leakroutine defined near the top of reclaim.c whenever an inaccessibleobject is found that has not been explicitly freed.  Such objects willalso be automatically reclaimed.  Productive use of this facility normally involves redefining report_leakto do something more intelligent.  This typically requires annotatingobjects with additional information (e.g. creation time stack trace) thatidentifies their origin.  Such code is typically not very portable, and isnot included here, except on SPARC machines.  If all objects are allocated with GC_DEBUG_MALLOC (see next section),then the default version of report_leak will report the source fileand line number at which the leaked object was allocated.  This maysometimes be sufficient.  (On SPARC/SUNOS4 machines, it will also reporta cryptic stack trace.  This can often be turned into a sympolic stacktrace by invoking program "foo" with "callprocs foo".  Callprocs isa short shell script that invokes adb to expand program counter valuesto symbolic addresses.  It was largely supplied by Scott Schwartz.)  Note that the debugging facilities described in the next section cansometimes be slightly LESS effective in leak finding mode, since inleak finding mode, GC_debug_free actually results in reuse of the object.(Otherwise the object is simply marked invalid.)  Also note that the testprogram is not designed to run meaningfully in FIND_LEAK mode.Use "make gc.a" to build the collector.DEBUGGING FACILITIES:  The routines GC_debug_malloc, GC_debug_malloc_atomic, GC_debug_realloc,and GC_debug_free provide an alternate interface to the collector, whichprovides some help with memory overwrite errors, and the like.Objects allocated in this way are annotated with additionalinformation.  Some of this information is checked during garbagecollections, and detected inconsistencies are reported to stderr.  Simple cases of writing past the end of an allocated object shouldbe caught if the object is explicitly deallocated, or if thecollector is invoked while the object is live.  The first deallocationof an object will clear the debugging info associated with anobject, so accidentally repeated calls to GC_debug_free will report thedeallocation of an object without debugging information.  Out ofmemory errors will be reported to stderr, in addition to returningNIL.  GC_debug_malloc checking  during garbage collection is enabledwith the first call to GC_debug_malloc.  This will result in someslowdown during collections.  If frequent heap checks are desired,this can be achieved by explicitly invoking GC_gcollect, e.g. fromthe debugger.  GC_debug_malloc allocated objects should not be passed to GC_reallocor GC_free, and conversely.  It is however acceptable to allocate onlysome objects with GC_debug_malloc, and to use GC_malloc for other objects,provided the two pools are kept distinct.  In this case, there is a verylow probablility that GC_malloc allocated objects may be misidentified ashaving been overwritten.  This should happen with probability at mostone in 2**32.  This probability is zero if GC_debug_malloc is never called.  GC_debug_malloc, GC_malloc_atomic, and GC_debug_realloc take twoadditional trailing arguments, a string and an integer.  These are notinterpreted by the allocator.  They are stored in the object (the string isnot copied).  If an error involving the object is detected, they are printed.  The macros GC_MALLOC, GC_MALLOC_ATOMIC, GC_REALLOC, GC_FREE, andGC_REGISTER_FINALIZER are also provided.  These require the same argumentsas the corresponding (nondebugging) routines.  If gc.h is includedwith GC_DEBUG defined, they call the debugging versions of thesefunctions, passing the current file name and line number as the twoextra arguments, where appropriate.  If gc.h is included without GC_DEBUGdefined, then all these macros will instead be defined to their nondebuggingequivalents.  (GC_REGISTER_FINALIZER is necessary, since pointers toobjects with debugging information are really pointers to a displacementof 16 bytes form the object beginning, and some translation is necessarywhen finalization routines are invoked.  For details, about what's storedin the header, see the definition of the type oh in debug_malloc.c)INCREMENTAL/GENERATIONAL COLLECTION:The collector normally interrupts client code for the duration of a garbage collection mark phase.  This may be unacceptable if interactiveresponse is needed for programs with large heaps.  The collectorcan also run in a "generational" mode, in which it usually attempts tocollect only objects allocated since the last garbage collection.Furthermore, in this mode, garbage collections run mostly incrementally,with a small amount of work performed in response to each of a large number ofGC_malloc requests.This mode is enabled by a call to GC_enable_incremental().Incremental and generational collection is effective in reducingpause times only if the collector has some way to tell which objectsor pages have been recently modified.  The collector uses two sourcesof information:1. Information provided by the VM system.  This may be provided inone of several forms.  Under Solaris 2.X (and potentially under othersimilar systems) information on dirty pages can be read from the/proc file system.  Under other systems (currently SunOS4.X) it ispossible to write-protect the heap, and catch the resulting faults.On these systems we require that system calls writing to the heap(other than read) be handled specially by client code.See os_dep.c for details.2. Information supplied by the programmer.  We define "stubborn"objects to be objects that are rarely changed.  Such an objectcan be allocated (and enabled for writing) with GC_malloc_stubborn.Once it has been initialized, the collector should be informed witha call to GC_end_stubborn_change.  Subsequent writes that storepointers into the object must be preceded by a call toGC_change_stubborn.This mechanism performs best for objects that are written only forinitialization, and such that only one stubborn object is writableat once.  It is typically not worth using for short-livedobjects.  Stubborn objects are treated less efficiently than pointerfree(atomic) objects.A rough rule of thumb is that, in the absence of VM information, garbagecollection pauses are proportional to the amount of pointerful storageplus the amount of modified "stubborn" storage that is reachable duringthe collection.  Initial allocation of stubborn objects takes longer than allocationof other objects, since other data structures need to be maintained.We recommend against random use of stubborn objects in clientcode, since bugs caused by inappropriate writes to stubborn objectsare likely to be very infrequently observed and hard to trace.  However, their use may be appropriate in a few carefully writtenlibrary routines that do not make the objects themselves availablefor writing by client code.BUGS:  Any memory that does not have a recognizable pointer to it will bereclaimed.  Exclusive-or'ing forward and backward links in a listdoesn't cut it.  Some C optimizers may lose the last undisguised pointer to a memoryobject as a consequence of clever optimizations.  This has almostnever been observed in practice.  Send mail to boehm@acm.orgfor suggestions on how to fix your compiler.  This is not a real-time collector.  In the standard configuration,percentage of time required for collection should be constant acrossheap sizes.  But collection pauses will increase for larger heaps.(On SPARCstation 2s collection times will be on the order of 300 msecsper MB of accessible memory that needs to be scanned.  Your mileagemay vary.)  The incremental/generational collection facility helps,but is portable only if "stubborn" allocation is used.  Please address bug reports to boehm@acm.org.  If you arecontemplating a major addition, you might also send mail to ask whetherit's already been done (or whether we tried and discarded it).

⌨️ 快捷键说明

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