Merge pull request #495 from nicolas-raoul/fix-for-issue2907-with-no-formatting-changes
[mono.git] / mono / metadata / sgen-minor-copy-object.h
index 947a6846a8e9a26822e823cc8fdc35525b4ded90..5b03713840e3fd0ed329dd5fc85230e223779a64 100644 (file)
@@ -1,29 +1,22 @@
 /*
+ * sgen-minor-copy-object.h: Copy functions for nursery collections.
+ *
  * Copyright 2001-2003 Ximian, Inc
  * Copyright 2003-2010 Novell, Inc.
- * 
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- * 
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-/*
- * This file defines copy functions for nursery collections.
+ * Copyright (C) 2012 Xamarin Inc
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License 2.0 as published by the Free Software Foundation;
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License 2.0 along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
 #define collector_pin_object(obj, queue) sgen_pin_object (obj, queue);
@@ -64,7 +57,7 @@ SERIAL_COPY_OBJECT (void **obj_slot, SgenGrayQueue *queue)
        char *forwarded;
        char *obj = *obj_slot;
 
-       DEBUG (9, g_assert (current_collection_generation == GENERATION_NURSERY));
+       SGEN_ASSERT (9, current_collection_generation == GENERATION_NURSERY, "calling minor-serial-copy from a %d generation collection", current_collection_generation);
 
        HEAVY_STAT (++stat_copy_object_called_nursery);
 
@@ -73,7 +66,7 @@ SERIAL_COPY_OBJECT (void **obj_slot, SgenGrayQueue *queue)
                return;
        }
 
-       DEBUG (9, fprintf (gc_debug_file, "Precise copy of %p from %p", obj, obj_slot));
+       SGEN_LOG (9, "Precise copy of %p from %p", obj, obj_slot);
 
        /*
         * Before we can copy the object we must make sure that we are
@@ -82,23 +75,23 @@ SERIAL_COPY_OBJECT (void **obj_slot, SgenGrayQueue *queue)
         */
 
        if ((forwarded = SGEN_OBJECT_IS_FORWARDED (obj))) {
-               DEBUG (9, g_assert ((*(MonoVTable**)SGEN_LOAD_VTABLE(obj))->gc_descr));
-               DEBUG (9, fprintf (gc_debug_file, " (already forwarded to %p)\n", forwarded));
+               SGEN_ASSERT (9, (*(MonoVTable**)SGEN_LOAD_VTABLE (obj))->gc_descr,  "forwarded object %p has no gc descriptor", forwarded);
+               SGEN_LOG (9, " (already forwarded to %p)", forwarded);
                HEAVY_STAT (++stat_nursery_copy_object_failed_forwarded);
                *obj_slot = forwarded;
                return;
        }
        if (G_UNLIKELY (SGEN_OBJECT_IS_PINNED (obj))) {
-               DEBUG (9, g_assert (((MonoVTable*)SGEN_LOAD_VTABLE(obj))->gc_descr));
-               DEBUG (9, fprintf (gc_debug_file, " (pinned, no change)\n"));
+               SGEN_ASSERT (9, ((MonoVTable*)SGEN_LOAD_VTABLE(obj))->gc_descr, "pinned object %p has no gc descriptor", obj);
+               SGEN_LOG (9, " (pinned, no change)");
                HEAVY_STAT (++stat_nursery_copy_object_failed_pinned);
                return;
        }
 
 #ifndef SGEN_SIMPLE_NURSERY
        if (sgen_nursery_is_to_space (obj)) {
-               DEBUG (9, g_assert (((MonoVTable*)SGEN_LOAD_VTABLE(obj))->gc_descr));
-               DEBUG (9, fprintf (gc_debug_file, " (tospace, no change)\n"));
+               SGEN_ASSERT (9, ((MonoVTable*)SGEN_LOAD_VTABLE(obj))->gc_descr, "to space object %p has no gc descriptor", obj);
+               SGEN_LOG (9, " (tospace, no change)");
                HEAVY_STAT (++stat_nursery_copy_object_failed_to_space);                
                return;
        }
