Merge pull request #2903 from krytarowski/netbsd-support-4
[mono.git] / mono / sgen / sgen-simple-nursery.c
1 /*
2  * sgen-simple-nursery.c: Simple always promote nursery.
3  *
4  * Copyright 2001-2003 Ximian, Inc
5  * Copyright 2003-2010 Novell, Inc.
6  * Copyright 2011 Xamarin Inc (http://www.xamarin.com)
7  * Copyright (C) 2012 Xamarin Inc
8  *
9  * Licensed under the MIT license. See LICENSE file in the project root for full license information.
10  */
11
12 #include "config.h"
13 #ifdef HAVE_SGEN_GC
14
15 #include <string.h>
16
17 #include "mono/sgen/sgen-gc.h"
18 #include "mono/sgen/sgen-protocol.h"
19 #include "mono/sgen/sgen-layout-stats.h"
20 #include "mono/sgen/sgen-client.h"
21 #include "mono/utils/mono-memory-model.h"
22
23 static inline GCObject*
24 alloc_for_promotion (GCVTable vtable, GCObject *obj, size_t objsize, gboolean has_references)
25 {
26         total_promoted_size += objsize;
27         return major_collector.alloc_object (vtable, objsize, has_references);
28 }
29
30 static SgenFragment*
31 build_fragments_get_exclude_head (void)
32 {
33         return NULL;
34 }
35
36 static void
37 build_fragments_release_exclude_head (void)
38 {
39 }
40
41 static void
42 build_fragments_finish (SgenFragmentAllocator *allocator)
43 {
44 }
45
46 static void
47 prepare_to_space (char *to_space_bitmap, size_t space_bitmap_size)
48 {
49 }
50
51 static void
52 clear_fragments (void)
53 {       
54 }
55
56 static void
57 init_nursery (SgenFragmentAllocator *allocator, char *start, char *end)
58 {
59         sgen_fragment_allocator_add (allocator, start, end);
60 }
61
62
63 /******************************************Copy/Scan functins ************************************************/
64
65 #define collector_pin_object(obj, queue) sgen_pin_object (obj, queue);
66 #define COLLECTOR_SERIAL_ALLOC_FOR_PROMOTION alloc_for_promotion
67
68 #include "sgen-copy-object.h"
69
70 #define SGEN_SIMPLE_NURSERY
71
72 #include "sgen-minor-copy-object.h"
73 #include "sgen-minor-scan-object.h"
74
75 static void
76 fill_serial_ops (SgenObjectOperations *ops)
77 {
78         ops->copy_or_mark_object = SERIAL_COPY_OBJECT;
79         FILL_MINOR_COLLECTOR_SCAN_OBJECT (ops);
80 }
81
82 #define SGEN_CONCURRENT_MAJOR
83
84 #include "sgen-minor-copy-object.h"
85 #include "sgen-minor-scan-object.h"
86
87 static void
88 fill_serial_with_concurrent_major_ops (SgenObjectOperations *ops)
89 {
90         ops->copy_or_mark_object = SERIAL_COPY_OBJECT;
91         FILL_MINOR_COLLECTOR_SCAN_OBJECT (ops);
92 }
93
94 void
95 sgen_simple_nursery_init (SgenMinorCollector *collector)
96 {
97         collector->is_split = FALSE;
98
99         collector->alloc_for_promotion = alloc_for_promotion;
100
101         collector->prepare_to_space = prepare_to_space;
102         collector->clear_fragments = clear_fragments;
103         collector->build_fragments_get_exclude_head = build_fragments_get_exclude_head;
104         collector->build_fragments_release_exclude_head = build_fragments_release_exclude_head;
105         collector->build_fragments_finish = build_fragments_finish;
106         collector->init_nursery = init_nursery;
107
108         fill_serial_ops (&collector->serial_ops);
109         fill_serial_with_concurrent_major_ops (&collector->serial_ops_with_concurrent_major);
110 }
111
112
113 #endif