Merge pull request #409 from Alkarex/patch-1
[mono.git] / mono / metadata / sgen-simple-nursery.c
1 /*
2  * sgen-simple-nursery.c: Simple always promote nursery.
3  *
4  *
5  * SGen is licensed under the terms of the MIT X11 license
6  *
7  * Copyright 2001-2003 Ximian, Inc
8  * Copyright 2003-2010 Novell, Inc.
9  * Copyright 2011 Xamarin Inc (http://www.xamarin.com)
10  * 
11  * Permission is hereby granted, free of charge, to any person obtaining
12  * a copy of this software and associated documentation files (the
13  * "Software"), to deal in the Software without restriction, including
14  * without limitation the rights to use, copy, modify, merge, publish,
15  * distribute, sublicense, and/or sell copies of the Software, and to
16  * permit persons to whom the Software is furnished to do so, subject to
17  * the following conditions:
18  * 
19  * The above copyright notice and this permission notice shall be
20  * included in all copies or substantial portions of the Software.
21  * 
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29  */
30
31 #include "config.h"
32 #ifdef HAVE_SGEN_GC
33
34 #include "metadata/profiler-private.h"
35
36 #include "metadata/sgen-gc.h"
37 #include "metadata/sgen-protocol.h"
38
39 static inline char*
40 alloc_for_promotion (char *obj, size_t objsize, gboolean has_references)
41 {
42         return major_collector.alloc_object (objsize, has_references);
43 }
44
45 static inline char*
46 par_alloc_for_promotion (char *obj, size_t objsize, gboolean has_references)
47 {
48         return major_collector.par_alloc_object (objsize, has_references);
49 }
50
51 static SgenFragment*
52 build_fragments_get_exclude_head (void)
53 {
54         return NULL;
55 }
56
57 static void
58 build_fragments_release_exclude_head (void)
59 {
60 }
61
62 static void
63 build_fragments_finish (SgenFragmentAllocator *allocator)
64 {
65 }
66
67 static void
68 prepare_to_space (char *to_space_bitmap, int space_bitmap_size)
69 {
70 }
71
72 static void
73 clear_fragments (void)
74 {       
75 }
76
77 static void
78 init_nursery (SgenFragmentAllocator *allocator, char *start, char *end)
79 {
80         sgen_fragment_allocator_add (allocator, start, end);
81 }
82
83
84 /******************************************Copy/Scan functins ************************************************/
85
86 #define SGEN_SIMPLE_NURSERY
87
88 #define SERIAL_COPY_OBJECT simple_nursery_serial_copy_object
89 #define PARALLEL_COPY_OBJECT simple_nursery_parallel_copy_object
90
91 #include "sgen-minor-copy-object.h"
92 #include "sgen-minor-scan-object.h"
93
94 void
95 sgen_simple_nursery_init (SgenMinorCollector *collector)
96 {
97         collector->alloc_for_promotion = alloc_for_promotion;
98         collector->par_alloc_for_promotion = par_alloc_for_promotion;
99
100         collector->prepare_to_space = prepare_to_space;
101         collector->clear_fragments = clear_fragments;
102         collector->build_fragments_get_exclude_head = build_fragments_get_exclude_head;
103         collector->build_fragments_release_exclude_head = build_fragments_release_exclude_head;
104         collector->build_fragments_finish = build_fragments_finish;
105         collector->init_nursery = init_nursery;
106
107         FILL_MINOR_COLLECTOR_COPY_OBJECT (collector);
108         FILL_MINOR_COLLECTOR_SCAN_OBJECT (collector);
109 }
110
111
112 #endif