Skip to content

Commit f355e32

Browse files
lucasmeijerTak
authored andcommitted
implement GC_remove_roots for win32 by letting it use the nonwin32 codepath. feels kinda scary. see this question on boehm maillinglist:
http://permalink.gmane.org/gmane.comp.programming.garbage-collection.boehmgc/4732
1 parent 4d97c23 commit f355e32

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

libgc/include/gc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,8 @@ extern void GC_thr_init(void); /* Needed for Solaris/X86 */
959959

960960
#endif /* defined(GC_WIN32_THREADS) && !cygwin */
961961

962+
#define UNITY_USE_REASONABLE_LOOKING_GCROOTS_CODEPATH_ON_WINDOWS 1
963+
962964
/*
963965
* Fully portable code should call GC_INIT() from the main program
964966
* before making any other GC_ calls. On most platforms this is a

libgc/include/private/gc_priv.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -797,14 +797,14 @@ struct exclusion {
797797
struct roots {
798798
ptr_t r_start;
799799
ptr_t r_end;
800-
# if !defined(MSWIN32) && !defined(MSWINCE)
800+
# if !defined(MSWIN32) && !defined(MSWINCE) || UNITY_USE_REASONABLE_LOOKING_GCROOTS_CODEPATH_ON_WINDOWS
801801
struct roots * r_next;
802802
# endif
803803
GC_bool r_tmp;
804804
/* Delete before registering new dynamic libraries */
805805
};
806806

807-
#if !defined(MSWIN32) && !defined(MSWINCE)
807+
#if !defined(MSWIN32) && !defined(MSWINCE) || UNITY_USE_REASONABLE_LOOKING_GCROOTS_CODEPATH_ON_WINDOWS
808808
/* Size of hash table index to roots. */
809809
# define LOG_RT_SIZE 6
810810
# define RT_SIZE (1 << LOG_RT_SIZE) /* Power of 2, may be != MAX_ROOT_SETS */
@@ -997,7 +997,7 @@ struct _GC_arrays {
997997
/* Commited lengths of memory regions obtained from kernel. */
998998
# endif
999999
struct roots _static_roots[MAX_ROOT_SETS];
1000-
# if !defined(MSWIN32) && !defined(MSWINCE)
1000+
# if !defined(MSWIN32) && !defined(MSWINCE) || UNITY_USE_REASONABLE_LOOKING_GCROOTS_CODEPATH_ON_WINDOWS
10011001
struct roots * _root_index[RT_SIZE];
10021002
# endif
10031003
struct exclusion _excl_table[MAX_EXCLUSIONS];

libgc/mark_rts.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ struct roots {
3232
struct roots GC_static_roots[MAX_ROOT_SETS];
3333
*/
3434

35+
3536
int GC_no_dls = 0; /* Register dynamic library data segments. */
3637

3738
static int n_root_sets = 0;
@@ -87,7 +88,7 @@ ptr_t p;
8788
return(FALSE);
8889
}
8990

90-
#if !defined(MSWIN32) && !defined(MSWINCE)
91+
#if !defined(MSWIN32) && !defined(MSWINCE) || UNITY_USE_REASONABLE_LOOKING_GCROOTS_CODEPATH_ON_WINDOWS
9192
/*
9293
# define LOG_RT_SIZE 6
9394
# define RT_SIZE (1 << LOG_RT_SIZE) -- Power of 2, may be != MAX_ROOT_SETS
@@ -175,7 +176,7 @@ GC_bool tmp;
175176
{
176177
struct roots * old;
177178

178-
# if defined(MSWIN32) || defined(MSWINCE)
179+
# if defined(MSWIN32) || defined(MSWINCE) && !UNITY_USE_REASONABLE_LOOKING_GCROOTS_CODEPATH_ON_WINDOWS
179180
/* Spend the time to ensure that there are no overlapping */
180181
/* or adjacent intervals. */
181182
/* This could be done faster with e.g. a */
@@ -222,7 +223,7 @@ GC_bool tmp;
222223
GC_root_size -= (other -> r_end - other -> r_start);
223224
other -> r_start = GC_static_roots[n_root_sets-1].r_start;
224225
other -> r_end = GC_static_roots[n_root_sets-1].r_end;
225-
n_root_sets--;
226+
n_root_sets--;
226227
}
227228
}
228229
return;
@@ -285,7 +286,7 @@ int i;
285286
n_root_sets--;
286287
}
287288

288-
#if !defined(MSWIN32) && !defined(MSWINCE)
289+
#if !defined(MSWIN32) && !defined(MSWINCE) || UNITY_USE_REASONABLE_LOOKING_GCROOTS_CODEPATH_ON_WINDOWS
289290
static void GC_rebuild_root_index()
290291
{
291292
register int i;
@@ -313,7 +314,7 @@ void GC_remove_tmp_roots()
313314
#endif
314315
}
315316

316-
#if !defined(MSWIN32) && !defined(MSWINCE)
317+
#if !defined(MSWIN32) && !defined(MSWINCE) || UNITY_USE_REASONABLE_LOOKING_GCROOTS_CODEPATH_ON_WINDOWS
317318
void GC_remove_roots(b, e)
318319
char * b; char * e;
319320
{

mono/metadata/boehm-gc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ mono_gc_register_root (char *start, size_t size, void *descr)
318318
void
319319
mono_gc_deregister_root (char* addr)
320320
{
321-
#ifndef PLATFORM_WIN32
321+
#ifndef PLATFORM_WIN32 || UNITY_USE_REASONABLE_LOOKING_GCROOTS_CODEPATH_ON_WINDOWS
322322
/* FIXME: libgc doesn't define this work win32 for some reason */
323323
/* FIXME: No size info */
324324
GC_remove_roots (addr, addr + sizeof (gpointer) + 1);

0 commit comments

Comments
 (0)