2 * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
3 * Copyright (c) 1991-1995 by Xerox Corporation. All rights reserved.
4 * Copyright 1996-1999 by Silicon Graphics. All rights reserved.
5 * Copyright 1999 by Hewlett-Packard Company. All rights reserved.
7 * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
8 * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
10 * Permission is hereby granted to use or copy this program
11 * for any purpose, provided the above notices are retained on all copies.
12 * Permission to modify the code and to distribute modified code is granted,
13 * provided the above notices are retained, and a notice that the code was
14 * modified is included with the above copyright notice.
17 /* This file assumes the collector has been compiled with GC_GCJ_SUPPORT. */
20 * We allocate objects whose first word contains a pointer to a struct
21 * describing the object type. This struct contains a garbage collector mark
22 * descriptor at offset MARK_DESCR_OFFSET. Alternatively, the objects
23 * may be marked by the mark procedure passed to GC_init_gcj_malloc.
29 /* Gcj keeps GC descriptor as second word of vtable. This */
30 /* probably needs to be adjusted for other clients. */
31 /* We currently assume that this offset is such that: */
32 /* - all objects of this kind are large enough to have */
33 /* a value at that offset, and */
34 /* - it is not zero. */
35 /* These assumptions allow objects on the free list to be */
36 /* marked normally. */
46 /* The following allocators signal an out of memory condition with */
47 /* return GC_oom_fn(bytes); */
49 /* The following function must be called before the gcj allocators */
51 /* mp_index and mp are the index and mark_proc (see gc_mark.h) */
52 /* respectively for the allocated objects. Mark_proc will be */
53 /* used to build the descriptor for objects allocated through the */
54 /* debugging interface. The mark_proc will be invoked on all such */
55 /* objects with an "environment" value of 1. The client may choose */
56 /* to use the same mark_proc for some of its generated mark descriptors.*/
57 /* In that case, it should use a different "environment" value to */
58 /* detect the presence or absence of the debug header. */
59 /* Mp is really of type mark_proc, as defined in gc_mark.h. We don't */
60 /* want to include that here for namespace pollution reasons. */
61 /* Passing in mp_index here instead of having GC_init_gcj_malloc() */
62 /* internally call GC_new_proc() is quite ugly, but in typical usage */
63 /* scenarios a compiler also has to know about mp_index, so */
64 /* generating it dynamically is not acceptable. Mp_index will */
65 /* typically be an integer < RESERVED_MARK_PROCS, so that it doesn't */
66 /* collide with GC_new_proc allocated indices. If the application */
67 /* needs no other reserved indices, zero */
68 /* (GC_GCJ_RESERVED_MARK_PROC_INDEX in gc_mark.h) is an obvious choice. */
69 GC_API void GC_CALL GC_init_gcj_malloc(int /* mp_index */,
70 void * /* really mark_proc */ /* mp */);
72 /* Allocate an object, clear it, and store the pointer to the */
73 /* type structure (vtable in gcj). */
74 /* This adds a byte at the end of the object if GC_malloc would.*/
75 GC_API void * GC_CALL GC_gcj_malloc(size_t /* lb */,
76 void * /* ptr_to_struct_containing_descr */)
77 GC_ATTR_MALLOC GC_ATTR_ALLOC_SIZE(1);
78 /* The debug versions allocate such that the specified mark_proc */
79 /* is always invoked. */
80 GC_API void * GC_CALL GC_debug_gcj_malloc(size_t /* lb */,
81 void * /* ptr_to_struct_containing_descr */,
83 GC_ATTR_MALLOC GC_ATTR_ALLOC_SIZE(1);
85 /* Similar to GC_gcj_malloc, but assumes that a pointer to near the */
86 /* beginning of the resulting object is always maintained. */
87 GC_API void * GC_CALL GC_gcj_malloc_ignore_off_page(size_t /* lb */,
88 void * /* ptr_to_struct_containing_descr */)
89 GC_ATTR_MALLOC GC_ATTR_ALLOC_SIZE(1);
91 /* The kind numbers of normal and debug gcj objects. */
92 /* Useful only for debug support, we hope. */
93 GC_API int GC_gcj_kind;
95 GC_API int GC_gcj_debug_kind;
98 # define GC_GCJ_MALLOC(s,d) GC_debug_gcj_malloc(s,d,GC_EXTRAS)
99 # define GC_GCJ_MALLOC_IGNORE_OFF_PAGE(s,d) GC_debug_gcj_malloc(s,d,GC_EXTRAS)
101 # define GC_GCJ_MALLOC(s,d) GC_gcj_malloc(s,d)
102 # define GC_GCJ_MALLOC_IGNORE_OFF_PAGE(s,d) GC_gcj_malloc_ignore_off_page(s,d)
106 } /* end of extern "C" */
109 #endif /* GC_GCJ_H */