Skip to content

Instantly share code, notes, and snippets.

@schani
Created February 28, 2011 19:28
Show Gist options
  • Select an option

  • Save schani/847858 to your computer and use it in GitHub Desktop.

Select an option

Save schani/847858 to your computer and use it in GitHub Desktop.
diff --git a/mono/metadata/sgen-gc.c b/mono/metadata/sgen-gc.c
index d4f309b..ab9b1f9 100644
--- a/mono/metadata/sgen-gc.c
+++ b/mono/metadata/sgen-gc.c
@@ -6913,12 +6913,17 @@ mono_gc_make_root_descr_all_refs (int numbits)
{
gsize *gc_bitmap;
void *descr;
+ int num_bytes = numbits / 8;
if (numbits < 32 && all_ref_root_descrs [numbits])
return all_ref_root_descrs [numbits];
gc_bitmap = g_malloc0 (ALIGN_TO (numbits, 8) + 1);
- memset (gc_bitmap, 0xff, numbits / 8);
+ memset (gc_bitmap, 0xff, num_bytes);
+ if (numbits < ((sizeof (*gc_bitmap) * 8) - ROOT_DESC_TYPE_SHIFT))
+ gc_bitmap [0] = GUINT64_TO_LE (gc_bitmap [0]);
+ else if (numbits && num_bytes % (sizeof (*gc_bitmap)))
+ gc_bitmap [num_bytes / 8] = GUINT64_TO_LE (gc_bitmap [num_bytes / 8]);
if (numbits % 8)
gc_bitmap [numbits / 8] = (1 << (numbits % 8)) - 1;
descr = mono_gc_make_descr_from_bitmap (gc_bitmap, numbits);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment