3 * Simple always promote nursery.
5 * Copyright 2001-2003 Ximian, Inc
6 * Copyright 2003-2010 Novell, Inc.
7 * Copyright 2011 Xamarin Inc (http://www.xamarin.com)
8 * Copyright (C) 2012 Xamarin Inc
10 * Licensed under the MIT license. See LICENSE file in the project root for full license information.
18 #include "mono/sgen/sgen-gc.h"
19 #include "mono/sgen/sgen-protocol.h"
20 #include "mono/sgen/sgen-layout-stats.h"
21 #include "mono/sgen/sgen-client.h"
22 #include "mono/utils/mono-memory-model.h"
24 static inline GCObject*
25 alloc_for_promotion (GCVTable vtable, GCObject *obj, size_t objsize, gboolean has_references)
27 total_promoted_size += objsize;
28 return major_collector.alloc_object (vtable, objsize, has_references);
31 static inline GCObject*
32 alloc_for_promotion_par (GCVTable vtable, GCObject *obj, size_t objsize, gboolean has_references)
36 * Note that the stat is not precise. total_promoted_size incrementing is not atomic and
37 * even in that case, the same object might be promoted simultaneously by different workers
38 * leading to one of the allocated major object to be discarded.
40 total_promoted_size += objsize;
41 return major_collector.alloc_object_par (vtable, objsize, has_references);
45 build_fragments_get_exclude_head (void)
51 build_fragments_release_exclude_head (void)
56 build_fragments_finish (SgenFragmentAllocator *allocator)
61 prepare_to_space (char *to_space_bitmap, size_t space_bitmap_size)
66 clear_fragments (void)
71 init_nursery (SgenFragmentAllocator *allocator, char *start, char *end)
73 char *nursery_limit = sgen_nursery_start + sgen_nursery_size;
75 if (start < nursery_limit && end > nursery_limit) {
76 sgen_fragment_allocator_add (allocator, start, nursery_limit);
77 sgen_fragment_allocator_add (allocator, nursery_limit, end);
79 sgen_fragment_allocator_add (allocator, start, end);
84 /******************************************Copy/Scan functins ************************************************/
86 #define collector_pin_object(obj, queue) sgen_pin_object (obj, queue);
87 #define COLLECTOR_SERIAL_ALLOC_FOR_PROMOTION alloc_for_promotion
88 #define COLLECTOR_PARALLEL_ALLOC_FOR_PROMOTION alloc_for_promotion_par
90 #define COPY_OR_MARK_PARALLEL
91 #include "sgen-copy-object.h"
93 #define SGEN_SIMPLE_NURSERY
95 #include "sgen-minor-copy-object.h"
96 #include "sgen-minor-scan-object.h"
99 fill_serial_ops (SgenObjectOperations *ops)
101 ops->copy_or_mark_object = SERIAL_COPY_OBJECT;
102 FILL_MINOR_COLLECTOR_SCAN_OBJECT (ops);
105 #define SGEN_SIMPLE_PAR_NURSERY
107 #include "sgen-minor-copy-object.h"
108 #include "sgen-minor-scan-object.h"
111 fill_parallel_ops (SgenObjectOperations *ops)
113 ops->copy_or_mark_object = SERIAL_COPY_OBJECT;
114 FILL_MINOR_COLLECTOR_SCAN_OBJECT (ops);
117 #undef SGEN_SIMPLE_PAR_NURSERY
118 #define SGEN_CONCURRENT_MAJOR
120 #include "sgen-minor-copy-object.h"
121 #include "sgen-minor-scan-object.h"
124 fill_serial_with_concurrent_major_ops (SgenObjectOperations *ops)
126 ops->copy_or_mark_object = SERIAL_COPY_OBJECT;
127 FILL_MINOR_COLLECTOR_SCAN_OBJECT (ops);
131 sgen_simple_nursery_init (SgenMinorCollector *collector, gboolean parallel)
133 collector->is_split = FALSE;
134 collector->is_parallel = parallel;
136 collector->alloc_for_promotion = alloc_for_promotion;
137 collector->alloc_for_promotion_par = alloc_for_promotion_par;
139 collector->prepare_to_space = prepare_to_space;
140 collector->clear_fragments = clear_fragments;
141 collector->build_fragments_get_exclude_head = build_fragments_get_exclude_head;
142 collector->build_fragments_release_exclude_head = build_fragments_release_exclude_head;
143 collector->build_fragments_finish = build_fragments_finish;
144 collector->init_nursery = init_nursery;
146 fill_serial_ops (&collector->serial_ops);
147 fill_serial_with_concurrent_major_ops (&collector->serial_ops_with_concurrent_major);
148 fill_parallel_ops (&collector->parallel_ops);