Merge pull request #3121 from lambdageek/dev/managed-init_message
authormonojenkins <jo.shields+jenkins@xamarin.com>
Thu, 9 Jun 2016 22:15:10 +0000 (23:15 +0100)
committerGitHub <noreply@github.com>
Thu, 9 Jun 2016 22:15:10 +0000 (23:15 +0100)
Rewriite `MonoMethodMessage::InitMessage` in managed code

Change icall
`System.Runtime.Remoting.Messaging/MonoMethodMessage::InitMessage` to
managed code.

Also update `mono_message_init()` to invoke `InitMessage`.

configure.ac
mono/metadata/sgen-mono.c
mono/sgen/sgen-alloc.c
mono/sgen/sgen-gc.c
mono/sgen/sgen-gc.h
mono/sgen/sgen-marksweep.c
mono/utils/mono-hwcap-arm.c

index 4999b8f2b48121fe7b9b357f7c5f702edd9c3177..0cd24ea88df8c4c419f2092bc028b6a33c6bb3a8 100644 (file)
@@ -3267,14 +3267,17 @@ AC_ARG_WITH(sgen-default-concurrent, [  --with-sgen-default-concurrent=yes,no
 if test x$buildsgen = xyes; then
    AC_DEFINE(HAVE_MOVING_COLLECTOR, 1, [Moving collector])
    SGEN_DEFINES="-DHAVE_SGEN_GC"
-   if test "x$gc_msg" = "x"; then
-      gc_msg="sgen"
-   else
-      gc_msg="sgen and $gc_msg"
-   fi
 
+       conc_gc_msg=""
    if test x$with_sgen_default_concurrent != xno; then
        AC_DEFINE(HAVE_CONC_GC_AS_DEFAULT, 1, [Defaults to concurrent GC])
+          conc_gc_msg=" (concurrent by default)"
+   fi
+
+   if test "x$gc_msg" = "x"; then
+      gc_msg="sgen$conc_gc_msg"
+   else
+      gc_msg="sgen$conc_gc_msg and $gc_msg"
    fi
 fi
 AC_SUBST(SGEN_DEFINES)
index 740b021a37d1da50cee6e887976d5da5a68f834f..bccc7d8aad53fa1b91dfb139a10df911b6132c13 100644 (file)
@@ -841,7 +841,7 @@ mono_gc_clear_domain (MonoDomain * domain)
        sgen_stop_world (0);
 
        if (sgen_concurrent_collection_in_progress ())
-               sgen_perform_collection (0, GENERATION_OLD, "clear domain", TRUE);
+               sgen_perform_collection (0, GENERATION_OLD, "clear domain", TRUE, FALSE);
        SGEN_ASSERT (0, !sgen_concurrent_collection_in_progress (), "We just ordered a synchronous collection.  Why are we collecting concurrently?");
 
        major_collector.finish_sweeping ();
@@ -2534,7 +2534,11 @@ mono_gc_get_gc_name (void)
 char*
 mono_gc_get_description (void)
 {
+#ifdef HAVE_CONC_GC_AS_DEFAULT
+       return g_strdup ("sgen (concurrent by default)");
+#else
        return g_strdup ("sgen");
+#endif
 }
 
 void
index dcf977c06e1b736e4f46ad3ec4ea9a0d760eb2af..2e9f4666d21675f5a13596ee5bb8d14ecd26c68d 100644 (file)
@@ -96,7 +96,7 @@ alloc_degraded (GCVTable vtable, size_t size, gboolean for_mature)
                sgen_ensure_free_space (size, GENERATION_OLD);
        } else {
                if (sgen_need_major_collection (size))
-                       sgen_perform_collection (size, GENERATION_OLD, "mature allocation failure", !for_mature);
+                       sgen_perform_collection (size, GENERATION_OLD, "mature allocation failure", !for_mature, TRUE);
        }
 
 
@@ -164,7 +164,7 @@ sgen_alloc_obj_nolock (GCVTable vtable, size_t size)
 
                if (collect_before_allocs) {
                        if (((current_alloc % collect_before_allocs) == 0) && nursery_section) {
-                               sgen_perform_collection (0, GENERATION_NURSERY, "collect-before-alloc-triggered", TRUE);
+                               sgen_perform_collection (0, GENERATION_NURSERY, "collect-before-alloc-triggered", TRUE, TRUE);
                                if (!degraded_mode && sgen_can_alloc_size (size) && real_size <= SGEN_MAX_SMALL_OBJ_SIZE) {
                                        // FIXME:
                                        g_assert_not_reached ();
@@ -424,7 +424,7 @@ sgen_alloc_obj (GCVTable vtable, size_t size)
                if (collect_before_allocs) {
                        if (((current_alloc % collect_before_allocs) == 0) && nursery_section) {
                                LOCK_GC;
-                               sgen_perform_collection (0, GENERATION_NURSERY, "collect-before-alloc-triggered", TRUE);
+                               sgen_perform_collection (0, GENERATION_NURSERY, "collect-before-alloc-triggered", TRUE, TRUE);
                                UNLOCK_GC;
                        }
                }
index 75699b7563f5a5152f9d1757d5ed924cb2c0266f..1393ea610e5a0b8783ad741dc894d19d7ed8a417 100644 (file)
@@ -2226,14 +2226,14 @@ sgen_ensure_free_space (size_t size, int generation)
 
        if (generation_to_collect == -1)
                return;
-       sgen_perform_collection (size, generation_to_collect, reason, FALSE);
+       sgen_perform_collection (size, generation_to_collect, reason, FALSE, TRUE);
 }
 
 /*
  * LOCKING: Assumes the GC lock is held.
  */
 void
-sgen_perform_collection (size_t requested_size, int generation_to_collect, const char *reason, gboolean wait_to_finish)
+sgen_perform_collection (size_t requested_size, int generation_to_collect, const char *reason, gboolean wait_to_finish, gboolean stw)
 {
        TV_DECLARE (gc_total_start);
        TV_DECLARE (gc_total_end);
@@ -2246,7 +2246,11 @@ sgen_perform_collection (size_t requested_size, int generation_to_collect, const
 
        SGEN_ASSERT (0, generation_to_collect == GENERATION_NURSERY || generation_to_collect == GENERATION_OLD, "What generation is this?");
 
-       sgen_stop_world (generation_to_collect);
+       if (stw)
+               sgen_stop_world (generation_to_collect);
+       else
+               SGEN_ASSERT (0, sgen_is_world_stopped (), "We can only collect if the world is stopped");
+               
 
        TV_GETTIME (gc_total_start);
 
@@ -2306,7 +2310,8 @@ sgen_perform_collection (size_t requested_size, int generation_to_collect, const
        TV_GETTIME (gc_total_end);
        time_max = MAX (time_max, TV_ELAPSED (gc_total_start, gc_total_end));
 
-       sgen_restart_world (oldest_generation_collected);
+       if (stw)
+               sgen_restart_world (oldest_generation_collected);
 }
 
 /*
@@ -2676,7 +2681,7 @@ sgen_gc_collect (int generation)
        LOCK_GC;
        if (generation > 1)
                generation = 1;
-       sgen_perform_collection (0, generation, "user request", TRUE);
+       sgen_perform_collection (0, generation, "user request", TRUE, TRUE);
        UNLOCK_GC;
 }
 
index 9ebd40c0d315c92101c79aea2fa95c00c3c7fbb5..21268a9f8ff71aa0ca7778f33860e6afead99c9d 100644 (file)
@@ -806,7 +806,7 @@ void sgen_set_pinned_from_failed_allocation (mword objsize);
 
 void sgen_ensure_free_space (size_t size, int generation);
 void sgen_gc_collect (int generation);
-void sgen_perform_collection (size_t requested_size, int generation_to_collect, const char *reason, gboolean wait_to_finish);
+void sgen_perform_collection (size_t requested_size, int generation_to_collect, const char *reason, gboolean wait_to_finish, gboolean stw);
 
 int sgen_gc_collection_count (int generation);
 /* FIXME: what exactly does this return? */
index f2c646b3952f678b513bd74b6f7667f110ca4a24..4d0c09d40a8514809c32b3ddc4f34cf838751f94 100644 (file)
@@ -713,7 +713,7 @@ major_alloc_small_pinned_obj (GCVTable vtable, size_t size, gboolean has_referen
          *as pinned alloc is requested by the runtime.
          */
         if (!res) {
-               sgen_perform_collection (0, GENERATION_OLD, "pinned alloc failure", TRUE);
+               sgen_perform_collection (0, GENERATION_OLD, "pinned alloc failure", TRUE, TRUE);
                res = alloc_obj (vtable, size, TRUE, has_references);
         }
         return (GCObject *)res;
index 6cf8065d06a43e421bfb59737800ff73536d3f86..d5621323f9f64289ae8e3396cb5f7aaf99f48d23 100644 (file)
@@ -28,6 +28,9 @@
 #include <sys/sysctl.h>
 #include <sys/types.h>
 #else
+#if defined (HAVE_SYS_UTSNAME_H)
+#include <sys/utsname.h>
+#endif
 #include <stdio.h>
 #endif
 
@@ -105,6 +108,50 @@ mono_hwcap_arch_init (void)
         * hit this path if the target doesn't have sys/auxv.h.
         */
 
+#if defined (HAVE_SYS_UTSNAME_H)
+       struct utsname name;
+
+       /* Only fails if `name` is invalid (it isn't). */
+       g_assert (!uname (&name));
+
+       if (!strncmp (name.machine, "aarch64", 7) || !strncmp (name.machine, "armv8", 5)) {
+               /*
+                * We're a 32-bit program running on an ARMv8 system.
+                * Whether the system is actually 32-bit or 64-bit
+                * doesn't matter to us. The important thing is that
+                * all 3 of ARMv8's execution states (A64, A32, T32)
+                * are guaranteed to have all of the features that
+                * we want to detect and use.
+                *
+                * We do this ARMv8 detection via uname () because
+                * in the early days of ARMv8 on Linux, the
+                * /proc/cpuinfo format was a disaster and there
+                * were multiple (merged into mainline) attempts at
+                * cleaning it up (read: breaking applications that
+                * tried to rely on it). So now multiple ARMv8
+                * systems in the wild have different /proc/cpuinfo
+                * output, some of which are downright useless.
+                *
+                * So, when it comes to detecting ARMv8 in a 32-bit
+                * program, it's better to just avoid /proc/cpuinfo
+                * entirely. Maybe in a decade or two, we won't
+                * have to worry about this mess that the Linux ARM
+                * maintainers created. One can hope.
+                */
+
+               mono_hwcap_arm_is_v5 = TRUE;
+               mono_hwcap_arm_is_v6 = TRUE;
+               mono_hwcap_arm_is_v7 = TRUE;
+
+               mono_hwcap_arm_has_vfp = TRUE;
+               mono_hwcap_arm_has_vfp3 = TRUE;
+               mono_hwcap_arm_has_vfp3_d16 = TRUE;
+
+               mono_hwcap_arm_has_thumb = TRUE;
+               mono_hwcap_arm_has_thumb2 = TRUE;
+       }
+#endif
+
        char buf [512];
        char *line;