Merge pull request #2774 from marek-safar/roslyn
authorMarek Safar <marek.safar@gmail.com>
Mon, 28 Nov 2016 13:38:54 +0000 (14:38 +0100)
committerGitHub <noreply@github.com>
Mon, 28 Nov 2016 13:38:54 +0000 (14:38 +0100)
Roslyn compiler switch

mono/metadata/w32process-unix.c
mono/mini/mini-llvm.c

index 46d7c4c2addd4bd6b0133276da3b5c07b8ce9c5a..0b387e6d2a48a617e3376fc15bc8acc38f7bd7a1 100644 (file)
@@ -710,7 +710,7 @@ gboolean
 mono_w32process_try_get_modules (gpointer process, gpointer *modules, guint32 size, guint32 *needed)
 {
        MonoW32HandleProcess *process_handle;
-       GSList *mods = NULL;
+       GSList *mods = NULL, *mods_iter;
        MonoW32ProcessModule *module;
        guint32 count, avail = size / sizeof(gpointer);
        int i;
@@ -758,10 +758,7 @@ mono_w32process_try_get_modules (gpointer process, gpointer *modules, guint32 si
                return TRUE;
        }
 
-       count = g_slist_length (mods);
-
-       /* count + 1 to leave slot 0 for the main module */
-       *needed = sizeof(gpointer) * (count + 1);
+       count = 0;
 
        /*
         * Use the NULL shortcut, as the first line in
@@ -772,19 +769,25 @@ mono_w32process_try_get_modules (gpointer process, gpointer *modules, guint32 si
         * be a problem.
         */
        modules[0] = NULL;
-       for (i = 0; i < (avail - 1) && i < count; i++) {
-               module = (MonoW32ProcessModule *)g_slist_nth_data (mods, i);
-               if (modules[0] != NULL)
-                       modules[i] = module->address_start;
-               else if (match_procname_to_modulename (proc_name, module->filename))
-                       modules[0] = module->address_start;
-               else
-                       modules[i + 1] = module->address_start;
+       mods_iter = mods;
+       for (i = 0; mods_iter; i++) {
+               if (i < avail - 1) {
+                       module = (MonoW32ProcessModule *)mods_iter->data;
+                       if (modules[0] != NULL)
+                               modules[i] = module->address_start;
+                       else if (match_procname_to_modulename (proc_name, module->filename))
+                               modules[0] = module->address_start;
+                       else
+                               modules[i + 1] = module->address_start;
+               }
+               mono_w32process_module_free ((MonoW32ProcessModule *)mods_iter->data);
+               mods_iter = g_slist_next (mods_iter);
+               count++;
        }
 
-       for (i = 0; i < count; i++) {
-               mono_w32process_module_free ((MonoW32ProcessModule *)g_slist_nth_data (mods, i));
-       }
+       /* count + 1 to leave slot 0 for the main module */
+       *needed = sizeof(gpointer) * (count + 1);
+
        g_slist_free (mods);
        g_free (proc_name);
 
@@ -843,10 +846,8 @@ mono_w32process_module_get_name (gpointer process, gpointer module, gunichar2 *b
        char *procname_ext = NULL;
        glong len;
        gsize bytes;
-       GSList *mods = NULL;
+       GSList *mods = NULL, *mods_iter;
        MonoW32ProcessModule *found_module;
-       guint32 count;
-       int i;
        char *proc_name = NULL;
        gboolean res;
 
@@ -879,14 +880,12 @@ mono_w32process_module_get_name (gpointer process, gpointer module, gunichar2 *b
                return 0;
        }
 
-       count = g_slist_length (mods);
-
        /* If module != NULL compare the address.
         * If module == NULL we are looking for the main module.
         * The best we can do for now check it the module name end with the process name.
         */
-       for (i = 0; i < count; i++) {
-               found_module = (MonoW32ProcessModule *)g_slist_nth_data (mods, i);
+       for (mods_iter = mods; mods_iter; mods_iter = g_slist_next (mods_iter)) {
+               found_module = (MonoW32ProcessModule *)mods_iter->data;
                if (procname_ext == NULL &&
                        ((module == NULL && match_procname_to_modulename (proc_name, found_module->filename)) ||
                         (module != NULL && found_module->address_start == module))) {
@@ -948,10 +947,8 @@ mono_w32process_module_get_information (gpointer process, gpointer module, WapiM
 {
        MonoW32HandleProcess *process_handle;
        pid_t pid;
-       GSList *mods = NULL;
+       GSList *mods = NULL, *mods_iter;
        MonoW32ProcessModule *found_module;
-       guint32 count;
-       int i;
        gboolean ret = FALSE;
        char *proc_name = NULL;
        gboolean res;
@@ -982,14 +979,12 @@ mono_w32process_module_get_information (gpointer process, gpointer module, WapiM
                return FALSE;
        }
 
-       count = g_slist_length (mods);
-
        /* If module != NULL compare the address.
         * If module == NULL we are looking for the main module.
         * The best we can do for now check it the module name end with the process name.
         */
-       for (i = 0; i < count; i++) {
-                       found_module = (MonoW32ProcessModule *)g_slist_nth_data (mods, i);
+       for (mods_iter = mods; mods_iter; mods_iter = g_slist_next (mods_iter)) {
+                       found_module = (MonoW32ProcessModule *)mods_iter->data;
                        if (ret == FALSE &&
                                ((module == NULL && match_procname_to_modulename (proc_name, found_module->filename)) ||
                                 (module != NULL && found_module->address_start == module))) {
index c403278c753feadc52a526f997f447468b8f2e97..bf27a3629862f2de220565184b045da383d6b7c2 100644 (file)
@@ -7330,8 +7330,10 @@ emit_method_inner (EmitContext *ctx)
                        LLVMValueRef switch_ins = (LLVMValueRef)l->data;
                        GSList *bb_list = info->call_handler_return_bbs;
 
-                       for (i = 0; i < g_slist_length (bb_list); ++i)
-                               LLVMAddCase (switch_ins, LLVMConstInt (LLVMInt32Type (), i + 1, FALSE), (LLVMBasicBlockRef)(g_slist_nth (bb_list, i)->data));
+                       GSList *bb_list_iter;
+                       for (bb_list_iter = bb_list; bb_list_iter; bb_list_iter = g_slist_next (bb_list_iter)) {
+                               LLVMAddCase (switch_ins, LLVMConstInt (LLVMInt32Type (), i + 1, FALSE), (LLVMBasicBlockRef)bb_list_iter->data);
+                       }
                }
        }