[sgen] Remove weak ref hashes.
[mono.git] / mono / sgen / gc-internal-agnostic.h
1 /*
2  * gc-internal-agnostic.h: Mono-agnostic GC interface.
3  *
4  * Copyright (C) 2015 Xamarin Inc
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License 2.0 as published by the Free Software Foundation;
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License 2.0 along with this library; if not, write to the Free
17  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19
20 #ifndef __MONO_METADATA_GCINTERNALAGNOSTIC_H__
21 #define __MONO_METADATA_GCINTERNALAGNOSTIC_H__
22
23 #include <config.h>
24 #include <glib.h>
25 #include <stdio.h>
26
27 #include "mono/utils/mono-compiler.h"
28 #include "mono/utils/parse.h"
29 #include "mono/utils/memfuncs.h"
30 #ifdef HAVE_SGEN_GC
31 #include "mono/sgen/sgen-conf.h"
32 #endif
33
34 #ifndef HIDE_POINTER
35 #define HIDE_POINTER(p) ((gpointer)~(size_t)(p))
36 #endif
37
38 #ifndef REVEAL_POINTER
39 #define REVEAL_POINTER(p) ((gpointer)~(size_t)(p))
40 #endif
41
42 typedef enum {
43         HANDLE_TYPE_MIN = 0,
44         HANDLE_WEAK = HANDLE_TYPE_MIN,
45         HANDLE_WEAK_TRACK,
46         HANDLE_NORMAL,
47         HANDLE_PINNED,
48         HANDLE_TYPE_MAX
49 } GCHandleType;
50
51 void mono_gchandle_iterate (GCHandleType handle_type, int max_generation, gpointer callback(gpointer *, GCHandleType, gpointer), gpointer user);
52
53 typedef struct {
54         guint minor_gc_count;
55         guint major_gc_count;
56         guint64 minor_gc_time;
57         guint64 major_gc_time;
58         guint64 major_gc_time_concurrent;
59 } GCStats;
60
61 extern GCStats gc_stats;
62
63 #ifdef HAVE_SGEN_GC
64 typedef SgenDescriptor MonoGCDescriptor;
65 #define MONO_GC_DESCRIPTOR_NULL SGEN_DESCRIPTOR_NULL
66 #else
67 typedef void* MonoGCDescriptor;
68 #define MONO_GC_DESCRIPTOR_NULL NULL
69 #endif
70
71 /*
72  * Try to register a foreign thread with the GC, if we fail or the backend
73  * can't cope with this concept - we return FALSE.
74  */
75 extern gboolean mono_gc_register_thread (void *baseptr);
76
77 gboolean mono_gc_parse_environment_string_extract_number (const char *str, size_t *out);
78
79 MonoGCDescriptor mono_gc_make_descr_for_object (gsize *bitmap, int numbits, size_t obj_size);
80 MonoGCDescriptor mono_gc_make_descr_for_array (int vector, gsize *elem_bitmap, int numbits, size_t elem_size);
81
82 /* simple interface for data structures needed in the runtime */
83 MonoGCDescriptor mono_gc_make_descr_from_bitmap (gsize *bitmap, int numbits);
84
85 /* Return a root descriptor for a root with all refs */
86 MonoGCDescriptor mono_gc_make_root_descr_all_refs (int numbits);
87
88 /* Return the bitmap encoded by a descriptor */
89 gsize* mono_gc_get_bitmap_for_descr (MonoGCDescriptor descr, int *numbits);
90
91 /*
92 These functions must be used when it's possible that either destination is not
93 word aligned or size is not a multiple of word size.
94 */
95 void mono_gc_bzero_atomic (void *dest, size_t size);
96 void mono_gc_bzero_aligned (void *dest, size_t size);
97 void mono_gc_memmove_atomic (void *dest, const void *src, size_t size);
98 void mono_gc_memmove_aligned (void *dest, const void *src, size_t size);
99
100 FILE *mono_gc_get_logfile (void);
101
102 #endif