e7f1e288f81c42d41e51a565c19eaa4d80a9e38c
[mono.git] / mono / sgen / sgen-pinning.h
1 /*
2  * sgen-pinning.h: All about pinning objects.
3  *
4  * Copyright 2011 Xamarin Inc (http://www.xamarin.com)
5  * Copyright (C) 2012 Xamarin Inc
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License 2.0 as published by the Free Software Foundation;
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License 2.0 along with this library; if not, write to the Free
18  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  */
20 #ifndef __MONO_SGEN_PINNING_H__
21 #define __MONO_SGEN_PINNING_H__
22
23 #include "mono/sgen/sgen-pointer-queue.h"
24
25 enum {
26         PIN_TYPE_STACK,
27         PIN_TYPE_STATIC_DATA,
28         PIN_TYPE_OTHER,
29         PIN_TYPE_MAX
30 };
31
32 void sgen_pin_stage_ptr (void *ptr);
33 void sgen_optimize_pin_queue (void);
34 void sgen_init_pinning (void);
35 void sgen_finish_pinning (void);
36 void sgen_pin_queue_clear_discarded_entries (GCMemSection *section, size_t max_pin_slot);
37 size_t sgen_get_pinned_count (void);
38 void sgen_pinning_setup_section (GCMemSection *section);
39 void sgen_pinning_trim_queue_to_section (GCMemSection *section);
40
41 void sgen_dump_pin_queue (void);
42
43 gboolean sgen_find_optimized_pin_queue_area (void *start, void *end, size_t *first_out, size_t *last_out);
44 void sgen_find_section_pin_queue_start_end (GCMemSection *section);
45 void** sgen_pinning_get_entry (size_t index);
46 void sgen_pin_objects_in_section (GCMemSection *section, ScanCopyContext ctx);
47
48 /* Pinning stats */
49
50 void sgen_pin_stats_register_address (char *addr, int pin_type);
51 size_t sgen_pin_stats_get_pinned_byte_count (int pin_type);
52 SgenPointerQueue *sgen_pin_stats_get_object_list (void);
53 void sgen_pin_stats_reset (void);
54
55 /* Perpetual pinning, aka cementing */
56
57 void sgen_cement_init (gboolean enabled);
58 void sgen_cement_reset (void);
59 gboolean sgen_cement_lookup (GCObject *obj);
60 gboolean sgen_cement_lookup_or_register (GCObject *obj);
61 void sgen_pin_cemented_objects (void);
62 void sgen_cement_clear_below_threshold (void);
63
64 #endif