Merge pull request #1659 from alexanderkyte/stringbuilder-referencesource
[mono.git] / mono / metadata / 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 enum {
24         PIN_TYPE_STACK,
25         PIN_TYPE_STATIC_DATA,
26         PIN_TYPE_OTHER,
27         PIN_TYPE_MAX
28 };
29
30 void sgen_pin_stage_ptr (void *ptr);
31 void sgen_optimize_pin_queue (void);
32 void sgen_init_pinning (void);
33 void sgen_finish_pinning (void);
34 void sgen_pin_queue_clear_discarded_entries (GCMemSection *section, size_t max_pin_slot);
35 size_t sgen_get_pinned_count (void);
36 void sgen_pinning_setup_section (GCMemSection *section);
37 void sgen_pinning_trim_queue_to_section (GCMemSection *section);
38
39 void sgen_dump_pin_queue (void);
40
41 gboolean sgen_find_optimized_pin_queue_area (void *start, void *end, size_t *first_out, size_t *last_out);
42 void sgen_find_section_pin_queue_start_end (GCMemSection *section);
43 void** sgen_pinning_get_entry (size_t index);
44 void sgen_pin_objects_in_section (GCMemSection *section, ScanCopyContext ctx);
45
46 /* Pinning stats */
47
48 void sgen_pin_stats_register_address (char *addr, int pin_type);
49 size_t sgen_pin_stats_get_pinned_byte_count (int pin_type);
50 ObjectList *sgen_pin_stats_get_object_list (void);
51 void sgen_pin_stats_reset (void);
52
53 /* Perpetual pinning, aka cementing */
54
55 void sgen_cement_init (gboolean enabled);
56 void sgen_cement_reset (void);
57 gboolean sgen_cement_lookup (char *obj);
58 gboolean sgen_cement_lookup_or_register (char *obj);
59 void sgen_pin_cemented_objects (void);
60 void sgen_cement_clear_below_threshold (void);
61
62 #endif