Merge pull request #2454 from tastywheattasteslikechicken/FixVtableAbort
[mono.git] / mono / sgen / sgen-memory-governor.h
1 /*
2  * Copyright 2001-2003 Ximian, Inc
3  * Copyright 2003-2010 Novell, Inc.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sublicense, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 #ifndef __MONO_SGEN_MEMORY_GOVERNOR_H__
25 #define __MONO_SGEN_MEMORY_GOVERNOR_H__
26
27 /* Heap limits */
28 void sgen_memgov_init (size_t max_heap, size_t soft_limit, gboolean debug_allowance, double min_allowance_ratio, double save_target);
29 void sgen_memgov_release_space (mword size, int space);
30 gboolean sgen_memgov_try_alloc_space (mword size, int space);
31
32 /* GC trigger heuristics */
33 void sgen_memgov_minor_collection_start (void);
34 void sgen_memgov_minor_collection_end (void);
35
36 void sgen_memgov_major_pre_sweep (void);
37 void sgen_memgov_major_collection_start (void);
38 void sgen_memgov_major_collection_end (gboolean forced);
39
40 void sgen_memgov_collection_start (int generation);
41 void sgen_memgov_collection_end (int generation, GGTimingInfo* info, int info_count);
42
43 gboolean sgen_need_major_collection (mword space_needed);
44
45
46 typedef enum {
47         SGEN_ALLOC_INTERNAL = 0,
48         SGEN_ALLOC_HEAP = 1,
49         SGEN_ALLOC_ACTIVATE = 2
50 } SgenAllocFlags;
51
52 /* OS memory allocation */
53 void* sgen_alloc_os_memory (size_t size, SgenAllocFlags flags, const char *assert_description);
54 void* sgen_alloc_os_memory_aligned (size_t size, mword alignment, SgenAllocFlags flags, const char *assert_description);
55 void sgen_free_os_memory (void *addr, size_t size, SgenAllocFlags flags);
56
57 /* Error handling */
58 void sgen_assert_memory_alloc (void *ptr, size_t requested_size, const char *assert_description);
59
60 #endif
61