2 * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
3 * Copyright (c) 1991-1996 by Xerox Corporation. All rights reserved.
4 * Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved.
6 * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
7 * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
9 * Permission is hereby granted to use or copy this program
10 * for any purpose, provided the above notices are retained on all copies.
11 * Permission to modify the code and to distribute modified code is granted,
12 * provided the above notices are retained, and a notice that the code was
13 * modified is included with the above copyright notice.
15 /* Boehm, February 1, 1996 1:19 pm PST */
16 # define I_HIDE_POINTERS
17 # include "private/gc_pmark.h"
19 # ifdef FINALIZE_ON_DEMAND
20 int GC_finalize_on_demand
= 1;
22 int GC_finalize_on_demand
= 0;
25 # ifdef JAVA_FINALIZATION
26 int GC_java_finalization
= 1;
28 int GC_java_finalization
= 0;
31 /* Type of mark procedure used for marking from finalizable object. */
32 /* This procedure normally does not mark the object, only its */
34 typedef void finalization_mark_proc(/* ptr_t finalizable_obj_ptr */);
36 # define HASH3(addr,size,log_size) \
37 ((((word)(addr) >> 3) ^ ((word)(addr) >> (3+(log_size)))) \
39 #define HASH2(addr,log_size) HASH3(addr, 1 << log_size, log_size)
41 struct hash_chain_entry
{
43 struct hash_chain_entry
* next
;
46 unsigned GC_finalization_failures
= 0;
47 /* Number of finalization requests that failed for lack of memory. */
49 static struct disappearing_link
{
50 struct hash_chain_entry prolog
;
51 # define dl_hidden_link prolog.hidden_key
52 /* Field to be cleared. */
53 # define dl_next(x) (struct disappearing_link *)((x) -> prolog.next)
54 # define dl_set_next(x,y) (x) -> prolog.next = (struct hash_chain_entry *)(y)
56 word dl_hidden_obj
; /* Pointer to object base */
59 static signed_word log_dl_table_size
= -1;
61 /* current size of array pointed to by dl_head. */
62 /* -1 ==> size is 0. */
64 word GC_dl_entries
= 0; /* Number of entries currently in disappearing */
67 static struct finalizable_object
{
68 struct hash_chain_entry prolog
;
69 # define fo_hidden_base prolog.hidden_key
70 /* Pointer to object base. */
71 /* No longer hidden once object */
72 /* is on finalize_now queue. */
73 # define fo_next(x) (struct finalizable_object *)((x) -> prolog.next)
74 # define fo_set_next(x,y) (x) -> prolog.next = (struct hash_chain_entry *)(y)
75 GC_finalization_proc fo_fn
; /* Finalizer. */
77 word fo_object_size
; /* In bytes. */
78 finalization_mark_proc
* fo_mark_proc
; /* Mark-through procedure */
81 struct finalizable_object
* GC_finalize_now
= 0;
82 /* LIst of objects that should be finalized now. */
84 static signed_word log_fo_table_size
= -1;
86 word GC_fo_entries
= 0;
88 void GC_push_finalizer_structures
GC_PROTO((void))
90 GC_push_all((ptr_t
)(&dl_head
), (ptr_t
)(&dl_head
) + sizeof(word
));
91 GC_push_all((ptr_t
)(&fo_head
), (ptr_t
)(&fo_head
) + sizeof(word
));
92 GC_push_all((ptr_t
)(&GC_finalize_now
),
93 (ptr_t
)(&GC_finalize_now
) + sizeof(word
));
96 /* Double the size of a hash table. *size_ptr is the log of its current */
97 /* size. May be a noop. */
98 /* *table is a pointer to an array of hash headers. If we succeed, we */
99 /* update both *table and *log_size_ptr. */
100 /* Lock is held. Signals are disabled. */
101 void GC_grow_table(table
, log_size_ptr
)
102 struct hash_chain_entry
***table
;
103 signed_word
* log_size_ptr
;
106 register struct hash_chain_entry
*p
;
107 int log_old_size
= *log_size_ptr
;
108 register int log_new_size
= log_old_size
+ 1;
109 word old_size
= ((log_old_size
== -1)? 0: (1 << log_old_size
));
110 register word new_size
= 1 << log_new_size
;
111 struct hash_chain_entry
**new_table
= (struct hash_chain_entry
**)
112 GC_INTERNAL_MALLOC_IGNORE_OFF_PAGE(
113 (size_t)new_size
* sizeof(struct hash_chain_entry
*), NORMAL
);
115 if (new_table
== 0) {
117 ABORT("Insufficient space for initial table allocation");
122 for (i
= 0; i
< old_size
; i
++) {
125 register ptr_t real_key
= (ptr_t
)REVEAL_POINTER(p
-> hidden_key
);
126 register struct hash_chain_entry
*next
= p
-> next
;
127 register int new_hash
= HASH3(real_key
, new_size
, log_new_size
);
129 p
-> next
= new_table
[new_hash
];
130 new_table
[new_hash
] = p
;
134 *log_size_ptr
= log_new_size
;
138 # if defined(__STDC__) || defined(__cplusplus)
139 int GC_register_disappearing_link(GC_PTR
* link
)
141 int GC_register_disappearing_link(link
)
147 base
= (ptr_t
)GC_base((GC_PTR
)link
);
149 ABORT("Bad arg to GC_register_disappearing_link");
150 return(GC_general_register_disappearing_link(link
, base
));
153 # if defined(__STDC__) || defined(__cplusplus)
154 int GC_general_register_disappearing_link(GC_PTR
* link
,
157 int GC_general_register_disappearing_link(link
, obj
)
163 struct disappearing_link
*curr_dl
;
165 struct disappearing_link
* new_dl
;
168 if ((word
)link
& (ALIGNMENT
-1))
169 ABORT("Bad arg to GC_general_register_disappearing_link");
174 if (log_dl_table_size
== -1
175 || GC_dl_entries
> ((word
)1 << log_dl_table_size
)) {
179 GC_grow_table((struct hash_chain_entry
***)(&dl_head
),
182 if (GC_print_stats
) {
183 GC_printf1("Grew dl table to %lu entries\n",
184 (unsigned long)(1 << log_dl_table_size
));
191 index
= HASH2(link
, log_dl_table_size
);
192 curr_dl
= dl_head
[index
];
193 for (curr_dl
= dl_head
[index
]; curr_dl
!= 0; curr_dl
= dl_next(curr_dl
)) {
194 if (curr_dl
-> dl_hidden_link
== HIDE_POINTER(link
)) {
195 curr_dl
-> dl_hidden_obj
= HIDE_POINTER(obj
);
203 new_dl
= (struct disappearing_link
*)
204 GC_INTERNAL_MALLOC(sizeof(struct disappearing_link
),NORMAL
);
206 new_dl
-> dl_hidden_obj
= HIDE_POINTER(obj
);
207 new_dl
-> dl_hidden_link
= HIDE_POINTER(link
);
208 dl_set_next(new_dl
, dl_head
[index
]);
209 dl_head
[index
] = new_dl
;
212 GC_finalization_failures
++;
221 # if defined(__STDC__) || defined(__cplusplus)
222 int GC_unregister_disappearing_link(GC_PTR
* link
)
224 int GC_unregister_disappearing_link(link
)
228 struct disappearing_link
*curr_dl
, *prev_dl
;
234 index
= HASH2(link
, log_dl_table_size
);
235 if (((unsigned long)link
& (ALIGNMENT
-1))) goto out
;
236 prev_dl
= 0; curr_dl
= dl_head
[index
];
237 while (curr_dl
!= 0) {
238 if (curr_dl
-> dl_hidden_link
== HIDE_POINTER(link
)) {
240 dl_head
[index
] = dl_next(curr_dl
);
242 dl_set_next(prev_dl
, dl_next(curr_dl
));
248 dl_next(curr_dl
) = 0;
250 GC_free((GC_PTR
)curr_dl
);
255 curr_dl
= dl_next(curr_dl
);
263 /* Possible finalization_marker procedures. Note that mark stack */
264 /* overflow is handled by the caller, and is not a disaster. */
265 GC_API
void GC_normal_finalize_mark_proc(p
)
270 PUSH_OBJ((word
*)p
, hhdr
, GC_mark_stack_top
,
271 &(GC_mark_stack
[GC_mark_stack_size
]));
274 /* This only pays very partial attention to the mark descriptor. */
275 /* It does the right thing for normal and atomic objects, and treats */
276 /* most others as normal. */
277 GC_API
void GC_ignore_self_finalize_mark_proc(p
)
281 word descr
= hhdr
-> hb_descr
;
284 ptr_t target_limit
= p
+ WORDS_TO_BYTES(hhdr
-> hb_sz
) - 1;
286 if ((descr
& GC_DS_TAGS
) == GC_DS_LENGTH
) {
287 scan_limit
= p
+ descr
- sizeof(word
);
289 scan_limit
= target_limit
+ 1 - sizeof(word
);
291 for (q
= p
; q
<= scan_limit
; q
+= ALIGNMENT
) {
293 if (r
< p
|| r
> target_limit
) {
294 GC_PUSH_ONE_HEAP((word
)r
, q
);
300 GC_API
void GC_null_finalize_mark_proc(p
)
307 /* Register a finalization function. See gc.h for details. */
308 /* in the nonthreads case, we try to avoid disabling signals, */
309 /* since it can be expensive. Threads packages typically */
310 /* make it cheaper. */
311 /* The last parameter is a procedure that determines */
312 /* marking for finalization ordering. Any objects marked */
313 /* by that procedure will be guaranteed to not have been */
314 /* finalized when this finalizer is invoked. */
315 GC_API
void GC_register_finalizer_inner(obj
, fn
, cd
, ofn
, ocd
, mp
)
317 GC_finalization_proc fn
;
319 GC_finalization_proc
* ofn
;
321 finalization_mark_proc
* mp
;
324 struct finalizable_object
* curr_fo
, * prev_fo
;
326 struct finalizable_object
*new_fo
;
334 if (log_fo_table_size
== -1
335 || GC_fo_entries
> ((word
)1 << log_fo_table_size
)) {
339 GC_grow_table((struct hash_chain_entry
***)(&fo_head
),
342 if (GC_print_stats
) {
343 GC_printf1("Grew fo table to %lu entries\n",
344 (unsigned long)(1 << log_fo_table_size
));
351 /* in the THREADS case signals are disabled and we hold allocation */
352 /* lock; otherwise neither is true. Proceed carefully. */
354 index
= HASH2(base
, log_fo_table_size
);
355 prev_fo
= 0; curr_fo
= fo_head
[index
];
356 while (curr_fo
!= 0) {
357 if (curr_fo
-> fo_hidden_base
== HIDE_POINTER(base
)) {
358 /* Interruption by a signal in the middle of this */
359 /* should be safe. The client may see only *ocd */
360 /* updated, but we'll declare that to be his */
362 if (ocd
) *ocd
= (GC_PTR
) curr_fo
-> fo_client_data
;
363 if (ofn
) *ofn
= curr_fo
-> fo_fn
;
364 /* Delete the structure for base. */
366 fo_head
[index
] = fo_next(curr_fo
);
368 fo_set_next(prev_fo
, fo_next(curr_fo
));
372 /* May not happen if we get a signal. But a high */
373 /* estimate will only make the table larger than */
375 # if !defined(THREADS) && !defined(DBG_HDRS_ALL)
376 GC_free((GC_PTR
)curr_fo
);
379 curr_fo
-> fo_fn
= fn
;
380 curr_fo
-> fo_client_data
= (ptr_t
)cd
;
381 curr_fo
-> fo_mark_proc
= mp
;
382 /* Reinsert it. We deleted it first to maintain */
383 /* consistency in the event of a signal. */
385 fo_head
[index
] = curr_fo
;
387 fo_set_next(prev_fo
, curr_fo
);
397 curr_fo
= fo_next(curr_fo
);
410 /* We won't collect it, hence finalizer wouldn't be run. */
417 new_fo
= (struct finalizable_object
*)
418 GC_INTERNAL_MALLOC(sizeof(struct finalizable_object
),NORMAL
);
420 new_fo
-> fo_hidden_base
= (word
)HIDE_POINTER(base
);
421 new_fo
-> fo_fn
= fn
;
422 new_fo
-> fo_client_data
= (ptr_t
)cd
;
423 new_fo
-> fo_object_size
= hhdr
-> hb_sz
;
424 new_fo
-> fo_mark_proc
= mp
;
425 fo_set_next(new_fo
, fo_head
[index
]);
427 fo_head
[index
] = new_fo
;
429 GC_finalization_failures
++;
437 # if defined(__STDC__)
438 void GC_register_finalizer(void * obj
,
439 GC_finalization_proc fn
, void * cd
,
440 GC_finalization_proc
*ofn
, void ** ocd
)
442 void GC_register_finalizer(obj
, fn
, cd
, ofn
, ocd
)
444 GC_finalization_proc fn
;
446 GC_finalization_proc
* ofn
;
450 GC_register_finalizer_inner(obj
, fn
, cd
, ofn
,
451 ocd
, GC_normal_finalize_mark_proc
);
454 # if defined(__STDC__)
455 void GC_register_finalizer_ignore_self(void * obj
,
456 GC_finalization_proc fn
, void * cd
,
457 GC_finalization_proc
*ofn
, void ** ocd
)
459 void GC_register_finalizer_ignore_self(obj
, fn
, cd
, ofn
, ocd
)
461 GC_finalization_proc fn
;
463 GC_finalization_proc
* ofn
;
467 GC_register_finalizer_inner(obj
, fn
, cd
, ofn
,
468 ocd
, GC_ignore_self_finalize_mark_proc
);
471 # if defined(__STDC__)
472 void GC_register_finalizer_no_order(void * obj
,
473 GC_finalization_proc fn
, void * cd
,
474 GC_finalization_proc
*ofn
, void ** ocd
)
476 void GC_register_finalizer_no_order(obj
, fn
, cd
, ofn
, ocd
)
478 GC_finalization_proc fn
;
480 GC_finalization_proc
* ofn
;
484 GC_register_finalizer_inner(obj
, fn
, cd
, ofn
,
485 ocd
, GC_null_finalize_mark_proc
);
489 void GC_dump_finalization()
491 struct disappearing_link
* curr_dl
;
492 struct finalizable_object
* curr_fo
;
493 ptr_t real_ptr
, real_link
;
494 int dl_size
= (log_dl_table_size
== -1 ) ? 0 : (1 << log_dl_table_size
);
495 int fo_size
= (log_fo_table_size
== -1 ) ? 0 : (1 << log_fo_table_size
);
498 GC_printf0("Disappearing links:\n");
499 for (i
= 0; i
< dl_size
; i
++) {
500 for (curr_dl
= dl_head
[i
]; curr_dl
!= 0; curr_dl
= dl_next(curr_dl
)) {
501 real_ptr
= (ptr_t
)REVEAL_POINTER(curr_dl
-> dl_hidden_obj
);
502 real_link
= (ptr_t
)REVEAL_POINTER(curr_dl
-> dl_hidden_link
);
503 GC_printf2("Object: 0x%lx, Link:0x%lx\n", real_ptr
, real_link
);
506 GC_printf0("Finalizers:\n");
507 for (i
= 0; i
< fo_size
; i
++) {
508 for (curr_fo
= fo_head
[i
]; curr_fo
!= 0; curr_fo
= fo_next(curr_fo
)) {
509 real_ptr
= (ptr_t
)REVEAL_POINTER(curr_fo
-> fo_hidden_base
);
510 GC_printf1("Finalizable object: 0x%lx\n", real_ptr
);
516 /* Called with world stopped. Cause disappearing links to disappear, */
517 /* and invoke finalizers. */
520 struct disappearing_link
* curr_dl
, * prev_dl
, * next_dl
;
521 struct finalizable_object
* curr_fo
, * prev_fo
, * next_fo
;
522 ptr_t real_ptr
, real_link
;
524 int dl_size
= (log_dl_table_size
== -1 ) ? 0 : (1 << log_dl_table_size
);
525 int fo_size
= (log_fo_table_size
== -1 ) ? 0 : (1 << log_fo_table_size
);
527 /* Make disappearing links disappear */
528 for (i
= 0; i
< dl_size
; i
++) {
529 curr_dl
= dl_head
[i
];
531 while (curr_dl
!= 0) {
532 real_ptr
= (ptr_t
)REVEAL_POINTER(curr_dl
-> dl_hidden_obj
);
533 real_link
= (ptr_t
)REVEAL_POINTER(curr_dl
-> dl_hidden_link
);
534 if (!GC_is_marked(real_ptr
)) {
535 *(word
*)real_link
= 0;
536 next_dl
= dl_next(curr_dl
);
538 dl_head
[i
] = next_dl
;
540 dl_set_next(prev_dl
, next_dl
);
542 GC_clear_mark_bit((ptr_t
)curr_dl
);
547 curr_dl
= dl_next(curr_dl
);
551 /* Mark all objects reachable via chains of 1 or more pointers */
552 /* from finalizable objects. */
553 GC_ASSERT(GC_mark_state
== MS_NONE
);
554 for (i
= 0; i
< fo_size
; i
++) {
555 for (curr_fo
= fo_head
[i
]; curr_fo
!= 0; curr_fo
= fo_next(curr_fo
)) {
556 real_ptr
= (ptr_t
)REVEAL_POINTER(curr_fo
-> fo_hidden_base
);
557 if (!GC_is_marked(real_ptr
)) {
558 GC_MARKED_FOR_FINALIZATION(real_ptr
);
559 GC_MARK_FO(real_ptr
, curr_fo
-> fo_mark_proc
);
560 if (GC_is_marked(real_ptr
)) {
561 WARN("Finalization cycle involving %lx\n", real_ptr
);
566 /* Enqueue for finalization all objects that are still */
568 GC_words_finalized
= 0;
569 for (i
= 0; i
< fo_size
; i
++) {
570 curr_fo
= fo_head
[i
];
572 while (curr_fo
!= 0) {
573 real_ptr
= (ptr_t
)REVEAL_POINTER(curr_fo
-> fo_hidden_base
);
574 if (!GC_is_marked(real_ptr
)) {
575 if (!GC_java_finalization
) {
576 GC_set_mark_bit(real_ptr
);
578 /* Delete from hash table */
579 next_fo
= fo_next(curr_fo
);
581 fo_head
[i
] = next_fo
;
583 fo_set_next(prev_fo
, next_fo
);
586 /* Add to list of objects awaiting finalization. */
587 fo_set_next(curr_fo
, GC_finalize_now
);
588 GC_finalize_now
= curr_fo
;
589 /* unhide object pointer so any future collections will */
591 curr_fo
-> fo_hidden_base
=
592 (word
) REVEAL_POINTER(curr_fo
-> fo_hidden_base
);
593 GC_words_finalized
+=
594 ALIGNED_WORDS(curr_fo
-> fo_object_size
)
595 + ALIGNED_WORDS(sizeof(struct finalizable_object
));
596 GC_ASSERT(GC_is_marked((ptr_t
)curr_fo
));
600 curr_fo
= fo_next(curr_fo
);
605 if (GC_java_finalization
) {
606 /* make sure we mark everything reachable from objects finalized
607 using the no_order mark_proc */
608 for (curr_fo
= GC_finalize_now
;
609 curr_fo
!= NULL
; curr_fo
= fo_next(curr_fo
)) {
610 real_ptr
= (ptr_t
)curr_fo
-> fo_hidden_base
;
611 if (!GC_is_marked(real_ptr
)) {
612 if (curr_fo
-> fo_mark_proc
== GC_null_finalize_mark_proc
) {
613 GC_MARK_FO(real_ptr
, GC_normal_finalize_mark_proc
);
615 GC_set_mark_bit(real_ptr
);
620 /* Remove dangling disappearing links. */
621 for (i
= 0; i
< dl_size
; i
++) {
622 curr_dl
= dl_head
[i
];
624 while (curr_dl
!= 0) {
625 real_link
= GC_base((ptr_t
)REVEAL_POINTER(curr_dl
-> dl_hidden_link
));
626 if (real_link
!= 0 && !GC_is_marked(real_link
)) {
627 next_dl
= dl_next(curr_dl
);
629 dl_head
[i
] = next_dl
;
631 dl_set_next(prev_dl
, next_dl
);
633 GC_clear_mark_bit((ptr_t
)curr_dl
);
638 curr_dl
= dl_next(curr_dl
);
644 #ifndef JAVA_FINALIZATION_NOT_NEEDED
646 /* Enqueue all remaining finalizers to be run - Assumes lock is
647 * held, and signals are disabled */
648 void GC_enqueue_all_finalizers()
650 struct finalizable_object
* curr_fo
, * prev_fo
, * next_fo
;
655 fo_size
= (log_fo_table_size
== -1 ) ? 0 : (1 << log_fo_table_size
);
656 GC_words_finalized
= 0;
657 for (i
= 0; i
< fo_size
; i
++) {
658 curr_fo
= fo_head
[i
];
660 while (curr_fo
!= 0) {
661 real_ptr
= (ptr_t
)REVEAL_POINTER(curr_fo
-> fo_hidden_base
);
662 GC_MARK_FO(real_ptr
, GC_normal_finalize_mark_proc
);
663 GC_set_mark_bit(real_ptr
);
665 /* Delete from hash table */
666 next_fo
= fo_next(curr_fo
);
668 fo_head
[i
] = next_fo
;
670 fo_set_next(prev_fo
, next_fo
);
674 /* Add to list of objects awaiting finalization. */
675 fo_set_next(curr_fo
, GC_finalize_now
);
676 GC_finalize_now
= curr_fo
;
678 /* unhide object pointer so any future collections will */
680 curr_fo
-> fo_hidden_base
=
681 (word
) REVEAL_POINTER(curr_fo
-> fo_hidden_base
);
683 GC_words_finalized
+=
684 ALIGNED_WORDS(curr_fo
-> fo_object_size
)
685 + ALIGNED_WORDS(sizeof(struct finalizable_object
));
693 /* Invoke all remaining finalizers that haven't yet been run.
694 * This is needed for strict compliance with the Java standard,
695 * which can make the runtime guarantee that all finalizers are run.
696 * Unfortunately, the Java standard implies we have to keep running
697 * finalizers until there are no more left, a potential infinite loop.
699 * Note that this is even more dangerous than the usual Java
700 * finalizers, in that objects reachable from static variables
701 * may have been finalized when these finalizers are run.
702 * Finalizers run at this point must be prepared to deal with a
703 * mostly broken world.
704 * This routine is externally callable, so is called without
705 * the allocation lock.
707 GC_API
void GC_finalize_all()
713 while (GC_fo_entries
> 0) {
714 GC_enqueue_all_finalizers();
717 GC_INVOKE_FINALIZERS();
726 /* Returns true if it is worth calling GC_invoke_finalizers. (Useful if */
727 /* finalizers can only be called from some kind of `safe state' and */
728 /* getting into that safe state is expensive.) */
729 int GC_should_invoke_finalizers
GC_PROTO((void))
731 return GC_finalize_now
!= 0;
734 /* Invoke finalizers for all objects that are ready to be finalized. */
735 /* Should be called without allocation lock. */
736 int GC_invoke_finalizers()
738 register struct finalizable_object
* curr_fo
;
739 register int count
= 0;
742 while (GC_finalize_now
!= 0) {
747 curr_fo
= GC_finalize_now
;
749 if (curr_fo
!= 0) GC_finalize_now
= fo_next(curr_fo
);
752 if (curr_fo
== 0) break;
754 GC_finalize_now
= fo_next(curr_fo
);
756 fo_set_next(curr_fo
, 0);
757 (*(curr_fo
-> fo_fn
))((ptr_t
)(curr_fo
-> fo_hidden_base
),
758 curr_fo
-> fo_client_data
);
759 curr_fo
-> fo_client_data
= 0;
762 /* This is probably a bad idea. It throws off accounting if */
763 /* nearly all objects are finalizable. O.w. it shouldn't */
765 GC_free((GC_PTR
)curr_fo
);
771 void (* GC_finalizer_notifier
)() = (void (*) GC_PROTO((void)))0;
773 static GC_word last_finalizer_notification
= 0;
775 void GC_notify_or_invoke_finalizers
GC_PROTO((void))
777 if (GC_finalize_now
== 0) return;
778 if (!GC_finalize_on_demand
) {
779 (void) GC_invoke_finalizers();
780 GC_ASSERT(GC_finalize_now
== 0);
783 if (GC_finalizer_notifier
!= (void (*) GC_PROTO((void)))0
784 && last_finalizer_notification
!= GC_gc_no
) {
785 last_finalizer_notification
= GC_gc_no
;
786 GC_finalizer_notifier();
791 GC_PTR
GC_call_with_alloc_lock(GC_fn_type fn
,
794 GC_PTR
GC_call_with_alloc_lock(fn
, client_data
)
807 result
= (*fn
)(client_data
);
809 # ifndef GC_ASSERTIONS
811 # endif /* o.w. UNLOCK() does it implicitly */