@@ -125,7 +118,7 @@ SERIAL_COPY_OBJECT_FROM_OBJ (void **obj_slot, SgenGrayQueue *queue)
        char *obj = *obj_slot;
        void *copy;
 
-       DEBUG (9, g_assert (current_collection_generation == GENERATION_NURSERY));
+       SGEN_ASSERT (9, current_collection_generation == GENERATION_NURSERY, "calling minor-serial-copy-from-obj from a %d generation collection", current_collection_generation);
 
        HEAVY_STAT (++stat_copy_object_called_nursery);
 
@@ -134,7 +127,7 @@ SERIAL_COPY_OBJECT_FROM_OBJ (void **obj_slot, SgenGrayQueue *queue)
                return;
        }
 
-       DEBUG (9, fprintf (gc_debug_file, "Precise copy of %p from %p", obj, obj_slot));
+       SGEN_LOG (9, "Precise copy of %p from %p", obj, obj_slot);
 
        /*
         * Before we can copy the object we must make sure that we are
@@ -143,8 +136,8 @@ SERIAL_COPY_OBJECT_FROM_OBJ (void **obj_slot, SgenGrayQueue *queue)
         */
 
        if ((forwarded = SGEN_OBJECT_IS_FORWARDED (obj))) {
-               DEBUG (9, g_assert ((*(MonoVTable**)SGEN_LOAD_VTABLE(obj))->gc_descr));
-               DEBUG (9, fprintf (gc_debug_file, " (already forwarded to %p)\n", forwarded));
+               SGEN_ASSERT (9, (*(MonoVTable**)SGEN_LOAD_VTABLE (obj))->gc_descr,  "forwarded object %p has no gc descriptor", forwarded);
+               SGEN_LOG (9, " (already forwarded to %p)", forwarded);
                HEAVY_STAT (++stat_nursery_copy_object_failed_forwarded);
                *obj_slot = forwarded;
 #ifndef SGEN_SIMPLE_NURSERY
@@ -154,8 +147,8 @@ SERIAL_COPY_OBJECT_FROM_OBJ (void **obj_slot, SgenGrayQueue *queue)
                return;
        }
        if (G_UNLIKELY (SGEN_OBJECT_IS_PINNED (obj))) {
-               DEBUG (9, g_assert (((MonoVTable*)SGEN_LOAD_VTABLE(obj))->gc_descr));
-               DEBUG (9, fprintf (gc_debug_file, " (pinned, no change)\n"));
+               SGEN_ASSERT (9, ((MonoVTable*)SGEN_LOAD_VTABLE(obj))->gc_descr, "pinned object %p has no gc descriptor", obj);
+               SGEN_LOG (9, " (pinned, no change)");
                HEAVY_STAT (++stat_nursery_copy_object_failed_pinned);
                if (!sgen_ptr_in_nursery (obj_slot))
                        sgen_add_to_global_remset (obj_slot);
@@ -164,8 +157,8 @@ SERIAL_COPY_OBJECT_FROM_OBJ (void **obj_slot, SgenGrayQueue *queue)
 
 #ifndef SGEN_SIMPLE_NURSERY
        if (sgen_nursery_is_to_space (obj)) {
-               DEBUG (9, g_assert (((MonoVTable*)SGEN_LOAD_VTABLE(obj))->gc_descr));
-               DEBUG (9, fprintf (gc_debug_file, " (tospace, no change)\n"));
+               SGEN_ASSERT (9, ((MonoVTable*)SGEN_LOAD_VTABLE(obj))->gc_descr, "to space object %p has no gc descriptor", obj);
+               SGEN_LOG (9, " (tospace, no change)");
                HEAVY_STAT (++stat_nursery_copy_object_failed_to_space);                
                return;
        }
@@ -196,7 +189,7 @@ PARALLEL_COPY_OBJECT (void **obj_slot, SgenGrayQueue *queue)
        void *destination;
        gboolean has_references;
 
-       DEBUG (9, g_assert (current_collection_generation == GENERATION_NURSERY));
+       SGEN_ASSERT (9, current_collection_generation == GENERATION_NURSERY, "calling minor-par-copy from a %d generation collection", current_collection_generation);
 
        HEAVY_STAT (++stat_copy_object_called_nursery);