2 * boehm-gc.c: GC implementation using either the installed or included Boehm GC.
4 * Copyright 2001-2003 Ximian, Inc (http://www.ximian.com)
5 * Copyright 2004-2009 Novell, Inc (http://www.novell.com)
9 #define GC_I_HIDE_POINTERS
10 #include <mono/metadata/gc-internal.h>
11 #include <mono/metadata/mono-gc.h>
12 #include <mono/metadata/gc-internal.h>
13 #include <mono/metadata/profiler-private.h>
14 #include <mono/metadata/class-internals.h>
15 #include <mono/metadata/method-builder.h>
16 #include <mono/metadata/opcodes.h>
17 #include <mono/utils/mono-logger.h>
18 #include <mono/utils/mono-time.h>
19 #include <mono/utils/dtrace.h>
23 #ifdef USE_INCLUDED_LIBGC
26 #define THREAD_LOCAL_ALLOC 1
27 #include "private/pthread_support.h"
30 #define GC_NO_DESCRIPTOR ((gpointer)(0 | GC_DS_LENGTH))
32 static gboolean gc_initialized
= FALSE
;
35 mono_gc_warning (char *msg
, GC_word arg
)
37 mono_trace (G_LOG_LEVEL_WARNING
, MONO_TRACE_GC
, msg
, (unsigned long)arg
);
41 mono_gc_base_init (void)
47 * Handle the case when we are called from a thread different from the main thread,
49 * FIXME: Move this to libgc where it belongs.
51 * we used to do this only when running on valgrind,
52 * but it happens also in other setups.
54 #if defined(HAVE_PTHREAD_GETATTR_NP) && defined(HAVE_PTHREAD_ATTR_GETSTACK)
59 pthread_getattr_np (pthread_self (), &attr
);
60 pthread_attr_getstack (&attr
, &sstart
, &size
);
61 pthread_attr_destroy (&attr
);
62 /*g_print ("stackbottom pth is: %p\n", (char*)sstart + size);*/
65 * The calculation above doesn't seem to work on ia64, also we need to set
66 * GC_register_stackbottom as well, but don't know how.
69 /* apparently with some linuxthreads implementations sstart can be NULL,
70 * fallback to the more imprecise method (bug# 78096).
73 GC_stackbottom
= (char*)sstart
+ size
;
76 gsize stack_bottom
= (gsize
)&dummy
;
78 stack_bottom
&= ~4095;
79 GC_stackbottom
= (char*)stack_bottom
;
83 #elif defined(HAVE_PTHREAD_GET_STACKSIZE_NP) && defined(HAVE_PTHREAD_GET_STACKADDR_NP)
84 GC_stackbottom
= (char*)pthread_get_stackaddr_np (pthread_self ());
88 gsize stack_bottom
= (gsize
)&dummy
;
90 stack_bottom
&= ~4095;
91 /*g_print ("stackbottom is: %p\n", (char*)stack_bottom);*/
92 GC_stackbottom
= (char*)stack_bottom
;
98 GC_oom_fn
= mono_gc_out_of_memory
;
99 GC_set_warn_proc (mono_gc_warning
);
100 GC_finalize_on_demand
= 1;
101 GC_finalizer_notifier
= mono_gc_finalize_notify
;
103 #ifdef HAVE_GC_GCJ_MALLOC
104 GC_init_gcj_malloc (5, NULL
);
106 mono_gc_enable_events ();
107 gc_initialized
= TRUE
;
111 mono_gc_collect (int generation
)
113 MONO_PROBE_GC_BEGIN (generation
);
115 mono_perfcounters
->gc_induced
++;
118 MONO_PROBE_GC_END (generation
);
119 #if defined(ENABLE_DTRACE) && defined(__sun__)
120 /* This works around a dtrace -G problem on Solaris.
121 Limit its actual use to when the probe is enabled. */
122 if (MONO_PROBE_GC_END_ENABLED ())
128 mono_gc_max_generation (void)
134 mono_gc_get_generation (MonoObject
*object
)
140 mono_gc_collection_count (int generation
)
146 mono_gc_add_memory_pressure (gint64 value
)
151 mono_gc_get_used_size (void)
153 return GC_get_heap_size () - GC_get_free_bytes ();
157 mono_gc_get_heap_size (void)
159 return GC_get_heap_size ();
163 mono_gc_disable (void)
165 #ifdef HAVE_GC_ENABLE
168 g_assert_not_reached ();
173 mono_gc_enable (void)
175 #ifdef HAVE_GC_ENABLE
178 g_assert_not_reached ();
183 mono_gc_is_gc_thread (void)
185 #if GC_VERSION_MAJOR >= 7
187 #elif defined(USE_INCLUDED_LIBGC)
188 return GC_thread_is_registered ();
194 extern int GC_thread_register_foreign (void *base_addr
);
197 mono_gc_register_thread (void *baseptr
)
199 #if GC_VERSION_MAJOR >= 7
200 struct GC_stack_base sb
;
203 res
= GC_get_stack_base (&sb
);
204 if (res
!= GC_SUCCESS
) {
205 sb
.mem_base
= baseptr
;
207 /* Can't determine the register stack bounds */
208 g_error ("mono_gc_register_thread failed ().\n");
211 res
= GC_register_my_thread (&sb
);
212 if ((res
!= GC_SUCCESS
) && (res
!= GC_DUPLICATE
)) {
213 g_warning ("GC_register_my_thread () failed.\n");
218 if (mono_gc_is_gc_thread())
220 #if defined(USE_INCLUDED_LIBGC) && !defined(PLATFORM_WIN32)
221 return GC_thread_register_foreign (baseptr
);
229 mono_object_is_alive (MonoObject
* o
)
231 #ifdef USE_INCLUDED_LIBGC
232 return GC_is_marked ((gpointer
)o
);
238 #ifdef USE_INCLUDED_LIBGC
240 static gint64 gc_start_time
;
243 on_gc_notification (GCEventType event
)
245 if (event
== MONO_GC_EVENT_START
) {
246 mono_perfcounters
->gc_collections0
++;
247 mono_stats
.major_gc_count
++;
248 gc_start_time
= mono_100ns_ticks ();
249 } else if (event
== MONO_GC_EVENT_END
) {
250 guint64 heap_size
= GC_get_heap_size ();
251 guint64 used_size
= heap_size
- GC_get_free_bytes ();
252 mono_perfcounters
->gc_total_bytes
= used_size
;
253 mono_perfcounters
->gc_committed_bytes
= heap_size
;
254 mono_perfcounters
->gc_reserved_bytes
= heap_size
;
255 mono_perfcounters
->gc_gen0size
= heap_size
;
256 mono_stats
.major_gc_time_usecs
+= (mono_100ns_ticks () - gc_start_time
) / 10;
258 mono_profiler_gc_event ((MonoGCEvent
) event
, 0);
262 on_gc_heap_resize (size_t new_size
)
264 guint64 heap_size
= GC_get_heap_size ();
265 mono_perfcounters
->gc_committed_bytes
= heap_size
;
266 mono_perfcounters
->gc_reserved_bytes
= heap_size
;
267 mono_perfcounters
->gc_gen0size
= heap_size
;
268 mono_profiler_gc_heap_resize (new_size
);
272 mono_gc_enable_events (void)
274 GC_notify_event
= on_gc_notification
;
275 GC_on_heap_resize
= on_gc_heap_resize
;
281 mono_gc_enable_events (void)
288 mono_gc_register_root (char *start
, size_t size
, void *descr
)
290 /* for some strange reason, they want one extra byte on the end */
291 GC_add_roots (start
, start
+ size
+ 1);
297 mono_gc_deregister_root (char* addr
)
299 #ifndef PLATFORM_WIN32
300 /* FIXME: libgc doesn't define this work win32 for some reason */
301 /* FIXME: No size info */
302 GC_remove_roots (addr
, addr
+ sizeof (gpointer
) + 1);
307 mono_gc_weak_link_add (void **link_addr
, MonoObject
*obj
)
309 /* libgc requires that we use HIDE_POINTER... */
310 *link_addr
= (void*)HIDE_POINTER (obj
);
311 GC_GENERAL_REGISTER_DISAPPEARING_LINK (link_addr
, obj
);
315 mono_gc_weak_link_remove (void **link_addr
)
317 GC_unregister_disappearing_link (link_addr
);
322 mono_gc_weak_link_get (void **link_addr
)
324 MonoObject
*obj
= REVEAL_POINTER (*link_addr
);
325 if (obj
== (MonoObject
*) -1)
331 mono_gc_make_descr_for_string (gsize
*bitmap
, int numbits
)
333 return mono_gc_make_descr_from_bitmap (bitmap
, numbits
);
337 mono_gc_make_descr_for_object (gsize
*bitmap
, int numbits
, size_t obj_size
)
339 return mono_gc_make_descr_from_bitmap (bitmap
, numbits
);
343 mono_gc_make_descr_for_array (int vector
, gsize
*elem_bitmap
, int numbits
, size_t elem_size
)
345 /* libgc has no usable support for arrays... */
346 return GC_NO_DESCRIPTOR
;
350 mono_gc_make_descr_from_bitmap (gsize
*bitmap
, int numbits
)
352 #ifdef HAVE_GC_GCJ_MALLOC
353 /* It seems there are issues when the bitmap doesn't fit: play it safe */
355 return GC_NO_DESCRIPTOR
;
357 return (gpointer
)GC_make_descriptor ((GC_bitmap
)bitmap
, numbits
);
364 mono_gc_alloc_fixed (size_t size
, void *descr
)
366 return GC_MALLOC (size
);
370 mono_gc_free_fixed (void* addr
)
375 mono_gc_invoke_finalizers (void)
377 /* There is a bug in GC_invoke_finalizer () in versions <= 6.2alpha4:
378 * the 'mem_freed' variable is not initialized when there are no
379 * objects to finalize, which leads to strange behavior later on.
380 * The check is necessary to work around that bug.
382 if (GC_should_invoke_finalizers ())
383 return GC_invoke_finalizers ();
388 mono_gc_pending_finalizers (void)
390 return GC_should_invoke_finalizers ();
394 mono_gc_wbarrier_set_field (MonoObject
*obj
, gpointer field_ptr
, MonoObject
* value
)
396 *(void**)field_ptr
= value
;
400 mono_gc_wbarrier_set_arrayref (MonoArray
*arr
, gpointer slot_ptr
, MonoObject
* value
)
402 *(void**)slot_ptr
= value
;
406 mono_gc_wbarrier_arrayref_copy (MonoArray
*arr
, gpointer slot_ptr
, int count
)
408 /* no need to do anything */
412 mono_gc_wbarrier_generic_store (gpointer ptr
, MonoObject
* value
)
414 *(void**)ptr
= value
;
418 mono_gc_wbarrier_value_copy (gpointer dest
, gpointer src
, int count
, MonoClass
*klass
)
423 mono_gc_wbarrier_object (MonoObject
*object
)
427 #if defined(USE_INCLUDED_LIBGC) && defined(USE_COMPILER_TLS) && defined(__linux__) && (defined(__i386__) || defined(__x86_64__))
428 extern __thread MONO_TLS_FAST
void* GC_thread_tls
;
429 #include "metadata-internals.h"
435 while (!(v
& (1 << i
)))
442 ATYPE_FREEPTR_FOR_BOX
,
450 create_allocator (int atype
, int offset
)
452 int index_var
, bytes_var
, my_fl_var
, my_entry_var
;
453 guint32 no_freelist_branch
, not_small_enough_branch
= 0;
454 guint32 size_overflow_branch
= 0;
455 MonoMethodBuilder
*mb
;
457 MonoMethodSignature
*csig
;
459 if (atype
== ATYPE_STRING
) {
460 csig
= mono_metadata_signature_alloc (mono_defaults
.corlib
, 2);
461 csig
->ret
= &mono_defaults
.string_class
->byval_arg
;
462 csig
->params
[0] = &mono_defaults
.int_class
->byval_arg
;
463 csig
->params
[1] = &mono_defaults
.int32_class
->byval_arg
;
465 csig
= mono_metadata_signature_alloc (mono_defaults
.corlib
, 1);
466 csig
->ret
= &mono_defaults
.object_class
->byval_arg
;
467 csig
->params
[0] = &mono_defaults
.int_class
->byval_arg
;
470 mb
= mono_mb_new (mono_defaults
.object_class
, "Alloc", MONO_WRAPPER_ALLOC
);
471 bytes_var
= mono_mb_add_local (mb
, &mono_defaults
.int32_class
->byval_arg
);
472 if (atype
== ATYPE_STRING
) {
473 /* a string alloator method takes the args: (vtable, len) */
474 /* bytes = (sizeof (MonoString) + ((len + 1) * 2)); */
475 mono_mb_emit_ldarg (mb
, 1);
476 mono_mb_emit_icon (mb
, 1);
477 mono_mb_emit_byte (mb
, MONO_CEE_ADD
);
478 mono_mb_emit_icon (mb
, 1);
479 mono_mb_emit_byte (mb
, MONO_CEE_SHL
);
480 // sizeof (MonoString) might include padding
481 mono_mb_emit_icon (mb
, G_STRUCT_OFFSET (MonoString
, chars
));
482 mono_mb_emit_byte (mb
, MONO_CEE_ADD
);
483 mono_mb_emit_stloc (mb
, bytes_var
);
485 /* bytes = vtable->klass->instance_size */
486 mono_mb_emit_ldarg (mb
, 0);
487 mono_mb_emit_icon (mb
, G_STRUCT_OFFSET (MonoVTable
, klass
));
488 mono_mb_emit_byte (mb
, MONO_CEE_ADD
);
489 mono_mb_emit_byte (mb
, MONO_CEE_LDIND_I
);
490 mono_mb_emit_icon (mb
, G_STRUCT_OFFSET (MonoClass
, instance_size
));
491 mono_mb_emit_byte (mb
, MONO_CEE_ADD
);
492 /* FIXME: assert instance_size stays a 4 byte integer */
493 mono_mb_emit_byte (mb
, MONO_CEE_LDIND_U4
);
494 mono_mb_emit_stloc (mb
, bytes_var
);
497 /* this is needed for strings/arrays only as the other big types are never allocated with this method */
498 if (atype
== ATYPE_STRING
) {
500 /* if (!SMALL_ENOUGH (bytes)) jump slow_path;*/
501 mono_mb_emit_ldloc (mb
, bytes_var
);
502 mono_mb_emit_icon (mb
, (NFREELISTS
-1) * GRANULARITY
);
503 not_small_enough_branch
= mono_mb_emit_short_branch (mb
, MONO_CEE_BGT_UN_S
);
504 /* check for overflow */
505 mono_mb_emit_ldloc (mb
, bytes_var
);
506 mono_mb_emit_icon (mb
, sizeof (MonoString
));
507 size_overflow_branch
= mono_mb_emit_short_branch (mb
, MONO_CEE_BLE_UN_S
);
510 /* int index = INDEX_FROM_BYTES(bytes); */
511 index_var
= mono_mb_add_local (mb
, &mono_defaults
.int32_class
->byval_arg
);
513 mono_mb_emit_ldloc (mb
, bytes_var
);
514 mono_mb_emit_icon (mb
, GRANULARITY
- 1);
515 mono_mb_emit_byte (mb
, MONO_CEE_ADD
);
516 mono_mb_emit_icon (mb
, shift_amount (GRANULARITY
));
517 mono_mb_emit_byte (mb
, MONO_CEE_SHR_UN
);
518 mono_mb_emit_icon (mb
, shift_amount (sizeof (gpointer
)));
519 mono_mb_emit_byte (mb
, MONO_CEE_SHL
);
520 /* index var is already adjusted into bytes */
521 mono_mb_emit_stloc (mb
, index_var
);
523 my_fl_var
= mono_mb_add_local (mb
, &mono_defaults
.int_class
->byval_arg
);
524 my_entry_var
= mono_mb_add_local (mb
, &mono_defaults
.int_class
->byval_arg
);
525 /* my_fl = ((GC_thread)tsd) -> ptrfree_freelists + index; */
526 mono_mb_emit_byte (mb
, MONO_CUSTOM_PREFIX
);
527 mono_mb_emit_byte (mb
, 0x0D); /* CEE_MONO_TLS */
528 mono_mb_emit_i4 (mb
, offset
);
529 if (atype
== ATYPE_FREEPTR
|| atype
== ATYPE_FREEPTR_FOR_BOX
|| atype
== ATYPE_STRING
)
530 mono_mb_emit_icon (mb
, G_STRUCT_OFFSET (struct GC_Thread_Rep
, ptrfree_freelists
));
531 else if (atype
== ATYPE_NORMAL
)
532 mono_mb_emit_icon (mb
, G_STRUCT_OFFSET (struct GC_Thread_Rep
, normal_freelists
));
533 else if (atype
== ATYPE_GCJ
)
534 mono_mb_emit_icon (mb
, G_STRUCT_OFFSET (struct GC_Thread_Rep
, gcj_freelists
));
536 g_assert_not_reached ();
537 mono_mb_emit_byte (mb
, MONO_CEE_ADD
);
538 mono_mb_emit_ldloc (mb
, index_var
);
539 mono_mb_emit_byte (mb
, MONO_CEE_ADD
);
540 mono_mb_emit_stloc (mb
, my_fl_var
);
542 /* my_entry = *my_fl; */
543 mono_mb_emit_ldloc (mb
, my_fl_var
);
544 mono_mb_emit_byte (mb
, MONO_CEE_LDIND_I
);
545 mono_mb_emit_stloc (mb
, my_entry_var
);
547 /* if (EXPECT((word)my_entry >= HBLKSIZE, 1)) { */
548 mono_mb_emit_ldloc (mb
, my_entry_var
);
549 mono_mb_emit_icon (mb
, HBLKSIZE
);
550 no_freelist_branch
= mono_mb_emit_short_branch (mb
, MONO_CEE_BLT_UN_S
);
552 /* ptr_t next = obj_link(my_entry); *my_fl = next; */
553 mono_mb_emit_ldloc (mb
, my_fl_var
);
554 mono_mb_emit_ldloc (mb
, my_entry_var
);
555 mono_mb_emit_byte (mb
, MONO_CEE_LDIND_I
);
556 mono_mb_emit_byte (mb
, MONO_CEE_STIND_I
);
558 /* set the vtable and clear the words in the object */
559 mono_mb_emit_ldloc (mb
, my_entry_var
);
560 mono_mb_emit_ldarg (mb
, 0);
561 mono_mb_emit_byte (mb
, MONO_CEE_STIND_I
);
563 if (atype
== ATYPE_FREEPTR
) {
564 int start_var
, end_var
, start_loop
;
565 /* end = my_entry + bytes; start = my_entry + sizeof (gpointer);
567 start_var
= mono_mb_add_local (mb
, &mono_defaults
.int_class
->byval_arg
);
568 end_var
= mono_mb_add_local (mb
, &mono_defaults
.int_class
->byval_arg
);
569 mono_mb_emit_ldloc (mb
, my_entry_var
);
570 mono_mb_emit_ldloc (mb
, bytes_var
);
571 mono_mb_emit_byte (mb
, MONO_CEE_ADD
);
572 mono_mb_emit_stloc (mb
, end_var
);
573 mono_mb_emit_ldloc (mb
, my_entry_var
);
574 mono_mb_emit_icon (mb
, G_STRUCT_OFFSET (MonoObject
, synchronisation
));
575 mono_mb_emit_byte (mb
, MONO_CEE_ADD
);
576 mono_mb_emit_stloc (mb
, start_var
);
580 * } while (start < end);
582 start_loop
= mono_mb_get_label (mb
);
583 mono_mb_emit_ldloc (mb
, start_var
);
584 mono_mb_emit_icon (mb
, 0);
585 mono_mb_emit_byte (mb
, MONO_CEE_STIND_I
);
586 mono_mb_emit_ldloc (mb
, start_var
);
587 mono_mb_emit_icon (mb
, sizeof (gpointer
));
588 mono_mb_emit_byte (mb
, MONO_CEE_ADD
);
589 mono_mb_emit_stloc (mb
, start_var
);
591 mono_mb_emit_ldloc (mb
, start_var
);
592 mono_mb_emit_ldloc (mb
, end_var
);
593 mono_mb_emit_byte (mb
, MONO_CEE_BLT_UN_S
);
594 mono_mb_emit_byte (mb
, start_loop
- (mono_mb_get_label (mb
) + 1));
595 } else if (atype
== ATYPE_FREEPTR_FOR_BOX
|| atype
== ATYPE_STRING
) {
596 /* need to clear just the sync pointer */
597 mono_mb_emit_ldloc (mb
, my_entry_var
);
598 mono_mb_emit_icon (mb
, G_STRUCT_OFFSET (MonoObject
, synchronisation
));
599 mono_mb_emit_byte (mb
, MONO_CEE_ADD
);
600 mono_mb_emit_icon (mb
, 0);
601 mono_mb_emit_byte (mb
, MONO_CEE_STIND_I
);
604 if (atype
== ATYPE_STRING
) {
605 /* need to set length and clear the last char */
606 /* s->length = len; */
607 mono_mb_emit_ldloc (mb
, my_entry_var
);
608 mono_mb_emit_icon (mb
, G_STRUCT_OFFSET (MonoString
, length
));
609 mono_mb_emit_byte (mb
, MONO_CEE_ADD
);
610 mono_mb_emit_ldarg (mb
, 1);
611 mono_mb_emit_byte (mb
, MONO_CEE_STIND_I4
);
612 /* s->chars [len] = 0; */
613 mono_mb_emit_ldloc (mb
, my_entry_var
);
614 mono_mb_emit_ldloc (mb
, bytes_var
);
615 mono_mb_emit_icon (mb
, 2);
616 mono_mb_emit_byte (mb
, MONO_CEE_SUB
);
617 mono_mb_emit_byte (mb
, MONO_CEE_ADD
);
618 mono_mb_emit_icon (mb
, 0);
619 mono_mb_emit_byte (mb
, MONO_CEE_STIND_I2
);
622 /* return my_entry; */
623 mono_mb_emit_ldloc (mb
, my_entry_var
);
624 mono_mb_emit_byte (mb
, MONO_CEE_RET
);
626 mono_mb_patch_short_branch (mb
, no_freelist_branch
);
627 if (not_small_enough_branch
> 0)
628 mono_mb_patch_short_branch (mb
, not_small_enough_branch
);
629 if (size_overflow_branch
> 0)
630 mono_mb_patch_short_branch (mb
, size_overflow_branch
);
631 /* the slow path: we just call back into the runtime */
632 if (atype
== ATYPE_STRING
) {
633 mono_mb_emit_ldarg (mb
, 1);
634 mono_mb_emit_icall (mb
, mono_string_alloc
);
636 mono_mb_emit_ldarg (mb
, 0);
637 mono_mb_emit_icall (mb
, mono_object_new_specific
);
640 mono_mb_emit_byte (mb
, MONO_CEE_RET
);
642 res
= mono_mb_create_method (mb
, csig
, 8);
644 mono_method_get_header (res
)->init_locals
= FALSE
;
648 static MonoMethod
* alloc_method_cache
[ATYPE_NUM
];
651 * If possible, generate a managed method that can quickly allocate objects in class
652 * @klass. The method will typically have an thread-local inline allocation sequence.
653 * The signature of the called method is:
654 * object allocate (MonoVTable *vtable)
655 * Some of the logic here is similar to mono_class_get_allocation_ftn () i object.c,
657 * The thread local alloc logic is taken from libgc/pthread_support.c.
661 mono_gc_get_managed_allocator (MonoVTable
*vtable
, gboolean for_box
)
665 MonoClass
*klass
= vtable
->klass
;
666 MONO_THREAD_VAR_OFFSET (GC_thread_tls
, offset
);
668 /*g_print ("thread tls: %d\n", offset);*/
671 if (!SMALL_ENOUGH (klass
->instance_size
))
673 if (klass
->has_finalize
|| klass
->marshalbyref
|| (mono_profiler_get_events () & MONO_PROFILE_ALLOCATIONS
))
677 if (klass
->byval_arg
.type
== MONO_TYPE_STRING
) {
678 atype
= ATYPE_STRING
;
679 } else if (!klass
->has_references
) {
681 atype
= ATYPE_FREEPTR_FOR_BOX
;
683 atype
= ATYPE_FREEPTR
;
687 * disabled because we currently do a runtime choice anyway, to
688 * deal with multiple appdomains.
689 if (vtable->gc_descr != GC_NO_DESCRIPTOR)
692 atype = ATYPE_NORMAL;
695 return mono_gc_get_managed_allocator_by_type (atype
);
699 * mono_gc_get_managed_allocator_id:
701 * Return a type for the managed allocator method MANAGED_ALLOC which can later be passed
702 * to mono_gc_get_managed_allocator_by_type () to get back this allocator method. This can be
703 * used by the AOT code to encode references to managed allocator methods.
706 mono_gc_get_managed_allocator_type (MonoMethod
*managed_alloc
)
711 for (i
= 0; i
< ATYPE_NUM
; ++i
) {
712 if (alloc_method_cache
[i
] == managed_alloc
) {
713 mono_loader_unlock ();
717 mono_loader_unlock ();
723 * mono_gc_get_managed_allocator_by_type:
725 * Return a managed allocator method corresponding to allocator type ATYPE.
728 mono_gc_get_managed_allocator_by_type (int atype
)
732 MONO_THREAD_VAR_OFFSET (GC_thread_tls
, offset
);
735 res
= alloc_method_cache
[atype
];
737 res
= alloc_method_cache
[atype
] = create_allocator (atype
, offset
);
738 mono_loader_unlock ();
743 mono_gc_get_managed_allocator_types (void)
751 mono_gc_get_managed_allocator (MonoVTable
*vtable
, gboolean for_box
)
757 mono_gc_get_managed_allocator_type (MonoMethod
*managed_alloc
)
763 mono_gc_get_managed_allocator_by_type (int atype
)
769 mono_gc_get_managed_allocator_types (void)
776 #endif /* no Boehm GC */