Improve a safety check when writing data into StatBuffer
[mono.git] / mono / sgen / sgen-marksweep-scan-object-concurrent.h
index 1ed9eb8a4bb454b793c29918310c8e5970014955..541a0a2b52fec22415a6468147e50a8aec241584 100644 (file)
@@ -19,8 +19,6 @@
  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-extern guint64 stat_scan_object_called_major;
-
 /*
  * FIXME: We use the same scanning function in the concurrent collector whether we scan
  * during the starting/finishing collection pause (with the world stopped) or from the
@@ -32,67 +30,14 @@ extern guint64 stat_scan_object_called_major;
  * it because we don't follow into the nursery.
  */
 
-#undef HANDLE_PTR
-#define HANDLE_PTR(ptr,obj)    do {                                    \
-               GCObject *__old = *(ptr);                                       \
-               SGEN_OBJECT_LAYOUT_STATISTICS_MARK_BITMAP ((obj), (ptr)); \
-               binary_protocol_scan_process_reference ((obj), (ptr), __old); \
-               if (__old && !sgen_ptr_in_nursery (__old)) {            \
-                       PREFETCH_READ (__old);                  \
-                       major_copy_or_mark_object_concurrent ((ptr), __old, queue); \
-               } else {                                                \
-                       if (G_UNLIKELY (sgen_ptr_in_nursery (__old) && !sgen_ptr_in_nursery ((ptr)))) \
-                               ADD_TO_GLOBAL_REMSET ((full_object), (ptr), __old); \
-               }                                                       \
-       } while (0)
-
-/* FIXME: Unify this with optimized code in sgen-marksweep.c. */
-
-#undef ADD_TO_GLOBAL_REMSET
-#define ADD_TO_GLOBAL_REMSET(object,ptr,target)        mark_mod_union_card ((object), (void**)(ptr))
-
-static void
-major_scan_object_no_mark_concurrent_anywhere (GCObject *full_object, SgenDescriptor desc, SgenGrayQueue *queue)
-{
-       char *start = (char*)full_object;
-
-       SGEN_OBJECT_LAYOUT_STATISTICS_DECLARE_BITMAP;
-
-#ifdef HEAVY_STATISTICS
-       sgen_descriptor_count_scanned_object (desc);
-#endif
-#ifdef SGEN_HEAVY_BINARY_PROTOCOL
-       add_scanned_object (start);
-#endif
-
-#define SCAN_OBJECT_PROTOCOL
-#include "sgen-scan-object.h"
-
-       SGEN_OBJECT_LAYOUT_STATISTICS_COMMIT_BITMAP;
-       HEAVY_STAT (++stat_scan_object_called_major);
-}
-
-static void
-major_scan_object_no_mark_concurrent_start (GCObject *start, SgenDescriptor desc, SgenGrayQueue *queue)
-{
-       major_scan_object_no_mark_concurrent_anywhere (start, desc, queue);
-}
-
-static void
-major_scan_object_no_mark_concurrent (GCObject *start, SgenDescriptor desc, SgenGrayQueue *queue)
-{
-       SGEN_ASSERT (0, !sgen_ptr_in_nursery (start), "Why are we scanning nursery objects in the concurrent collector?");
-       major_scan_object_no_mark_concurrent_anywhere (start, desc, queue);
-}
-
 #undef HANDLE_PTR
 #define HANDLE_PTR(ptr,obj)     do {                                    \
-                void *__old = *(ptr);                                   \
-                binary_protocol_scan_process_reference ((obj), (ptr), __old); \
+                GCObject *__old = *(ptr);                                   \
+                binary_protocol_scan_process_reference ((full_object), (ptr), __old); \
                 if (__old) {                                            \
-                        gboolean __still_in_nursery = major_copy_or_mark_object_no_evacuation ((ptr), __old, queue); \
+                        gboolean __still_in_nursery = major_copy_or_mark_object_with_evacuation ((ptr), __old, queue); \
                         if (G_UNLIKELY (__still_in_nursery && !sgen_ptr_in_nursery ((ptr)) && !SGEN_OBJECT_IS_CEMENTED (*(ptr)))) { \
-                                void *__copy = *(ptr);                  \
+                                GCObject *__copy = *(ptr);                  \
                                 sgen_add_to_global_remset ((ptr), __copy); \
                         }                                              \
                 }                                                       \