Back to index

plt-scheme  4.2.1
gc_gcj.h
Go to the documentation of this file.
00001 /* 
00002  * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
00003  * Copyright (c) 1991-1995 by Xerox Corporation.  All rights reserved.
00004  * Copyright 1996-1999 by Silicon Graphics.  All rights reserved.
00005  * Copyright 1999 by Hewlett-Packard Company.  All rights reserved.
00006  *
00007  * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
00008  * OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
00009  *
00010  * Permission is hereby granted to use or copy this program
00011  * for any purpose,  provided the above notices are retained on all copies.
00012  * Permission to modify the code and to distribute modified code is granted,
00013  * provided the above notices are retained, and a notice that the code was
00014  * modified is included with the above copyright notice.
00015  */
00016 
00017 /* This file assumes the collector has been compiled with GC_GCJ_SUPPORT */
00018 /* and that an ANSI C compiler is available.                           */
00019 
00020 /*
00021  * We allocate objects whose first word contains a pointer to a struct
00022  * describing the object type.  This struct contains a garbage collector mark
00023  * descriptor at offset MARK_DESCR_OFFSET.  Alternatively, the objects
00024  * may be marked by the mark procedure passed to GC_init_gcj_malloc.
00025  */
00026 
00027 #ifndef GC_GCJ_H
00028 
00029 #define GC_GCJ_H
00030 
00031 #ifndef MARK_DESCR_OFFSET
00032 #  define MARK_DESCR_OFFSET sizeof(word)
00033 #endif
00034        /* Gcj keeps GC descriptor as second word of vtable.    This   */
00035        /* probably needs to be adjusted for other clients.            */
00036        /* We currently assume that this offset is such that:          */
00037        /*     - all objects of this kind are large enough to have     */
00038        /*       a value at that offset, and                           */
00039        /*     - it is not zero.                                */
00040        /* These assumptions allow objects on the free list to be      */
00041        /* marked normally.                                     */
00042 
00043 #ifndef _GC_H
00044 #   include "gc.h"
00045 #endif
00046 
00047 /* The following allocators signal an out of memory condition with    */
00048 /* return GC_oom_fn(bytes);                                    */
00049 
00050 /* The following function must be called before the gcj allocators    */
00051 /* can be invoked.                                             */
00052 /* mp_index and mp are the index and mark_proc (see gc_mark.h)        */
00053 /* respectively for the allocated objects.  Mark_proc will be         */
00054 /* used to build the descriptor for objects allocated through the     */
00055 /* debugging interface.  The mark_proc will be invoked on all such    */
00056 /* objects with an "environment" value of 1.  The client may choose   */
00057 /* to use the same mark_proc for some of its generated mark descriptors.*/
00058 /* In that case, it should use a different "environment" value to     */
00059 /* detect the presence or absence of the debug header.                */
00060 /* Mp is really of type mark_proc, as defined in gc_mark.h.  We don't        */
00061 /* want to include that here for namespace pollution reasons.         */
00062 extern void GC_init_gcj_malloc(int mp_index, void * /* really mark_proc */mp);
00063 
00064 /* Allocate an object, clear it, and store the pointer to the  */
00065 /* type structure (vtable in gcj).                      */
00066 /* This adds a byte at the end of the object if GC_malloc would.*/
00067 extern void * GC_gcj_malloc(size_t lb, void * ptr_to_struct_containing_descr);
00068 /* The debug versions allocate such that the specified mark_proc      */
00069 /* is always invoked.                                                 */
00070 extern void * GC_debug_gcj_malloc(size_t lb,
00071                               void * ptr_to_struct_containing_descr,
00072                               GC_EXTRA_PARAMS);
00073 
00074 /* Similar to the above, but the size is in words, and we don't       */
00075 /* adjust it.  The size is assumed to be such that it can be   */
00076 /* allocated as a small object.                                */
00077 /* Unless it is known that the collector is not configured     */
00078 /* with USE_MARK_BYTES and unless it is known that the object  */
00079 /* has weak alignment requirements, lw must be even.           */
00080 extern void * GC_gcj_fast_malloc(size_t lw,
00081                              void * ptr_to_struct_containing_descr);
00082 extern void * GC_debug_gcj_fast_malloc(size_t lw,
00083                              void * ptr_to_struct_containing_descr,
00084                              GC_EXTRA_PARAMS);
00085 
00086 /* Similar to GC_gcj_malloc, but assumes that a pointer to near the   */
00087 /* beginning of the resulting object is always maintained.            */
00088 extern void * GC_gcj_malloc_ignore_off_page(size_t lb,
00089                             void * ptr_to_struct_containing_descr);
00090 
00091 /* The kind numbers of normal and debug gcj objects.           */
00092 /* Useful only for debug support, we hope.                     */
00093 extern int GC_gcj_kind;
00094 
00095 extern int GC_gcj_debug_kind;
00096 
00097 # if defined(GC_LOCAL_ALLOC_H) && defined(GC_REDIRECT_TO_LOCAL)
00098     --> gc_local_alloc.h should be included after this.  Otherwise
00099     --> we undo the redirection.
00100 # endif
00101 
00102 # ifdef GC_DEBUG
00103 #   define GC_GCJ_MALLOC(s,d) GC_debug_gcj_malloc(s,d,GC_EXTRAS)
00104 #   define GC_GCJ_FAST_MALLOC(s,d) GC_debug_gcj_fast_malloc(s,d,GC_EXTRAS)
00105 #   define GC_GCJ_MALLOC_IGNORE_OFF_PAGE(s,d) GC_debug_gcj_malloc(s,d,GC_EXTRAS)
00106 # else
00107 #   define GC_GCJ_MALLOC(s,d) GC_gcj_malloc(s,d)
00108 #   define GC_GCJ_FAST_MALLOC(s,d) GC_gcj_fast_malloc(s,d)
00109 #   define GC_GCJ_MALLOC_IGNORE_OFF_PAGE(s,d) \
00110        GC_gcj_malloc_ignore_off_page(s,d)
00111 # endif
00112 
00113 #endif /* GC_GCJ_H */