Correctly calculate the number of cards to be marked.
authorRodrigo Kumpera <kumpera@gmail.com>
Wed, 23 Nov 2011 22:23:37 +0000 (20:23 -0200)
committerRodrigo Kumpera <kumpera@gmail.com>
Wed, 23 Nov 2011 22:53:43 +0000 (20:53 -0200)
* sgen-cardtable.c (sgen_card_table_mark_range): The number of
pages to be marked must be correctly calculated to avoid the case
when the in-card offset of the start address is bigger than
of the end address and cause the last card to be skipped.

Fixes #1917

mono/metadata/sgen-cardtable.c

index e56f0480162b2ca24ca781f4ea56d0eba06c4a5c..ec4cbbcd1e6075ab2177014308844d809ee27e7c 100644 (file)
@@ -8,6 +8,7 @@
  *
  * Copyright 2001-2003 Ximian, Inc
  * Copyright 2003-2010 Novell, Inc.
+ * Copyright 2011 Xamarin Inc (http://www.xamarin.com)
  * 
  * Permission is hereby granted, free of charge, to any person obtaining
  * a copy of this software and associated documentation files (the
@@ -153,11 +154,7 @@ sgen_card_table_align_pointer (void *ptr)
 void
 sgen_card_table_mark_range (mword address, mword size)
 {
-       mword end = address + size;
-       do {
-               sgen_card_table_mark_address (address);
-               address += CARD_SIZE_IN_BYTES;
-       } while (address < end);
+       memset (sgen_card_table_get_card_address (address), 1, cards_in_range (address, size));
 }
 
 static gboolean
@@ -315,6 +312,24 @@ collect_faulted_cards (void)
 
        printf ("TOTAL card pages %d faulted %d\n", CARD_PAGES, count);
 }
+
+void
+sgen_card_table_dump_obj_card (char *object, size_t size, void *dummy)
+{
+       guint8 *start = sgen_card_table_get_card_scan_address (object);
+       guint8 *end = start + cards_in_range (object, size);
+       int cnt = 0;
+       printf ("--obj %p %d cards [%p %p]--", object, size, start, end);
+       for (; start < end; ++start) {
+               if (cnt == 0)
+                       printf ("\n\t[%p] ", start);
+               printf ("%x ", *start);
+               ++cnt;
+               if (cnt == 8)
+                       cnt = 0;
+       }
+       printf ("\n");
+}
 #endif
 
 #define MWORD_MASK (sizeof (mword) - 1)