2 * sgen-marksweep.c: Simple generational GC.
5 * Mark Probst <mark.probst@gmail.com>
7 * Copyright 2009-2010 Novell, Inc.
9 * Permission is hereby granted, free of charge, to any person obtaining
10 * a copy of this software and associated documentation files (the
11 * "Software"), to deal in the Software without restriction, including
12 * without limitation the rights to use, copy, modify, merge, publish,
13 * distribute, sublicense, and/or sell copies of the Software, and to
14 * permit persons to whom the Software is furnished to do so, subject to
15 * the following conditions:
17 * The above copyright notice and this permission notice shall be
18 * included in all copies or substantial portions of the Software.
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 #include "utils/mono-counters.h"
34 #include "metadata/object-internals.h"
35 #include "metadata/profiler-private.h"
37 #include "metadata/sgen-gc.h"
38 #include "metadata/sgen-protocol.h"
39 #include "metadata/sgen-cardtable.h"
44 #define MS_BLOCK_SIZE (16*1024)
45 #define MS_BLOCK_SIZE_SHIFT 14
46 #define MAJOR_SECTION_SIZE MS_BLOCK_SIZE
47 #define CARDS_PER_BLOCK (MS_BLOCK_SIZE / CARD_SIZE_IN_BYTES)
50 #define MS_DEFAULT_HEAP_NUM_BLOCKS (32 * 1024) /* 512 MB */
54 * Don't allocate single blocks, but alloc a contingent of this many
55 * blocks in one swoop.
57 #define MS_BLOCK_ALLOC_NUM 32
60 * Number of bytes before the first object in a block. At the start
61 * of a block is the MSBlockHeader, then opional padding, then come
62 * the objects, so this must be >= sizeof (MSBlockHeader).
65 #define MS_BLOCK_SKIP 0
67 #define MS_BLOCK_SKIP 16
70 #define MS_BLOCK_FREE (MS_BLOCK_SIZE - MS_BLOCK_SKIP)
72 #define MS_NUM_MARK_WORDS ((MS_BLOCK_SIZE / SGEN_ALLOC_ALIGN + sizeof (mword) * 8 - 1) / (sizeof (mword) * 8))
74 #if SGEN_MAX_SMALL_OBJ_SIZE > MS_BLOCK_FREE / 2
75 #error MAX_SMALL_OBJ_SIZE must be at most MS_BLOCK_FREE / 2
78 typedef struct _MSBlockInfo MSBlockInfo;
83 gboolean has_references;
84 #ifndef SGEN_PARALLEL_MARK
85 gboolean has_pinned; /* means cannot evacuate */
95 MSBlockInfo *next_free;
96 void **pin_queue_start;
97 int pin_queue_num_entries;
98 mword mark_words [MS_NUM_MARK_WORDS];
102 static int ms_heap_num_blocks = MS_DEFAULT_HEAP_NUM_BLOCKS;
104 #define ms_heap_start nursery_end
105 static char *ms_heap_end;
107 #define MS_PTR_IN_SMALL_MAJOR_HEAP(p) ((char*)(p) >= ms_heap_start && (char*)(p) < ms_heap_end)
109 /* array of all all block infos in the system */
110 static MSBlockInfo *block_infos;
113 #define MS_BLOCK_OBJ(b,i) ((b)->block + MS_BLOCK_SKIP + (b)->obj_size * (i))
114 #define MS_BLOCK_DATA_FOR_OBJ(o) ((char*)((mword)(o) & ~(mword)(MS_BLOCK_SIZE - 1)))
117 #define MS_BLOCK_FOR_OBJ(o) (&block_infos [(mword)((char*)(o) - ms_heap_start) >> MS_BLOCK_SIZE_SHIFT])
123 #define MS_BLOCK_FOR_OBJ(o) (((MSBlockHeader*)MS_BLOCK_DATA_FOR_OBJ ((o)))->info)
126 #define MS_BLOCK_OBJ_INDEX(o,b) (((char*)(o) - ((b)->block + MS_BLOCK_SKIP)) / (b)->obj_size)
128 #define MS_CALC_MARK_BIT(w,b,o) do { \
129 int i = ((char*)(o) - MS_BLOCK_DATA_FOR_OBJ ((o))) >> SGEN_ALLOC_ALIGN_BITS; \
130 if (sizeof (mword) == 4) { \
139 #define MS_MARK_BIT(bl,w,b) ((bl)->mark_words [(w)] & (1L << (b)))
140 #define MS_SET_MARK_BIT(bl,w,b) ((bl)->mark_words [(w)] |= (1L << (b)))
141 #define MS_PAR_SET_MARK_BIT(was_marked,bl,w,b) do { \
142 mword __old = (bl)->mark_words [(w)]; \
143 mword __bitmask = 1L << (b); \
144 if (__old & __bitmask) { \
148 if (SGEN_CAS_PTR ((gpointer*)&(bl)->mark_words [(w)], \
149 (gpointer)(__old | __bitmask), \
150 (gpointer)__old) == \
152 was_marked = FALSE; \
157 #define MS_OBJ_ALLOCED(o,b) (*(void**)(o) && (*(char**)(o) < (b)->block || *(char**)(o) >= (b)->block + MS_BLOCK_SIZE))
159 #define MS_BLOCK_OBJ_SIZE_FACTOR (sqrt (2.0))
162 * This way we can lookup block object size indexes for sizes up to
163 * 256 bytes with a single load.
165 #define MS_NUM_FAST_BLOCK_OBJ_SIZE_INDEXES 32
167 static int *block_obj_sizes;
168 static int num_block_obj_sizes;
169 static int fast_block_obj_size_indexes [MS_NUM_FAST_BLOCK_OBJ_SIZE_INDEXES];
171 #define MS_BLOCK_FLAG_PINNED 1
172 #define MS_BLOCK_FLAG_REFS 2
174 #define MS_BLOCK_TYPE_MAX 4
176 #ifdef SGEN_PARALLEL_MARK
177 static LOCK_DECLARE (ms_block_list_mutex);
178 #define LOCK_MS_BLOCK_LIST pthread_mutex_lock (&ms_block_list_mutex)
179 #define UNLOCK_MS_BLOCK_LIST pthread_mutex_unlock (&ms_block_list_mutex)
181 #define LOCK_MS_BLOCK_LIST
182 #define UNLOCK_MS_BLOCK_LIST
185 /* we get this at init */
186 static int nursery_bits;
187 static char *nursery_start;
188 static char *nursery_end;
190 #ifndef SGEN_PARALLEL_MARK
191 static gboolean *evacuate_block_obj_sizes;
192 static float evacuation_threshold = 0.666;
195 #define ptr_in_nursery(p) (SGEN_PTR_IN_NURSERY ((p), nursery_bits, nursery_start, nursery_end))
198 /* non-allocated block free-list */
199 static MSBlockInfo *empty_blocks = NULL;
201 /* non-allocated block free-list */
202 static void *empty_blocks = NULL;
203 /* all allocated blocks in the system */
204 static MSBlockInfo *all_blocks;
205 static int num_empty_blocks = 0;
209 #define FOREACH_BLOCK(bl) { \
211 for (__block_i = 0; __block_i < ms_heap_num_blocks; ++__block_i) { \
212 (bl) = &block_infos [__block_i]; \
213 if (!(bl)->used) continue;
214 #define END_FOREACH_BLOCK }}
216 #define FOREACH_BLOCK(bl) for ((bl) = all_blocks; (bl); (bl) = (bl)->next) {
217 #define END_FOREACH_BLOCK }
220 static int num_major_sections = 0;
221 /* one free block list for each block object size */
222 static MSBlockInfo **free_block_lists [MS_BLOCK_TYPE_MAX];
224 static long long stat_major_blocks_alloced = 0;
225 static long long stat_major_blocks_freed = 0;
226 static long long stat_major_objects_evacuated = 0;
229 ms_find_block_obj_size_index (int size)
232 DEBUG (9, g_assert (size <= SGEN_MAX_SMALL_OBJ_SIZE));
233 for (i = 0; i < num_block_obj_sizes; ++i)
234 if (block_obj_sizes [i] >= size)
236 g_assert_not_reached ();
239 #define FREE_BLOCKS(p,r) (free_block_lists [((p) ? MS_BLOCK_FLAG_PINNED : 0) | ((r) ? MS_BLOCK_FLAG_REFS : 0)])
241 #define MS_BLOCK_OBJ_SIZE_INDEX(s) \
242 (((s)+7)>>3 < MS_NUM_FAST_BLOCK_OBJ_SIZE_INDEXES ? \
243 fast_block_obj_size_indexes [((s)+7)>>3] : \
244 ms_find_block_obj_size_index ((s)))
248 major_alloc_heap (mword nursery_size, mword nursery_align, int the_nursery_bits)
251 mword major_heap_size = ms_heap_num_blocks * MS_BLOCK_SIZE;
252 mword alloc_size = nursery_size + major_heap_size;
255 g_assert (ms_heap_num_blocks > 0);
256 g_assert (nursery_size % MS_BLOCK_SIZE == 0);
258 g_assert (nursery_align % MS_BLOCK_SIZE == 0);
260 nursery_start = mono_sgen_alloc_os_memory_aligned (alloc_size, nursery_align ? nursery_align : MS_BLOCK_SIZE, TRUE);
261 nursery_end = heap_start = nursery_start + nursery_size;
262 nursery_bits = the_nursery_bits;
264 ms_heap_end = heap_start + major_heap_size;
266 block_infos = mono_sgen_alloc_internal_dynamic (sizeof (MSBlockInfo) * ms_heap_num_blocks, INTERNAL_MEM_MS_BLOCK_INFO);
268 for (i = 0; i < ms_heap_num_blocks; ++i) {
269 block_infos [i].block = heap_start + i * MS_BLOCK_SIZE;
270 if (i < ms_heap_num_blocks - 1)
271 block_infos [i].next_free = &block_infos [i + 1];
273 block_infos [i].next_free = NULL;
276 empty_blocks = &block_infos [0];
278 return nursery_start;
282 major_alloc_heap (mword nursery_size, mword nursery_align, int the_nursery_bits)
285 nursery_start = mono_sgen_alloc_os_memory_aligned (nursery_size, nursery_align, TRUE);
287 nursery_start = mono_sgen_alloc_os_memory (nursery_size, TRUE);
289 nursery_end = nursery_start + nursery_size;
290 nursery_bits = the_nursery_bits;
292 return nursery_start;
298 ms_get_empty_block (void)
302 g_assert (empty_blocks);
304 block = empty_blocks;
305 empty_blocks = empty_blocks->next_free;
309 mono_sgen_update_heap_boundaries ((mword)block->block, (mword)block->block + MS_BLOCK_SIZE);
315 ms_free_block (MSBlockInfo *block)
317 block->next_free = empty_blocks;
318 empty_blocks = block;
323 ms_get_empty_block (void)
327 void *block, *empty, *next;
331 p = mono_sgen_alloc_os_memory_aligned (MS_BLOCK_SIZE * MS_BLOCK_ALLOC_NUM, MS_BLOCK_SIZE, TRUE);
333 for (i = 0; i < MS_BLOCK_ALLOC_NUM; ++i) {
336 * We do the free list update one after the
337 * other so that other threads can use the new
338 * blocks as quickly as possible.
341 empty = empty_blocks;
342 *(void**)block = empty;
343 } while (SGEN_CAS_PTR (&empty_blocks, block, empty) != empty);
347 SGEN_ATOMIC_ADD (num_empty_blocks, MS_BLOCK_ALLOC_NUM);
349 stat_major_blocks_alloced += MS_BLOCK_ALLOC_NUM;
353 empty = empty_blocks;
357 next = *(void**)block;
358 } while (SGEN_CAS_PTR (&empty_blocks, next, empty) != empty);
360 SGEN_ATOMIC_ADD (num_empty_blocks, -1);
362 *(void**)block = NULL;
364 g_assert (!((mword)block & (MS_BLOCK_SIZE - 1)));
366 mono_sgen_update_heap_boundaries ((mword)block, (mword)block + MS_BLOCK_SIZE);
372 ms_free_block (void *block)
376 memset (block, 0, MS_BLOCK_SIZE);
379 empty = empty_blocks;
380 *(void**)block = empty;
381 } while (SGEN_CAS_PTR (&empty_blocks, block, empty) != empty);
383 SGEN_ATOMIC_ADD (num_empty_blocks, 1);
387 //#define MARKSWEEP_CONSISTENCY_CHECK
389 #ifdef MARKSWEEP_CONSISTENCY_CHECK
391 check_block_free_list (MSBlockInfo *block, int size, gboolean pinned)
395 for (; block; block = block->next_free) {
396 g_assert (block->obj_size == size);
397 g_assert ((pinned && block->pinned) || (!pinned && !block->pinned));
399 /* blocks in the free lists must have at least
401 g_assert (block->free_list);
404 /* the block must not be in the empty_blocks list */
405 for (b = empty_blocks; b; b = b->next_free)
406 g_assert (b != block);
408 /* the block must be in the all_blocks list */
409 for (b = all_blocks; b; b = b->next) {
413 g_assert (b == block);
419 check_empty_blocks (void)
424 for (p = empty_blocks; p; p = *(void**)p)
426 g_assert (i == num_empty_blocks);
431 consistency_check (void)
436 /* check all blocks */
437 FOREACH_BLOCK (block) {
438 int count = MS_BLOCK_FREE / block->obj_size;
443 /* check block header */
444 g_assert (((MSBlockHeader*)block->block)->info == block);
447 /* count number of free slots */
448 for (i = 0; i < count; ++i) {
449 void **obj = (void**) MS_BLOCK_OBJ (block, i);
450 if (!MS_OBJ_ALLOCED (obj, block))
454 /* check free list */
455 for (free = block->free_list; free; free = (void**)*free) {
456 g_assert (MS_BLOCK_FOR_OBJ (free) == block);
459 g_assert (num_free == 0);
461 /* check all mark words are zero */
462 for (i = 0; i < MS_NUM_MARK_WORDS; ++i)
463 g_assert (block->mark_words [i] == 0);
466 /* check free blocks */
467 for (i = 0; i < num_block_obj_sizes; ++i) {
469 for (j = 0; j < MS_BLOCK_TYPE_MAX; ++j)
470 check_block_free_list (free_block_lists [j][i], block_obj_sizes [i], j & MS_BLOCK_FLAG_PINNED);
473 check_empty_blocks ();
478 ms_alloc_block (int size_index, gboolean pinned, gboolean has_references)
480 int size = block_obj_sizes [size_index];
481 int count = MS_BLOCK_FREE / size;
483 MSBlockInfo *info = ms_get_empty_block ();
485 MSBlockInfo *info = mono_sgen_alloc_internal (INTERNAL_MEM_MS_BLOCK_INFO);
486 MSBlockHeader *header;
488 MSBlockInfo **free_blocks = FREE_BLOCKS (pinned, has_references);
492 DEBUG (9, g_assert (count >= 2));
494 info->obj_size = size;
495 info->obj_size_index = size_index;
496 info->pinned = pinned;
497 info->has_references = has_references;
498 #ifndef SGEN_PARALLEL_MARK
499 info->has_pinned = pinned;
500 info->is_to_space = (mono_sgen_get_current_collection_generation () == GENERATION_OLD);
503 info->block = ms_get_empty_block ();
505 header = (MSBlockHeader*) info->block;
509 /* build free list */
510 obj_start = info->block + MS_BLOCK_SKIP;
511 info->free_list = (void**)obj_start;
512 /* we're skipping the last one - it must be nulled */
513 for (i = 0; i < count - 1; ++i) {
514 char *next_obj_start = obj_start + size;
515 *(void**)obj_start = next_obj_start;
516 obj_start = next_obj_start;
519 *(void**)obj_start = NULL;
521 info->next_free = free_blocks [size_index];
522 free_blocks [size_index] = info;
525 info->next = all_blocks;
529 ++num_major_sections;
533 obj_is_from_pinned_alloc (char *obj)
535 MSBlockInfo *block = MS_BLOCK_FOR_OBJ (obj);
536 return block->pinned;
540 alloc_obj (int size, gboolean pinned, gboolean has_references)
542 int size_index = MS_BLOCK_OBJ_SIZE_INDEX (size);
543 MSBlockInfo **free_blocks = FREE_BLOCKS (pinned, has_references);
547 /* FIXME: try to do this without locking */
551 if (!free_blocks [size_index])
552 ms_alloc_block (size_index, pinned, has_references);
554 block = free_blocks [size_index];
555 DEBUG (9, g_assert (block));
557 obj = block->free_list;
558 DEBUG (9, g_assert (obj));
560 block->free_list = *(void**)obj;
561 if (!block->free_list) {
562 free_blocks [size_index] = block->next_free;
563 block->next_free = NULL;
566 UNLOCK_MS_BLOCK_LIST;
569 * FIXME: This should not be necessary because it'll be
570 * overwritten by the vtable immediately.
578 major_alloc_object (int size, gboolean has_references)
580 return alloc_obj (size, FALSE, has_references);
584 * We're not freeing the block if it's empty. We leave that work for
585 * the next major collection.
587 * This is just called from the domain clearing code, which runs in a
588 * single thread and has the GC lock, so we don't need an extra lock.
591 free_object (char *obj, size_t size, gboolean pinned)
593 MSBlockInfo *block = MS_BLOCK_FOR_OBJ (obj);
595 DEBUG (9, g_assert ((pinned && block->pinned) || (!pinned && !block->pinned)));
596 DEBUG (9, g_assert (MS_OBJ_ALLOCED (obj, block)));
597 MS_CALC_MARK_BIT (word, bit, obj);
598 DEBUG (9, g_assert (!MS_MARK_BIT (block, word, bit)));
599 if (!block->free_list) {
600 MSBlockInfo **free_blocks = FREE_BLOCKS (pinned, block->has_references);
601 int size_index = MS_BLOCK_OBJ_SIZE_INDEX (size);
602 DEBUG (9, g_assert (!block->next_free));
603 block->next_free = free_blocks [size_index];
604 free_blocks [size_index] = block;
606 memset (obj, 0, size);
607 *(void**)obj = block->free_list;
608 block->free_list = (void**)obj;
612 major_free_non_pinned_object (char *obj, size_t size)
614 free_object (obj, size, FALSE);
617 /* size is a multiple of SGEN_ALLOC_ALIGN */
619 major_alloc_small_pinned_obj (size_t size, gboolean has_references)
621 return alloc_obj (size, TRUE, has_references);
625 free_pinned_object (char *obj, size_t size)
627 free_object (obj, size, TRUE);
631 * size is already rounded up and we hold the GC lock.
634 major_alloc_degraded (MonoVTable *vtable, size_t size)
637 int old_num_sections = num_major_sections;
638 obj = alloc_obj (size, FALSE, vtable->klass->has_references);
639 *(MonoVTable**)obj = vtable;
640 HEAVY_STAT (++stat_objects_alloced_degraded);
641 HEAVY_STAT (stat_bytes_alloced_degraded += size);
642 g_assert (num_major_sections >= old_num_sections);
643 mono_sgen_register_major_sections_alloced (num_major_sections - old_num_sections);
647 #define MAJOR_OBJ_IS_IN_TO_SPACE(obj) FALSE
650 * obj is some object. If it's not in the major heap (i.e. if it's in
651 * the nursery or LOS), return FALSE. Otherwise return whether it's
652 * been marked or copied.
655 major_is_object_live (char *obj)
663 if (ptr_in_nursery (obj))
668 if (!MS_PTR_IN_SMALL_MAJOR_HEAP (obj))
671 objsize = SGEN_ALIGN_UP (mono_sgen_safe_object_get_size ((MonoObject*)obj));
674 if (objsize > SGEN_MAX_SMALL_OBJ_SIZE)
678 /* now we know it's in a major block */
679 block = MS_BLOCK_FOR_OBJ (obj);
680 DEBUG (9, g_assert (!block->pinned));
681 MS_CALC_MARK_BIT (word, bit, obj);
682 return MS_MARK_BIT (block, word, bit) ? TRUE : FALSE;
686 major_ptr_is_in_non_pinned_space (char *ptr)
688 g_assert_not_reached ();
692 major_iterate_objects (gboolean non_pinned, gboolean pinned, IterateObjectCallbackFunc callback, void *data)
696 FOREACH_BLOCK (block) {
697 int count = MS_BLOCK_FREE / block->obj_size;
700 if (block->pinned && !pinned)
702 if (!block->pinned && !non_pinned)
705 for (i = 0; i < count; ++i) {
706 void **obj = (void**) MS_BLOCK_OBJ (block, i);
707 if (MS_OBJ_ALLOCED (obj, block))
708 callback ((char*)obj, block->obj_size, data);
714 major_check_scan_starts (void)
719 major_dump_heap (FILE *heap_dump_file)
722 int *slots_available = alloca (sizeof (int) * num_block_obj_sizes);
723 int *slots_used = alloca (sizeof (int) * num_block_obj_sizes);
726 for (i = 0; i < num_block_obj_sizes; ++i)
727 slots_available [i] = slots_used [i] = 0;
729 FOREACH_BLOCK (block) {
730 int index = ms_find_block_obj_size_index (block->obj_size);
731 int count = MS_BLOCK_FREE / block->obj_size;
733 slots_available [index] += count;
734 for (i = 0; i < count; ++i) {
735 if (MS_OBJ_ALLOCED (MS_BLOCK_OBJ (block, i), block))
736 ++slots_used [index];
740 fprintf (heap_dump_file, "<occupancies>\n");
741 for (i = 0; i < num_block_obj_sizes; ++i) {
742 fprintf (heap_dump_file, "<occupancy size=\"%d\" available=\"%d\" used=\"%d\" />\n",
743 block_obj_sizes [i], slots_available [i], slots_used [i]);
745 fprintf (heap_dump_file, "</occupancies>\n");
747 FOREACH_BLOCK (block) {
748 int count = MS_BLOCK_FREE / block->obj_size;
752 fprintf (heap_dump_file, "<section type=\"%s\" size=\"%zu\">\n", "old", (size_t)MS_BLOCK_FREE);
754 for (i = 0; i <= count; ++i) {
755 if ((i < count) && MS_OBJ_ALLOCED (MS_BLOCK_OBJ (block, i), block)) {
760 mono_sgen_dump_occupied (MS_BLOCK_OBJ (block, start), MS_BLOCK_OBJ (block, i), block->block);
766 fprintf (heap_dump_file, "</section>\n");
770 #define LOAD_VTABLE SGEN_LOAD_VTABLE
772 #define MS_MARK_OBJECT_AND_ENQUEUE_CHECKED(obj,block,queue) do { \
774 MS_CALC_MARK_BIT (__word, __bit, (obj)); \
775 if (!MS_MARK_BIT ((block), __word, __bit) && MS_OBJ_ALLOCED ((obj), (block))) { \
776 MS_SET_MARK_BIT ((block), __word, __bit); \
777 if ((block)->has_references) \
778 GRAY_OBJECT_ENQUEUE ((queue), (obj)); \
779 binary_protocol_mark ((obj), (gpointer)LOAD_VTABLE ((obj)), mono_sgen_safe_object_get_size ((MonoObject*)(obj))); \
782 #define MS_MARK_OBJECT_AND_ENQUEUE(obj,block,queue) do { \
784 MS_CALC_MARK_BIT (__word, __bit, (obj)); \
785 DEBUG (9, g_assert (MS_OBJ_ALLOCED ((obj), (block)))); \
786 if (!MS_MARK_BIT ((block), __word, __bit)) { \
787 MS_SET_MARK_BIT ((block), __word, __bit); \
788 if ((block)->has_references) \
789 GRAY_OBJECT_ENQUEUE ((queue), (obj)); \
790 binary_protocol_mark ((obj), (gpointer)LOAD_VTABLE ((obj)), mono_sgen_safe_object_get_size ((MonoObject*)(obj))); \
793 #define MS_PAR_MARK_OBJECT_AND_ENQUEUE(obj,block,queue) do { \
795 gboolean __was_marked; \
796 DEBUG (9, g_assert (MS_OBJ_ALLOCED ((obj), (block)))); \
797 MS_CALC_MARK_BIT (__word, __bit, (obj)); \
798 MS_PAR_SET_MARK_BIT (__was_marked, (block), __word, __bit); \
799 if (!__was_marked) { \
800 if ((block)->has_references) \
801 GRAY_OBJECT_ENQUEUE ((queue), (obj)); \
802 binary_protocol_mark ((obj), (gpointer)LOAD_VTABLE ((obj)), mono_sgen_safe_object_get_size ((MonoObject*)(obj))); \
806 #include "sgen-major-copy-object.h"
808 #ifdef SGEN_PARALLEL_MARK
810 major_copy_or_mark_object (void **ptr, SgenGrayQueue *queue)
813 mword vtable_word = *(mword*)obj;
814 MonoVTable *vt = (MonoVTable*)(vtable_word & ~SGEN_VTABLE_BITS_MASK);
818 HEAVY_STAT (++stat_copy_object_called_major);
820 DEBUG (9, g_assert (obj));
821 DEBUG (9, g_assert (current_collection_generation == GENERATION_OLD));
823 if (ptr_in_nursery (obj)) {
825 gboolean has_references;
828 if (vtable_word & SGEN_FORWARDED_BIT) {
833 if (vtable_word & SGEN_PINNED_BIT)
836 HEAVY_STAT (++stat_objects_copied_major);
838 objsize = SGEN_ALIGN_UP (mono_sgen_par_object_get_size (vt, (MonoObject*)obj));
839 has_references = SGEN_VTABLE_HAS_REFERENCES (vt);
841 destination = major_alloc_object (objsize, has_references);
843 if (SGEN_CAS_PTR (obj, (void*)((mword)destination | SGEN_FORWARDED_BIT), vt) == vt) {
846 par_copy_object_no_checks (destination, vt, obj, objsize, has_references ? queue : NULL);
851 * FIXME: If we make major_alloc_object() give
852 * us the block info, too, we won't have to
855 block = MS_BLOCK_FOR_OBJ (obj);
856 MS_CALC_MARK_BIT (word, bit, obj);
857 DEBUG (9, g_assert (!MS_MARK_BIT (block, word, bit)));
858 MS_PAR_SET_MARK_BIT (was_marked, block, word, bit);
861 * FIXME: We have allocated destination, but
862 * we cannot use it. Give it back to the
865 *(void**)destination = NULL;
867 vtable_word = *(mword*)obj;
868 g_assert (vtable_word & SGEN_FORWARDED_BIT);
870 obj = (void*)(vtable_word & ~SGEN_VTABLE_BITS_MASK);
876 if (MS_PTR_IN_SMALL_MAJOR_HEAP (obj))
878 objsize = SGEN_ALIGN_UP (mono_sgen_par_object_get_size (vt, (MonoObject*)obj));
880 if (objsize <= SGEN_MAX_SMALL_OBJ_SIZE)
883 block = MS_BLOCK_FOR_OBJ (obj);
884 MS_PAR_MARK_OBJECT_AND_ENQUEUE (obj, block, queue);
886 if (vtable_word & SGEN_PINNED_BIT)
888 binary_protocol_pin (obj, vt, mono_sgen_safe_object_get_size ((MonoObject*)obj));
889 if (SGEN_CAS_PTR (obj, (void*)(vtable_word | SGEN_PINNED_BIT), (void*)vtable_word) == (void*)vtable_word) {
890 if (SGEN_VTABLE_HAS_REFERENCES (vt))
891 GRAY_OBJECT_ENQUEUE (queue, obj);
893 g_assert (SGEN_OBJECT_IS_PINNED (obj));
900 major_copy_or_mark_object (void **ptr, SgenGrayQueue *queue)
905 HEAVY_STAT (++stat_copy_object_called_major);
907 DEBUG (9, g_assert (obj));
908 DEBUG (9, g_assert (current_collection_generation == GENERATION_OLD));
910 if (ptr_in_nursery (obj)) {
914 if ((forwarded = SGEN_OBJECT_IS_FORWARDED (obj))) {
918 if (SGEN_OBJECT_IS_PINNED (obj))
921 HEAVY_STAT (++stat_objects_copied_major);
924 obj = copy_object_no_checks (obj, queue);
928 * FIXME: See comment for copy_object_no_checks(). If
929 * we have that, we can let the allocation function
930 * give us the block info, too, and we won't have to
933 block = MS_BLOCK_FOR_OBJ (obj);
934 MS_CALC_MARK_BIT (word, bit, obj);
935 DEBUG (9, g_assert (!MS_MARK_BIT (block, word, bit)));
936 MS_SET_MARK_BIT (block, word, bit);
939 if ((forwarded = SGEN_OBJECT_IS_FORWARDED (obj))) {
945 if (MS_PTR_IN_SMALL_MAJOR_HEAP (obj))
949 objsize = SGEN_ALIGN_UP (mono_sgen_safe_object_get_size ((MonoObject*)obj));
951 if (objsize <= SGEN_MAX_SMALL_OBJ_SIZE)
956 block = MS_BLOCK_FOR_OBJ (obj);
957 size_index = block->obj_size_index;
959 if (!block->has_pinned && evacuate_block_obj_sizes [size_index]) {
960 if (block->is_to_space)
962 HEAVY_STAT (++stat_major_objects_evacuated);
965 MS_MARK_OBJECT_AND_ENQUEUE (obj, block, queue);
968 if (SGEN_OBJECT_IS_PINNED (obj))
970 binary_protocol_pin (obj, (gpointer)SGEN_LOAD_VTABLE (obj), mono_sgen_safe_object_get_size ((MonoObject*)obj));
971 SGEN_PIN_OBJECT (obj);
972 /* FIXME: only enqueue if object has references */
973 GRAY_OBJECT_ENQUEUE (queue, obj);
979 #include "sgen-major-scan-object.h"
982 mark_pinned_objects_in_block (MSBlockInfo *block, SgenGrayQueue *queue)
987 if (!block->pin_queue_num_entries)
990 #ifndef SGEN_PARALLEL_MARK
991 block->has_pinned = TRUE;
994 for (i = 0; i < block->pin_queue_num_entries; ++i) {
995 int index = MS_BLOCK_OBJ_INDEX (block->pin_queue_start [i], block);
996 DEBUG (9, g_assert (index >= 0 && index < MS_BLOCK_FREE / block->obj_size));
997 if (index == last_index)
999 MS_MARK_OBJECT_AND_ENQUEUE_CHECKED (MS_BLOCK_OBJ (block, index), block, queue);
1013 #ifndef SGEN_PARALLEL_MARK
1014 /* statistics for evacuation */
1015 int *slots_available = alloca (sizeof (int) * num_block_obj_sizes);
1016 int *slots_used = alloca (sizeof (int) * num_block_obj_sizes);
1017 int *num_blocks = alloca (sizeof (int) * num_block_obj_sizes);
1019 for (i = 0; i < num_block_obj_sizes; ++i)
1020 slots_available [i] = slots_used [i] = num_blocks [i] = 0;
1023 /* clear all the free lists */
1024 for (i = 0; i < MS_BLOCK_TYPE_MAX; ++i) {
1025 MSBlockInfo **free_blocks = free_block_lists [i];
1027 for (j = 0; j < num_block_obj_sizes; ++j)
1028 free_blocks [j] = NULL;
1031 /* traverse all blocks, free and zero unmarked objects */
1033 for (j = 0; j < ms_heap_num_blocks; ++j) {
1034 MSBlockInfo *block = &block_infos [j];
1038 MSBlockInfo *block = *iter;
1041 gboolean have_live = FALSE;
1042 gboolean has_pinned;
1051 obj_size_index = block->obj_size_index;
1053 #ifndef SGEN_PARALLEL_MARK
1054 has_pinned = block->has_pinned;
1055 block->has_pinned = block->pinned;
1057 block->is_to_space = FALSE;
1060 count = MS_BLOCK_FREE / block->obj_size;
1061 block->free_list = NULL;
1063 for (obj_index = 0; obj_index < count; ++obj_index) {
1065 void *obj = MS_BLOCK_OBJ (block, obj_index);
1067 MS_CALC_MARK_BIT (word, bit, obj);
1068 if (MS_MARK_BIT (block, word, bit)) {
1069 DEBUG (9, g_assert (MS_OBJ_ALLOCED (obj, block)));
1071 #ifndef SGEN_PARALLEL_MARK
1073 ++slots_used [obj_size_index];
1076 /* an unmarked object */
1077 if (MS_OBJ_ALLOCED (obj, block)) {
1078 binary_protocol_empty (obj, block->obj_size);
1079 memset (obj, 0, block->obj_size);
1081 *(void**)obj = block->free_list;
1082 block->free_list = obj;
1086 /* reset mark bits */
1087 memset (block->mark_words, 0, sizeof (mword) * MS_NUM_MARK_WORDS);
1090 * FIXME: reverse free list so that it's in address
1095 #ifndef SGEN_PARALLEL_MARK
1097 ++num_blocks [obj_size_index];
1098 slots_available [obj_size_index] += count;
1103 iter = &block->next;
1107 * If there are free slots in the block, add
1108 * the block to the corresponding free list.
1110 if (block->free_list) {
1111 MSBlockInfo **free_blocks = FREE_BLOCKS (block->pinned, block->has_references);
1112 int index = MS_BLOCK_OBJ_SIZE_INDEX (block->obj_size);
1113 block->next_free = free_blocks [index];
1114 free_blocks [index] = block;
1118 * Blocks without live objects are removed from the
1119 * block list and freed.
1122 ms_free_block (block);
1124 *iter = block->next;
1126 ms_free_block (block->block);
1127 mono_sgen_free_internal (block, INTERNAL_MEM_MS_BLOCK_INFO);
1130 --num_major_sections;
1134 #ifndef SGEN_PARALLEL_MARK
1135 for (i = 0; i < num_block_obj_sizes; ++i) {
1136 float usage = (float)slots_used [i] / (float)slots_available [i];
1137 if (num_blocks [i] > 5 && usage < evacuation_threshold) {
1138 evacuate_block_obj_sizes [i] = TRUE;
1140 g_print ("slot size %d - %d of %d used\n",
1141 block_obj_sizes [i], slots_used [i], slots_available [i]);
1144 evacuate_block_obj_sizes [i] = FALSE;
1150 static int count_pinned_ref;
1151 static int count_pinned_nonref;
1152 static int count_nonpinned_ref;
1153 static int count_nonpinned_nonref;
1156 count_nonpinned_callback (char *obj, size_t size, void *data)
1158 MonoVTable *vtable = (MonoVTable*)LOAD_VTABLE (obj);
1160 if (vtable->klass->has_references)
1161 ++count_nonpinned_ref;
1163 ++count_nonpinned_nonref;
1167 count_pinned_callback (char *obj, size_t size, void *data)
1169 MonoVTable *vtable = (MonoVTable*)LOAD_VTABLE (obj);
1171 if (vtable->klass->has_references)
1174 ++count_pinned_nonref;
1177 static void __attribute__ ((unused))
1178 count_ref_nonref_objs (void)
1182 count_pinned_ref = 0;
1183 count_pinned_nonref = 0;
1184 count_nonpinned_ref = 0;
1185 count_nonpinned_nonref = 0;
1187 major_iterate_objects (TRUE, FALSE, count_nonpinned_callback, NULL);
1188 major_iterate_objects (FALSE, TRUE, count_pinned_callback, NULL);
1190 total = count_pinned_nonref + count_nonpinned_nonref + count_pinned_ref + count_nonpinned_ref;
1192 g_print ("ref: %d pinned %d non-pinned non-ref: %d pinned %d non-pinned -- %.1f\n",
1193 count_pinned_ref, count_nonpinned_ref,
1194 count_pinned_nonref, count_nonpinned_nonref,
1195 (count_pinned_nonref + count_nonpinned_nonref) * 100.0 / total);
1199 ms_calculate_block_obj_sizes (double factor, int *arr)
1201 double target_size = sizeof (MonoObject);
1206 int target_count = ceil (MS_BLOCK_FREE / target_size);
1207 int size = MIN ((MS_BLOCK_FREE / target_count) & ~(SGEN_ALLOC_ALIGN - 1), SGEN_MAX_SMALL_OBJ_SIZE);
1209 if (size != last_size) {
1211 arr [num_sizes] = size;
1216 target_size *= factor;
1217 } while (last_size < SGEN_MAX_SMALL_OBJ_SIZE);
1222 /* only valid during minor collections */
1223 static int old_num_major_sections;
1226 major_start_nursery_collection (void)
1228 #ifdef MARKSWEEP_CONSISTENCY_CHECK
1229 consistency_check ();
1232 old_num_major_sections = num_major_sections;
1236 major_finish_nursery_collection (void)
1238 #ifdef MARKSWEEP_CONSISTENCY_CHECK
1239 consistency_check ();
1241 mono_sgen_register_major_sections_alloced (num_major_sections - old_num_major_sections);
1245 major_start_major_collection (void)
1247 #ifndef SGEN_PARALLEL_MARK
1250 /* clear the free lists */
1251 for (i = 0; i < num_block_obj_sizes; ++i) {
1252 if (!evacuate_block_obj_sizes [i])
1255 free_block_lists [0][i] = NULL;
1256 free_block_lists [MS_BLOCK_FLAG_REFS][i] = NULL;
1262 major_finish_major_collection (void)
1265 int section_reserve = mono_sgen_get_minor_collection_allowance () / MS_BLOCK_SIZE;
1268 * FIXME: We don't free blocks on 32 bit platforms because it
1269 * can lead to address space fragmentation, since we're
1270 * allocating blocks in larger contingents.
1272 if (sizeof (mword) < 8)
1275 while (num_empty_blocks > section_reserve) {
1276 void *next = *(void**)empty_blocks;
1277 mono_sgen_free_os_memory (empty_blocks, MS_BLOCK_SIZE);
1278 empty_blocks = next;
1280 * Needs not be atomic because this is running
1285 ++stat_major_blocks_freed;
1291 major_find_pin_queue_start_ends (SgenGrayQueue *queue)
1295 FOREACH_BLOCK (block) {
1296 block->pin_queue_start = mono_sgen_find_optimized_pin_queue_area (block->block + MS_BLOCK_SKIP, block->block + MS_BLOCK_SIZE,
1297 &block->pin_queue_num_entries);
1298 } END_FOREACH_BLOCK;
1302 major_pin_objects (SgenGrayQueue *queue)
1306 FOREACH_BLOCK (block) {
1307 mark_pinned_objects_in_block (block, queue);
1308 } END_FOREACH_BLOCK;
1312 major_init_to_space (void)
1317 major_report_pinned_memory_usage (void)
1319 g_assert_not_reached ();
1323 major_get_used_size (void)
1328 FOREACH_BLOCK (block) {
1329 int count = MS_BLOCK_FREE / block->obj_size;
1331 size += count * block->obj_size;
1332 for (iter = block->free_list; iter; iter = (void**)*iter)
1333 size -= block->obj_size;
1334 } END_FOREACH_BLOCK;
1340 get_num_major_sections (void)
1342 return num_major_sections;
1346 major_handle_gc_param (const char *opt)
1349 if (g_str_has_prefix (opt, "major-heap-size=")) {
1350 const char *arg = strchr (opt, '=') + 1;
1352 if (!mono_sgen_parse_environment_string_extract_number (arg, &size))
1354 ms_heap_num_blocks = (size + MS_BLOCK_SIZE - 1) / MS_BLOCK_SIZE;
1355 g_assert (ms_heap_num_blocks > 0);
1359 #ifndef SGEN_PARALLEL_MARK
1360 if (g_str_has_prefix (opt, "evacuation-threshold=")) {
1361 const char *arg = strchr (opt, '=') + 1;
1362 int percentage = atoi (arg);
1363 if (percentage < 0 || percentage > 100) {
1364 fprintf (stderr, "evacuation-threshold must be an integer in the range 0-100.\n");
1367 evacuation_threshold = (float)percentage / 100.0;
1376 major_print_gc_param_usage (void)
1381 " major-heap-size=N (where N is an integer, possibly with a k, m or a g suffix)\n"
1383 #ifndef SGEN_PARALLEL_MARK
1384 " evacuation-threshold=P (where P is a percentage, an integer in 0-100)\n"
1389 #ifdef SGEN_HAVE_CARDTABLE
1391 major_iterate_live_block_ranges (sgen_cardtable_block_callback callback)
1395 FOREACH_BLOCK (block) {
1396 if (block->has_references)
1397 callback ((mword)block->block, MS_BLOCK_SIZE);
1398 } END_FOREACH_BLOCK;
1401 #define CARD_WORDS_PER_BLOCK (CARDS_PER_BLOCK / SIZEOF_VOID_P)
1403 * MS blocks are 16K aligned.
1404 * Cardtables are 4K aligned, at least.
1405 * This means that the cardtable of a given block is 32 bytes aligned.
1408 initial_skip_card (guint8 *card_data)
1410 mword *cards = (mword*)card_data;
1413 for (i = 0; i < CARD_WORDS_PER_BLOCK; ++i) {
1419 if (i == CARD_WORDS_PER_BLOCK)
1420 return card_data + CARDS_PER_BLOCK;
1422 #if defined(__i386__) && defined(__GNUC__)
1423 return card_data + i * 4 + (__builtin_ffs (card) - 1) / 8;
1424 #elif defined(__x86_64__) && defined(__GNUC__)
1425 return card_data + i * 8 + (__builtin_ffsll (card) - 1) / 8;
1427 for (i = i * SIZEOF_VOID_P; i < CARDS_PER_BLOCK; ++i) {
1429 return &card_data [i];
1436 static G_GNUC_UNUSED guint8*
1437 skip_card (guint8 *card_data, guint8 *card_data_end)
1439 while (card_data < card_data_end && !*card_data)
1444 #define MS_BLOCK_OBJ_INDEX_FAST(o,b,os) (((char*)(o) - ((b) + MS_BLOCK_SKIP)) / (os))
1445 #define MS_BLOCK_OBJ_FAST(b,os,i) ((b) + MS_BLOCK_SKIP + (os) * (i))
1446 #define MS_OBJ_ALLOCED_FAST(o,b) (*(void**)(o) && (*(char**)(o) < (b) || *(char**)(o) >= (b) + MS_BLOCK_SIZE))
1449 major_scan_card_table (SgenGrayQueue *queue)
1453 FOREACH_BLOCK (block) {
1457 if (!block->has_references)
1460 block_obj_size = block->obj_size;
1461 block_start = block->block;
1463 if (block_obj_size >= CARD_SIZE_IN_BYTES) {
1465 #ifndef SGEN_HAVE_OVERLAPPING_CARDS
1466 guint8 cards_data [CARDS_PER_BLOCK];
1468 char *obj, *end, *base;
1470 /*We can avoid the extra copy since the remark cardtable was cleaned before */
1471 #ifdef SGEN_HAVE_OVERLAPPING_CARDS
1472 cards = sgen_card_table_get_card_scan_address ((mword)block_start);
1475 if (!sgen_card_table_get_card_data (cards_data, (mword)block_start, CARDS_PER_BLOCK))
1479 obj = (char*)MS_BLOCK_OBJ_FAST (block_start, block_obj_size, 0);
1480 end = block_start + MS_BLOCK_SIZE;
1481 base = sgen_card_table_align_pointer (obj);
1484 if (MS_OBJ_ALLOCED_FAST (obj, block_start)) {
1485 int card_offset = (obj - base) >> CARD_BITS;
1486 sgen_cardtable_scan_object (obj, block_obj_size, cards + card_offset, queue);
1488 obj += block_obj_size;
1491 guint8 *card_data, *card_base;
1492 guint8 *card_data_end;
1495 * This is safe in face of card aliasing for the following reason:
1497 * Major blocks are 16k aligned, or 32 cards aligned.
1498 * Cards aliasing happens in powers of two, so as long as major blocks are aligned to their
1499 * sizes, they won't overflow the cardtable overlap modulus.
1501 card_data = card_base = sgen_card_table_get_card_scan_address ((mword)block_start);
1502 card_data_end = card_data + CARDS_PER_BLOCK;
1504 for (card_data = initial_skip_card (card_data); card_data < card_data_end; ++card_data) { //card_data = skip_card (card_data + 1, card_data_end)) {
1506 int idx = card_data - card_base;
1507 char *start = (char*)(block_start + idx * CARD_SIZE_IN_BYTES);
1508 char *end = start + CARD_SIZE_IN_BYTES;
1513 sgen_card_table_prepare_card_for_scanning (card_data);
1518 index = MS_BLOCK_OBJ_INDEX_FAST (start, block_start, block_obj_size);
1520 obj = (char*)MS_BLOCK_OBJ_FAST (block_start, block_obj_size, index);
1522 if (MS_OBJ_ALLOCED_FAST (obj, block_start))
1523 minor_scan_object (obj, queue);
1524 obj += block_obj_size;
1528 } END_FOREACH_BLOCK;
1533 #ifdef SGEN_PARALLEL_MARK
1535 mono_sgen_marksweep_fixed_par_init
1537 mono_sgen_marksweep_par_init
1541 mono_sgen_marksweep_fixed_init
1543 mono_sgen_marksweep_init
1546 (SgenMajorCollector *collector)
1551 mono_sgen_register_fixed_internal_mem_type (INTERNAL_MEM_MS_BLOCK_INFO, sizeof (MSBlockInfo));
1554 num_block_obj_sizes = ms_calculate_block_obj_sizes (MS_BLOCK_OBJ_SIZE_FACTOR, NULL);
1555 block_obj_sizes = mono_sgen_alloc_internal_dynamic (sizeof (int) * num_block_obj_sizes, INTERNAL_MEM_MS_TABLES);
1556 ms_calculate_block_obj_sizes (MS_BLOCK_OBJ_SIZE_FACTOR, block_obj_sizes);
1558 #ifndef SGEN_PARALLEL_MARK
1559 evacuate_block_obj_sizes = mono_sgen_alloc_internal_dynamic (sizeof (gboolean) * num_block_obj_sizes, INTERNAL_MEM_MS_TABLES);
1560 for (i = 0; i < num_block_obj_sizes; ++i)
1561 evacuate_block_obj_sizes [i] = FALSE;
1567 g_print ("block object sizes:\n");
1568 for (i = 0; i < num_block_obj_sizes; ++i)
1569 g_print ("%d\n", block_obj_sizes [i]);
1573 for (i = 0; i < MS_BLOCK_TYPE_MAX; ++i)
1574 free_block_lists [i] = mono_sgen_alloc_internal_dynamic (sizeof (MSBlockInfo*) * num_block_obj_sizes, INTERNAL_MEM_MS_TABLES);
1576 for (i = 0; i < MS_NUM_FAST_BLOCK_OBJ_SIZE_INDEXES; ++i)
1577 fast_block_obj_size_indexes [i] = ms_find_block_obj_size_index (i * 8);
1578 for (i = 0; i < MS_NUM_FAST_BLOCK_OBJ_SIZE_INDEXES * 8; ++i)
1579 g_assert (MS_BLOCK_OBJ_SIZE_INDEX (i) == ms_find_block_obj_size_index (i));
1581 LOCK_INIT (ms_block_list_mutex);
1583 mono_counters_register ("# major blocks allocated", MONO_COUNTER_GC | MONO_COUNTER_LONG, &stat_major_blocks_alloced);
1584 mono_counters_register ("# major blocks freed", MONO_COUNTER_GC | MONO_COUNTER_LONG, &stat_major_blocks_freed);
1585 mono_counters_register ("# major objects evacuated", MONO_COUNTER_GC | MONO_COUNTER_LONG, &stat_major_objects_evacuated);
1587 collector->section_size = MAJOR_SECTION_SIZE;
1588 #ifdef SGEN_PARALLEL_MARK
1589 collector->is_parallel = TRUE;
1591 collector->is_parallel = FALSE;
1593 collector->supports_cardtable = TRUE;
1595 collector->alloc_heap = major_alloc_heap;
1596 collector->is_object_live = major_is_object_live;
1597 collector->alloc_small_pinned_obj = major_alloc_small_pinned_obj;
1598 collector->alloc_degraded = major_alloc_degraded;
1599 collector->copy_or_mark_object = major_copy_or_mark_object;
1600 collector->alloc_object = major_alloc_object;
1601 collector->free_pinned_object = free_pinned_object;
1602 collector->iterate_objects = major_iterate_objects;
1603 collector->free_non_pinned_object = major_free_non_pinned_object;
1604 collector->find_pin_queue_start_ends = major_find_pin_queue_start_ends;
1605 collector->pin_objects = major_pin_objects;
1606 #ifdef SGEN_HAVE_CARDTABLE
1607 collector->scan_card_table = major_scan_card_table;
1608 collector->iterate_live_block_ranges = (void*)(void*) major_iterate_live_block_ranges;
1610 collector->init_to_space = major_init_to_space;
1611 collector->sweep = major_sweep;
1612 collector->check_scan_starts = major_check_scan_starts;
1613 collector->dump_heap = major_dump_heap;
1614 collector->get_used_size = major_get_used_size;
1615 collector->start_nursery_collection = major_start_nursery_collection;
1616 collector->finish_nursery_collection = major_finish_nursery_collection;
1617 collector->start_major_collection = major_start_major_collection;
1618 collector->finish_major_collection = major_finish_major_collection;
1619 collector->ptr_is_in_non_pinned_space = major_ptr_is_in_non_pinned_space;
1620 collector->obj_is_from_pinned_alloc = obj_is_from_pinned_alloc;
1621 collector->report_pinned_memory_usage = major_report_pinned_memory_usage;
1622 collector->get_num_major_sections = get_num_major_sections;
1623 collector->handle_gc_param = major_handle_gc_param;
1624 collector->print_gc_param_usage = major_print_gc_param_usage;
1626 FILL_COLLECTOR_COPY_OBJECT (collector);
1627 FILL_COLLECTOR_SCAN_OBJECT (collector);
1630 /*cardtable requires major pages to be 8 cards aligned*/
1631 g_assert ((MS_BLOCK_SIZE % (8 * CARD_SIZE_IN_BYTES)) == 0);